diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 44a5ced761..c7abfebf3a 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing to LAMMPS via GitHub -Thank your for considering to contribute to the LAMMPS software project. +Thank you for considering to contribute to the LAMMPS software project. The following is a set of guidelines as well as explanations of policies and work flows for contributing to the LAMMPS molecular dynamics software project. These guidelines focus on submitting issues or pull requests on the LAMMPS GitHub project. diff --git a/.gitignore b/.gitignore index a89f75cc9a..4faef4b8db 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,6 @@ out/x86 out/x64 src/Makefile.package-e src/Makefile.package.settings-e +/cmake/build/x64-Debug-Clang +/install/x64-GUI-MSVC +/install diff --git a/cmake/CMakeLists.jpeg b/cmake/CMakeLists.jpeg deleted file mode 100644 index f0bd85a90d..0000000000 --- a/cmake/CMakeLists.jpeg +++ /dev/null @@ -1,615 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -# When using CMake 3.4 and later, don't export symbols from executables unless -# the CMAKE_ENABLE_EXPORTS variable is set. -if(POLICY CMP0065) - cmake_policy(SET CMP0065 NEW) -endif() -if (POLICY CMP0077) - cmake_policy(SET CMP0077 NEW) -endif() -if(CMAKE_EXECUTABLE_SUFFIX) - set(CMAKE_EXECUTABLE_SUFFIX_TMP ${CMAKE_EXECUTABLE_SUFFIX}) -endif() - -project(libjpeg-turbo C) -set(VERSION 2.1.3) -set(COPYRIGHT_YEAR "1991-2022") -string(REPLACE "." ";" VERSION_TRIPLET ${VERSION}) -list(GET VERSION_TRIPLET 0 VERSION_MAJOR) -list(GET VERSION_TRIPLET 1 VERSION_MINOR) -list(GET VERSION_TRIPLET 2 VERSION_REVISION) -function(pad_number NUMBER OUTPUT_LEN) - string(LENGTH "${${NUMBER}}" INPUT_LEN) - if(INPUT_LEN LESS OUTPUT_LEN) - math(EXPR ZEROES "${OUTPUT_LEN} - ${INPUT_LEN} - 1") - set(NUM ${${NUMBER}}) - foreach(C RANGE ${ZEROES}) - set(NUM "0${NUM}") - endforeach() - set(${NUMBER} ${NUM} PARENT_SCOPE) - endif() -endfunction() -pad_number(VERSION_MINOR 3) -pad_number(VERSION_REVISION 3) -set(LIBJPEG_TURBO_VERSION_NUMBER ${VERSION_MAJOR}${VERSION_MINOR}${VERSION_REVISION}) - -# CMake 3.14 and later sets CMAKE_MACOSX_BUNDLE to TRUE by default when -# CMAKE_SYSTEM_NAME is iOS, tvOS, or watchOS, which breaks the libjpeg-turbo -# build. (Specifically, when CMAKE_MACOSX_BUNDLE is TRUE, executables for -# Apple platforms are built as application bundles, which causes CMake to -# complain that our install() directives for executables do not specify a -# BUNDLE DESTINATION. Even if CMake did not complain, building executables as -# application bundles would break our iOS packages.) -set(CMAKE_MACOSX_BUNDLE FALSE) - -string(TIMESTAMP DEFAULT_BUILD "%Y%m%d") -set(BUILD ${DEFAULT_BUILD} CACHE STRING "Build string (default: ${DEFAULT_BUILD})") - -# NOTE: On Windows, this does nothing except when using MinGW or Cygwin. -# CMAKE_BUILD_TYPE has no meaning in Visual Studio, and it always defaults to -# Debug when using NMake. -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release) -endif() -message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}") - -message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}") - -include(cmakescripts/PackageInfo.cmake) - -# Detect CPU type and whether we're building 64-bit or 32-bit code -math(EXPR BITS "${CMAKE_SIZEOF_VOID_P} * 8") -string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CMAKE_SYSTEM_PROCESSOR_LC) -set(COUNT 1) -foreach(ARCH ${CMAKE_OSX_ARCHITECTURES}) - if(COUNT GREATER 1) - message(FATAL_ERROR "The libjpeg-turbo build system does not support multiple values in CMAKE_OSX_ARCHITECTURES.") - endif() - math(EXPR COUNT "${COUNT}+1") -endforeach() -if(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86_64" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "amd64" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "i[0-9]86" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ia32") - if(BITS EQUAL 64 OR CMAKE_C_COMPILER_ABI MATCHES "ELF X32") - set(CPU_TYPE x86_64) - else() - set(CPU_TYPE i386) - endif() - if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ${CPU_TYPE}) - set(CMAKE_SYSTEM_PROCESSOR ${CPU_TYPE}) - endif() -elseif(CMAKE_SYSTEM_PROCESSOR_LC STREQUAL "aarch64" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^arm") - if(BITS EQUAL 64) - set(CPU_TYPE arm64) - else() - set(CPU_TYPE arm) - endif() -elseif(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^ppc" OR - CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^powerpc") - set(CPU_TYPE powerpc) -else() - set(CPU_TYPE ${CMAKE_SYSTEM_PROCESSOR_LC}) -endif() -if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR - CMAKE_OSX_ARCHITECTURES MATCHES "arm64" OR - CMAKE_OSX_ARCHITECTURES MATCHES "i386") - set(CPU_TYPE ${CMAKE_OSX_ARCHITECTURES}) -endif() -if(CMAKE_OSX_ARCHITECTURES MATCHES "ppc") - set(CPU_TYPE powerpc) -endif() -if(MSVC_IDE AND CMAKE_GENERATOR_PLATFORM MATCHES "arm64") - set(CPU_TYPE arm64) -endif() - -message(STATUS "${BITS}-bit build (${CPU_TYPE})") - -macro(report_directory var) - if(CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_FULL_${var}) - message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}}") - else() - message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}} (${CMAKE_INSTALL_FULL_${var}})") - endif() - mark_as_advanced(CLEAR CMAKE_INSTALL_${var}) -endmacro() - -set(DIRLIST "BINDIR;DATAROOTDIR;DOCDIR;INCLUDEDIR;LIBDIR") -if(UNIX) - list(APPEND DIRLIST "MANDIR") -endif() -foreach(dir ${DIRLIST}) - report_directory(${dir}) -endforeach() - - -############################################################################### -# CONFIGURATION OPTIONS -############################################################################### - -macro(boolean_number var) - if(${var}) - set(${var} 1 ${ARGN}) - else() - set(${var} 0 ${ARGN}) - endif() -endmacro() - -option(ENABLE_SHARED "Build shared libraries" FALSE) -boolean_number(ENABLE_SHARED) -option(ENABLE_STATIC "Build static libraries" TRUE) -boolean_number(ENABLE_STATIC) -option(REQUIRE_SIMD "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)" FALSE) -boolean_number(REQUIRE_SIMD) -option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_ARITH_DEC=0 WITH_ARITH_ENC=0 WITH_JAVA=0 WITH_SIMD=0 WITH_TURBOJPEG=0 )" FALSE) -boolean_number(WITH_12BIT) -option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" TRUE) -boolean_number(WITH_ARITH_DEC) -option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" TRUE) -boolean_number(WITH_ARITH_ENC) -if(CMAKE_C_COMPILER_ABI MATCHES "ELF X32") - set(WITH_JAVA 0) -else() - option(WITH_JAVA "Build Java wrapper for the TurboJPEG API library (implies ENABLE_SHARED=1)" FALSE) - boolean_number(WITH_JAVA) -endif() -option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE) -boolean_number(WITH_JPEG7) -option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE) -boolean_number(WITH_JPEG8) -option(WITH_MEM_SRCDST "Include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI" TRUE) -boolean_number(WITH_MEM_SRCDST) -option(WITH_SIMD "Include SIMD extensions, if available for this platform" FALSE) -boolean_number(WITH_SIMD) -option(WITH_TURBOJPEG "Include the TurboJPEG API library and associated test programs" FALSE) -boolean_number(WITH_TURBOJPEG) -option(WITH_FUZZ "Build fuzz targets" FALSE) - -macro(report_option var desc) - if(${var}) - message(STATUS "${desc} enabled (${var} = ${${var}})") - else() - message(STATUS "${desc} disabled (${var} = ${${var}})") - endif() -endmacro() - -if(WITH_JAVA) - set(ENABLE_SHARED 1) -endif() - -# Explicitly setting CMAKE_POSITION_INDEPENDENT_CODE=FALSE disables PIC for all -# targets, which will cause the shared library builds to fail. Thus, if shared -# libraries are enabled and CMAKE_POSITION_INDEPENDENT_CODE is explicitly set -# to FALSE, we need to unset it, thus restoring the default behavior -# (automatically using PIC for shared library targets.) -if(DEFINED CMAKE_POSITION_INDEPENDENT_CODE AND - NOT CMAKE_POSITION_INDEPENDENT_CODE AND ENABLE_SHARED) - unset(CMAKE_POSITION_INDEPENDENT_CODE CACHE) -endif() - -report_option(ENABLE_SHARED "Shared libraries") -report_option(ENABLE_STATIC "Static libraries") - -if(ENABLE_SHARED) - set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) -endif() - -if(WITH_JPEG8 OR WITH_JPEG7) - set(WITH_ARITH_ENC 1) - set(WITH_ARITH_DEC 1) -endif() -if(WITH_JPEG8) - set(WITH_MEM_SRCDST 0) -endif() - -if(WITH_12BIT) - set(WITH_ARITH_DEC 0) - set(WITH_ARITH_ENC 0) - set(WITH_JAVA 0) - set(WITH_SIMD 0) - set(WITH_TURBOJPEG 0) - set(BITS_IN_JSAMPLE 12) -else() - set(BITS_IN_JSAMPLE 8) -endif() -report_option(WITH_12BIT "12-bit JPEG support") - -if(WITH_ARITH_DEC) - set(D_ARITH_CODING_SUPPORTED 1) -endif() -if(NOT WITH_12BIT) - report_option(WITH_ARITH_DEC "Arithmetic decoding support") -endif() - -if(WITH_ARITH_ENC) - set(C_ARITH_CODING_SUPPORTED 1) -endif() -if(NOT WITH_12BIT) - report_option(WITH_ARITH_ENC "Arithmetic encoding support") -endif() - -if(NOT WITH_12BIT) - report_option(WITH_TURBOJPEG "TurboJPEG API library") - report_option(WITH_JAVA "TurboJPEG Java wrapper") -endif() - -if(WITH_MEM_SRCDST) - set(MEM_SRCDST_SUPPORTED 1) - set(MEM_SRCDST_FUNCTIONS "global: jpeg_mem_dest; jpeg_mem_src;") -endif() -if(NOT WITH_JPEG8) - report_option(WITH_MEM_SRCDST "In-memory source/destination managers") -endif() - -set(SO_AGE 2) -if(WITH_MEM_SRCDST) - set(SO_AGE 3) -endif() - -if(WITH_JPEG8) - set(JPEG_LIB_VERSION 80) -elseif(WITH_JPEG7) - set(JPEG_LIB_VERSION 70) -else() - set(JPEG_LIB_VERSION 62) -endif() - -math(EXPR JPEG_LIB_VERSION_DIV10 "${JPEG_LIB_VERSION} / 10") -math(EXPR JPEG_LIB_VERSION_MOD10 "${JPEG_LIB_VERSION} % 10") -if(JPEG_LIB_VERSION STREQUAL "62") - set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION}) -else() - set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION_DIV10}) -endif() -if(JPEG_LIB_VERSION STREQUAL "80") - set(DEFAULT_SO_MINOR_VERSION 2) -else() - set(DEFAULT_SO_MINOR_VERSION 0) -endif() - -# This causes SO_MAJOR_VERSION/SO_MINOR_VERSION to reset to defaults if -# WITH_JPEG7 or WITH_JPEG8 has changed. -if((DEFINED WITH_JPEG7_INT AND NOT WITH_JPEG7 EQUAL WITH_JPEG7_INT) OR - (DEFINED WITH_JPEG8_INT AND NOT WITH_JPEG8 EQUAL WITH_JPEG8_INT)) - set(FORCE_SO_VERSION "FORCE") -endif() -set(WITH_JPEG7_INT ${WITH_JPEG7} CACHE INTERNAL "") -set(WITH_JPEG8_INT ${WITH_JPEG8} CACHE INTERNAL "") - -set(SO_MAJOR_VERSION ${DEFAULT_SO_MAJOR_VERSION} CACHE STRING - "Major version of the libjpeg API shared library (default: ${DEFAULT_SO_MAJOR_VERSION})" - ${FORCE_SO_VERSION}) -set(SO_MINOR_VERSION ${DEFAULT_SO_MINOR_VERSION} CACHE STRING - "Minor version of the libjpeg API shared library (default: ${DEFAULT_SO_MINOR_VERSION})" - ${FORCE_SO_VERSION}) - -set(JPEG_LIB_VERSION_DECIMAL "${JPEG_LIB_VERSION_DIV10}.${JPEG_LIB_VERSION_MOD10}") -message(STATUS "Emulating libjpeg API/ABI v${JPEG_LIB_VERSION_DECIMAL} (WITH_JPEG7 = ${WITH_JPEG7}, WITH_JPEG8 = ${WITH_JPEG8})") -message(STATUS "libjpeg API shared library version = ${SO_MAJOR_VERSION}.${SO_AGE}.${SO_MINOR_VERSION}") - -# Because the TurboJPEG API library uses versioned symbols and changes the -# names of functions whenever they are modified in a backward-incompatible -# manner, it is always backward-ABI-compatible with itself, so the major and -# minor SO versions don't change. However, we increase the middle number (the -# SO "age") whenever functions are added to the API. -set(TURBOJPEG_SO_MAJOR_VERSION 0) -set(TURBOJPEG_SO_AGE 2) -set(TURBOJPEG_SO_VERSION 0.${TURBOJPEG_SO_AGE}.0) - - -############################################################################### -# COMPILER SETTINGS -############################################################################### - -if(MSVC) - option(WITH_CRT_DLL - "Link all ${CMAKE_PROJECT_NAME} libraries and executables with the C run-time DLL (msvcr*.dll) instead of the static C run-time library (libcmt*.lib.) The default is to use the C run-time DLL only with the libraries and executables that need it." - FALSE) - if(NOT WITH_CRT_DLL) - # Use the static C library for all build types - foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) - if(${var} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}") - endif() - endforeach() - endif() - add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) -endif() - -if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") - # Use the maximum optimization level for release builds - foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO) - if(${var} MATCHES "-O2") - string(REGEX REPLACE "-O2" "-O3" ${var} "${${var}}") - endif() - endforeach() -endif() - -if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") - if(CMAKE_C_COMPILER_ID MATCHES "SunPro") - # Use the maximum optimization level for release builds - foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO) - if(${var} MATCHES "-xO3") - string(REGEX REPLACE "-xO3" "-xO5" ${var} "${${var}}") - endif() - if(${var} MATCHES "-xO2") - string(REGEX REPLACE "-xO2" "-xO5" ${var} "${${var}}") - endif() - endforeach() - endif() -endif() - -string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC) - -set(EFFECTIVE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}") -message(STATUS "Compiler flags = ${EFFECTIVE_C_FLAGS}") - -set(EFFECTIVE_LD_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}}") -message(STATUS "Linker flags = ${EFFECTIVE_LD_FLAGS}") - -include(CheckCSourceCompiles) -include(CheckIncludeFiles) -include(CheckTypeSize) - -check_type_size("size_t" SIZE_T) -check_type_size("unsigned long" UNSIGNED_LONG) - -if(SIZE_T EQUAL UNSIGNED_LONG) - check_c_source_compiles("int main(int argc, char **argv) { unsigned long a = argc; return __builtin_ctzl(a); }" - HAVE_BUILTIN_CTZL) -endif() -if(MSVC) - check_include_files("intrin.h" HAVE_INTRIN_H) -endif() - -if(UNIX) - if(CMAKE_CROSSCOMPILING) - set(RIGHT_SHIFT_IS_UNSIGNED 0) - else() - include(CheckCSourceRuns) - check_c_source_runs(" - #include - #include - int is_shifting_signed (long arg) { - long res = arg >> 4; - if (res == -0x7F7E80CL) - return 1; /* right shift is signed */ - /* see if unsigned-shift hack will fix it. */ - /* we can't just test exact value since it depends on width of long... */ - res |= (~0L) << (32-4); - if (res == -0x7F7E80CL) - return 0; /* right shift is unsigned */ - printf(\"Right shift isn't acting as I expect it to.\\\\n\"); - printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\"); - return 0; /* try it with unsigned anyway */ - } - int main (void) { - exit(is_shifting_signed(-0x7F7E80B1L)); - }" RIGHT_SHIFT_IS_UNSIGNED) - endif() -endif() - -if(MSVC) - set(INLINE_OPTIONS "__inline;inline") -else() - set(INLINE_OPTIONS "__inline__;inline") -endif() -option(FORCE_INLINE "Force function inlining" TRUE) -boolean_number(FORCE_INLINE) -if(FORCE_INLINE) - if(MSVC) - list(INSERT INLINE_OPTIONS 0 "__forceinline") - else() - list(INSERT INLINE_OPTIONS 0 "inline __attribute__((always_inline))") - list(INSERT INLINE_OPTIONS 0 "__inline__ __attribute__((always_inline))") - endif() -endif() -foreach(inline ${INLINE_OPTIONS}) - check_c_source_compiles("${inline} static int foo(void) { return 0; } int main(void) { return foo(); }" - INLINE_WORKS) - if(INLINE_WORKS) - set(INLINE ${inline}) - break() - endif() -endforeach() -if(NOT INLINE_WORKS) - message(FATAL_ERROR "Could not determine how to inline functions.") -endif() -message(STATUS "INLINE = ${INLINE} (FORCE_INLINE = ${FORCE_INLINE})") - -if(WITH_TURBOJPEG) - if(MSVC) - set(THREAD_LOCAL "__declspec(thread)") - else() - set(THREAD_LOCAL "__thread") - endif() - check_c_source_compiles("${THREAD_LOCAL} int i; int main(void) { i = 0; return i; }" HAVE_THREAD_LOCAL) - if(HAVE_THREAD_LOCAL) - message(STATUS "THREAD_LOCAL = ${THREAD_LOCAL}") - else() - message(WARNING "Thread-local storage is not available. The TurboJPEG API library's global error handler will not be thread-safe.") - unset(THREAD_LOCAL) - endif() -endif() - -if(UNIX AND NOT APPLE) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map "VERS_1 { global: *; };") - set(CMAKE_REQUIRED_FLAGS - "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") - check_c_source_compiles("int main(void) { return 0; }" HAVE_VERSION_SCRIPT) - set(CMAKE_REQUIRED_FLAGS) - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map) - if(HAVE_VERSION_SCRIPT) - message(STATUS "Linker supports GNU-style version scripts") - set(MAPFLAG "-Wl,--version-script,") - set(TJMAPFLAG "-Wl,--version-script,") - else() - message(STATUS "Linker does not support GNU-style version scripts") - if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") - # The Solaris linker doesn't like our version script for the libjpeg API - # library, but the version script for the TurboJPEG API library should - # still work. - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map - "VERS_1 { global: foo; local: *; }; VERS_2 { global: foo2; } VERS_1;") - set(CMAKE_REQUIRED_FLAGS "-Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/conftest.map -shared") - check_c_source_compiles("int foo() { return 0; } int foo2() { return 2; }" - HAVE_MAPFILE) - set(CMAKE_REQUIRED_FLAGS) - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map) - if(HAVE_MAPFILE) - message(STATUS "Linker supports mapfiles") - set(TJMAPFLAG "-Wl,-M,") - else() - message(STATUS "Linker does not support mapfiles") - endif() - endif() - endif() -endif() - -# Generate files -if(WIN32) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win/jconfig.h.in jconfig.h) -else() - configure_file(jconfig.h.in jconfig.h) -endif() -configure_file(jconfigint.h.in jconfigint.h) -configure_file(jversion.h.in jversion.h) -if(UNIX) - configure_file(libjpeg.map.in libjpeg.map) -endif() - -# Include directories and compiler definitions -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) - - -############################################################################### -# TARGETS -############################################################################### - -if(CMAKE_EXECUTABLE_SUFFIX_TMP) - set(CMAKE_EXECUTABLE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX_TMP}) -endif() -message(STATUS "CMAKE_EXECUTABLE_SUFFIX = ${CMAKE_EXECUTABLE_SUFFIX}") - -set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c - jcicc.c jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c - jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c - jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdicc.c jdinput.c - jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c - jdtrans.c jerror.c jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c - jidctint.c jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c) - -if(WITH_ARITH_ENC OR WITH_ARITH_DEC) - set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c) -endif() - -if(WITH_ARITH_ENC) - set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c) -endif() - -if(WITH_ARITH_DEC) - set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c) -endif() - -if(WITH_SIMD) - add_subdirectory(simd) - if(NEON_INTRINSICS) - add_definitions(-DNEON_INTRINSICS) - endif() -elseif(NOT WITH_12BIT) - message(STATUS "SIMD extensions: None (WITH_SIMD = ${WITH_SIMD})") -endif() -if(WITH_SIMD) - message(STATUS "SIMD extensions: ${CPU_TYPE} (WITH_SIMD = ${WITH_SIMD})") - if(MSVC_IDE OR XCODE) - set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1) - endif() -else() - add_library(simd OBJECT jsimd_none.c) - if(NOT WIN32 AND (CMAKE_POSITION_INDEPENDENT_CODE OR ENABLE_SHARED)) - set_target_properties(simd PROPERTIES POSITION_INDEPENDENT_CODE 1) - endif() -endif() - -if(WITH_JAVA) - add_subdirectory(java) -endif() - -if(ENABLE_SHARED) - add_subdirectory(sharedlib) -endif() - -if(ENABLE_STATIC) - add_library(jpeg-static STATIC ${JPEG_SOURCES} $ - ${SIMD_OBJS}) - if(NOT MSVC) - set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg) - endif() -endif() - -if(WITH_TURBOJPEG) - if(ENABLE_SHARED) - set(TURBOJPEG_SOURCES ${JPEG_SOURCES} $ ${SIMD_OBJS} - turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c rdppm.c - wrbmp.c wrppm.c) - set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile) - if(WITH_JAVA) - set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c) - include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) - set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile.jni) - endif() - if(MSVC) - configure_file(${CMAKE_SOURCE_DIR}/win/turbojpeg.rc.in - ${CMAKE_BINARY_DIR}/win/turbojpeg.rc) - set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} - ${CMAKE_BINARY_DIR}/win/turbojpeg.rc) - endif() - add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES}) - set_property(TARGET turbojpeg PROPERTY COMPILE_FLAGS - "-DBMP_SUPPORTED -DPPM_SUPPORTED") - if(WIN32) - set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE) - endif() - if(MINGW) - set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at) - endif() - if(APPLE AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET OR - CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER 10.4)) - if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG) - set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") - endif() - set_target_properties(turbojpeg PROPERTIES MACOSX_RPATH 1) - endif() - set_target_properties(turbojpeg PROPERTIES - SOVERSION ${TURBOJPEG_SO_MAJOR_VERSION} VERSION ${TURBOJPEG_SO_VERSION}) - if(TJMAPFLAG) - set_target_properties(turbojpeg PROPERTIES - LINK_FLAGS "${TJMAPFLAG}${TJMAPFILE}") - endif() - endif() - - if(ENABLE_STATIC) - add_library(turbojpeg-static STATIC ${JPEG_SOURCES} $ - ${SIMD_OBJS} turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c - rdppm.c wrbmp.c wrppm.c) - set_property(TARGET turbojpeg-static PROPERTY COMPILE_FLAGS - "-DBMP_SUPPORTED -DPPM_SUPPORTED") - if(NOT MSVC) - set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg) - endif() - endif() -endif() - -if(WIN32) - set(USE_SETMODE "-DUSE_SETMODE") -endif() -if(WITH_12BIT) - set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED ${USE_SETMODE}") -else() - set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}") - set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c) - set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c) -endif() \ No newline at end of file diff --git a/cmake/CMakeLists.png b/cmake/CMakeLists.png deleted file mode 100644 index 2521ab41be..0000000000 --- a/cmake/CMakeLists.png +++ /dev/null @@ -1,741 +0,0 @@ -# CMakeLists.txt - -# Copyright (C) 2018 Cosmin Truta -# Copyright (C) 2007,2009-2018 Glenn Randers-Pehrson -# Written by Christian Ehrlicher, 2007 -# Revised by Roger Lowman, 2009-2010 -# Revised by Clifford Yapp, 2011-2012,2017 -# Revised by Roger Leigh, 2016 -# Revised by Andreas Franek, 2016 -# Revised by Sam Serrels, 2017 -# Revised by Vadim Barkov, 2017 -# Revised by Vicky Pfau, 2018 -# Revised by Cameron Cawley, 2018 -# Revised by Cosmin Truta, 2018 -# Revised by Kyle Bentley, 2018 - -# This code is released under the libpng license. -# For conditions of distribution and use, see the disclaimer -# and license in png.h - -cmake_minimum_required(VERSION 3.10) -cmake_policy(VERSION 3.1) -# When using CMake 3.4 and later, don't export symbols from executables unless -# the CMAKE_ENABLE_EXPORTS variable is set. -if(POLICY CMP0065) - cmake_policy(SET CMP0065 NEW) -endif() -if (POLICY CMP0077) - cmake_policy(SET CMP0077 NEW) -endif() -set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) - -project(libpng C ASM) -enable_testing() - -set(PNGLIB_MAJOR 1) -set(PNGLIB_MINOR 6) -set(PNGLIB_RELEASE 37) -set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) -set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) - -include(GNUInstallDirs) - -# needed packages - -# Allow users to specify location of Zlib. -# Useful if zlib is being built alongside this as a sub-project. -option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" ON) - -if(NOT PNG_BUILD_ZLIB) - find_package(ZLIB REQUIRED) - include_directories(${ZLIB_INCLUDE_DIR}) -endif() - -if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU) - find_library(M_LIBRARY m) -else() - # libm is not needed and/or not available - set(M_LIBRARY "") -endif() - -# COMMAND LINE OPTIONS -option(PNG_SHARED "Build shared lib" OFF) -option(PNG_STATIC "Build static lib" ON) -option(PNG_TESTS "Build libpng tests" OFF) - -# Many more configuration options could be added here -option(PNG_FRAMEWORK "Build OS X framework" OFF) -option(PNG_DEBUG "Build with debug output" OFF) -option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" OFF) - -set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names") -set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings") - -if(PNG_HARDWARE_OPTIMIZATIONS) - -# set definitions and sources for arm -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") - set(PNG_ARM_NEON_POSSIBLE_VALUES check on off) - set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations: - check: (default) use internal checking code; - off: disable the optimizations; - on: turn on unconditionally.") - set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS - ${PNG_ARM_NEON_POSSIBLE_VALUES}) - list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index) - if(index EQUAL -1) - message(FATAL_ERROR - "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]") - elseif(NOT ${PNG_ARM_NEON} STREQUAL "off") - set(libpng_arm_sources - arm/arm_init.c - arm/filter_neon.S - arm/filter_neon_intrinsics.c - arm/palette_neon_intrinsics.c) - - if(${PNG_ARM_NEON} STREQUAL "on") - add_definitions(-DPNG_ARM_NEON_OPT=2) - elseif(${PNG_ARM_NEON} STREQUAL "check") - add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED) - endif() - else() - add_definitions(-DPNG_ARM_NEON_OPT=0) - endif() -endif() - -# set definitions and sources for powerpc -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*") - set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off) - set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations: - off: disable the optimizations.") - set_property(CACHE PNG_POWERPC_VSX PROPERTY STRINGS - ${PNG_POWERPC_VSX_POSSIBLE_VALUES}) - list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index) - if(index EQUAL -1) - message(FATAL_ERROR - "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]") - elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "off") - set(libpng_powerpc_sources - powerpc/powerpc_init.c - powerpc/filter_vsx_intrinsics.c) - if(${PNG_POWERPC_VSX} STREQUAL "on") - add_definitions(-DPNG_POWERPC_VSX_OPT=2) - endif() - else() - add_definitions(-DPNG_POWERPC_VSX_OPT=0) - endif() -endif() - -# set definitions and sources for intel -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*") - set(PNG_INTEL_SSE_POSSIBLE_VALUES on off) - set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations: - off: disable the optimizations") - set_property(CACHE PNG_INTEL_SSE PROPERTY STRINGS - ${PNG_INTEL_SSE_POSSIBLE_VALUES}) - list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index) - if(index EQUAL -1) - message(FATAL_ERROR - "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]") - elseif(NOT ${PNG_INTEL_SSE} STREQUAL "off") - set(libpng_intel_sources - intel/intel_init.c - intel/filter_sse2_intrinsics.c) - if(${PNG_INTEL_SSE} STREQUAL "on") - add_definitions(-DPNG_INTEL_SSE_OPT=1) - endif() - else() - add_definitions(-DPNG_INTEL_SSE_OPT=0) - endif() -endif() - -# set definitions and sources for MIPS -if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*") - set(PNG_MIPS_MSA_POSSIBLE_VALUES on off) - set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations: - off: disable the optimizations") - set_property(CACHE PNG_MIPS_MSA PROPERTY STRINGS - ${PNG_MIPS_MSA_POSSIBLE_VALUES}) - list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index) - if(index EQUAL -1) - message(FATAL_ERROR - "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]") - elseif(NOT ${PNG_MIPS_MSA} STREQUAL "off") - set(libpng_mips_sources - mips/mips_init.c - mips/filter_msa_intrinsics.c) - if(${PNG_MIPS_MSA} STREQUAL "on") - add_definitions(-DPNG_MIPS_MSA_OPT=2) - endif() - else() - add_definitions(-DPNG_MIPS_MSA_OPT=0) - endif() -endif() - -else(PNG_HARDWARE_OPTIMIZATIONS) - -# set definitions and sources for arm -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") - add_definitions(-DPNG_ARM_NEON_OPT=0) -endif() - -# set definitions and sources for powerpc -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*") - add_definitions(-DPNG_POWERPC_VSX_OPT=0) -endif() - -# set definitions and sources for intel -if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*") - add_definitions(-DPNG_INTEL_SSE_OPT=0) -endif() - -# set definitions and sources for MIPS -if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR - CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*") - add_definitions(-DPNG_MIPS_MSA_OPT=0) -endif() - -endif(PNG_HARDWARE_OPTIMIZATIONS) - -# SET LIBNAME -set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) - -# to distinguish between debug and release lib -set(CMAKE_DEBUG_POSTFIX "d") - -include(CheckCSourceCompiles) -option(ld-version-script "Enable linker version script" ON) -if(ld-version-script AND NOT APPLE) - # Check if LD supports linker scripts. - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 { - global: sym; - local: *; -}; - -VERS_2 { - global: sym2; - main; -} VERS_1; -") - set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") - check_c_source_compiles("void sym(void) {} -void sym2(void) {} -int main(void) {return 0;} -" HAVE_LD_VERSION_SCRIPT) - if(NOT HAVE_LD_VERSION_SCRIPT) - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") - check_c_source_compiles("void sym(void) {} -void sym2(void) {} -int main(void) {return 0;} -" HAVE_SOLARIS_LD_VERSION_SCRIPT) - endif() - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") -endif() - -# Find symbol prefix. Likely obsolete and unnecessary with recent -# toolchains (it's not done in many other projects). -function(symbol_prefix) - set(SYMBOL_PREFIX) - - execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-" - INPUT_FILE /dev/null - OUTPUT_VARIABLE OUT - RESULT_VARIABLE STATUS) - - if(CPP_FAIL) - message(WARNING "Failed to run the C preprocessor") - endif() - - string(REPLACE "\n" ";" OUT "${OUT}") - foreach(line ${OUT}) - string(REGEX MATCH "^PREFIX=" found_match "${line}") - if(found_match) - string(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}") - string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}") - if(found_match) - string(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}") - endif() - set(SYMBOL_PREFIX "${prefix}") - endif() - endforeach() - - message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}") - set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE) -endfunction() - -if(UNIX) - symbol_prefix() -endif() - -find_program(AWK NAMES gawk awk) - -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -if(NOT AWK OR ANDROID) - # No awk available to generate sources; use pre-built pnglibconf.h - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt - ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) - add_custom_target(genfiles) # Dummy -else() - include(CMakeParseArguments) - # Generate .chk from .out with awk - # generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) - function(generate_chk) - set(options) - set(oneValueArgs INPUT OUTPUT) - set(multiValueArgs DEPENDS) - cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _GC_INPUT) - message(FATAL_ERROR "generate_chk: Missing INPUT argument") - endif() - if(NOT _GC_OUTPUT) - message(FATAL_ERROR "generate_chk: Missing OUTPUT argument") - endif() - - add_custom_command(OUTPUT "${_GC_OUTPUT}" - COMMAND "${CMAKE_COMMAND}" - "-DINPUT=${_GC_INPUT}" - "-DOUTPUT=${_GC_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake" - DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endfunction() - - # Generate .out from .c with awk - # generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) - function(generate_out) - set(options) - set(oneValueArgs INPUT OUTPUT) - set(multiValueArgs DEPENDS) - cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _GO_INPUT) - message(FATAL_ERROR "generate_out: Missing INPUT argument") - endif() - if(NOT _GO_OUTPUT) - message(FATAL_ERROR "generate_out: Missing OUTPUT argument") - endif() - - add_custom_command(OUTPUT "${_GO_OUTPUT}" - COMMAND "${CMAKE_COMMAND}" - "-DINPUT=${_GO_INPUT}" - "-DOUTPUT=${_GO_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake" - DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endfunction() - - # Generate specific source file with awk - # generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]]) - function(generate_source) - set(options) - set(oneValueArgs OUTPUT) - set(multiValueArgs DEPENDS) - cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT _GSO_OUTPUT) - message(FATAL_ERROR "generate_source: Missing OUTPUT argument") - endif() - - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}" - COMMAND "${CMAKE_COMMAND}" - "-DOUTPUT=${_GSO_OUTPUT}" - -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" - DEPENDS ${_GSO_DEPENDS} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endfunction() - - # Copy file - function(generate_copy source destination) - add_custom_command(OUTPUT "${destination}" - COMMAND "${CMAKE_COMMAND}" -E remove "${destination}" - COMMAND "${CMAKE_COMMAND}" -E copy "${source}" - "${destination}" - DEPENDS "${source}") - endfunction() - - # Generate scripts/pnglibconf.h - generate_source(OUTPUT "scripts/pnglibconf.c" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" - "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk" - "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") - - # Generate pnglibconf.c - generate_source(OUTPUT "pnglibconf.c" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" - "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk" - "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") - - if(PNG_PREFIX) - set(PNGLIBCONF_H_EXTRA_DEPENDS - "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" - "${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst") - set(PNGPREFIX_H_EXTRA_DEPENDS - "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") - endif() - - generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") - - # Generate pnglibconf.h - generate_source(OUTPUT "pnglibconf.h" - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" - ${PNGLIBCONF_H_EXTRA_DEPENDS}) - - generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") - - generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" - "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") - - # Generate pngprefix.h - generate_source(OUTPUT "pngprefix.h" - DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS}) - - generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" - DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") - - generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" - "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" - "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt") - - generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" - "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") - - generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk" - "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def") - - add_custom_target(symbol-check DEPENDS - "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk") - - generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" - "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") - generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" - "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") - - add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") - add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") - - add_custom_target("genprebuilt" - COMMAND "${CMAKE_COMMAND}" - "-DOUTPUT=scripts/pnglibconf.h.prebuilt" - -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - - # A single target handles generation of all generated files. If - # they are depended upon separately by multiple targets, this - # confuses parallel make (it would require a separate top-level - # target for each file to track the dependencies properly). - add_custom_target(genfiles DEPENDS - "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" - "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" - "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" - "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out") -endif(NOT AWK OR ANDROID) - -# OUR SOURCES -set(libpng_public_hdrs - png.h - pngconf.h - "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" -) -set(libpng_private_hdrs - pngpriv.h - pngdebug.h - pnginfo.h - pngstruct.h -) -if(AWK AND NOT ANDROID) - list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h") -endif() -set(libpng_sources - ${libpng_public_hdrs} - ${libpng_private_hdrs} - png.c - pngerror.c - pngget.c - pngmem.c - pngpread.c - pngread.c - pngrio.c - pngrtran.c - pngrutil.c - pngset.c - pngtrans.c - pngwio.c - pngwrite.c - pngwtran.c - pngwutil.c - ${libpng_arm_sources} - ${libpng_intel_sources} - ${libpng_mips_sources} - ${libpng_powerpc_sources} -) -set(pngtest_sources - pngtest.c -) -set(pngvalid_sources - contrib/libtests/pngvalid.c -) -set(pngstest_sources - contrib/libtests/pngstest.c -) -set(pngunknown_sources - contrib/libtests/pngunknown.c -) -set(pngimage_sources - contrib/libtests/pngimage.c -) -set(pngfix_sources - contrib/tools/pngfix.c -) -set(png_fix_itxt_sources - contrib/tools/png-fix-itxt.c -) - -if(MSVC) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) -endif() - -if(PNG_DEBUG) - add_definitions(-DPNG_DEBUG) -endif() - -# NOW BUILD OUR TARGET -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) - -unset(PNG_LIB_TARGETS) - -if(PNG_STATIC) - # does not work without changing name - set(PNG_LIB_NAME_STATIC png_static) - add_library(png_static STATIC ${libpng_sources}) - add_dependencies(png_static genfiles) - # MSVC doesn't use a different file extension for shared vs. static - # libs. We are able to change OUTPUT_NAME to remove the _static - # for all other platforms. - if(NOT MSVC) - set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_LIB_NAME}" - CLEAN_DIRECT_OUTPUT 1) - else() - set_target_properties(png_static PROPERTIES - OUTPUT_NAME "${PNG_LIB_NAME}_static" - CLEAN_DIRECT_OUTPUT 1) - endif() - list(APPEND PNG_LIB_TARGETS png_static) - if(MSVC) - # msvc does not append 'lib' - do it here to have consistent name - set_target_properties(png_static PROPERTIES PREFIX "lib") - endif() - target_link_libraries(png_static ${M_LIBRARY}) -endif() - -if(NOT PNG_LIB_TARGETS) - message(SEND_ERROR - "No library variant selected to build. " - "Please enable at least one of the following options: " - "PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK") -endif() - -# Set a variable with CMake code which: -# Creates a symlink from src to dest (if possible) or alternatively -# copies if different. -include(CMakeParseArguments) - -function(create_symlink DEST_FILE) - - cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN}) - - if(NOT S_TARGET AND NOT S_FILE) - message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument") - endif() - - if(S_TARGET AND S_FILE) - message(FATAL_ERROR "create_symlink: Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; can only have one.") - endif() - - if(S_FILE) - # If we don't need to symlink something that's coming from a build target, - # we can go ahead and symlink/copy at configure time. - if(CMAKE_HOST_WIN32 AND NOT CYGWIN) - execute_process( - COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - else() - execute_process( - COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE} - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endif() - endif() - - if(S_TARGET) - # We need to use generator expressions, which can be a bit tricky, so for - # simplicity make the symlink a POST_BUILD step and use the TARGET - # signature of add_custom_command. - if(CMAKE_HOST_WIN32 AND NOT CYGWIN) - add_custom_command(TARGET ${S_TARGET} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy_if_different $ $/${DEST_FILE}) - else() - add_custom_command(TARGET ${S_TARGET} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E create_symlink $ $/${DEST_FILE}) - endif() - endif() - -endfunction() - -# Create source generation scripts. -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY) - -# libpng is a library so default to 'lib' -if(NOT DEFINED CMAKE_INSTALL_LIBDIR) - set(CMAKE_INSTALL_LIBDIR lib) -endif() - -# CREATE PKGCONFIG FILES -# We use the same files like ./configure, so we have to set its vars. -# Only do this on Windows for Cygwin - the files don't make much sense outside -# of a UNIX look-alike. -if(NOT WIN32 OR CYGWIN OR MINGW) - set(prefix ${CMAKE_INSTALL_PREFIX}) - set(exec_prefix ${CMAKE_INSTALL_PREFIX}) - set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) - set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) - set(LIBS "-lz -lm") - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY) - create_symlink(libpng.pc FILE ${PNGLIB_NAME}.pc) - - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in - ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY) - create_symlink(libpng-config FILE ${PNGLIB_NAME}-config) -endif() - -# SET UP LINKS -if(PNG_SHARED) - set_target_properties(png PROPERTIES -# VERSION 16.${PNGLIB_RELEASE}.1.6.37 - VERSION 16.${PNGLIB_RELEASE}.0 - SOVERSION 16 - CLEAN_DIRECT_OUTPUT 1) -endif() - -# INSTALL -if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) - install(TARGETS ${PNG_LIB_TARGETS} - EXPORT libpng - RUNTIME DESTINATION bin - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}) - - if(PNG_SHARED) - # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin - if(CYGWIN OR MINGW) - create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png) - install(FILES $/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - - if(NOT WIN32) - create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png) - install(FILES $/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - endif() - - if(PNG_STATIC) - if(NOT WIN32 OR CYGWIN OR MINGW) - create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static) - install(FILES $/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - endif() -endif() - -if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) - install(FILES ${libpng_public_hdrs} DESTINATION include) - install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME}) -endif() -if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL) - if(NOT WIN32 OR CYGWIN OR MINGW) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin) - endif() -endif() - -if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL) - install(TARGETS ${PNG_BIN_TARGETS} - RUNTIME DESTINATION bin) -endif() - -if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL) - # Install man pages - if(NOT PNG_MAN_DIR) - set(PNG_MAN_DIR "share/man") - endif() - install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3) - install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5) - # Install pkg-config files - if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config - DESTINATION bin) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config - DESTINATION bin) - endif() -endif() - -# Create an export file that CMake users can include() to import our targets. -if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL) - install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake) -endif() - -# what's with libpng-manual.txt and all the extra files? - -# UNINSTALL -# do we need this? - -# DIST -# do we need this? - -# to create msvc import lib for mingw compiled shared lib -# pexports libpng.dll > libpng.def -# lib /def:libpng.def /machine:x86 diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f9c5b74589..32c5ff01dc 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -192,6 +192,7 @@ option(BUILD_SHARED_LIBS "Build shared library" OFF) option(CMAKE_POSITION_INDEPENDENT_CODE "Create object compatible with shared libraries" ON) option(BUILD_TOOLS "Build and install LAMMPS tools (msi2lmp, binary2txt, chain)" OFF) option(BUILD_LAMMPS_SHELL "Build and install the LAMMPS shell" OFF) +option(BUILD_LAMMPS_GUI "Build and install the LAMMPS GUI" OFF) # Support using clang-tidy for C++ files with selected options set(ENABLE_CLANG_TIDY OFF CACHE BOOL "Include clang-tidy processing when compiling") @@ -790,9 +791,11 @@ include(Tools) include(Documentation) ############################################################################### -# Install potential and force field files in data directory +# Install bench, potential and force field files in data directory ############################################################################### -set(LAMMPS_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/lammps) +set(LAMMPS_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/lammps) + +install(DIRECTORY ${LAMMPS_DIR}/bench DESTINATION ${LAMMPS_INSTALL_DATADIR}) install(DIRECTORY ${LAMMPS_POTENTIALS_DIR} DESTINATION ${LAMMPS_INSTALL_DATADIR}) if(BUILD_TOOLS) install(DIRECTORY ${LAMMPS_TOOLS_DIR}/msi2lmp/frc_files DESTINATION ${LAMMPS_INSTALL_DATADIR}) diff --git a/cmake/CMakeLists.zlib b/cmake/CMakeLists.zlib deleted file mode 100644 index a33f14ce64..0000000000 --- a/cmake/CMakeLists.zlib +++ /dev/null @@ -1,195 +0,0 @@ -cmake_minimum_required(VERSION 3.10) -# When using CMake 3.4 and later, don't export symbols from executables unless -# the CMAKE_ENABLE_EXPORTS variable is set. -if(POLICY CMP0065) - cmake_policy(SET CMP0065 NEW) -endif() -if (POLICY CMP0077) - cmake_policy(SET CMP0077 NEW) -endif() -set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) - -project(zlib C) - -set(VERSION "1.2.11") - -option(ASM686 "Enable building i686 assembly implementation" OFF) -option(AMD64 "Enable building amd64 assembly implementation" OFF) - -set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") -set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") -set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") -set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") -set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") - -include(CheckTypeSize) -include(CheckFunctionExists) -include(CheckIncludeFile) -include(CheckCSourceCompiles) - -check_include_file(sys/types.h HAVE_SYS_TYPES_H) -check_include_file(stdint.h HAVE_STDINT_H) -check_include_file(stddef.h HAVE_STDDEF_H) - -# -# Check to see if we have large file support -# -set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) -# We add these other definitions here because CheckTypeSize.cmake -# in CMake 2.4.x does not automatically do so and we want -# compatibility with CMake 2.4.x. -if(HAVE_SYS_TYPES_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) -endif() -if(HAVE_STDINT_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) -endif() -if(HAVE_STDDEF_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) -endif() -check_type_size(off64_t OFF64_T) -check_type_size(off64_t OFF64_T) -if(HAVE_OFF64_T) - add_definitions(-D_LARGEFILE64_SOURCE=1) -endif() -set(CMAKE_REQUIRED_DEFINITIONS) # clear variable - -# -# Check for fseeko -# -check_function_exists(fseeko HAVE_FSEEKO) -if(NOT HAVE_FSEEKO) - add_definitions(-DNO_FSEEKO) -endif() - -# -# Check for unistd.h -# -check_include_file(unistd.h Z_HAVE_UNISTD_H) - -if(MSVC) - set(CMAKE_DEBUG_POSTFIX "d") - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -endif() - -if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) - # If we're doing an out of source build and the user has a zconf.h - # in their source tree... - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) - file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included) - endif() -endif() - -set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein - ${ZLIB_PC} @ONLY) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein - ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) - - -#============================================================================ -# zlib -#============================================================================ - -set(ZLIB_PUBLIC_HDRS - ${CMAKE_CURRENT_BINARY_DIR}/zconf.h - zlib.h -) -set(ZLIB_PRIVATE_HDRS - crc32.h - deflate.h - gzguts.h - inffast.h - inffixed.h - inflate.h - inftrees.h - trees.h - zutil.h -) -set(ZLIB_SRCS - adler32.c - compress.c - crc32.c - deflate.c - gzclose.c - gzlib.c - gzread.c - gzwrite.c - inflate.c - infback.c - inftrees.c - inffast.c - trees.c - uncompr.c - zutil.c -) - -if(NOT MINGW) - set(ZLIB_DLL_SRCS - win32/zlib1.rc # If present will override custom build rule below. - ) -endif() - -if(CMAKE_COMPILER_IS_GNUCC) - if(ASM686) - set(ZLIB_ASMS contrib/asm686/match.S) - elseif (AMD64) - set(ZLIB_ASMS contrib/amd64/amd64-match.S) - endif () - - if(ZLIB_ASMS) - add_definitions(-DASMV) - set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE) - endif() -endif() - -if(MSVC) - if(ASM686) - ENABLE_LANGUAGE(ASM_MASM) - set(ZLIB_ASMS - contrib/masmx86/inffas32.asm - contrib/masmx86/match686.asm - ) - elseif (AMD64) - ENABLE_LANGUAGE(ASM_MASM) - set(ZLIB_ASMS - contrib/masmx64/gvmat64.asm - contrib/masmx64/inffasx64.asm - ) - endif() - - if(ZLIB_ASMS) - add_definitions(-DASMV -DASMINF) - endif() -endif() - -# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) -string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" - "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) - -if(MINGW) - # This gets us DLL resource information when compiling on MinGW. - if(NOT CMAKE_RC_COMPILER) - set(CMAKE_RC_COMPILER windres.exe) - endif() - - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj - COMMAND ${CMAKE_RC_COMPILER} - -D GCC_WINDRES - -I ${CMAKE_CURRENT_SOURCE_DIR} - -I ${CMAKE_CURRENT_BINARY_DIR} - -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj - -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) - set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) -endif(MINGW) - -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) - -if(UNIX) - # On unix-like platforms the library is almost always called libz - set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME z) -endif() \ No newline at end of file diff --git a/cmake/CMakeSettings.json b/cmake/CMakeSettings.json index 205b443bf1..c880962535 100644 --- a/cmake/CMakeSettings.json +++ b/cmake/CMakeSettings.json @@ -63,6 +63,11 @@ "name": "ENABLE_TESTING", "value": "True", "type": "BOOL" + }, + { + "name": "BUILD_LAMMPS_GUI", + "value": "False", + "type": "BOOL" } ] }, @@ -303,6 +308,54 @@ "type": "STRING" } ] + }, + { + "name": "x64-GUI-MSVC", + "generator": "Ninja", + "configurationType": "Release", + "buildRoot": "${workspaceRoot}\\build\\${name}", + "installRoot": "${workspaceRoot}\\install\\${name}", + "cmakeCommandArgs": "-C ${workspaceRoot}\\cmake\\presets\\windows.cmake -D QT_DIR=C:\\Qt\\5.15.2\\msvc2019_64\\lib\\cmake\\Qt5 -D Qt5_DIR=C:\\Qt\\5.15.2\\msvc2019_64\\lib\\cmake\\Qt5", + "buildCommandArgs": "", + "ctestCommandArgs": "-V", + "inheritEnvironments": [ "msvc_x64_x64" ], + "variables": [ + { + "name": "BUILD_SHARED_LIBS", + "value": "True", + "type": "BOOL" + }, + { + "name": "BUILD_TOOLS", + "value": "True", + "type": "BOOL" + }, + { + "name": "LAMMPS_EXCEPTIONS", + "value": "True", + "type": "BOOL" + }, + { + "name": "ENABLE_TESTING", + "value": "False", + "type": "BOOL" + }, + { + "name": "BUILD_MPI", + "value": "False", + "type": "BOOL" + }, + { + "name": "WITH_PNG", + "value": "False", + "type": "BOOL" + }, + { + "name": "BUILD_LAMMPS_GUI", + "value": "True", + "type": "BOOL" + } + ] } ] } \ No newline at end of file diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index 4a70eb7a1e..99321fce9f 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -64,6 +64,8 @@ if(GPU_API STREQUAL "CUDA") endif() set(GPU_CUDA_MPS_FLAGS "-DCUDA_MPS_SUPPORT") endif() + option(CUDA_BUILD_MULTIARCH "Enable building CUDA kernels for all supported GPU architectures" ON) + mark_as_advanced(GPU_BUILD_MULTIARCH) set(GPU_ARCH "sm_50" CACHE STRING "LAMMPS GPU CUDA SM primary architecture (e.g. sm_60)") @@ -93,56 +95,58 @@ if(GPU_API STREQUAL "CUDA") # --arch translates directly instead of JIT, so this should be for the preferred or most common architecture set(GPU_CUDA_GENCODE "-arch=${GPU_ARCH}") - # apply the following to build "fat" CUDA binaries only for known CUDA toolkits since version 8.0 - # only the Kepler achitecture and beyond is supported - # comparison chart according to: https://en.wikipedia.org/wiki/CUDA#GPUs_supported - if(CUDA_VERSION VERSION_LESS 8.0) - message(FATAL_ERROR "CUDA Toolkit version 8.0 or later is required") - elseif(CUDA_VERSION VERSION_GREATER_EQUAL "13.0") - message(WARNING "Untested CUDA Toolkit version ${CUDA_VERSION}. Use at your own risk") - set(GPU_CUDA_GENCODE "-arch=all") - elseif(CUDA_VERSION VERSION_GREATER_EQUAL "12.0") - set(GPU_CUDA_GENCODE "-arch=all") - else() - # Kepler (GPU Arch 3.0) is supported by CUDA 5 to CUDA 10.2 - if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "11.0")) - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_30,code=[sm_30,compute_30] ") - endif() - # Kepler (GPU Arch 3.5) is supported by CUDA 5 to CUDA 11 - if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "12.0")) - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_35,code=[sm_35,compute_35]") - endif() - # Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "6.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52]") - endif() - # Pascal (GPU Arch 6.x) is supported by CUDA 8 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "8.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61]") - endif() - # Volta (GPU Arch 7.0) is supported by CUDA 9 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "9.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_70,code=[sm_70,compute_70]") - endif() - # Turing (GPU Arch 7.5) is supported by CUDA 10 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "10.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_75,code=[sm_75,compute_75]") - endif() - # Ampere (GPU Arch 8.0) is supported by CUDA 11 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_80,code=[sm_80,compute_80]") - endif() - # Ampere (GPU Arch 8.6) is supported by CUDA 11.1 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.1") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_86,code=[sm_86,compute_86]") - endif() - # Lovelace (GPU Arch 8.9) is supported by CUDA 11.8 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.8") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_90,code=[sm_90,compute_90]") - endif() - # Hopper (GPU Arch 9.0) is supported by CUDA 12.0 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "12.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_90,code=[sm_90,compute_90]") + if(CUDA_BUILD_MULTIARCH) + # apply the following to build "fat" CUDA binaries only for known CUDA toolkits since version 8.0 + # only the Kepler achitecture and beyond is supported + # comparison chart according to: https://en.wikipedia.org/wiki/CUDA#GPUs_supported + if(CUDA_VERSION VERSION_LESS 8.0) + message(FATAL_ERROR "CUDA Toolkit version 8.0 or later is required") + elseif(CUDA_VERSION VERSION_GREATER_EQUAL "13.0") + message(WARNING "Untested CUDA Toolkit version ${CUDA_VERSION}. Use at your own risk") + set(GPU_CUDA_GENCODE "-arch=all") + elseif(CUDA_VERSION VERSION_GREATER_EQUAL "12.0") + set(GPU_CUDA_GENCODE "-arch=all") + else() + # Kepler (GPU Arch 3.0) is supported by CUDA 5 to CUDA 10.2 + if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "11.0")) + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_30,code=[sm_30,compute_30] ") + endif() + # Kepler (GPU Arch 3.5) is supported by CUDA 5 to CUDA 11 + if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "12.0")) + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_35,code=[sm_35,compute_35]") + endif() + # Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "6.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52]") + endif() + # Pascal (GPU Arch 6.x) is supported by CUDA 8 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "8.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61]") + endif() + # Volta (GPU Arch 7.0) is supported by CUDA 9 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "9.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_70,code=[sm_70,compute_70]") + endif() + # Turing (GPU Arch 7.5) is supported by CUDA 10 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "10.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_75,code=[sm_75,compute_75]") + endif() + # Ampere (GPU Arch 8.0) is supported by CUDA 11 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_80,code=[sm_80,compute_80]") + endif() + # Ampere (GPU Arch 8.6) is supported by CUDA 11.1 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.1") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_86,code=[sm_86,compute_86]") + endif() + # Lovelace (GPU Arch 8.9) is supported by CUDA 11.8 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.8") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_90,code=[sm_90,compute_90]") + endif() + # Hopper (GPU Arch 9.0) is supported by CUDA 12.0 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "12.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_90,code=[sm_90,compute_90]") + endif() endif() endif() diff --git a/cmake/Modules/Packages/KOKKOS.cmake b/cmake/Modules/Packages/KOKKOS.cmake index 8b695667ae..795b087bcb 100644 --- a/cmake/Modules/Packages/KOKKOS.cmake +++ b/cmake/Modules/Packages/KOKKOS.cmake @@ -88,7 +88,7 @@ else() if(CMAKE_REQUEST_PIC) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() - add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR}) + add_subdirectory(${LAMMPS_LIB_KOKKOS_SRC_DIR} ${LAMMPS_LIB_KOKKOS_BIN_DIR} EXCLUDE_FROM_ALL) set(Kokkos_INCLUDE_DIRS ${LAMMPS_LIB_KOKKOS_SRC_DIR}/core/src ${LAMMPS_LIB_KOKKOS_SRC_DIR}/containers/src diff --git a/cmake/Modules/Tools.cmake b/cmake/Modules/Tools.cmake index 81d6d66aff..b9ead04e45 100644 --- a/cmake/Modules/Tools.cmake +++ b/cmake/Modules/Tools.cmake @@ -37,7 +37,11 @@ if(BUILD_TOOLS) add_subdirectory(${LAMMPS_TOOLS_DIR}/phonon ${CMAKE_BINARY_DIR}/phana_build) endif() +find_package(PkgConfig QUIET) if(BUILD_LAMMPS_SHELL) + if(NOT PkgConfig_FOUND) + message(FATAL_ERROR "Must have pkg-config installed for building LAMMPS shell") + endif() find_package(PkgConfig REQUIRED) pkg_check_modules(READLINE IMPORTED_TARGET REQUIRED readline) @@ -64,4 +68,8 @@ if(BUILD_LAMMPS_SHELL) install(FILES ${LAMMPS_TOOLS_DIR}/lammps-shell/lammps-shell.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications/) endif() - +if(BUILD_LAMMPS_GUI) + get_filename_component(LAMMPS_GUI_DIR ${LAMMPS_SOURCE_DIR}/../tools/lammps-gui ABSOLUTE) + get_filename_component(LAMMPS_GUI_BIN ${CMAKE_BINARY_DIR}/lammps-gui-build ABSOLUTE) + add_subdirectory(${LAMMPS_GUI_DIR} ${LAMMPS_GUI_BIN}) +endif() diff --git a/cmake/packaging/LAMMPS_DMG_Background.png b/cmake/packaging/LAMMPS_DMG_Background.png new file mode 100644 index 0000000000..5ceb55c5e7 Binary files /dev/null and b/cmake/packaging/LAMMPS_DMG_Background.png differ diff --git a/cmake/packaging/MacOSXBundleInfo.plist.in b/cmake/packaging/MacOSXBundleInfo.plist.in new file mode 100644 index 0000000000..33ce5a602b --- /dev/null +++ b/cmake/packaging/MacOSXBundleInfo.plist.in @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en-US + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleDisplayName + The LAMMPS Molecular Dynamics Software + CFBundleIconFile + lammps + CFBundleIdentifier + org.lammps.gui + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + ${MACOSX_BUNDLE_LONG_VERSION_STRING} + CFBundleName + LAMMPS + CFBundlePackageType + APPL + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleSignature + ???? + CFBundleVersion + ${MACOSX_BUNDLE_BUNDLE_VERSION} + CSResourcesFileMapped + + NSHumanReadableCopyright + ${MACOSX_BUNDLE_COPYRIGHT} + + diff --git a/cmake/packaging/README.macos b/cmake/packaging/README.macos new file mode 100644 index 0000000000..0325045983 --- /dev/null +++ b/cmake/packaging/README.macos @@ -0,0 +1,69 @@ +LAMMPS and LAMMPS GUI universal binaries for macOS (arm64/x86_64) +================================================================= + +This package provides universal binaries of LAMMPS and LAMMPS GUI that should +run on macOS systems running running macOS version 11 (Big Sur) or newer. Note +the binaries are compiled without MPI support and contain a compatible subset +of the available packages. + +The following individual commands are included: +binary2txt lammps-gui lmp msi2lmp phana stl_bin2txt + +After copying the lammps-gui folder into your Applications folder, please follow +these steps: + +1. Open the Terminal app + +2. Type the following command and press ENTER: + + open ~/.zprofile + + This will open a text editor for modifying the .zprofile file in your home + directory. + +3. Add the following lines to the end of the file, save it, and close the editor + + LAMMPS_INSTALL_DIR=/Applications/LAMMPS.app/Contents + LAMMPS_POTENTIALS=${LAMMPS_INSTALL_DIR}/share/lammps/potentials + LAMMPS_BENCH_DIR=${LAMMPS_INSTALL_DIR}/share/lammps/bench + MSI2LMP_LIBRARY=${LAMMPS_INSTALL_DIR}/share/lammps/frc_files + PATH=${LAMMPS_INSTALL_DIR}/bin:$PATH + export LAMMPS_POTENTIALS LAMMPS_BENCH_DIR PATH + +4. In your existing terminal, type the following command make the settings active + + source ~/.zprofile + + Note, you don't have to type this in new terminals, since they will apply + the changes from .zprofile automatically. + + Note: the above assumes you use the default shell (zsh) that comes with + MacOS. If you customized MacOS to use a different shell, you'll need to modify + that shell's init file (.cshrc, .bashrc, etc.) instead with appropiate commands + to modify the same environment variables. + +5. Try running LAMMPS (which might fail, see step 7) + + lmp -in ${LAMMPS_BENCH_DIR}/in.lj + +6. Try running the LAMMPS GUI + + lammps-gui ${LAMMPS_BENCH_DIR}/in.rhodo + + Depending on the size and resolution of your screen, the fonts may + be too small to read. This can be adjusted by setting the environment + variable QT_FONT_DPI. The default value would be 72, so to increase + the fonts by a third one can add to the .zprofile file the line + + export QT_FONT_DPI=96 + + and reload as shown above. + +7. Give permission to execute the commands (lmp, lammps-gui, msi2lmp, binary2txt, phana, stl_bin2txt) + + MacOS will likely block the initial run of the executables, since they + were downloaded from the internet and are missing a known signature from an + identified developer. Go to "Settings" and search for "Security settings". It + should display a message that an executable like "lmp" was blocked. Press + "Open anyway", which might prompt you for your admin credentials. Afterwards + "lmp" and the other executables should work as expected. diff --git a/cmake/packaging/build_linux_tgz.sh b/cmake/packaging/build_linux_tgz.sh new file mode 100755 index 0000000000..e0222858ce --- /dev/null +++ b/cmake/packaging/build_linux_tgz.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +APP_NAME=lammps-gui +DESTDIR=${PWD}/../LAMMPS_GUI + +echo "Delete old files, if they exist" +rm -rf ${DESTDIR} ../LAMMPS-Linux-amd64.tar.gz + +echo "Create staging area for deployment and populate" +DESTDIR=${DESTDIR} cmake --install . --prefix "/" + +echo "Remove debug info" +for s in ${DESTDIR}/bin/* ${DESTDIR}/lib/liblammps* +do \ + test -f $s && strip --strip-debug $s +done + +echo "Remove libc, gcc, and X11 related shared libs" +rm -f ${DESTDIR}/lib/ld*.so ${DESTDIR}/lib/ld*.so.[0-9] +rm -f ${DESTDIR}/lib/lib{c,dl,rt,m,pthread}.so.? +rm -f ${DESTDIR}/lib/lib{c,dl,rt,m,pthread}-[0-9].[0-9]*.so +rm -f ${DESTDIR}/lib/libX* ${DESTDIR}/lib/libxcb* +rm -f ${DESTDIR}/lib/libgcc_s* +rm -f ${DESTDIR}/lib/libstdc++* + +# get qt dir +QTDIR=$(ldd ${DESTDIR}/bin/lammps-gui | grep libQt5Core | sed -e 's/^.*=> *//' -e 's/libQt5Core.so.*$/qt5/') +cat > ${DESTDIR}/bin/qt.conf < *//' -e 's/\(libQt5.*.so.*\) .*$/\1/') +for dep in ${QTDEPS} +do \ + cp ${dep} ${DESTDIR}/lib +done + +echo "Add additional plugins for Qt" +for dir in styles imageformats +do \ + cp -r ${QTDIR}/plugins/${dir} ${DESTDIR}/qt5plugins/ +done + +# get imageplugin dependencies +for s in ${DESTDIR}/qt5plugins/imageformats/*.so +do \ + QTDEPS=$(LD_LIBRARY_PATH=${DESTDIR}/lib ldd $s | grep -v ${DESTDIR} | grep -E '(libQt5|jpeg)' | sed -e 's/^.*=> *//' -e 's/\(lib.*.so.*\) .*$/\1/') + for dep in ${QTDEPS} + do \ + cp ${dep} ${DESTDIR}/lib + done +done + +echo "Set up wrapper script" +MYDIR=$(dirname "$0") +cp ${MYDIR}/linux_wrapper.sh ${DESTDIR}/bin +for s in ${DESTDIR}/bin/* +do \ + EXE=$(basename $s) + test ${EXE} = linux_wrapper.sh && continue + test ${EXE} = qt.conf && continue + ln -s bin/linux_wrapper.sh ${DESTDIR}/${EXE} +done + +pushd .. +tar -czvvf LAMMPS-Linux-amd64.tar.gz LAMMPS_GUI +popd + +echo "Cleanup dir" +rm -r ${DESTDIR} +exit 0 diff --git a/cmake/packaging/build_macos_dmg.sh b/cmake/packaging/build_macos_dmg.sh new file mode 100755 index 0000000000..5204e519c2 --- /dev/null +++ b/cmake/packaging/build_macos_dmg.sh @@ -0,0 +1,111 @@ +#!/bin/bash + +APP_NAME=lammps-gui + +echo "Delete old files, if they exist" +rm -f ${APP_NAME}.dmg ${APP_NAME}-rw.dmg LAMMPS-macOS-multiarch.dmg + +echo "Create initial dmg file with macdeployqt" +macdeployqt lammps-gui.app -dmg +echo "Create writable dmg file" +hdiutil convert ${APP_NAME}.dmg -format UDRW -o ${APP_NAME}-rw.dmg + +echo "Mount writeable DMG file in read-write mode. Keep track of device and volume names" +DEVICE=$(hdiutil attach -readwrite -noverify ${APP_NAME}-rw.dmg | grep '^/dev/' | sed 1q | awk '{print $1}') +VOLUME=$(df | grep ${DEVICE} | sed -e 's/^.*\(\/Volumes\/\)/\1/') +sleep 2 + +echo "Create link to Application folder and move README and background image files" + +pushd "${VOLUME}" +ln -s /Applications . +mv ${APP_NAME}.app/Contents/Resources/README.txt . +mkdir .background +mv ${APP_NAME}.app/Contents/Resources/LAMMPS_DMG_Background.png .background/background.png +mv ${APP_NAME}.app LAMMPS.app +cd LAMMPS.app/Contents + +echo "Attach icons to LAMMPS console and GUI executables" +echo "read 'icns' (-16455) \"Resources/lammps.icns\";" > icon.rsrc +Rez -a icon.rsrc -o bin/lmp +SetFile -a C bin/lmp +Rez -a icon.rsrc -o MacOS/lammps-gui +SetFile -a C MacOS/lammps-gui +rm icon.rsrc +popd + +echo 'Tell the Finder to resize the window, set the background,' +echo 'change the icon size, place the icons in the right position, etc.' +echo ' + tell application "Finder" + tell disk "'${APP_NAME}'" + + -- wait for the image to finish mounting + set open_attempts to 0 + repeat while open_attempts < 4 + try + open + delay 1 + set open_attempts to 5 + close + on error errStr number errorNumber + set open_attempts to open_attempts + 1 + delay 10 + end try + end repeat + delay 5 + + -- open the image the first time and save a .DS_Store + -- just the background and icon setup + open + set current view of container window to icon view + set theViewOptions to the icon view options of container window + set background picture of theViewOptions to file ".background:background.png" + set arrangement of theViewOptions to not arranged + set icon size of theViewOptions to 64 + delay 5 + close + + -- next set up the position of the app and Applications symlink + -- plus hide all window decorations + open + update without registering applications + tell container window + set sidebar width to 0 + set statusbar visible to false + set toolbar visible to false + set the bounds to { 100, 40, 868, 640 } + set position of item "'LAMMPS'.app" to { 190, 216 } + set position of item "Applications" to { 576, 216 } + set position of item "README.txt" to { 190, 400 } + end tell + update without registering applications + delay 5 + close + + -- one last open and close to check the results + open + delay 5 + close + end tell + delay 1 + end tell +' | osascript + +sync + +echo "Unmount modified disk image and convert to compressed read-only image" +hdiutil detach "${DEVICE}" +hdiutil convert "${APP_NAME}-rw.dmg" -format UDZO -o "LAMMPS-macOS-multiarch.dmg" + +echo "Attach icon to .dmg file" +echo "read 'icns' (-16455) \"lammps-gui.app/Contents/Resources/lammps.icns\";" > icon.rsrc +Rez -a icon.rsrc -o LAMMPS-macOS-multiarch.dmg +SetFile -a C LAMMPS-macOS-multiarch.dmg +rm icon.rsrc + +echo "Delete temporary disk images" +rm -f "${APP_NAME}-rw.dmg" +rm -f "${APP_NAME}.dmg" + +exit 0 diff --git a/cmake/packaging/build_windows_cross_zip.sh b/cmake/packaging/build_windows_cross_zip.sh new file mode 100755 index 0000000000..5659b84f74 --- /dev/null +++ b/cmake/packaging/build_windows_cross_zip.sh @@ -0,0 +1,26 @@ +#!/bin/bash -vx + +APP_NAME=lammps-gui +DESTDIR=${PWD}/../LAMMPS_GUI + +echo "Delete old files, if they exist" +rm -rvf ${DESTDIR} LAMMPS-Win10-amd64.zip + +echo "Create staging area for deployment and populate" +DESTDIR=${DESTDIR} cmake --install . --prefix "/" + +echo "Add required dependencies for Qt" +for dll in Qt5Core.dll Qt5Gui.dll Qt5Widgets.dll +do \ + cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/${dll} ${DESTDIR}/bin/ +done +for dir in styles platforms imageformats +do \ + mkdir -p ${DESTDIR}/${dir} + cp -r /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/${dir}/*.dll ${DESTDIR}/${dir} +done + +pushd .. +zip -9rv LAMMPS-Win10-amd64.zip LAMMPS_GUI +popd +exit 0 diff --git a/cmake/packaging/build_windows_vs.cmake b/cmake/packaging/build_windows_vs.cmake new file mode 100644 index 0000000000..f051ff351f --- /dev/null +++ b/cmake/packaging/build_windows_vs.cmake @@ -0,0 +1,28 @@ +# CMake script to be run post installation to build zipped package + +# clean up old zipfile and deployment tree +file(REMOVE LAMMPS-Win10-amd64.zip) +file(REMOVE_RECURSE LAMMPS_GUI) +file(RENAME ${INSTNAME} LAMMPS_GUI) + +# move all executables and dlls to main folder and delete bin folder +file(GLOB BINFILES LIST_DIRECTORIES FALSE LAMMPS_GUI/bin/*.exe LAMMPS_GUI/bin/*.dll) +foreach(bin ${BINFILES}) + get_filename_component(exe ${bin} NAME) + file(RENAME ${bin} LAMMPS_GUI/${exe}) +endforeach() +file(REMOVE_RECURSE LAMMPS_GUI/bin) + +# create qt.conf so Qt will find its plugins +file(WRITE LAMMPS_GUI/qt.conf "[Paths]\r\nPlugins = qt5plugins\r\n") + +# initialize environment and then run windeployqt to populate folder with missing dependencies and Qt plugins +file(WRITE qtdeploy.bat "@ECHO OFF\r\nset VSCMD_DEBUG=0\r\nCALL ${VC_INIT} x64\r\nset PATH=${QT5_BIN_DIR};%PATH%\r\nwindeployqt --plugindir LAMMPS_GUI/qt5plugins --release LAMMPS_GUI/lammps-gui.exe --no-quick-import --no-webkit2 --no-translations --no-system-d3d-compiler --no-angle --no-opengl-sw\r\n") +execute_process(COMMAND cmd.exe /c qtdeploy.bat COMMAND_ECHO STDERR) +file(REMOVE qtdeploy.bat) + +# create zip archive +file(WRITE makearchive.ps1 "Compress-Archive -Path LAMMPS_GUI -CompressionLevel Optimal -DestinationPath LAMMPS-Win10-amd64.zip") +execute_process(COMMAND powershell -ExecutionPolicy Bypass -File makearchive.ps1) +file(REMOVE makearchive.ps1) +file(REMOVE_RECURSE LAMMPS_GUI) diff --git a/cmake/packaging/lammps-icon-1024x1024.png b/cmake/packaging/lammps-icon-1024x1024.png new file mode 100644 index 0000000000..f79b034b12 Binary files /dev/null and b/cmake/packaging/lammps-icon-1024x1024.png differ diff --git a/cmake/packaging/lammps.icns b/cmake/packaging/lammps.icns new file mode 100644 index 0000000000..836faa7e22 Binary files /dev/null and b/cmake/packaging/lammps.icns differ diff --git a/cmake/packaging/linux_wrapper.sh b/cmake/packaging/linux_wrapper.sh new file mode 100755 index 0000000000..b3aee1cb4f --- /dev/null +++ b/cmake/packaging/linux_wrapper.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# wrapper for bundled executables + +BASEDIR=$(dirname "$0") +EXENAME=$(basename "$0") + +# append to LD_LIBRARY_PATH to prefer local (newer) libs +LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${BASEDIR}/lib + +# set some environment variables for LAMMPS etc. +LAMMPS_POTENTIALS=${BASEDIR}/share/lammps/potentials +MSI2LMP_LIBRARY=${BASEDIR}/share/lammps/frc_files +export LD_LIBRARY_PATH LAMMPS_POTENTIALS MSI2LMP_LIBRARY + +exec "${BASEDIR}/bin/${EXENAME}" "$@" diff --git a/cmake/packaging/png2iconset.sh b/cmake/packaging/png2iconset.sh new file mode 100755 index 0000000000..c89a5c3381 --- /dev/null +++ b/cmake/packaging/png2iconset.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +if [ $# != 2 ] +then + echo "usage: $0 " + exit 1 +fi + +png="$1" +ico="$2" + +if [ ! -f ${png} ] +then + echo "PNG Image $1 not found" +fi + +rm -rf ${ico}.iconset +mkdir ${ico}.iconset +sips -z 16 16 ${png} --out ${ico}.iconset/icon_16x16.png +sips -z 32 32 ${png} --out ${ico}.iconset/icon_16x16@2x.png +sips -z 32 32 ${png} --out ${ico}.iconset/icon_32x32.png +sips -z 64 64 ${png} --out ${ico}.iconset/icon_32x32@2x.png +sips -z 128 128 ${png} --out ${ico}.iconset/icon_128x128.png +sips -z 256 256 ${png} --out ${ico}.iconset/icon_128x128@2x.png +sips -z 256 256 ${png} --out ${ico}.iconset/icon_256x256.png +sips -z 512 512 ${png} --out ${ico}.iconset/icon_256x256@2x.png +sips -z 512 512 ${png} --out ${ico}.iconset/icon_512x512.png +sips -z 1024 1024 ${png} --out ${ico}.iconset/icon_512x512@2x.png +iconutil -c icns ${ico}.iconset +rm -rf ${ico}.iconset diff --git a/cmake/presets/macos-multiarch.cmake b/cmake/presets/macos-multiarch.cmake new file mode 100644 index 0000000000..58ef013f68 --- /dev/null +++ b/cmake/presets/macos-multiarch.cmake @@ -0,0 +1,14 @@ +# preset that will build portable multi-arch binaries on macOS without MPI + +set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE) +set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0 CACHE STRING "" FORCE) +set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE) + +set(CMAKE_CXX_COMPILER "clang++" CACHE STRING "" FORCE) +set(CMAKE_C_COMPILER "clang" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "" FORCE) + +set(BUILD_MPI FALSE CACHE BOOL "" FORCE) +set(BUILD_SHARED_LIBS FALSE CACHE BOOL "" FORCE) +set(LAMMPS_EXCEPTIONS TRUE CACHE BOOL "" FORCE) diff --git a/doc/lammps.1 b/doc/lammps.1 index 9bc107624f..79964d1680 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,7 +1,7 @@ -.TH LAMMPS "1" "15 June 2023" "2023-06-15" +.TH LAMMPS "1" "2 August 2023" "2023-08-2" .SH NAME .B LAMMPS -\- Molecular Dynamics Simulator. Version 15 June 2023 +\- Molecular Dynamics Simulator. Version 2 August 2023 .SH SYNOPSIS .B lmp diff --git a/doc/src/Bibliography.rst b/doc/src/Bibliography.rst index 2d27d2e6f9..e9ea8b0925 100644 --- a/doc/src/Bibliography.rst +++ b/doc/src/Bibliography.rst @@ -203,7 +203,7 @@ Bibliography A Caro, DA Crowson, M Caro; Phys Rev Lett, 95, 075702 (2005) **(CasP)** - CasP webpage: https://www.helmholtz-berlin.de/people/gregor-schiwietz/casp_en.html + CasP webpage: http://www.casp-program.org/ **(Cawkwell2012)** A.\ M. N. Niklasson, M. J. Cawkwell, Phys. Rev. B, 86 (17), 174308 (2012). diff --git a/doc/src/Build_extras.rst b/doc/src/Build_extras.rst index 0ecf54f744..c1ab6ecb87 100644 --- a/doc/src/Build_extras.rst +++ b/doc/src/Build_extras.rst @@ -140,6 +140,8 @@ CMake build # value = yes or no (default) -D CUDA_MPS_SUPPORT=value # enables some tweaks required to run with active nvidia-cuda-mps daemon # value = yes or no (default) + -D CUDA_BUILD_MULTIARCH=value # enables building CUDA kernels for all supported GPU architectures + # value = yes (default) or no -D USE_STATIC_OPENCL_LOADER=value # downloads/includes OpenCL ICD loader library, no local OpenCL headers/libs needed # value = yes (default) or no @@ -158,41 +160,49 @@ CMake build A more detailed list can be found, for example, at `Wikipedia's CUDA article `_ -CMake can detect which version of the CUDA toolkit is used and thus will try -to include support for **all** major GPU architectures supported by this toolkit. -Thus the GPU_ARCH setting is merely an optimization, to have code for -the preferred GPU architecture directly included rather than having to wait -for the JIT compiler of the CUDA driver to translate it. +CMake can detect which version of the CUDA toolkit is used and thus will +try to include support for **all** major GPU architectures supported by +this toolkit. Thus the GPU_ARCH setting is merely an optimization, to +have code for the preferred GPU architecture directly included rather +than having to wait for the JIT compiler of the CUDA driver to translate +it. This behavior can be turned off (e.g. to speed up compilation) by +setting :code:`CUDA_ENABLE_MULTIARCH` to :code:`no`. -When compiling for CUDA or HIP with CUDA, version 8.0 or later of the CUDA toolkit -is required and a GPU architecture of Kepler or later, which must *also* be -supported by the CUDA toolkit in use **and** the CUDA driver in use. -When compiling for OpenCL, OpenCL version 1.2 or later is required and the -GPU must be supported by the GPU driver and OpenCL runtime bundled with the driver. +When compiling for CUDA or HIP with CUDA, version 8.0 or later of the +CUDA toolkit is required and a GPU architecture of Kepler or later, +which must *also* be supported by the CUDA toolkit in use **and** the +CUDA driver in use. When compiling for OpenCL, OpenCL version 1.2 or +later is required and the GPU must be supported by the GPU driver and +OpenCL runtime bundled with the driver. -When building with CMake, you **must NOT** build the GPU library in ``lib/gpu`` -using the traditional build procedure. CMake will detect files generated by that -process and will terminate with an error and a suggestion for how to remove them. +When building with CMake, you **must NOT** build the GPU library in +``lib/gpu`` using the traditional build procedure. CMake will detect +files generated by that process and will terminate with an error and a +suggestion for how to remove them. -If you are compiling for OpenCL, the default setting is to download, build, and -link with a static OpenCL ICD loader library and standard OpenCL headers. This -way no local OpenCL development headers or library needs to be present and only -OpenCL compatible drivers need to be installed to use OpenCL. If this is not -desired, you can set :code:`USE_STATIC_OPENCL_LOADER` to :code:`no`. +If you are compiling for OpenCL, the default setting is to download, +build, and link with a static OpenCL ICD loader library and standard +OpenCL headers. This way no local OpenCL development headers or library +needs to be present and only OpenCL compatible drivers need to be +installed to use OpenCL. If this is not desired, you can set +:code:`USE_STATIC_OPENCL_LOADER` to :code:`no`. -The GPU library has some multi-thread support using OpenMP. If LAMMPS is built -with ``-D BUILD_OMP=on`` this will also be enabled. +The GPU library has some multi-thread support using OpenMP. If LAMMPS +is built with ``-D BUILD_OMP=on`` this will also be enabled. -If you are compiling with HIP, note that before running CMake you will have to -set appropriate environment variables. Some variables such as -:code:`HCC_AMDGPU_TARGET` (for ROCm <= 4.0) or :code:`CUDA_PATH` are necessary for :code:`hipcc` -and the linker to work correctly. +If you are compiling with HIP, note that before running CMake you will +have to set appropriate environment variables. Some variables such as +:code:`HCC_AMDGPU_TARGET` (for ROCm <= 4.0) or :code:`CUDA_PATH` are +necessary for :code:`hipcc` and the linker to work correctly. -Using CHIP-SPV implementation of HIP is now supported. It allows one to run HIP -code on Intel GPUs via the OpenCL or Level Zero backends. To use CHIP-SPV, you must -set :code:`-DHIP_USE_DEVICE_SORT=OFF` in your CMake command line as CHIP-SPV does not -yet support hipCUB. The use of HIP for Intel GPUs is still experimental so you -should only use this option in preparations to run on Aurora system at ANL. +.. versionadded:: 3Aug2022 + +Using the CHIP-SPV implementation of HIP is supported. It allows one to +run HIP code on Intel GPUs via the OpenCL or Level Zero backends. To use +CHIP-SPV, you must set :code:`-DHIP_USE_DEVICE_SORT=OFF` in your CMake +command line as CHIP-SPV does not yet support hipCUB. As of Summer 2022, +the use of HIP for Intel GPUs is experimental. You should only use this +option in preparations to run on Aurora system at Argonne. .. code:: bash diff --git a/doc/src/Developer_grid.rst b/doc/src/Developer_grid.rst index cd6d8d12ab..22eadd5da8 100644 --- a/doc/src/Developer_grid.rst +++ b/doc/src/Developer_grid.rst @@ -92,8 +92,8 @@ Arguments for these methods can be values returned by the *setup_grid()* method (described below), which define the extent of the grid cells (owned+ghost) the processor owns. These 4 methods allocate memory for 2d (first two) and 3d (second two) grid data. The -two methods that end in "_one" allocate an array which stores a single -value per grid cell. The two that end in "_multi" allocate an array +two methods that end in "_offset" allocate an array which stores a single +value per grid cell. The two that end in "_last" allocate an array which stores *Nvalues* per grid cell. .. code-block:: c++ diff --git a/doc/src/Howto_2d.rst b/doc/src/Howto_2d.rst index be223c076a..ae58711063 100644 --- a/doc/src/Howto_2d.rst +++ b/doc/src/Howto_2d.rst @@ -13,9 +13,9 @@ box with a single z plane of atoms - e.g. .. code-block:: LAMMPS - create box 1 -10 10 -10 10 -0.25 0.25 + create_box 1 -10 10 -10 10 -0.25 0.25 -If using the :doc:`read data ` command to read in a file of +If using the :doc:`read_data ` command to read in a file of atom coordinates, set the "zlo zhi" values to be finite but narrow, similar to the create_box command settings just described. For each atom in the file, assign a z coordinate so it falls inside the diff --git a/doc/src/Howto_bpm.rst b/doc/src/Howto_bpm.rst index 8b84e96b99..0ca4e85fbb 100644 --- a/doc/src/Howto_bpm.rst +++ b/doc/src/Howto_bpm.rst @@ -79,9 +79,9 @@ As bonds can be broken between neighbor list builds, the bond styles. There are two possible settings which determine how pair interactions work between bonded particles. First, one can overlay pair forces with bond forces such that all bonded particles also -feel pair interactions. This can be accomplished by using the *overlay/pair* -keyword present in all bpm bond styles and by using the following special -bond settings +feel pair interactions. This can be accomplished by setting the *overlay/pair* +keyword present in all bpm bond styles to *yes* and requires using the +following special bond settings .. code-block:: LAMMPS @@ -107,7 +107,17 @@ bond lists is expensive. By setting the lj weight for 1-2 bonds to zero, this turns off pairwise interactions. Even though there are no charges in BPM models, setting a nonzero coul weight for 1-2 bonds ensures all bonded neighbors are still included in the neighbor list -in case bonds break between neighbor list builds. +in case bonds break between neighbor list builds. If bond breakage is +disabled during a simulation run by setting the *break* keyword to *no*, +a zero coul weight for 1-2 bonds can be used to exclude bonded atoms +from the neighbor list builds + + .. code-block:: LAMMPS + + special_bonds lj 0 1 1 coul 0 1 1 + +This can be useful for post-processing, or to determine pair interaction +properties between distinct bonded particles. To monitor the fracture of bonds in the system, all BPM bond styles have the ability to record instances of bond breakage to output using diff --git a/doc/src/Modify_style.rst b/doc/src/Modify_style.rst index c5aef71597..e02c2ce59f 100644 --- a/doc/src/Modify_style.rst +++ b/doc/src/Modify_style.rst @@ -28,20 +28,34 @@ Include files (varied) packages and hard-to-find bugs have regularly manifested in the past. -- Header files, especially those defining a "style", should only use - the absolute minimum number of include files and **must not** - contain any ``using`` statements. Typically, that would only be the - header for the base class. Instead, any include statements should - be put in the corresponding implementation files and forward - declarations be used. For implementation files, the "include what - you use" principle should be employed. However, there is the - notable exception that when the ``pointers.h`` header is included - (or one of the base classes derived from it) certain headers will - always be included and thus do not need to be explicitly specified. - These are: `mpi.h`, `cstddef`, `cstdio`, `cstdlib`, `string`, - `utils.h`, `vector`, `fmt/format.h`, `climits`, `cinttypes`. This - also means any such file can assume that `FILE`, `NULL`, and - `INT_MAX` are defined. +- Header files, especially those defining a "style", should only use the + absolute minimum number of include files and **must not** contain any + ``using`` statements. Typically, that would only be the header for the + base class. Instead, any include statements should be put in the + corresponding implementation files and forward declarations be used. + For implementation files, the "include what you use" principle should + be employed. However, there is the notable exception that when the + ``pointers.h`` header is included (or the header of one of the classes + derived from it), certain headers will *always* be included and thus + do not need to be explicitly specified. These are: `mpi.h`, + `cstddef`, `cstdio`, `cstdlib`, `string`, `utils.h`, `vector`, + `fmt/format.h`, `climits`, `cinttypes`. This also means any such file + can assume that `FILE`, `NULL`, and `INT_MAX` are defined. + +- Class members variables should not be initialized in the header file, + but instead should be initialized either in the initializer list of + the constructor or explicitly assigned in the body of the constructor. + If the member variable is relevant to the functionality of a class + (for example when it stores a value from a command line argument), the + member variable declaration is followed by a brief comment explaining + its purpose and what its values can be. Class members that are + pointers should always be initialized to ``nullptr`` in the + initializer list of the constructor. This reduces clutter in the + header and avoids accessing uninitialized pointers, which leads to + hard to debug issues, class members are often implicitly initialized + to ``NULL`` on the first use (but *not* after a :doc:`clear command + `). Please see the files ``reset_atoms_mol.h`` and + ``reset_atoms_mol.cpp`` as an example. - System headers or headers from installed libraries are included with angular brackets (example: ``#include ``), while local diff --git a/doc/src/Tools.rst b/doc/src/Tools.rst index bccb9abe73..b20b722bfd 100644 --- a/doc/src/Tools.rst +++ b/doc/src/Tools.rst @@ -93,6 +93,7 @@ Miscellaneous tools * :ref:`i-pi ` * :ref:`kate ` * :ref:`LAMMPS shell ` + * :ref:`LAMMPS GUI ` * :ref:`LAMMPS magic patterns for file(1) ` * :ref:`Offline build tool ` * :ref:`singularity/apptainer ` @@ -634,6 +635,229 @@ you first need to use the :doc:`clear` command. ---------- +.. _lammps_gui: + +LAMMPS GUI +---------- + +.. versionadded:: 2Aug2023 + +Overview +^^^^^^^^ + +LAMMPS GUI is essentially a small graphical text editor that is linked +to the :ref:`LAMMPS C-library interface ` and thus can run +LAMMPS directly using the contents of the editor's text buffer as input. +This is similar to what people usually would do using a text editor to +edit the input and then a command line terminal window to run the input +commands. The main benefit is that this integrates very well with +graphical desktop environments and that it is easier to use for +beginners in running computations and thus very suitable for tutorials +on LAMMPS. A small difference is that for the LAMMPS GUI it is not +require to first commit its buffer of the text editor to a file. + +Features +^^^^^^^^ + +The main window of the LAMMPS GUI is a generic text editor window with +line numbers and syntax highlighting set up for LAMMPS input files. It +can be used to edit any kind of text file, though. The output of a run +is captured and displayed in a separate dialog window and *not* sent to +the console or a log file (unless the :doc:`log command ` is used +in the input. The log window is regularly updated during the run and a +progress bar for the run command shown at the bottom of the main window. +Starting a new run will open another log windows. The state of LAMMPS +will be reset between two runs. After the simulation is finished, an +image of the simulated system can be created and shown in an image +viewer window. Ongoing runs can be stopped at the next iteration via +triggering a timeout. + +When opening a file, the editor will determine the directory where the +file resides and switch its current working directory to the folder of +that file. Many LAMMPS inputs contain commands that read other files, +typically from the folder of the input file. The GUI will always show +the current working directory in the bottom. The editor window can also +receive (entire) files via drag-n-drop from a file manager GUI or a +desktop environment. When exiting the GUI with a modified buffer, a +dialog asking to either cancel, ignore the modifications, or save the +file with show up. Same when attempting to load a new file into a +modified buffer. + +Hotkeys +^^^^^^^ + +Almost all functionality is accessible from the menu or via hotkeys. +The following hotkeys are available (On macOS use the Command key +instead of Ctrl (aka Control)). + +.. list-table:: + :header-rows: 1 + :widths: auto + + * - Hotkey + - Function + - Hotkey + - Function + - Hotkey + - Function + - Hotkey + - Function + * - Ctrl+N + - New File + - Ctrl+Z + - Undo edit + - Ctrl+V + - Paste text + - Ctrl+Q + - Quit (Main Window only) + * - Ctrl+O + - Open File + - Ctrl+Shift+Z + - Redo edit + - Ctrl+Enter + - Run LAMMPS + - Ctrl+W + - Close (Log and Image Window only) + * - CTRL+S + - Save File + - Ctrl+C + - Copy text + - Ctrl+/ + - Stop Active Run + - Ctrl+P + - Preferences + * - Ctrl+Shift+S + - Save File As + - Ctrl+X + - Cut text + - Ctrl+I + - Create Snapshot Image + - Ctrl+Shift+/ + - Quick Help + +Further editing keybindings `are documented with the Qt documentation +`_. In +case of conflicts the list above takes precedence. + +Parallelization +^^^^^^^^^^^^^^^ + +Due to its nature as a graphical application, it is not possible to use +the LAMMPS GUI in parallel with MPI, but OpenMP multi-threading is +available and enabled by default. + +Prerequisites and portability +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +LAMMPS GUI is programmed in C++ based on the C++11 standard and using +the `Qt GUI framework `_. +Currently, Qt version 5.12 or later is required; Qt 5.15LTS is +recommended Qt 6.x not (yet) supported. Furthermore, CMake version 3.16 +is required and LAMMPS must be configured with ``-D +LAMMPS_EXCETIONS=on`` and ``-D BUILD_MPI=off``. It has been successfully +compiled and tested on: + +- Ubuntu Linux 20.04LTS x86_64 using GCC 9, Qt version 5.12 +- Fedora Linux 38 x86\_64 using GCC 13 and Clang 16, Qt version 5.15LTS +- Apple macOS 12 (Monterey) and macOS 13 (Ventura) with Xcode on arm64 and x86\_64, Qt version 5.15LTS +- Windows 10 and 11 x86_64 with Visual Studio 2022 and Visual C++ 14.36, Qt version 5.15LTS + +Pre-compiled executables +^^^^^^^^^^^^^^^^^^^^^^^^ + +Pre-compiled LAMMPS executables including the GUI are currently +available from https://download.lammps.org/static. You can unpack the +archive (or mount the macOS disk image) and run the GUI directly in +place. The folder may also be moved around and added to the ``PATH`` +environment variable so the executables will be found automatically. The +LAMMPS GUI executable is called ``lammps-gui`` and takes no arguments or +will interpret the first argument as filename to load. + +Compilation +^^^^^^^^^^^ + +The source for the LAMMPS GUI is included with the LAMMPS source code +distribution in the folder `tools/lammps-gui` and thus it can be can be +built as part of a regular LAMMPS compilation. +:doc:`Using CMake ` is required. +To enable its compilation the CMake variable ``-D BUILD_LAMMPS_GUI=on`` +must be set when creating the CMake configuration. All other settings +(compiler, flags, compile type) for LAMMPS GUI are then inherited from +the regular LAMMPS build. If the Qt library is packaged for Linux +distributions, then its location is typically auto-detected since the +required CMake configuration files are stored in a location where CMake +can find them without additional help. Otherwise, the location of the +Qt library installation must be indicated by setting +``-D Qt5_DIR=/path/to/qt5/lib/cmake/Qt5``, which is a path to a folder inside +the Qt installation that contains the file ``Qt5Config.cmake``. + +It is also possible to build the LAMMPS GUI as a standalone executable +(e.g. when LAMMPS has been compiled with traditional make), then the +CMake configuration needs to be told where to find the LAMMPS headers +and the LAMMPS library, via `-D LAMMPS_SOURCE_DIR=/path/to/lammps/src`. +CMake will try to guess a build folder with the LAMMPS library from that +path, but it can also be set with `-D LAMMPS_LIB_DIR=/path/to/lammps/lib`. + +Rather than linking to the LAMMPS library during compilation, it is also +possible to compile the GUI with a plugin loader library that will load +the LAMMPS library dynamically at runtime during the start of the GUI +from a shared library; e.g. `liblammps.so` or `liblammps.dylib` or +`liblammps.dll` (depending on the operating system). This has the +advantage that the LAMMPS library can be updated LAMMPS without having +to recompile the GUI. The ABI of the LAMMPS C-library interface is very +stable and generally backward compatible. This feature is enabled by +setting ``-D LAMMPS_GUI_USE_PLUGIN=on`` and then +``-D LAMMPS_PLUGINLIB_DIR=/path/to/lammps/plugin/loader``. Typically, this +would be the ``examples/COUPLE/plugin`` folder of the LAMMPS distribution. + +Platform notes +^^^^^^^^^^^^^^ + +macOS +""""" + +When building on macOS, the build procedure will try to manufacture a +drag-n-drop installer, LAMMPS-macOS-multiarch.dmg, when using the 'dmg' +target (i.e. `cmake --build --target dmg` or `make dmg`. + +To build multi-arch executables that will run on both, arm64 and x86_64 +architectures natively, it is necessary to set the CMake variable ``-D +CMAKE_OSX_ARCHITECTURES=arm64;x86_64``. To achieve wide compatibility +with different macOS versions, you can also set ``-D +CMAKE_OSX_DEPLOYMENT_TARGET=11.0`` which will set compatibility to macOS +11 (Big Sur) and later, even if you are compiling on a more recent macOS +version. + +Windows +""""""" + +On Windows currently only compilation from within Visual Studio 2022 is +supported and tested. Using CMake and Ninja as build system is +required. Qt needs to be installed, tested was a package downloaded from +https://www.qt.io, into the ``C:\\Qt`` folder. There is a custom +`x64-GUI-MSVC` build configuration provided that will activate building +the `lammps-gui.exe` executable in addition to LAMMPS. When requesting +an installation from the `Build` menu, it will create a compressed zip +file with the executables and required dependent .dll files. This zip +file can be uncompressed and ``lammps-gui.exe`` run directly from there. +The uncompressed folder can be added to the ``PATH`` environment and +LAMMPS and LAMMPS GUI can be launched from anywhere from the command +line. + +Linux +""""" + +Version 5.12 or later of the Qt library and CMake version 3.16 are +required and those are provided by, e.g., Ubuntu 20.04LTS. Thus older +Linux distributions are not likely to be supported, while more recent +ones will work, even for pre-compiled executables (see above). After +compiling with ``cmake --build ``, use +``cmake --build --target tgz`` or ``make tgz`` to build +a ``LAMMPS-Linux-amd64.tar.gz`` file with the executables and their +support libraries. + +---------- + .. _arc: lmp2arc tool diff --git a/doc/src/atc_add_molecule.rst b/doc/src/atc_add_molecule.rst index dc0f0318ac..68330da256 100644 --- a/doc/src/atc_add_molecule.rst +++ b/doc/src/atc_add_molecule.rst @@ -6,7 +6,7 @@ fix_modify AtC add_molecule command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify add_molecule diff --git a/doc/src/atc_add_species.rst b/doc/src/atc_add_species.rst index 0b39379e62..3fc2bcb2d3 100644 --- a/doc/src/atc_add_species.rst +++ b/doc/src/atc_add_species.rst @@ -6,7 +6,7 @@ fix_modify AtC add_species command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify add_species diff --git a/doc/src/atc_atom_element_map.rst b/doc/src/atc_atom_element_map.rst index 96895acc8e..f614e8f350 100644 --- a/doc/src/atc_atom_element_map.rst +++ b/doc/src/atc_atom_element_map.rst @@ -6,7 +6,7 @@ fix_modify AtC atom_element_map command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify atom_element_map [] diff --git a/doc/src/atc_atom_weight.rst b/doc/src/atc_atom_weight.rst index 50e7ea146d..1e1d771ef1 100644 --- a/doc/src/atc_atom_weight.rst +++ b/doc/src/atc_atom_weight.rst @@ -6,7 +6,7 @@ fix_modify AtC atom_weight command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify atom_weight diff --git a/doc/src/atc_atomic_charge.rst b/doc/src/atc_atomic_charge.rst index 4b3d34b815..1207043324 100644 --- a/doc/src/atc_atomic_charge.rst +++ b/doc/src/atc_atomic_charge.rst @@ -6,7 +6,7 @@ fix_modify AtC atomic_charge command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify atomic_charge diff --git a/doc/src/atc_boundary_dynamics.rst b/doc/src/atc_boundary_dynamics.rst index 696d091094..6b571f53d0 100644 --- a/doc/src/atc_boundary_dynamics.rst +++ b/doc/src/atc_boundary_dynamics.rst @@ -6,7 +6,7 @@ fix_modify AtC boundary_dynamics command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify boundary_dynamics diff --git a/doc/src/atc_boundary_faceset.rst b/doc/src/atc_boundary_faceset.rst index c33239b833..7c0654cc00 100644 --- a/doc/src/atc_boundary_faceset.rst +++ b/doc/src/atc_boundary_faceset.rst @@ -6,7 +6,7 @@ fix_modify AtC boundary_faceset command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify boundary_faceset diff --git a/doc/src/atc_boundary_type.rst b/doc/src/atc_boundary_type.rst index 26b40e5a12..a43c17a658 100644 --- a/doc/src/atc_boundary_type.rst +++ b/doc/src/atc_boundary_type.rst @@ -6,7 +6,7 @@ fix_modify AtC boundary type command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify boundary type diff --git a/doc/src/atc_consistent_fe_initialization.rst b/doc/src/atc_consistent_fe_initialization.rst index 3241752262..78f7699906 100644 --- a/doc/src/atc_consistent_fe_initialization.rst +++ b/doc/src/atc_consistent_fe_initialization.rst @@ -6,7 +6,7 @@ fix_modify AtC consistent_fe_initialization command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify consistent_fe_initialization diff --git a/doc/src/atc_control_localized_lambda.rst b/doc/src/atc_control_localized_lambda.rst index eb286756b7..ca0bba30d5 100644 --- a/doc/src/atc_control_localized_lambda.rst +++ b/doc/src/atc_control_localized_lambda.rst @@ -6,7 +6,7 @@ fix_modify AtC control localized_lambda command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify control localized_lambda diff --git a/doc/src/atc_control_momentum.rst b/doc/src/atc_control_momentum.rst index e87bd789b9..fcc3570e06 100644 --- a/doc/src/atc_control_momentum.rst +++ b/doc/src/atc_control_momentum.rst @@ -6,7 +6,7 @@ fix_modify AtC control momentum command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify control fix_modify AtC control momentum none diff --git a/doc/src/atc_control_thermal.rst b/doc/src/atc_control_thermal.rst index 7a17701c5c..c14e52ac8f 100644 --- a/doc/src/atc_control_thermal.rst +++ b/doc/src/atc_control_thermal.rst @@ -6,7 +6,7 @@ fix_modify AtC control thermal command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify control fix_modify control thermal diff --git a/doc/src/atc_decomposition.rst b/doc/src/atc_decomposition.rst index 50d11bf52f..182a27d915 100644 --- a/doc/src/atc_decomposition.rst +++ b/doc/src/atc_decomposition.rst @@ -6,7 +6,7 @@ fix_modify AtC decomposition command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify decomposition diff --git a/doc/src/atc_electron_integration.rst b/doc/src/atc_electron_integration.rst index 2f3fd9eee2..b3cd858e3d 100644 --- a/doc/src/atc_electron_integration.rst +++ b/doc/src/atc_electron_integration.rst @@ -6,7 +6,7 @@ fix_modify AtC extrinsic electron_integration command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify extrinsic electron_integration [] diff --git a/doc/src/atc_equilibrium_start.rst b/doc/src/atc_equilibrium_start.rst index 0068dc02c3..b1ef99dc11 100644 --- a/doc/src/atc_equilibrium_start.rst +++ b/doc/src/atc_equilibrium_start.rst @@ -6,7 +6,7 @@ fix_modify AtC equilibrium_start command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify equilibrium_start diff --git a/doc/src/atc_extrinsic_exchange.rst b/doc/src/atc_extrinsic_exchange.rst index 03d794115b..55aa4115b5 100644 --- a/doc/src/atc_extrinsic_exchange.rst +++ b/doc/src/atc_extrinsic_exchange.rst @@ -6,7 +6,7 @@ fix_modify AtC extrinsic exchange command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify extrinsic exchange diff --git a/doc/src/atc_fe_md_boundary.rst b/doc/src/atc_fe_md_boundary.rst index ad66bf6d49..ebc783c333 100644 --- a/doc/src/atc_fe_md_boundary.rst +++ b/doc/src/atc_fe_md_boundary.rst @@ -6,7 +6,7 @@ fix_modify AtC fe_md_boundary command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify fe_md_boundary diff --git a/doc/src/atc_filter_scale.rst b/doc/src/atc_filter_scale.rst index ce62a589eb..100906d9f7 100644 --- a/doc/src/atc_filter_scale.rst +++ b/doc/src/atc_filter_scale.rst @@ -6,7 +6,7 @@ fix_modify AtC filter scale command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify filter scale diff --git a/doc/src/atc_filter_type.rst b/doc/src/atc_filter_type.rst index 5e2da80755..605c84c192 100644 --- a/doc/src/atc_filter_type.rst +++ b/doc/src/atc_filter_type.rst @@ -6,7 +6,7 @@ fix_modify AtC filter type command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify filter type diff --git a/doc/src/atc_fix.rst b/doc/src/atc_fix.rst index d3ba972508..77bc37ccef 100644 --- a/doc/src/atc_fix.rst +++ b/doc/src/atc_fix.rst @@ -6,7 +6,7 @@ fix_modify AtC fix command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify fix diff --git a/doc/src/atc_fix_flux.rst b/doc/src/atc_fix_flux.rst index 12699e9163..71513eb1f9 100644 --- a/doc/src/atc_fix_flux.rst +++ b/doc/src/atc_fix_flux.rst @@ -6,7 +6,7 @@ fix_modify AtC fix_flux command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify fix_flux diff --git a/doc/src/atc_hardy_computes.rst b/doc/src/atc_hardy_computes.rst index 609740fe99..fe42a6265f 100644 --- a/doc/src/atc_hardy_computes.rst +++ b/doc/src/atc_hardy_computes.rst @@ -6,7 +6,7 @@ fix_modify AtC computes command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify computes diff --git a/doc/src/atc_hardy_fields.rst b/doc/src/atc_hardy_fields.rst index bef051bbe8..0159bb55ab 100644 --- a/doc/src/atc_hardy_fields.rst +++ b/doc/src/atc_hardy_fields.rst @@ -6,7 +6,7 @@ fix_modify AtC fields command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify fields fix_modify fields diff --git a/doc/src/atc_hardy_gradients.rst b/doc/src/atc_hardy_gradients.rst index 2e7649d73c..52d05eac7c 100644 --- a/doc/src/atc_hardy_gradients.rst +++ b/doc/src/atc_hardy_gradients.rst @@ -6,7 +6,7 @@ fix_modify AtC gradients command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify gradients diff --git a/doc/src/atc_hardy_kernel.rst b/doc/src/atc_hardy_kernel.rst index 74316ec8b2..b3a10e8e99 100644 --- a/doc/src/atc_hardy_kernel.rst +++ b/doc/src/atc_hardy_kernel.rst @@ -6,7 +6,7 @@ fix_modify AtC kernel command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify kernel diff --git a/doc/src/atc_hardy_on_the_fly.rst b/doc/src/atc_hardy_on_the_fly.rst index fe7c688387..4635d72d13 100644 --- a/doc/src/atc_hardy_on_the_fly.rst +++ b/doc/src/atc_hardy_on_the_fly.rst @@ -6,7 +6,7 @@ fix_modify AtC on_the_fly command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify on_the_fly diff --git a/doc/src/atc_hardy_rates.rst b/doc/src/atc_hardy_rates.rst index 56166087d7..0c23e211ba 100644 --- a/doc/src/atc_hardy_rates.rst +++ b/doc/src/atc_hardy_rates.rst @@ -6,7 +6,7 @@ fix_modify AtC rates command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify rates diff --git a/doc/src/atc_initial.rst b/doc/src/atc_initial.rst index 7d62251c6c..721f0f3538 100644 --- a/doc/src/atc_initial.rst +++ b/doc/src/atc_initial.rst @@ -6,7 +6,7 @@ fix_modify AtC initial command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify initial diff --git a/doc/src/atc_internal_element_set.rst b/doc/src/atc_internal_element_set.rst index 4a376f55a3..e50463feed 100644 --- a/doc/src/atc_internal_element_set.rst +++ b/doc/src/atc_internal_element_set.rst @@ -6,7 +6,7 @@ fix_modify AtC internal_element_set command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify internal_element_set diff --git a/doc/src/atc_internal_quadrature.rst b/doc/src/atc_internal_quadrature.rst index b171914021..d8e241572c 100644 --- a/doc/src/atc_internal_quadrature.rst +++ b/doc/src/atc_internal_quadrature.rst @@ -6,7 +6,7 @@ fix_modify AtC internal_quadrature command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify internal_quadrature [region] diff --git a/doc/src/atc_kernel_bandwidth.rst b/doc/src/atc_kernel_bandwidth.rst index 02707cfd30..f166a063e3 100644 --- a/doc/src/atc_kernel_bandwidth.rst +++ b/doc/src/atc_kernel_bandwidth.rst @@ -6,7 +6,7 @@ fix_modify AtC kernel_bandwidth command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify kernel_bandwidth diff --git a/doc/src/atc_lumped_lambda_solve.rst b/doc/src/atc_lumped_lambda_solve.rst index e777116da5..b64ffb2d01 100644 --- a/doc/src/atc_lumped_lambda_solve.rst +++ b/doc/src/atc_lumped_lambda_solve.rst @@ -6,7 +6,7 @@ fix_modify AtC control lumped_lambda_solve command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify control lumped_lambda_solve diff --git a/doc/src/atc_mask_direction.rst b/doc/src/atc_mask_direction.rst index ed5c605834..0e55cc7190 100644 --- a/doc/src/atc_mask_direction.rst +++ b/doc/src/atc_mask_direction.rst @@ -6,7 +6,7 @@ fix_modify AtC control mask_direction command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify control mask_direction diff --git a/doc/src/atc_mass_matrix.rst b/doc/src/atc_mass_matrix.rst index eb586b933b..7763044ec8 100644 --- a/doc/src/atc_mass_matrix.rst +++ b/doc/src/atc_mass_matrix.rst @@ -6,7 +6,7 @@ fix_modify AtC mass_matrix command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mass_matrix diff --git a/doc/src/atc_material.rst b/doc/src/atc_material.rst index 471bffffb2..eef5dbdd0e 100644 --- a/doc/src/atc_material.rst +++ b/doc/src/atc_material.rst @@ -6,7 +6,7 @@ fix_modify AtC material command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify material diff --git a/doc/src/atc_mesh_add_to_nodeset.rst b/doc/src/atc_mesh_add_to_nodeset.rst index f9f6f575fe..0944a51099 100644 --- a/doc/src/atc_mesh_add_to_nodeset.rst +++ b/doc/src/atc_mesh_add_to_nodeset.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh add_to_nodeset command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh add_to_nodeset diff --git a/doc/src/atc_mesh_create.rst b/doc/src/atc_mesh_create.rst index b17bb8ac0d..289c0e5c56 100644 --- a/doc/src/atc_mesh_create.rst +++ b/doc/src/atc_mesh_create.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh create command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh create diff --git a/doc/src/atc_mesh_create_elementset.rst b/doc/src/atc_mesh_create_elementset.rst index 3cb406e7bc..35086b0fc9 100644 --- a/doc/src/atc_mesh_create_elementset.rst +++ b/doc/src/atc_mesh_create_elementset.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh create_elementset command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh create_elementset diff --git a/doc/src/atc_mesh_create_faceset_box.rst b/doc/src/atc_mesh_create_faceset_box.rst index 09b099d179..29dcfa69ad 100644 --- a/doc/src/atc_mesh_create_faceset_box.rst +++ b/doc/src/atc_mesh_create_faceset_box.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh create_faceset box command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh create_faceset box [units] diff --git a/doc/src/atc_mesh_create_faceset_plane.rst b/doc/src/atc_mesh_create_faceset_plane.rst index 035e584044..e36990de40 100644 --- a/doc/src/atc_mesh_create_faceset_plane.rst +++ b/doc/src/atc_mesh_create_faceset_plane.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh create_faceset plane command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh create_faceset plane [units] diff --git a/doc/src/atc_mesh_create_nodeset.rst b/doc/src/atc_mesh_create_nodeset.rst index a2f9d74d07..943d1c7d19 100644 --- a/doc/src/atc_mesh_create_nodeset.rst +++ b/doc/src/atc_mesh_create_nodeset.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh create_nodeset command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh create_nodeset diff --git a/doc/src/atc_mesh_delete_elements.rst b/doc/src/atc_mesh_delete_elements.rst index 9785f0adf6..2c9d83d506 100644 --- a/doc/src/atc_mesh_delete_elements.rst +++ b/doc/src/atc_mesh_delete_elements.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh delete_elements command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh delete_elements diff --git a/doc/src/atc_mesh_nodeset_to_elementset.rst b/doc/src/atc_mesh_nodeset_to_elementset.rst index d8721cc295..1838aa120f 100644 --- a/doc/src/atc_mesh_nodeset_to_elementset.rst +++ b/doc/src/atc_mesh_nodeset_to_elementset.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh nodeset_to_elementset command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh nodeset_to_elementset diff --git a/doc/src/atc_mesh_output.rst b/doc/src/atc_mesh_output.rst index 63756df98e..237b88eff6 100644 --- a/doc/src/atc_mesh_output.rst +++ b/doc/src/atc_mesh_output.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh output command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh output diff --git a/doc/src/atc_mesh_quadrature.rst b/doc/src/atc_mesh_quadrature.rst index 0c9bd4b30f..4cc94d77e2 100644 --- a/doc/src/atc_mesh_quadrature.rst +++ b/doc/src/atc_mesh_quadrature.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh quadrature command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh quatrature diff --git a/doc/src/atc_mesh_read.rst b/doc/src/atc_mesh_read.rst index 9848e12b07..dcc999166f 100644 --- a/doc/src/atc_mesh_read.rst +++ b/doc/src/atc_mesh_read.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh read command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh read diff --git a/doc/src/atc_mesh_write.rst b/doc/src/atc_mesh_write.rst index dbb8f9c219..2636f51fc5 100644 --- a/doc/src/atc_mesh_write.rst +++ b/doc/src/atc_mesh_write.rst @@ -6,7 +6,7 @@ fix_modify AtC mesh write command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify mesh write diff --git a/doc/src/atc_output.rst b/doc/src/atc_output.rst index 5003817daa..13df4c7d58 100644 --- a/doc/src/atc_output.rst +++ b/doc/src/atc_output.rst @@ -6,7 +6,7 @@ fix_modify AtC output command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify output [text|full_text|binary|vector_components|tensor_components] fix_modify output index [step|time] diff --git a/doc/src/atc_output_boundary_integral.rst b/doc/src/atc_output_boundary_integral.rst index 71a3e03ac2..65ad6e835e 100644 --- a/doc/src/atc_output_boundary_integral.rst +++ b/doc/src/atc_output_boundary_integral.rst @@ -6,7 +6,7 @@ fix_modify AtC output boundary_integral command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify output boundary_integral faceset [name] diff --git a/doc/src/atc_output_contour_integral.rst b/doc/src/atc_output_contour_integral.rst index 24678ef6cc..fa6ab8c9d1 100644 --- a/doc/src/atc_output_contour_integral.rst +++ b/doc/src/atc_output_contour_integral.rst @@ -6,7 +6,7 @@ fix_modify AtC output contour_integral command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify output contour_integral faceset [axis [x|y|z]] diff --git a/doc/src/atc_output_nodeset.rst b/doc/src/atc_output_nodeset.rst index eb12a2344e..e5d1580274 100644 --- a/doc/src/atc_output_nodeset.rst +++ b/doc/src/atc_output_nodeset.rst @@ -6,7 +6,7 @@ fix_modify AtC output nodeset command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify output nodeset diff --git a/doc/src/atc_output_volume_integral.rst b/doc/src/atc_output_volume_integral.rst index 464d43cbce..a740c56e8b 100644 --- a/doc/src/atc_output_volume_integral.rst +++ b/doc/src/atc_output_volume_integral.rst @@ -6,7 +6,7 @@ fix_modify AtC output volume_integral command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify output volume_integral diff --git a/doc/src/atc_pair_interactions.rst b/doc/src/atc_pair_interactions.rst index 73ada09001..d8de219d89 100644 --- a/doc/src/atc_pair_interactions.rst +++ b/doc/src/atc_pair_interactions.rst @@ -9,7 +9,7 @@ fix_modify AtC bond_interactions command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify pair_interactions fix_modify bond_interactions diff --git a/doc/src/atc_poisson_solver.rst b/doc/src/atc_poisson_solver.rst index d37f214b97..e203c3dc51 100644 --- a/doc/src/atc_poisson_solver.rst +++ b/doc/src/atc_poisson_solver.rst @@ -6,7 +6,7 @@ fix_modify AtC poisson_solver command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify poisson_solver mesh create diff --git a/doc/src/atc_read_restart.rst b/doc/src/atc_read_restart.rst index 11ba4519a4..32badbd3a8 100644 --- a/doc/src/atc_read_restart.rst +++ b/doc/src/atc_read_restart.rst @@ -6,7 +6,7 @@ fix_modify AtC read_restart command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify read_restart diff --git a/doc/src/atc_remove_molecule.rst b/doc/src/atc_remove_molecule.rst index a654cd5c1d..13c0856307 100644 --- a/doc/src/atc_remove_molecule.rst +++ b/doc/src/atc_remove_molecule.rst @@ -6,7 +6,7 @@ fix_modify AtC remove_molecule command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify remove_molecule diff --git a/doc/src/atc_remove_source.rst b/doc/src/atc_remove_source.rst index d98b7933da..253166cd3c 100644 --- a/doc/src/atc_remove_source.rst +++ b/doc/src/atc_remove_source.rst @@ -6,7 +6,7 @@ fix_modify AtC remove_source command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify remove_source diff --git a/doc/src/atc_remove_species.rst b/doc/src/atc_remove_species.rst index 5c4fd771ba..b7718a6874 100644 --- a/doc/src/atc_remove_species.rst +++ b/doc/src/atc_remove_species.rst @@ -6,7 +6,7 @@ fix_modify AtC remove_species command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify remove_species diff --git a/doc/src/atc_reset_atomic_reference.rst b/doc/src/atc_reset_atomic_reference.rst index 8f53cbfbe9..43acc9b4b2 100644 --- a/doc/src/atc_reset_atomic_reference.rst +++ b/doc/src/atc_reset_atomic_reference.rst @@ -6,7 +6,7 @@ fix_modify AtC reset_atomic_reference_positions command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify reset_atomic_reference_positions diff --git a/doc/src/atc_reset_time.rst b/doc/src/atc_reset_time.rst index 147a6ab910..f02c723011 100644 --- a/doc/src/atc_reset_time.rst +++ b/doc/src/atc_reset_time.rst @@ -6,7 +6,7 @@ fix_modify AtC reset_time command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify reset_time diff --git a/doc/src/atc_sample_frequency.rst b/doc/src/atc_sample_frequency.rst index 5b0da6d9dd..e61e9fd6ed 100644 --- a/doc/src/atc_sample_frequency.rst +++ b/doc/src/atc_sample_frequency.rst @@ -6,7 +6,7 @@ fix_modify AtC sample_frequency command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify sample_frequency diff --git a/doc/src/atc_set_reference_pe.rst b/doc/src/atc_set_reference_pe.rst index 8053a1df98..f85e3f7ebc 100644 --- a/doc/src/atc_set_reference_pe.rst +++ b/doc/src/atc_set_reference_pe.rst @@ -6,7 +6,7 @@ fix_modify AtC set reference_potential_energy command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify set reference_potential_energy [] diff --git a/doc/src/atc_source.rst b/doc/src/atc_source.rst index 6df4b67d1c..ce712c8186 100644 --- a/doc/src/atc_source.rst +++ b/doc/src/atc_source.rst @@ -6,7 +6,7 @@ fix_modify AtC source command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify source diff --git a/doc/src/atc_source_integration.rst b/doc/src/atc_source_integration.rst index b10e6c7e2a..a145a7c9f1 100644 --- a/doc/src/atc_source_integration.rst +++ b/doc/src/atc_source_integration.rst @@ -6,7 +6,7 @@ fix_modify AtC source_integration command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify source_integration diff --git a/doc/src/atc_temperature_definition.rst b/doc/src/atc_temperature_definition.rst index b5a27467ca..0194e38314 100644 --- a/doc/src/atc_temperature_definition.rst +++ b/doc/src/atc_temperature_definition.rst @@ -6,7 +6,7 @@ fix_modify AtC temperature_definition command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify temperature_definition diff --git a/doc/src/atc_time_filter.rst b/doc/src/atc_time_filter.rst index 0a97c83259..76163a77b5 100644 --- a/doc/src/atc_time_filter.rst +++ b/doc/src/atc_time_filter.rst @@ -6,7 +6,7 @@ fix_modify AtC filter command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify filter diff --git a/doc/src/atc_time_integration.rst b/doc/src/atc_time_integration.rst index cf746dde0d..3eae147a6e 100644 --- a/doc/src/atc_time_integration.rst +++ b/doc/src/atc_time_integration.rst @@ -6,7 +6,7 @@ fix_modify AtC time_integration command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify time_integration diff --git a/doc/src/atc_track_displacement.rst b/doc/src/atc_track_displacement.rst index 043f42ea9c..f5a2d1742c 100644 --- a/doc/src/atc_track_displacement.rst +++ b/doc/src/atc_track_displacement.rst @@ -6,7 +6,7 @@ fix_modify AtC track_displacement command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify track_displacement diff --git a/doc/src/atc_unfix.rst b/doc/src/atc_unfix.rst index 12ee37bbde..c6ada6dcca 100644 --- a/doc/src/atc_unfix.rst +++ b/doc/src/atc_unfix.rst @@ -6,7 +6,7 @@ fix_modify AtC unfix command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify unfix diff --git a/doc/src/atc_unfix_flux.rst b/doc/src/atc_unfix_flux.rst index da9d1b4aba..73ef5b17af 100644 --- a/doc/src/atc_unfix_flux.rst +++ b/doc/src/atc_unfix_flux.rst @@ -6,7 +6,7 @@ fix_modify AtC unfix_flux command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify unfix_flux diff --git a/doc/src/atc_write_atom_weights.rst b/doc/src/atc_write_atom_weights.rst index ecb69b5deb..40af619356 100644 --- a/doc/src/atc_write_atom_weights.rst +++ b/doc/src/atc_write_atom_weights.rst @@ -6,7 +6,7 @@ fix_modify AtC write_atom_weights command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify write_atom_weights diff --git a/doc/src/atc_write_restart.rst b/doc/src/atc_write_restart.rst index e4f19dea10..75945e1715 100644 --- a/doc/src/atc_write_restart.rst +++ b/doc/src/atc_write_restart.rst @@ -6,7 +6,7 @@ fix_modify AtC write_restart command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix_modify write_restart diff --git a/doc/src/bond_bpm_rotational.rst b/doc/src/bond_bpm_rotational.rst index ca12d86ccc..7459d491d6 100644 --- a/doc/src/bond_bpm_rotational.rst +++ b/doc/src/bond_bpm_rotational.rst @@ -10,7 +10,7 @@ Syntax bond_style bpm/rotational keyword value attribute1 attribute2 ... -* optional keyword = *overlay/pair* or *store/local* or *smooth* or *break/no* +* optional keyword = *overlay/pair* or *store/local* or *smooth* or *break* .. parsed-literal:: @@ -80,32 +80,32 @@ respectively. Details on the calculations of shear displacements and angular displacements can be found in :ref:`(Wang) ` and :ref:`(Wang and Mora) `. -Bonds will break under sufficient stress. A breaking criteria is calculated +Bonds will break under sufficient stress. A breaking criterion is calculated .. math:: - B = \mathrm{max}\{0, \frac{f_r}{f_{r,c}} + \frac{|f_s|}{f_{s,c}} + - \frac{|\tau_b|}{\tau_{b,c}} + \frac{|\tau_t|}{\tau_{t,c}} \} + B = \mathrm{max}\left\{0, \frac{f_r}{f_{r,c}} + \frac{|f_s|}{f_{s,c}} + + \frac{|\tau_b|}{\tau_{b,c}} + \frac{|\tau_t|}{\tau_{t,c}} \right\} where :math:`|f_s|` is the magnitude of the shear force and :math:`|\tau_b|` and :math:`|\tau_t|` are the magnitudes of the -bending and twisting forces, respectively. The corresponding variables +bending and twisting torques, respectively. The corresponding variables :math:`f_{r,c}` :math:`f_{s,c}`, :math:`\tau_{b,c}`, and :math:`\tau_{t,c}` are critical limits to each force or torque. If :math:`B` is ever equal to or exceeds one, the bond will break. This -is done by setting by setting its type to 0 such that forces and +is done by setting the bond type to 0 such that forces and torques are no longer computed. After computing the base magnitudes of the forces and torques, they can be optionally multiplied by an extra factor :math:`w` to smoothly interpolate forces and torques to zero as the bond breaks. This term -is calculated as :math:`w = (1.0 - B^4)`. This smoothing factor can be -added or removed using the *smooth* keyword. +is calculated as :math:`w = (1.0 - B^4)`. This smoothing factor can be added +or removed by setting the *smooth* keyword to *yes* or *no*, respectively. Finally, additional damping forces and torques are applied to the two particles. A force is applied proportional to the difference in the normal velocity of particles using a similar construction as -dissipative particle dynamics (:ref:`(Groot) `): +dissipative particle dynamics :ref:`(Groot) `: .. math:: @@ -115,8 +115,8 @@ where :math:`\gamma_n` is the damping strength, :math:`\hat{r}` is the radial normal vector, and :math:`\vec{v}` is the velocity difference between the two particles. Similarly, tangential forces are applied to each atom proportional to the relative differences in sliding -velocities with a constant prefactor :math:`\gamma_s` (:ref:`(Wang et -al.) `) along with their associated torques. The rolling and +velocities with a constant prefactor :math:`\gamma_s` :ref:`(Wang et +al.) ` along with their associated torques. The rolling and twisting components of the relative angular velocities of the two atoms are also damped by applying torques with prefactors of :math:`\gamma_r` and :math:`\gamma_t`, respectively. @@ -139,21 +139,23 @@ or :doc:`read_restart ` commands: * :math:`\gamma_r` (force*distance/velocity units) * :math:`\gamma_t` (force*distance/velocity units) -However, the *normalize* option will normalize the radial and shear forces -by :math:`r_0` such that :math:`k_r` and :math:`k_s` are unit less. +If the *normalize* keyword is set to *yes*, the radial and shear forces +will be normalized by :math:`r_0` such that :math:`k_r` and :math:`k_s` +must be given in force units. By default, pair forces are not calculated between bonded particles. -Pair forces can alternatively be overlaid on top of bond forces using -the *overlay/pair* option. These settings require specific +Pair forces can alternatively be overlaid on top of bond forces by setting +the *overlay/pair* keyword to *yes*. These settings require specific :doc:`special_bonds ` settings described in the -restrictions. Further details can be found in the `:doc: how to -` page on BPMs. +restrictions. Further details can be found in the :doc:`how to +` page on BPMs. .. versionadded:: 28Mar2023 -If the *break* option is used, then LAMMPS assumes bonds should not break +If the *break* keyword is set to *no*, LAMMPS assumes bonds should not break during a simulation run. This will prevent some unnecessary calculation. -However, if a bond does break, it will trigger an error. +However, if a bond reaches a damage criterion greater than one, +it will trigger an error. If the *store/local* keyword is used, an internal fix will track bonds that break during the simulation. Whenever a bond breaks, data is processed @@ -232,16 +234,15 @@ This bond style is part of the BPM package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. -By default if pair interactions are to be disabled, this bond style -requires setting +By default if pair interactions between bonded atoms are to be disabled, +this bond style requires setting .. code-block:: LAMMPS special_bonds lj 0 1 1 coul 1 1 1 -and :doc:`newton ` must be set to bond off. If the -*overlay/pair* option is used, this bond style alternatively requires -setting +and :doc:`newton ` must be set to bond off. If the *overlay/pair* +keyword is set to *yes*, this bond style alternatively requires setting .. code-block:: LAMMPS diff --git a/doc/src/bond_bpm_spring.rst b/doc/src/bond_bpm_spring.rst index d89035dcad..04ff4d5991 100644 --- a/doc/src/bond_bpm_spring.rst +++ b/doc/src/bond_bpm_spring.rst @@ -10,7 +10,7 @@ Syntax bond_style bpm/spring keyword value attribute1 attribute2 ... -* optional keyword = *overlay/pair* or *store/local* or *smooth* or *break/no* +* optional keyword = *overlay/pair* or *store/local* or *smooth* or *break* .. parsed-literal:: @@ -72,13 +72,13 @@ particles based on a model described by Clemmer and Robbins where :math:`k` is a stiffness, :math:`r` is the current distance and :math:`r_0` is the initial distance between the two particles, and :math:`w` is an optional smoothing factor discussed below. Bonds will -break at a strain of :math:`\epsilon_c`. This is done by setting by -setting its type to 0 such that forces are no longer computed. +break at a strain of :math:`\epsilon_c`. This is done by setting +the bond type to 0 such that forces are no longer computed. An additional damping force is applied to the bonded particles. This forces is proportional to the difference in the normal velocity of particles using a similar construction as -dissipative particle dynamics (:ref:`(Groot) `): +dissipative particle dynamics :ref:`(Groot) `: .. math:: @@ -88,9 +88,10 @@ where :math:`\gamma` is the damping strength, :math:`\hat{r}` is the radial normal vector, and :math:`\vec{v}` is the velocity difference between the two particles. -The smoothing factor :math:`w` can be added or removed using the -*smooth* keyword. It is constructed such that forces smoothly go -to zero, avoiding discontinuities, as bonds approach the critical strain +The smoothing factor :math:`w` can be added or removed by setting the +*smooth* keyword to *yes* or *no*, respectively. It is constructed such +that forces smoothly go to zero, avoiding discontinuities, as bonds +approach the critical strain .. math:: @@ -105,21 +106,22 @@ the data file or restart files read by the :doc:`read_data * :math:`\epsilon_c` (unit less) * :math:`\gamma` (force/velocity units) -However, the *normalize* option will normalize the elastic bond force by -:math:`r_0` such that :math:`k` is unit less. +If the *normalize* keyword is set to *yes*, the elastic bond force will be +normalized by :math:`r_0` such that :math:`k` must be given in force units. By default, pair forces are not calculated between bonded particles. -Pair forces can alternatively be overlaid on top of bond forces using -the *overlay/pair* option. These settings require specific +Pair forces can alternatively be overlaid on top of bond forces by setting +the *overlay/pair* keyword to *yes*. These settings require specific :doc:`special_bonds ` settings described in the -restrictions. Further details can be found in the `:doc: how to -` page on BPMs. +restrictions. Further details can be found in the :doc:`how to +` page on BPMs. .. versionadded:: 28Mar2023 -If the *break* option is used, then LAMMPS assumes bonds should not break +If the *break* keyword is set to *no*, LAMMPS assumes bonds should not break during a simulation run. This will prevent some unnecessary calculation. -However, if a bond does break, it will trigger an error. +However, if a bond reaches a strain greater than :math:`\epsilon_c`, +it will trigger an error. If the *store/local* keyword is used, an internal fix will track bonds that break during the simulation. Whenever a bond breaks, data is processed @@ -189,16 +191,15 @@ This bond style is part of the BPM package. It is only enabled if LAMMPS was built with that package. See the :doc:`Build package ` page for more info. -By default if pair interactions are to be disabled, this bond style -requires setting +By default if pair interactions between bonded atoms are to be disabled, +this bond style requires setting .. code-block:: LAMMPS special_bonds lj 0 1 1 coul 1 1 1 -and :doc:`newton ` must be set to bond off. If the -*overlay/pair* option is used, this bond style alternatively requires -setting +and :doc:`newton ` must be set to bond off. If the *overlay/pair* +keyword is set to *yes*, this bond style alternatively requires setting .. code-block:: LAMMPS diff --git a/doc/src/compute_modify.rst b/doc/src/compute_modify.rst index 2c5f7d0e8e..028eb8b66d 100644 --- a/doc/src/compute_modify.rst +++ b/doc/src/compute_modify.rst @@ -12,16 +12,14 @@ Syntax * compute-ID = ID of the compute to modify * one or more keyword/value pairs may be listed -* keyword = *extra/dof* or *extra* or *dynamic/dof* or *dynamic* +* keyword = *extra/dof* or *dynamic/dof* .. parsed-literal:: *extra/dof* value = N N = # of extra degrees of freedom to subtract - *extra* syntax is identical to *extra/dof*, will be disabled at some point *dynamic/dof* value = *yes* or *no* yes/no = do or do not re-compute the number of degrees of freedom (DOF) contributing to the temperature - *dynamic* syntax is identical to *dynamic/dof*, will be disabled at some point Examples """""""" @@ -37,19 +35,18 @@ Description Modify one or more parameters of a previously defined compute. Not all compute styles support all parameters. -The *extra/dof* or *extra* keyword refers to how many degrees of -freedom are subtracted (typically from :math:`3N`) as a normalizing -factor in a temperature computation. Only computes that compute a -temperature use this option. The default is 2 or 3 for :doc:`2d or 3d -systems ` which is a correction factor for an ensemble of -velocities with zero total linear momentum. For compute temp/partial, -if one or more velocity components are excluded, the value used for -*extra* is scaled accordingly. You can use a negative number for the -*extra* parameter if you need to add degrees-of-freedom. See the -:doc:`compute temp/asphere ` command for an -example. +The *extra/dof* keyword refers to how many degrees of freedom are +subtracted (typically from :math:`3N`) as a normalizing factor in a +temperature computation. Only computes that compute a temperature use +this option. The default is 2 or 3 for :doc:`2d or 3d systems +` which is a correction factor for an ensemble of velocities +with zero total linear momentum. For compute temp/partial, if one or +more velocity components are excluded, the value used for *extra/dof* is +scaled accordingly. You can use a negative number for the *extra/dof* +parameter if you need to add degrees-of-freedom. See the :doc:`compute +temp/asphere ` command for an example. -The *dynamic/dof* or *dynamic* keyword determines whether the number +The *dynamic/dof* keyword determines whether the number of atoms :math:`N` in the compute group and their associated degrees of freedom (DOF) are re-computed each time a temperature is computed. Only compute styles that calculate a temperature use this option. By @@ -61,12 +58,6 @@ are adding atoms or molecules to the system (see the :doc:`fix pour `), then this option should be used to ensure the temperature is correctly normalized. -.. note:: - - The *extra* and *dynamic* keywords should not be used as they - are deprecated (March 2017) and will eventually be disabled. Instead, - use the equivalent *extra/dof* and *dynamic/dof* keywords. - Restrictions """""""""""" none @@ -79,5 +70,5 @@ Related commands Default """"""" -The option defaults are extra/dof = 2 or 3 for 2d or 3d systems and -dynamic/dof = *no*. +The option defaults are extra/dof = 2 or 3 for 2d or 3d systems, +respectively, and dynamic/dof = *no*. diff --git a/doc/src/compute_property_grid.rst b/doc/src/compute_property_grid.rst index e65e822516..44389320d6 100644 --- a/doc/src/compute_property_grid.rst +++ b/doc/src/compute_property_grid.rst @@ -6,7 +6,7 @@ compute property/grid command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID property/grid Nx Ny Nz input1 input2 ... diff --git a/doc/src/compute_rdf.rst b/doc/src/compute_rdf.rst index 88bd7ec74c..ed73800f82 100644 --- a/doc/src/compute_rdf.rst +++ b/doc/src/compute_rdf.rst @@ -202,7 +202,7 @@ change from zero to one at the location of the spike in :math:`g(r)`. parallel efficiency and scaling. For systems, where only the type of atoms changes (e.g., when using :doc:`fix atom/swap `), you need to explicitly request the dynamic normalization updates - via :doc:`compute_modify dynamic yes ` + via :doc:`compute_modify dynamic/dof yes ` Related commands """""""""""""""" diff --git a/doc/src/compute_reduce_chunk.rst b/doc/src/compute_reduce_chunk.rst index 43fee39cf2..8ec19ade66 100644 --- a/doc/src/compute_reduce_chunk.rst +++ b/doc/src/compute_reduce_chunk.rst @@ -6,7 +6,7 @@ compute reduce/chunk command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID reduce/chunk chunkID mode input1 input2 ... diff --git a/doc/src/compute_saed.rst b/doc/src/compute_saed.rst index deb6a61f7c..9ec455d03b 100644 --- a/doc/src/compute_saed.rst +++ b/doc/src/compute_saed.rst @@ -6,7 +6,7 @@ compute saed command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID saed lambda type1 type2 ... typeN keyword value ... diff --git a/doc/src/compute_slice.rst b/doc/src/compute_slice.rst index 9b4e7df626..0da7c99573 100644 --- a/doc/src/compute_slice.rst +++ b/doc/src/compute_slice.rst @@ -6,7 +6,7 @@ compute slice command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID slice Nstart Nstop Nskip input1 input2 ... diff --git a/doc/src/compute_smd_contact_radius.rst b/doc/src/compute_smd_contact_radius.rst index 4911ac4e27..2ac039a3b5 100644 --- a/doc/src/compute_smd_contact_radius.rst +++ b/doc/src/compute_smd_contact_radius.rst @@ -6,7 +6,7 @@ compute smd/contact/radius command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/contact/radius diff --git a/doc/src/compute_smd_damage.rst b/doc/src/compute_smd_damage.rst index fe5d94fa83..72307bc184 100644 --- a/doc/src/compute_smd_damage.rst +++ b/doc/src/compute_smd_damage.rst @@ -6,7 +6,7 @@ compute smd/damage command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/damage diff --git a/doc/src/compute_smd_hourglass_error.rst b/doc/src/compute_smd_hourglass_error.rst index 7e0aadd6d2..533c0f03c0 100644 --- a/doc/src/compute_smd_hourglass_error.rst +++ b/doc/src/compute_smd_hourglass_error.rst @@ -6,7 +6,7 @@ compute smd/hourglass/error command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/hourglass/error diff --git a/doc/src/compute_smd_internal_energy.rst b/doc/src/compute_smd_internal_energy.rst index 36bd816e8f..91c671c6a1 100644 --- a/doc/src/compute_smd_internal_energy.rst +++ b/doc/src/compute_smd_internal_energy.rst @@ -6,7 +6,7 @@ compute smd/internal/energy command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/internal/energy diff --git a/doc/src/compute_smd_plastic_strain.rst b/doc/src/compute_smd_plastic_strain.rst index 00c6cb9a4a..b1e5719249 100644 --- a/doc/src/compute_smd_plastic_strain.rst +++ b/doc/src/compute_smd_plastic_strain.rst @@ -6,7 +6,7 @@ compute smd/plastic/strain command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/plastic/strain diff --git a/doc/src/compute_smd_plastic_strain_rate.rst b/doc/src/compute_smd_plastic_strain_rate.rst index 681573be9b..bf9b3b23f4 100644 --- a/doc/src/compute_smd_plastic_strain_rate.rst +++ b/doc/src/compute_smd_plastic_strain_rate.rst @@ -6,7 +6,7 @@ compute smd/plastic/strain/rate command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/plastic/strain/rate diff --git a/doc/src/compute_smd_rho.rst b/doc/src/compute_smd_rho.rst index 605dd5b79c..8ecb09f318 100644 --- a/doc/src/compute_smd_rho.rst +++ b/doc/src/compute_smd_rho.rst @@ -6,7 +6,7 @@ compute smd/rho command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/rho diff --git a/doc/src/compute_smd_tlsph_defgrad.rst b/doc/src/compute_smd_tlsph_defgrad.rst index 399e54d055..aceecc1722 100644 --- a/doc/src/compute_smd_tlsph_defgrad.rst +++ b/doc/src/compute_smd_tlsph_defgrad.rst @@ -6,7 +6,7 @@ compute smd/tlsph/defgrad command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/tlsph/defgrad diff --git a/doc/src/compute_smd_tlsph_dt.rst b/doc/src/compute_smd_tlsph_dt.rst index 9490f7da14..1cafecdb7c 100644 --- a/doc/src/compute_smd_tlsph_dt.rst +++ b/doc/src/compute_smd_tlsph_dt.rst @@ -6,7 +6,7 @@ compute smd/tlsph/dt command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/tlsph/dt diff --git a/doc/src/compute_smd_tlsph_num_neighs.rst b/doc/src/compute_smd_tlsph_num_neighs.rst index ef8c19d49c..8bf244a8db 100644 --- a/doc/src/compute_smd_tlsph_num_neighs.rst +++ b/doc/src/compute_smd_tlsph_num_neighs.rst @@ -6,7 +6,7 @@ compute smd/tlsph/num/neighs command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/tlsph/num/neighs diff --git a/doc/src/compute_smd_tlsph_shape.rst b/doc/src/compute_smd_tlsph_shape.rst index 4a5abd868b..b682e72fdd 100644 --- a/doc/src/compute_smd_tlsph_shape.rst +++ b/doc/src/compute_smd_tlsph_shape.rst @@ -6,7 +6,7 @@ compute smd/tlsph/shape command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/tlsph/shape diff --git a/doc/src/compute_smd_tlsph_strain.rst b/doc/src/compute_smd_tlsph_strain.rst index 053488886b..89b9bee132 100644 --- a/doc/src/compute_smd_tlsph_strain.rst +++ b/doc/src/compute_smd_tlsph_strain.rst @@ -6,7 +6,7 @@ compute smd/tlsph/strain command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/tlsph/strain diff --git a/doc/src/compute_smd_tlsph_strain_rate.rst b/doc/src/compute_smd_tlsph_strain_rate.rst index 2f3d561cee..83797edd49 100644 --- a/doc/src/compute_smd_tlsph_strain_rate.rst +++ b/doc/src/compute_smd_tlsph_strain_rate.rst @@ -6,7 +6,7 @@ compute smd/tlsph/strain/rate command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/tlsph/strain/rate diff --git a/doc/src/compute_smd_tlsph_stress.rst b/doc/src/compute_smd_tlsph_stress.rst index 4f0473f30a..12539ffda7 100644 --- a/doc/src/compute_smd_tlsph_stress.rst +++ b/doc/src/compute_smd_tlsph_stress.rst @@ -6,7 +6,7 @@ compute smd/tlsph/stress command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/tlsph/stress diff --git a/doc/src/compute_smd_triangle_vertices.rst b/doc/src/compute_smd_triangle_vertices.rst index 309c4260e9..2e7dd0cfd0 100644 --- a/doc/src/compute_smd_triangle_vertices.rst +++ b/doc/src/compute_smd_triangle_vertices.rst @@ -6,7 +6,7 @@ compute smd/triangle/vertices command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/triangle/vertices diff --git a/doc/src/compute_smd_vol.rst b/doc/src/compute_smd_vol.rst index d31eb53785..94372c23ce 100644 --- a/doc/src/compute_smd_vol.rst +++ b/doc/src/compute_smd_vol.rst @@ -6,7 +6,7 @@ compute smd/vol command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID smd/vol diff --git a/doc/src/compute_sna_atom.rst b/doc/src/compute_sna_atom.rst index d604ca9d29..8d06868f3d 100644 --- a/doc/src/compute_sna_atom.rst +++ b/doc/src/compute_sna_atom.rst @@ -26,7 +26,7 @@ compute sna/grid/local command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID sna/atom rcutfac rfac0 twojmax R_1 R_2 ... w_1 w_2 ... keyword values ... compute ID group-ID snad/atom rcutfac rfac0 twojmax R_1 R_2 ... w_1 w_2 ... keyword values ... diff --git a/doc/src/compute_sph_e_atom.rst b/doc/src/compute_sph_e_atom.rst index 5e6706fa27..d557eb7920 100644 --- a/doc/src/compute_sph_e_atom.rst +++ b/doc/src/compute_sph_e_atom.rst @@ -6,7 +6,7 @@ compute sph/e/atom command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID sph/e/atom diff --git a/doc/src/compute_sph_rho_atom.rst b/doc/src/compute_sph_rho_atom.rst index 7fcec0c9da..6e8579476a 100644 --- a/doc/src/compute_sph_rho_atom.rst +++ b/doc/src/compute_sph_rho_atom.rst @@ -6,7 +6,7 @@ compute sph/rho/atom command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID sph/rho/atom diff --git a/doc/src/compute_sph_t_atom.rst b/doc/src/compute_sph_t_atom.rst index 702d81027d..3383c26145 100644 --- a/doc/src/compute_sph_t_atom.rst +++ b/doc/src/compute_sph_t_atom.rst @@ -6,7 +6,7 @@ compute sph/t/atom command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS compute ID group-ID sph/t/atom diff --git a/doc/src/compute_temp.rst b/doc/src/compute_temp.rst index 8f6f9f225f..e081280496 100644 --- a/doc/src/compute_temp.rst +++ b/doc/src/compute_temp.rst @@ -37,20 +37,24 @@ The temperature is calculated by the formula .. math:: - \text{KE} = \frac{\text{dim}}{2} N k_B T, + T = \frac{2 E_\mathrm{kin}}{N_\mathrm{DOF} k_B} \quad \mathrm{with} \quad + E_\mathrm{kin} = \sum^{N_\mathrm{atoms}}_{i=1} \frac{1}{2} m_i v^2_i \quad \mathrm{and} \quad + N_\mathrm{DOF} = n_\mathrm{dim} N_\mathrm{atoms} - n_\mathrm{dim} - N_\mathrm{fix DOFs} -where KE = total kinetic energy of the group of atoms (sum of -:math:`\frac12 m v^2`), dim = 2 or 3 is the dimensionality of the -simulation, :math:`N` is the number of atoms in the group, :math:`k_B` -is the Boltzmann constant, and :math:`T` is the absolute temperature. +where :math:`E_\mathrm{kin}` is the total kinetic energy of the group of +atoms, :math:`n_\mathrm{dim}` is the dimensionality of the simulation +(i.e. either 2 or 3), :math:`N_\mathrm{atoms}` is the number of atoms in +the group, :math:`N_\mathrm{fix DOFs}` is the number of degrees of +freedom removed by fix commands (see below), :math:`k_B` is the +Boltzmann constant, and :math:`T` is the resulting computed temperature. A kinetic energy tensor, stored as a six-element vector, is also calculated by this compute for use in the computation of a pressure -tensor. The formula for the components of the tensor is the same as -the above formula, except that :math:`v^2` is replaced by :math:`v_x -v_y` for the :math:`xy` component, and so on. The six components of -the vector are ordered :math:`xx`, :math:`yy`, :math:`zz`, :math:`xy`, -:math:`xz`, :math:`yz`. +tensor. The formula for the components of the tensor is the same as the +above expression for :math:`E_\mathrm{kin}`, except that :math:`v_i^2` is +replaced by :math:`v_{i,x} v_{i,y}` for the :math:`xy` component, and so on. +The six components of the vector are ordered :math:`xx`, :math:`yy`, +:math:`zz`, :math:`xy`, :math:`xz`, :math:`yz`. The number of atoms contributing to the temperature is assumed to be constant for the duration of the run; use the *dynamic* option of the @@ -62,6 +66,10 @@ constrain molecular motion, such as :doc:`fix shake ` and atoms that include these constraints will be computed correctly. If needed, the subtracted degrees-of-freedom can be altered using the *extra* option of the :doc:`compute_modify ` command. +By default this *extra* component is initialized to +:math:`n_\mathrm{dim}` (as shown in the formula above) to represent the +degrees of freedom removed from a system due to its translation +invariance due to periodic boundary conditions. A compute of this style with the ID of "thermo_temp" is created when LAMMPS starts up, as if this command were in the input script: diff --git a/doc/src/compute_temp_asphere.rst b/doc/src/compute_temp_asphere.rst index cba52a68b4..5741db76aa 100644 --- a/doc/src/compute_temp_asphere.rst +++ b/doc/src/compute_temp_asphere.rst @@ -49,25 +49,26 @@ rotational). .. note:: - This choice for degrees of freedom (DOF) assumes that all - finite-size aspherical or spherical particles in your model will - freely rotate, sampling all their rotational DOF. It is possible to - use a combination of interaction potentials and fixes that induce no - torque or otherwise constrain some of all of your particles so that - this is not the case. Then there are fewer DOF and you should use the - :doc:`compute_modify extra ` command to adjust the DOF - accordingly. + This choice for degrees of freedom (DOF) assumes that all finite-size + aspherical or spherical particles in your model will freely rotate, + sampling all their rotational DOF. It is possible to use a + combination of interaction potentials and fixes that induce no torque + or otherwise constrain some of all of your particles so that this is + not the case. Then there are fewer DOF and you should use the + :doc:`compute_modify extra/dof ` command to adjust + the DOF accordingly. For example, an aspherical particle with all three of its shape -parameters the same is a sphere. If it does not rotate, then it -should have 3 DOF instead of 6 in 3d (or two instead of three in 2d). -A uniaxial aspherical particle has two of its three shape parameters the +parameters the same is a sphere. If it does not rotate, then it should +have 3 DOF instead of 6 in 3d (or two instead of three in 2d). A +uniaxial aspherical particle has two of its three shape parameters the same. If it does not rotate around the axis perpendicular to its circular cross section, then it should have 5 DOF instead of 6 in 3d. -The latter is the case for uniaxial ellipsoids in a :doc:`GayBerne model ` since there is no induced torque around the -optical axis. It will also be the case for biaxial ellipsoids when -exactly two of the semiaxes have the same length and the corresponding -relative well depths are equal. +The latter is the case for uniaxial ellipsoids in a :doc:`GayBerne model +` since there is no induced torque around the optical +axis. It will also be the case for biaxial ellipsoids when exactly two +of the semiaxes have the same length and the corresponding relative well +depths are equal. The translational kinetic energy is computed the same as is described by the :doc:`compute temp ` command. The rotational @@ -90,15 +91,17 @@ inertia tensor are used. The six components of the vector are ordered :math:`xx`, :math:`yy`, :math:`zz`, :math:`xy`, :math:`xz`, :math:`yz`. The number of atoms contributing to the temperature is assumed to be -constant for the duration of the run; use the *dynamic* option of the -:doc:`compute_modify ` command if this is not the case. +constant for the duration of the run; use the *dynamic/dof* option of +the :doc:`compute_modify ` command if this is not the +case. -This compute subtracts out translational degrees-of-freedom due to -fixes that constrain molecular motion, such as :doc:`fix shake ` and :doc:`fix rigid `. This means the -temperature of groups of atoms that include these constraints will be -computed correctly. If needed, the subtracted degrees-of-freedom can -be altered using the *extra* option of the -:doc:`compute_modify ` command. +This compute subtracts out translational degrees-of-freedom due to fixes +that constrain molecular motion, such as :doc:`fix shake ` +and :doc:`fix rigid `. This means the temperature of groups +of atoms that include these constraints will be computed correctly. If +needed, the subtracted degrees-of-freedom can be altered using the +*extra/dof* option of the :doc:`compute_modify ` +command. See the :doc:`Howto thermostat ` page for a discussion of different ways to compute temperature and perform diff --git a/doc/src/compute_temp_body.rst b/doc/src/compute_temp_body.rst index 64f5ce9a0f..f29ca5c39b 100644 --- a/doc/src/compute_temp_body.rst +++ b/doc/src/compute_temp_body.rst @@ -51,11 +51,10 @@ rotational). This choice for degrees of freedom (DOF) assumes that all body particles in your model will freely rotate, sampling all their rotational DOF. It is possible to use a combination of interaction - potentials and fixes that induce no torque or otherwise constrain some - of all of your particles so that this is not the case. Then there are - less DOF and you should use the - :doc:`compute_modify extra ` command to adjust the DOF - accordingly. + potentials and fixes that induce no torque or otherwise constrain + some of all of your particles so that this is not the case. Then + there are less DOF and you should use the :doc:`compute_modify + extra/dof ` command to adjust the DOF accordingly. The translational kinetic energy is computed the same as is described by the :doc:`compute temp ` command. The rotational @@ -72,15 +71,16 @@ used. The six components of the vector are ordered :math:`xx`, :math:`yy`, :math:`zz`, :math:`xy`, :math:`xz`, :math:`yz`. The number of atoms contributing to the temperature is assumed to be -constant for the duration of the run; use the *dynamic* option of the -:doc:`compute_modify ` command if this is not the case. +constant for the duration of the run; use the *dynamic/dof* option of +the :doc:`compute_modify ` command if this is not the +case. This compute subtracts out translational degrees-of-freedom due to fixes that constrain molecular motion, such as :doc:`fix shake ` and :doc:`fix rigid `. This means the temperature of groups of atoms that include these constraints will be computed correctly. If needed, the subtracted degrees-of-freedom can -be altered using the *extra* option of the +be altered using the *extra/dof* option of the :doc:`compute_modify ` command. See the :doc:`Howto thermostat ` page for a diff --git a/doc/src/compute_temp_drude.rst b/doc/src/compute_temp_drude.rst index 8602bc3589..be09afc6a4 100644 --- a/doc/src/compute_temp_drude.rst +++ b/doc/src/compute_temp_drude.rst @@ -75,7 +75,8 @@ Restrictions The number of degrees of freedom contributing to the temperature is assumed to be constant for the duration of the run unless the -*fix_modify* command sets the option *dynamic yes*\ . +:doc:`fix_modify command ` sets the option *dynamic/dof +yes*\ . Related commands """""""""""""""" diff --git a/doc/src/compute_temp_sphere.rst b/doc/src/compute_temp_sphere.rst index 5c7c73a8d2..d1891f64bf 100644 --- a/doc/src/compute_temp_sphere.rst +++ b/doc/src/compute_temp_sphere.rst @@ -49,14 +49,13 @@ each has three degrees of freedom (two translational, one rotational). .. note:: - This choice for degrees of freedom (DOF) assumes that all - finite-size spherical particles in your model will freely rotate, - sampling all their rotational DOF. It is possible to use a - combination of interaction potentials and fixes that induce no torque - or otherwise constrain some of all of your particles so that this is - not the case. Then there are less DOF and you should use the - :doc:`compute_modify extra ` command to adjust the DOF - accordingly. + This choice for degrees of freedom (DOF) assumes that all finite-size + spherical particles in your model will freely rotate, sampling all + their rotational DOF. It is possible to use a combination of + interaction potentials and fixes that induce no torque or otherwise + constrain some of all of your particles so that this is not the case. + Then there are less DOF and you should use the :doc:`compute_modify + extra/dof ` command to adjust the DOF accordingly. The translational kinetic energy is computed the same as is described by the :doc:`compute temp ` command. The rotational @@ -73,20 +72,22 @@ velocity. A kinetic energy tensor, stored as a six-element vector, is also calculated by this compute. The formula for the components of the tensor is the same as the above formulas, except that :math:`v^2` and -:math:`\omega^2` are replaced by :math:`v_x v_y` and :math:`\omega_x \omega_y` -for the :math:`xy` component. The six components of the vector are ordered -:math:`xx`, :math:`yy`, :math:`zz`, :math:`xy`, :math:`xz`, :math:`yz`. +:math:`\omega^2` are replaced by :math:`v_x v_y` and :math:`\omega_x +\omega_y` for the :math:`xy` component. The six components of the +vector are ordered :math:`xx`, :math:`yy`, :math:`zz`, :math:`xy`, +:math:`xz`, :math:`yz`. The number of atoms contributing to the temperature is assumed to be constant for the duration of the run; use the *dynamic* option of the :doc:`compute_modify ` command if this is not the case. -This compute subtracts out translational degrees-of-freedom due to -fixes that constrain molecular motion, such as :doc:`fix shake ` and :doc:`fix rigid `. This means the -temperature of groups of atoms that include these constraints will be -computed correctly. If needed, the subtracted degrees of freedom can -be altered using the *extra* option of the -:doc:`compute_modify ` command. +This compute subtracts out translational degrees-of-freedom due to fixes +that constrain molecular motion, such as :doc:`fix shake ` +and :doc:`fix rigid `. This means the temperature of groups +of atoms that include these constraints will be computed correctly. If +needed, the subtracted degrees of freedom can be altered using the +*extra/dof* option of the :doc:`compute_modify ` +command. See the :doc:`Howto thermostat ` page for a discussion of different ways to compute temperature and perform diff --git a/doc/src/create_bonds.rst b/doc/src/create_bonds.rst index d520f1a88e..53a9a1ca50 100644 --- a/doc/src/create_bonds.rst +++ b/doc/src/create_bonds.rst @@ -86,19 +86,20 @@ data file for a complex system of molecules. .. note:: - If the system has no bonds (angles, dihedrals, impropers) to begin with, - or if more bonds per atom are being added than currently exist, then you - must ensure that the number of bond types and the maximum number of - bonds per atom are set to large enough values, and similarly for - angles, dihedrals, and impropers, otherwise an error may occur when too many - bonds (angles, dihedrals, impropers) are added to an atom. If the - :doc:`read_data ` command is used to define the system, these - parameters can be set via the "bond types" and "extra bond per atom" - fields in the header section of the data file. If the - :doc:`create_box ` command is used to define the system, - these two parameters can be set via its optional *bond/types* and - *extra/bond/per/atom* arguments, and similarly for angles, dihedrals, and - impropers. See the doc pages for these two commands for details. + If the system has no bonds (angles, dihedrals, impropers) to begin + with, or if more bonds per atom are being added than currently exist, + then you must ensure that the number of bond types and the maximum + number of bonds per atom are set to large enough values, and + similarly for angles, dihedrals, impropers, and special neighbors, + otherwise an error may occur when too many bonds (angles, dihedrals, + impropers) are added to an atom. If the :doc:`read_data ` + command is used to define the system, these parameters can be set via + its optional *extra/bond/types*, *extra/bond/per/atom*, and similar + keywords to the command. If the :doc:`create_box ` + command is used to define the system, these two parameters can be set + via its optional *bond/types* and *extra/bond/per/atom* arguments, + and similarly for angles, dihedrals, and impropers. See the + corresponding documentation pages for these two commands for details. ---------- @@ -112,7 +113,7 @@ For a bond to be created, an :math:`I,J` pair of atoms must be a distance :math:`D` apart such that :math:`r_\text{min} \le D \le r_\text{max}`. The following settings must have been made in an input script before -this style is used: +the *many* style is used: * special_bonds weight for 1--2 interactions must be 0.0 * a :doc:`pair_style ` must be defined @@ -121,10 +122,13 @@ this style is used: skin :math:`\ge r_\text{max}` These settings are required so that a neighbor list can be created to -search for nearby atoms. Pairs of atoms that are already bonded -cannot appear in the neighbor list, to avoid creation of duplicate -bonds. The neighbor list for all atom type pairs must also extend to -a distance that encompasses the *rmax* for new bonds to create. +search for nearby atoms. Pairs of atoms that are already bonded cannot +appear in the neighbor list, to avoid creation of duplicate bonds. The +neighbor list for all atom type pairs must also extend to a distance +that encompasses the *rmax* for new bonds to create. When using +periodic boundary conditions, the box length in each periodic dimension +must be larger than *rmax*, so that no bonds are created between the +system and its own periodic image. .. note:: @@ -219,6 +223,11 @@ This command cannot be used with molecular systems defined using molecule template files via the :doc:`molecule ` and :doc:`atom_style template ` commands. +For style *many*, no :doc:`kspace style ` must be +defined. Also, the *rmax* value must be smaller than any periodic box +length and the neighbor list cutoff (largest pair cutoff plus neighbor +skin). + Related commands """""""""""""""" diff --git a/doc/src/dump_image.rst b/doc/src/dump_image.rst index dd3354faaa..25d1efff7d 100644 --- a/doc/src/dump_image.rst +++ b/doc/src/dump_image.rst @@ -98,7 +98,7 @@ dump_modify options for dump image/movie Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS dump_modify dump-ID keyword values ... diff --git a/doc/src/dump_molfile.rst b/doc/src/dump_molfile.rst index ffc0b443e0..2878bc7b73 100644 --- a/doc/src/dump_molfile.rst +++ b/doc/src/dump_molfile.rst @@ -6,7 +6,7 @@ dump molfile command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS dump ID group-ID molfile N file format path diff --git a/doc/src/dump_netcdf.rst b/doc/src/dump_netcdf.rst index 296b725e20..f7495e29a8 100644 --- a/doc/src/dump_netcdf.rst +++ b/doc/src/dump_netcdf.rst @@ -10,7 +10,7 @@ dump netcdf/mpiio command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS dump ID group-ID netcdf N file args dump ID group-ID netcdf/mpiio N file args diff --git a/doc/src/dynamical_matrix.rst b/doc/src/dynamical_matrix.rst index 93e4c2a1aa..0243fb49db 100644 --- a/doc/src/dynamical_matrix.rst +++ b/doc/src/dynamical_matrix.rst @@ -4,7 +4,7 @@ dynamical_matrix command ======================== -Accelerator Variants: dynamical_matrix/kk +Accelerator Variant: dynamical_matrix/kk Syntax """""" diff --git a/doc/src/fitpod_command.rst b/doc/src/fitpod_command.rst index fc21caec70..28afb990ff 100644 --- a/doc/src/fitpod_command.rst +++ b/doc/src/fitpod_command.rst @@ -6,7 +6,7 @@ fitpod command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fitpod Ta_param.pod Ta_data.pod diff --git a/doc/src/fix_alchemy.rst b/doc/src/fix_alchemy.rst index 4f0ad06fd4..14273d65c4 100644 --- a/doc/src/fix_alchemy.rst +++ b/doc/src/fix_alchemy.rst @@ -6,7 +6,7 @@ fix alchemy command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID alchemy v_name diff --git a/doc/src/fix_ave_grid.rst b/doc/src/fix_ave_grid.rst index 5760bb4508..a79a6cf486 100644 --- a/doc/src/fix_ave_grid.rst +++ b/doc/src/fix_ave_grid.rst @@ -6,7 +6,7 @@ fix ave/grid command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID ave/grid Nevery Nrepeat Nfreq Nx Ny Nz value1 value2 ... keyword args ... @@ -129,12 +129,12 @@ overlays the simulation box. For 2d simulations, *Nz* must be 1. The very coarse compared to the particle count, or very fine. If one or more of the values = 1, then bins are 2d planes or 1d slices of the simulation domain. Note that if the total number of grid cells is -small, it may be more efficient to use the doc:`fix ave/chunk +small, it may be more efficient to use the :doc:`fix ave/chunk ` command which can treat a grid defined by the :doc:`compute chunk/atom ` command as a global grid where each processor owns a copy of all the grid cells. If *Nx* = *Ny* = *Nz* = 1 is used, the same calculation would be more -efficiently performed by the doc:`fix ave/atom ` +efficiently performed by the :doc:`fix ave/atom ` command. If the simulation box size or shape changes during a simulation, the diff --git a/doc/src/fix_bond_swap.rst b/doc/src/fix_bond_swap.rst index c7535c21b1..6448dd6e1c 100644 --- a/doc/src/fix_bond_swap.rst +++ b/doc/src/fix_bond_swap.rst @@ -6,7 +6,7 @@ fix bond/swap command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID bond/swap Nevery fraction cutoff seed diff --git a/doc/src/fix_box_relax.rst b/doc/src/fix_box_relax.rst index 5efbfcab1b..9f1dade765 100644 --- a/doc/src/fix_box_relax.rst +++ b/doc/src/fix_box_relax.rst @@ -6,7 +6,7 @@ fix box/relax command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID box/relax keyword value ... diff --git a/doc/src/fix_charge_regulation.rst b/doc/src/fix_charge_regulation.rst index c1e790c691..bc2651a55b 100644 --- a/doc/src/fix_charge_regulation.rst +++ b/doc/src/fix_charge_regulation.rst @@ -7,7 +7,7 @@ fix charge/regulation command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID charge/regulation cation_type anion_type keyword value(s) @@ -45,10 +45,10 @@ Syntax Examples """""""" + .. code-block:: LAMMPS fix chareg all charge/regulation 1 2 acid_type 3 base_type 4 pKa 5.0 pKb 6.0 pH 7.0 pIp 3.0 pIm 3.0 nevery 200 nmc 200 seed 123 tempfixid fT - fix chareg all charge/regulation 1 2 pIp 3 pIm 3 onlysalt yes 2 -1 seed 123 tag yes temp 1.0 Description @@ -171,7 +171,7 @@ Langevin thermostat: .. code-block:: LAMMPS compute dtemp all temp - compute_modify dtemp dynamic yes + compute_modify dtemp dynamic/dof yes fix fT all langevin 1.0 1.0 1.0 123 fix_modify fT temp dtemp diff --git a/doc/src/fix_cmap.rst b/doc/src/fix_cmap.rst index 19d8cd2d52..316ad5d038 100644 --- a/doc/src/fix_cmap.rst +++ b/doc/src/fix_cmap.rst @@ -6,7 +6,7 @@ fix cmap command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID cmap filename diff --git a/doc/src/fix_colvars.rst b/doc/src/fix_colvars.rst index 77a90cc54f..5acd79ba34 100644 --- a/doc/src/fix_colvars.rst +++ b/doc/src/fix_colvars.rst @@ -6,7 +6,7 @@ fix colvars command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID colvars configfile keyword values ... diff --git a/doc/src/fix_controller.rst b/doc/src/fix_controller.rst index d03d9a123c..fc8186ef29 100644 --- a/doc/src/fix_controller.rst +++ b/doc/src/fix_controller.rst @@ -6,7 +6,7 @@ fix controller command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID controller Nevery alpha Kp Ki Kd pvar setpoint cvar diff --git a/doc/src/fix_damping_cundall.rst b/doc/src/fix_damping_cundall.rst index 262291c0b8..5c532f08d0 100644 --- a/doc/src/fix_damping_cundall.rst +++ b/doc/src/fix_damping_cundall.rst @@ -6,7 +6,7 @@ fix damping/cundall command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID damping/cundall gamma_l gamma_a keyword values ... diff --git a/doc/src/fix_deform.rst b/doc/src/fix_deform.rst index 9adf5b4aa2..ee010f5645 100644 --- a/doc/src/fix_deform.rst +++ b/doc/src/fix_deform.rst @@ -9,7 +9,7 @@ Accelerator Variants: *deform/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID deform N parameter args ... keyword value ... diff --git a/doc/src/fix_deposit.rst b/doc/src/fix_deposit.rst index 7d19e93148..7d2d28bfa9 100644 --- a/doc/src/fix_deposit.rst +++ b/doc/src/fix_deposit.rst @@ -6,7 +6,7 @@ fix deposit command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID deposit N type M seed keyword values ... @@ -95,10 +95,9 @@ default group "all" and the group specified in the fix deposit command (which can also be "all"). If you are computing temperature values which include inserted -particles, you will want to use the -:doc:`compute_modify ` dynamic option, which ensures the -current number of atoms is used as a normalizing factor each time the -temperature is computed. +particles, you will want to use the :doc:`compute_modify dynamic/dof yes +` option, which ensures the current number of atoms is +used as a normalizing factor each time the temperature is computed. Care must be taken that inserted particles are not too near existing atoms, using the options described below. When inserting particles @@ -160,15 +159,17 @@ command which also appears in your input script. .. note:: - If you wish the new rigid molecules (and other rigid molecules) - to be thermostatted correctly via :doc:`fix rigid/small/nvt ` - or :doc:`fix rigid/small/npt `, then you need to use the - "fix_modify dynamic/dof yes" command for the rigid fix. This is to - inform that fix that the molecule count will vary dynamically. + If you wish the new rigid molecules (and other rigid molecules) to be + thermostatted correctly via :doc:`fix rigid/small/nvt ` or + :doc:`fix rigid/small/npt `, then you need to use the + :doc:`fix_modify dynamic/dof yes ` command for the rigid + fix. This is to inform that fix that the molecule count will vary + dynamically. If you wish to insert molecules via the *mol* keyword, that will have their bonds or angles constrained via SHAKE, use the *shake* keyword, -specifying as its value the ID of a separate :doc:`fix shake ` command which also appears in your input script. +specifying as its value the ID of a separate :doc:`fix shake +` command which also appears in your input script. Each timestep a particle is inserted, the coordinates for its atoms are chosen as follows. For insertion of individual atoms, the @@ -268,8 +269,8 @@ units of distance or velocity. If you are monitoring the temperature of a system where the atom count is changing due to adding particles, you typically should use - the :doc:`compute_modify dynamic yes ` command for the - temperature compute you are using. + the :doc:`compute_modify dynamic/dof yes ` command + for the temperature compute you are using. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/doc/src/fix_dpd_energy.rst b/doc/src/fix_dpd_energy.rst index d6e8dd7230..ef5a5ed073 100644 --- a/doc/src/fix_dpd_energy.rst +++ b/doc/src/fix_dpd_energy.rst @@ -9,7 +9,7 @@ Accelerator Variants: *dpd/energy/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID dpd/energy diff --git a/doc/src/fix_dpd_source.rst b/doc/src/fix_dpd_source.rst index 71894161f1..8ec5163854 100644 --- a/doc/src/fix_dpd_source.rst +++ b/doc/src/fix_dpd_source.rst @@ -10,7 +10,7 @@ fix tdpd/source command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID edpd/source keyword values ... fix ID group-ID tdpd/source cc_index keyword values ... diff --git a/doc/src/fix_drag.rst b/doc/src/fix_drag.rst index 3bfc5420de..9e29762cf5 100644 --- a/doc/src/fix_drag.rst +++ b/doc/src/fix_drag.rst @@ -6,7 +6,7 @@ fix drag command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID drag x y z fmag delta diff --git a/doc/src/fix_drude.rst b/doc/src/fix_drude.rst index 5300d1f490..679d6eb4bf 100644 --- a/doc/src/fix_drude.rst +++ b/doc/src/fix_drude.rst @@ -6,7 +6,7 @@ fix drude command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID drude flag1 flag2 ... flagN diff --git a/doc/src/fix_drude_transform.rst b/doc/src/fix_drude_transform.rst index bd63a411be..399bf2dd45 100644 --- a/doc/src/fix_drude_transform.rst +++ b/doc/src/fix_drude_transform.rst @@ -10,7 +10,7 @@ fix drude/transform/inverse command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style keyword value ... diff --git a/doc/src/fix_dt_reset.rst b/doc/src/fix_dt_reset.rst index 5757f0ec99..03b07776e6 100644 --- a/doc/src/fix_dt_reset.rst +++ b/doc/src/fix_dt_reset.rst @@ -9,7 +9,7 @@ Accelerator Variants: *dt/reset/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID dt/reset N Tmin Tmax Xmax keyword values ... diff --git a/doc/src/fix_efield.rst b/doc/src/fix_efield.rst index e38e1e6894..2958d89794 100644 --- a/doc/src/fix_efield.rst +++ b/doc/src/fix_efield.rst @@ -10,7 +10,7 @@ fix efield/tip4p command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style ex ey ez keyword value ... diff --git a/doc/src/fix_ehex.rst b/doc/src/fix_ehex.rst index 186ed7065e..d7c09ce36c 100644 --- a/doc/src/fix_ehex.rst +++ b/doc/src/fix_ehex.rst @@ -6,7 +6,7 @@ fix ehex command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID ehex nevery F keyword value diff --git a/doc/src/fix_electron_stopping.rst b/doc/src/fix_electron_stopping.rst index fa0fc763f5..990e4203f4 100644 --- a/doc/src/fix_electron_stopping.rst +++ b/doc/src/fix_electron_stopping.rst @@ -10,7 +10,7 @@ fix electron/stopping/fit command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style args @@ -204,7 +204,7 @@ The default is no limitation by region, and minneigh = 1. .. _CasP: -**(CasP)** CasP webpage: https://www.helmholtz-berlin.de/people/gregor-schiwietz/casp_en.html +**(CasP)** CasP webpage: http://www.casp-program.org/ .. _PASS: diff --git a/doc/src/fix_enforce2d.rst b/doc/src/fix_enforce2d.rst index a8061e5eaa..5dd0b79057 100644 --- a/doc/src/fix_enforce2d.rst +++ b/doc/src/fix_enforce2d.rst @@ -9,7 +9,7 @@ Accelerator Variants: *enforce2d/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID enforce2d diff --git a/doc/src/fix_eos_cv.rst b/doc/src/fix_eos_cv.rst index c43b5461b1..3f5c87cd38 100644 --- a/doc/src/fix_eos_cv.rst +++ b/doc/src/fix_eos_cv.rst @@ -6,7 +6,7 @@ fix eos/cv command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID eos/cv cv diff --git a/doc/src/fix_eos_table.rst b/doc/src/fix_eos_table.rst index bfb8ec2c3c..533904b0e7 100644 --- a/doc/src/fix_eos_table.rst +++ b/doc/src/fix_eos_table.rst @@ -6,7 +6,7 @@ fix eos/table command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID eos/table style file N keyword diff --git a/doc/src/fix_eos_table_rx.rst b/doc/src/fix_eos_table_rx.rst index c9f134f985..104fa79c20 100644 --- a/doc/src/fix_eos_table_rx.rst +++ b/doc/src/fix_eos_table_rx.rst @@ -9,7 +9,7 @@ Accelerator Variants: *eos/table/rx/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID eos/table/rx style file1 N keyword ... diff --git a/doc/src/fix_evaporate.rst b/doc/src/fix_evaporate.rst index 4c5ea01e13..1df58aa5d5 100644 --- a/doc/src/fix_evaporate.rst +++ b/doc/src/fix_evaporate.rst @@ -6,7 +6,7 @@ fix evaporate command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID evaporate N M region-ID seed @@ -69,14 +69,15 @@ incur overhead due to the cost of building neighbor lists. If you are monitoring the temperature of a system where the atom count is changing due to evaporation, you typically should use the - :doc:`compute_modify dynamic yes ` command for the + :doc:`compute_modify dynamic/dof yes ` command for the temperature compute you are using. 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 information about this fix is written to :doc:`binary restart files +`. None of the :doc:`fix_modify ` options are +relevant to this fix. This fix computes a global scalar, which can be accessed by various :doc:`output commands `. The scalar is the cumulative @@ -84,7 +85,8 @@ number of deleted atoms. The scalar value calculated by this fix is "intensive". 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 `. +the :doc:`run ` command. This fix is not invoked during +:doc:`energy minimization `. Restrictions """""""""""" diff --git a/doc/src/fix_external.rst b/doc/src/fix_external.rst index a3677a350c..44dd0929ee 100644 --- a/doc/src/fix_external.rst +++ b/doc/src/fix_external.rst @@ -6,7 +6,7 @@ fix external command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID external mode args diff --git a/doc/src/fix_ffl.rst b/doc/src/fix_ffl.rst index 6058b0ed3e..04e4d9be90 100644 --- a/doc/src/fix_ffl.rst +++ b/doc/src/fix_ffl.rst @@ -6,7 +6,7 @@ fix ffl command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID id-group ffl tau Tstart Tstop seed [flip-type] diff --git a/doc/src/fix_filter_corotate.rst b/doc/src/fix_filter_corotate.rst index c0a2216be3..7c091140df 100644 --- a/doc/src/fix_filter_corotate.rst +++ b/doc/src/fix_filter_corotate.rst @@ -6,7 +6,7 @@ fix filter/corotate command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID filter/corotate keyword value ... diff --git a/doc/src/fix_flow_gauss.rst b/doc/src/fix_flow_gauss.rst index 87ab283923..6100c5d635 100644 --- a/doc/src/fix_flow_gauss.rst +++ b/doc/src/fix_flow_gauss.rst @@ -6,7 +6,7 @@ fix flow/gauss command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID flow/gauss xflag yflag zflag keyword diff --git a/doc/src/fix_freeze.rst b/doc/src/fix_freeze.rst index ce79ce3caf..9b579633b1 100644 --- a/doc/src/fix_freeze.rst +++ b/doc/src/fix_freeze.rst @@ -9,7 +9,7 @@ Accelerator Variants: *freeze/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID freeze diff --git a/doc/src/fix_gcmc.rst b/doc/src/fix_gcmc.rst index c348e2a44f..13ae509684 100644 --- a/doc/src/fix_gcmc.rst +++ b/doc/src/fix_gcmc.rst @@ -6,7 +6,7 @@ fix gcmc command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID gcmc N X M type seed T mu displace keyword values ... @@ -146,8 +146,8 @@ center-of-mass is inside the specified region. If used with :doc:`fix nvt `, the temperature of the imaginary reservoir, T, should be set to be equivalent to the target temperature used in fix nvt. Otherwise, the imaginary reservoir will not be in -thermal equilibrium with the simulation cell. Also, it is important -that the temperature used by fix nvt be dynamic/dof, which can be +thermal equilibrium with the simulation cell. Also, it is important that +the temperature used by *fix nvt* is dynamically updated, which can be achieved as follows: .. code-block:: LAMMPS @@ -197,15 +197,17 @@ which also appears in your input script. .. note:: - If you wish the new rigid molecules (and other rigid molecules) - to be thermostatted correctly via :doc:`fix rigid/small/nvt ` - or :doc:`fix rigid/small/npt `, then you need to use the - "fix_modify dynamic/dof yes" command for the rigid fix. This is to - inform that fix that the molecule count will vary dynamically. + If you wish the new rigid molecules (and other rigid molecules) to be + thermostatted correctly via :doc:`fix rigid/small/nvt ` or + :doc:`fix rigid/small/npt `, then you need to use the + :doc:`fix_modify dynamic/dof yes ` command for the rigid + fix. This is to inform that fix that the molecule count will vary + dynamically. If you wish to insert molecules via the *mol* keyword, that will have their bonds or angles constrained via SHAKE, use the *shake* keyword, -specifying as its value the ID of a separate :doc:`fix shake ` command which also appears in your input script. +specifying as its value the ID of a separate :doc:`fix shake +` command which also appears in your input script. Optionally, users may specify the relative amounts of different MC moves using the *mcmoves* keyword. The values *Patomtrans*, @@ -335,31 +337,30 @@ temperature. Some fixes have an associated potential energy. Examples of such fixes include: :doc:`efield `, :doc:`gravity `, :doc:`addforce `, :doc:`langevin `, -:doc:`restrain `, -:doc:`temp/berendsen `, -:doc:`temp/rescale `, and :doc:`wall fixes `. -For that energy to be included in the total potential energy of the -system (the quantity used when performing GCMC exchange and MC moves), -you MUST enable -the :doc:`fix_modify ` *energy* option for that fix. The -doc pages for individual :doc:`fix ` commands specify if this -should be done. +:doc:`restrain `, :doc:`temp/berendsen +`, :doc:`temp/rescale `, and +:doc:`wall fixes `. For that energy to be included in the +total potential energy of the system (the quantity used when performing +GCMC exchange and MC moves), you MUST enable the :doc:`fix_modify +` *energy* option for that fix. The doc pages for +individual :doc:`fix ` commands specify if this should be done. Use the *charge* option to insert atoms with a user-specified point -charge. Note that doing so will cause the system to become -non-neutral. LAMMPS issues a warning when using long-range -electrostatics (kspace) with non-neutral systems. See the :doc:`compute group/group ` documentation for more details -about simulating non-neutral systems with kspace on. +charge. Note that doing so will cause the system to become non-neutral. +LAMMPS issues a warning when using long-range electrostatics (kspace) +with non-neutral systems. See the :doc:`compute group/group +` documentation for more details about simulating +non-neutral systems with kspace on. Use of this fix typically will cause the number of atoms to fluctuate, -therefore, you will want to use the -:doc:`compute_modify dynamic/dof ` command to ensure that the -current number of atoms is used as a normalizing factor each time -temperature is computed. A simple example of this is: +therefore, you will want to use the :doc:`compute_modify dynamic/dof +` command to ensure that the current number of atoms is +used as a normalizing factor each time temperature is computed. A simple +example of this is: .. code-block:: LAMMPS - compute_modify thermo_temp dynamic yes + compute_modify thermo_temp dynamic/dof yes A more complicated example is listed earlier on this page in the context of NVT dynamics. @@ -369,31 +370,29 @@ in the context of NVT dynamics. If the density of the cell is initially very small or zero, and increases to a much larger density after a period of equilibration, then certain quantities that are only calculated once at the start - (kspace parameters) may no longer be accurate. The - solution is to start a new simulation after the equilibrium density - has been reached. + (kspace parameters) may no longer be accurate. The solution is to + start a new simulation after the equilibrium density has been + reached. With some pair_styles, such as :doc:`Buckingham `, -:doc:`Born-Mayer-Huggins ` and :doc:`ReaxFF `, two -atoms placed close to each other may have an arbitrary large, negative -potential energy due to the functional form of the potential. While -these unphysical configurations are inaccessible to typical dynamical -trajectories, they can be generated by Monte Carlo moves. The -*overlap_cutoff* keyword suppresses these moves by effectively -assigning an infinite positive energy to all new configurations that -place any pair of atoms closer than the specified overlap cutoff -distance. +:doc:`Born-Mayer-Huggins ` and :doc:`ReaxFF `, +two atoms placed close to each other may have an arbitrary large, +negative potential energy due to the functional form of the potential. +While these unphysical configurations are inaccessible to typical +dynamical trajectories, they can be generated by Monte Carlo moves. The +*overlap_cutoff* keyword suppresses these moves by effectively assigning +an infinite positive energy to all new configurations that place any +pair of atoms closer than the specified overlap cutoff distance. -The *max* and *min* keywords allow for the restriction of the number -of atoms in the simulation. They automatically reject all insertion -or deletion moves that would take the system beyond the set boundaries. +The *max* and *min* keywords allow for the restriction of the number of +atoms in the simulation. They automatically reject all insertion or +deletion moves that would take the system beyond the set boundaries. Should the system already be beyond the boundary, only moves that bring the system closer to the bounds may be accepted. -The *group* keyword adds all inserted atoms to the -:doc:`group ` of the group-ID value. The *grouptype* keyword -adds all inserted atoms of the specified type to the -:doc:`group ` of the group-ID value. +The *group* keyword adds all inserted atoms to the :doc:`group ` +of the group-ID value. The *grouptype* keyword adds all inserted atoms +of the specified type to the :doc:`group ` of the group-ID value. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -446,22 +445,21 @@ called. Reneighboring is required. Only usable for 3D simulations. -Can be run in parallel, but aspects of the GCMC part will not scale -well in parallel. Currently, molecule translations and rotations -are not supported with more than one MPI process. -It is still possible to do parallel molecule exchange without -translation and rotation moves by setting MC moves to zero -and/or by using the *mcmoves* keyword with *Pmoltrans* = *Pmolrotate* = 0 . +This fix can be run in parallel, but aspects of the GCMC part will not +scale well in parallel. Currently, molecule translations and rotations +are not supported with more than one MPI process. It is still possible +to do parallel molecule exchange without translation and rotation moves +by setting MC moves to zero and/or by using the *mcmoves* keyword with +*Pmoltrans* = *Pmolrotate* = 0 . -When using fix gcmc in combination with fix shake or fix rigid, -only GCMC exchange moves are supported, so the argument -*M* must be zero. +When using fix gcmc in combination with fix shake or fix rigid, only +GCMC exchange moves are supported, so the argument *M* must be zero. -When using fix gcmc in combination with fix rigid, deletion -of the last remaining molecule is not allowed for technical reasons, -and so the molecule count will never drop below 1, regardless of the -specified chemical potential. +When using fix gcmc in combination with fix rigid, deletion of the last +remaining molecule is not allowed for technical reasons, and so the +molecule count will never drop below 1, regardless of the specified +chemical potential. Note that very lengthy simulations involving insertions/deletions of billions of gas molecules may run out of atom or molecule IDs and diff --git a/doc/src/fix_gld.rst b/doc/src/fix_gld.rst index d0fd6a4c9e..ba26f7a51b 100644 --- a/doc/src/fix_gld.rst +++ b/doc/src/fix_gld.rst @@ -6,7 +6,7 @@ fix gld command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID gld Tstart Tstop N_k seed series c_1 tau_1 ... c_N_k tau_N_k keyword values ... diff --git a/doc/src/fix_gle.rst b/doc/src/fix_gle.rst index 03add9d354..d28a9bbf0d 100644 --- a/doc/src/fix_gle.rst +++ b/doc/src/fix_gle.rst @@ -6,7 +6,7 @@ fix gle command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID id-group gle Ns Tstart Tstop seed Amatrix [noneq Cmatrix] [every stride] diff --git a/doc/src/fix_gravity.rst b/doc/src/fix_gravity.rst index 6d34cc1bf3..cd7cfcc3df 100644 --- a/doc/src/fix_gravity.rst +++ b/doc/src/fix_gravity.rst @@ -10,7 +10,7 @@ Accelerator Variants: *gravity/omp*, *gravity/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group gravity magnitude style args diff --git a/doc/src/fix_grem.rst b/doc/src/fix_grem.rst index 3e3ec02994..9cc6e3f43e 100644 --- a/doc/src/fix_grem.rst +++ b/doc/src/fix_grem.rst @@ -6,7 +6,7 @@ fix grem command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID grem lambda eta H0 thermostat-ID diff --git a/doc/src/fix_halt.rst b/doc/src/fix_halt.rst index 56e86208cd..4231c77cc5 100644 --- a/doc/src/fix_halt.rst +++ b/doc/src/fix_halt.rst @@ -6,7 +6,7 @@ fix halt command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID halt N attribute operator avalue keyword value ... diff --git a/doc/src/fix_heat.rst b/doc/src/fix_heat.rst index 19bc3d84ca..1badf08bff 100644 --- a/doc/src/fix_heat.rst +++ b/doc/src/fix_heat.rst @@ -6,7 +6,7 @@ fix heat command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID heat N eflux diff --git a/doc/src/fix_heat_flow.rst b/doc/src/fix_heat_flow.rst index ee73d7d4f2..1ca99a1686 100644 --- a/doc/src/fix_heat_flow.rst +++ b/doc/src/fix_heat_flow.rst @@ -6,7 +6,7 @@ fix heat/flow command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID heat/flow style values ... diff --git a/doc/src/fix_hyper_global.rst b/doc/src/fix_hyper_global.rst index c8643b3b86..2ac1e5e4f3 100644 --- a/doc/src/fix_hyper_global.rst +++ b/doc/src/fix_hyper_global.rst @@ -6,7 +6,7 @@ fix hyper/global command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID hyper/global cutbond qfactor Vmax Tequil diff --git a/doc/src/fix_hyper_local.rst b/doc/src/fix_hyper_local.rst index b5350e9765..76b17cddc4 100644 --- a/doc/src/fix_hyper_local.rst +++ b/doc/src/fix_hyper_local.rst @@ -6,7 +6,7 @@ fix hyper/local command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID hyper/local cutbond qfactor Vmax Tequil Dcut alpha Btarget diff --git a/doc/src/fix_imd.rst b/doc/src/fix_imd.rst index cb1831d174..520af505a1 100644 --- a/doc/src/fix_imd.rst +++ b/doc/src/fix_imd.rst @@ -6,7 +6,7 @@ fix imd command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID imd trate port keyword values ... diff --git a/doc/src/fix_indent.rst b/doc/src/fix_indent.rst index c8349e9381..15790e15d0 100644 --- a/doc/src/fix_indent.rst +++ b/doc/src/fix_indent.rst @@ -6,7 +6,7 @@ fix indent command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID indent K keyword values ... diff --git a/doc/src/fix_ipi.rst b/doc/src/fix_ipi.rst index 5e13d25971..7705f211e8 100644 --- a/doc/src/fix_ipi.rst +++ b/doc/src/fix_ipi.rst @@ -6,7 +6,7 @@ fix ipi command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID ipi address port [unix] [reset] diff --git a/doc/src/fix_langevin.rst b/doc/src/fix_langevin.rst index c09fc7b928..e04805427e 100644 --- a/doc/src/fix_langevin.rst +++ b/doc/src/fix_langevin.rst @@ -9,7 +9,7 @@ Accelerator Variants: *langevin/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID langevin Tstart Tstop damp seed keyword values ... diff --git a/doc/src/fix_langevin_drude.rst b/doc/src/fix_langevin_drude.rst index 5e62e4f416..c53c29b3ac 100644 --- a/doc/src/fix_langevin_drude.rst +++ b/doc/src/fix_langevin_drude.rst @@ -6,7 +6,7 @@ fix langevin/drude command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID langevin/drude Tcom damp_com seed_com Tdrude damp_drude seed_drude keyword values ... diff --git a/doc/src/fix_langevin_eff.rst b/doc/src/fix_langevin_eff.rst index 506b5052d5..21cdc4a789 100644 --- a/doc/src/fix_langevin_eff.rst +++ b/doc/src/fix_langevin_eff.rst @@ -6,7 +6,7 @@ fix langevin/eff command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID langevin/eff Tstart Tstop damp seed keyword values ... diff --git a/doc/src/fix_langevin_spin.rst b/doc/src/fix_langevin_spin.rst index 0ca291a732..c82751a755 100644 --- a/doc/src/fix_langevin_spin.rst +++ b/doc/src/fix_langevin_spin.rst @@ -6,7 +6,7 @@ fix langevin/spin command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID langevin/spin T Tdamp seed diff --git a/doc/src/fix_lb_fluid.rst b/doc/src/fix_lb_fluid.rst index 04f306156a..a461175f71 100644 --- a/doc/src/fix_lb_fluid.rst +++ b/doc/src/fix_lb_fluid.rst @@ -6,7 +6,7 @@ fix lb/fluid command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID lb/fluid nevery viscosity density keyword values ... diff --git a/doc/src/fix_lb_momentum.rst b/doc/src/fix_lb_momentum.rst index 8b2c5e6ae2..67a8d86d5f 100644 --- a/doc/src/fix_lb_momentum.rst +++ b/doc/src/fix_lb_momentum.rst @@ -6,7 +6,7 @@ fix lb/momentum command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID lb/momentum nevery keyword values ... diff --git a/doc/src/fix_lb_viscous.rst b/doc/src/fix_lb_viscous.rst index 6e0ec21b7e..5557cba57f 100644 --- a/doc/src/fix_lb_viscous.rst +++ b/doc/src/fix_lb_viscous.rst @@ -6,7 +6,7 @@ fix lb/viscous command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID lb/viscous diff --git a/doc/src/fix_lineforce.rst b/doc/src/fix_lineforce.rst index e82f6ed556..9b1d30e832 100644 --- a/doc/src/fix_lineforce.rst +++ b/doc/src/fix_lineforce.rst @@ -6,7 +6,7 @@ fix lineforce command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID lineforce x y z diff --git a/doc/src/fix_manifoldforce.rst b/doc/src/fix_manifoldforce.rst index 2d72743707..cd5fffc881 100644 --- a/doc/src/fix_manifoldforce.rst +++ b/doc/src/fix_manifoldforce.rst @@ -6,7 +6,7 @@ fix manifoldforce command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID manifoldforce manifold manifold-args ... diff --git a/doc/src/fix_mdi_qm.rst b/doc/src/fix_mdi_qm.rst index 3d0b350407..0868cbbac8 100644 --- a/doc/src/fix_mdi_qm.rst +++ b/doc/src/fix_mdi_qm.rst @@ -6,7 +6,7 @@ fix mdi/qm command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID mdi/qm keyword value(s) keyword value(s) ... diff --git a/doc/src/fix_mdi_qmmm.rst b/doc/src/fix_mdi_qmmm.rst index 1afce0f7e4..a39f8ba71d 100644 --- a/doc/src/fix_mdi_qmmm.rst +++ b/doc/src/fix_mdi_qmmm.rst @@ -6,7 +6,7 @@ fix mdi/qmmm command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID mdi/qmmm mode keyword value(s) keyword value(s) ... diff --git a/doc/src/fix_meso_move.rst b/doc/src/fix_meso_move.rst index 7b3609a8c7..55d54b2107 100644 --- a/doc/src/fix_meso_move.rst +++ b/doc/src/fix_meso_move.rst @@ -6,7 +6,7 @@ fix meso/move command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID meso/move style args keyword values ... diff --git a/doc/src/fix_modify.rst b/doc/src/fix_modify.rst index 175d02dd8f..265803c213 100644 --- a/doc/src/fix_modify.rst +++ b/doc/src/fix_modify.rst @@ -131,24 +131,24 @@ with their specified level at the beginning of a r-RESPA run. The *dynamic/dof* keyword determines whether the number of atoms N in the fix group and their associated degrees of freedom are re-computed each time a temperature is computed. Only fix styles that calculate -their own internal temperature use this option. Currently this is -only the :doc:`fix rigid/nvt/small ` and :doc:`fix -rigid/npt/small ` commands for the purpose of -thermostatting rigid body translation and rotation. By default, N and -their DOF are assumed to be constant. If you are adding atoms or -molecules to the system (see the :doc:`fix pour `, :doc:`fix -deposit `, and :doc:`fix gcmc ` commands) or -expect atoms or molecules to be lost (e.g. due to exiting the -simulation box or via :doc:`fix evaporate `), then this -option should be used to ensure the temperature is correctly -normalized. +their own internal temperature use this option. Currently this is only +the :doc:`fix rigid/nvt/small ` and :doc:`fix rigid/npt/small +` commands for the purpose of thermostatting rigid body +translation and rotation. By default, N and their DOF are assumed to be +constant. If you are adding atoms or molecules to the system (see the +:doc:`fix pour `, :doc:`fix deposit `, and +:doc:`fix gcmc ` commands) or expect atoms or molecules to be +lost (e.g. due to exiting the simulation box or via :doc:`fix evaporate +`), then this option should be used to ensure the +temperature is correctly normalized. .. note:: - Other thermostatting fixes, such as :doc:`fix nvt `, do - not use the *dynamic/dof* keyword because they use a temperature - compute to calculate temperature. See the :doc:`compute_modify dynamic/dof ` command for a similar way to ensure - correct temperature normalization for those thermostats. + Other thermostatting fixes, such as :doc:`fix nvt `, do not + use the *dynamic/dof* keyword because they use a temperature compute + to calculate temperature. See the :doc:`compute_modify dynamic/dof + ` command for a similar way to ensure correct + temperature normalization for those thermostats. The *bodyforces* keyword determines whether the forces and torques acting on rigid bodies are computed *early* at the post-force stage of @@ -156,7 +156,8 @@ each timestep (right after per-atom forces have been computed and communicated among processors), or *late* at the final-integrate stage of each timestep (after any other fixes have finished their post-force tasks). Only the rigid-body integration fixes use this option, which -includes :doc:`fix rigid ` and :doc:`fix rigid/small `, and their variants, and also :doc:`fix poems `. +includes :doc:`fix rigid ` and :doc:`fix rigid/small +`, and their variants, and also :doc:`fix poems `. The default is *late*\ . If there are other fixes that add forces to individual atoms, then the rigid-body constraints will include these diff --git a/doc/src/fix_mol_swap.rst b/doc/src/fix_mol_swap.rst index 737536fa0d..b344b9c0e6 100644 --- a/doc/src/fix_mol_swap.rst +++ b/doc/src/fix_mol_swap.rst @@ -6,7 +6,7 @@ fix mol/swap command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID mol/swap N X itype jtype seed T keyword value ... diff --git a/doc/src/fix_momentum.rst b/doc/src/fix_momentum.rst index dff30fffc4..727cb176a1 100644 --- a/doc/src/fix_momentum.rst +++ b/doc/src/fix_momentum.rst @@ -13,7 +13,7 @@ fix momentum/chunk command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID momentum N keyword values ... diff --git a/doc/src/fix_move.rst b/doc/src/fix_move.rst index ff1f8403df..3fde5f0861 100644 --- a/doc/src/fix_move.rst +++ b/doc/src/fix_move.rst @@ -6,7 +6,7 @@ fix move command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID move style args keyword values ... diff --git a/doc/src/fix_mscg.rst b/doc/src/fix_mscg.rst index 3255f3fbe9..91eb0fe772 100644 --- a/doc/src/fix_mscg.rst +++ b/doc/src/fix_mscg.rst @@ -6,7 +6,7 @@ fix mscg command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID mscg N keyword args ... diff --git a/doc/src/fix_msst.rst b/doc/src/fix_msst.rst index 9502fe21b8..6750934f61 100644 --- a/doc/src/fix_msst.rst +++ b/doc/src/fix_msst.rst @@ -6,7 +6,7 @@ fix msst command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID msst dir shockvel keyword value ... diff --git a/doc/src/fix_mvv_dpd.rst b/doc/src/fix_mvv_dpd.rst index c2f8a50391..ff5b169f97 100644 --- a/doc/src/fix_mvv_dpd.rst +++ b/doc/src/fix_mvv_dpd.rst @@ -14,7 +14,7 @@ fix mvv/tdpd command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID mvv/dpd lambda diff --git a/doc/src/fix_neb.rst b/doc/src/fix_neb.rst index 5f22acfb2b..ccd0f9b83d 100644 --- a/doc/src/fix_neb.rst +++ b/doc/src/fix_neb.rst @@ -6,7 +6,7 @@ fix neb command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID neb Kspring keyword value diff --git a/doc/src/fix_neb_spin.rst b/doc/src/fix_neb_spin.rst index 16baba44c0..d04ba367c4 100644 --- a/doc/src/fix_neb_spin.rst +++ b/doc/src/fix_neb_spin.rst @@ -6,7 +6,7 @@ fix neb/spin command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID neb/spin Kspring diff --git a/doc/src/fix_nh.rst b/doc/src/fix_nh.rst index 7f2ec69f9b..0cfbc8f921 100644 --- a/doc/src/fix_nh.rst +++ b/doc/src/fix_nh.rst @@ -30,7 +30,7 @@ Accelerator Variants: *nph/kk*, *nph/omp* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style_name keyword value ... diff --git a/doc/src/fix_nh_eff.rst b/doc/src/fix_nh_eff.rst index 11990d365b..7f0f8ee8f1 100644 --- a/doc/src/fix_nh_eff.rst +++ b/doc/src/fix_nh_eff.rst @@ -14,7 +14,7 @@ fix nph/eff command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style_name keyword value ... diff --git a/doc/src/fix_nh_uef.rst b/doc/src/fix_nh_uef.rst index 922c2d515a..a515375746 100644 --- a/doc/src/fix_nh_uef.rst +++ b/doc/src/fix_nh_uef.rst @@ -10,7 +10,7 @@ fix npt/uef command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style_name erate edot_x edot_y temp Tstart Tstop Tdamp keyword value ... diff --git a/doc/src/fix_nph_asphere.rst b/doc/src/fix_nph_asphere.rst index a1028efacc..93938fdd58 100644 --- a/doc/src/fix_nph_asphere.rst +++ b/doc/src/fix_nph_asphere.rst @@ -9,7 +9,7 @@ Accelerator Variants: *nph/asphere/omp* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nph/asphere args keyword value ... diff --git a/doc/src/fix_nph_body.rst b/doc/src/fix_nph_body.rst index 1b740a5ae2..9ee0bd7669 100644 --- a/doc/src/fix_nph_body.rst +++ b/doc/src/fix_nph_body.rst @@ -6,7 +6,7 @@ fix nph/body command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nph/body args keyword value ... diff --git a/doc/src/fix_nph_sphere.rst b/doc/src/fix_nph_sphere.rst index 2ef85953e5..9d47cedc28 100644 --- a/doc/src/fix_nph_sphere.rst +++ b/doc/src/fix_nph_sphere.rst @@ -9,7 +9,7 @@ Accelerator Variants: *nph/sphere/omp* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nph/sphere args keyword value ... diff --git a/doc/src/fix_nphug.rst b/doc/src/fix_nphug.rst index 1cedfa909a..ce63f5eddd 100644 --- a/doc/src/fix_nphug.rst +++ b/doc/src/fix_nphug.rst @@ -9,7 +9,7 @@ Accelerator Variants: *nphug/omp* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nphug keyword value ... diff --git a/doc/src/fix_npt_asphere.rst b/doc/src/fix_npt_asphere.rst index 64e1c45be7..0d195821ad 100644 --- a/doc/src/fix_npt_asphere.rst +++ b/doc/src/fix_npt_asphere.rst @@ -9,7 +9,7 @@ Accelerator Variants: *npt/asphere/omp* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID npt/asphere keyword value ... diff --git a/doc/src/fix_npt_body.rst b/doc/src/fix_npt_body.rst index ff98638b63..31ef1653b8 100644 --- a/doc/src/fix_npt_body.rst +++ b/doc/src/fix_npt_body.rst @@ -6,7 +6,7 @@ fix npt/body command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID npt/body keyword value ... diff --git a/doc/src/fix_npt_cauchy.rst b/doc/src/fix_npt_cauchy.rst index 36b22037bf..6764f88eee 100644 --- a/doc/src/fix_npt_cauchy.rst +++ b/doc/src/fix_npt_cauchy.rst @@ -6,7 +6,7 @@ fix npt/cauchy command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style_name keyword value ... diff --git a/doc/src/fix_npt_sphere.rst b/doc/src/fix_npt_sphere.rst index afaa2c9d67..f881bc2dfe 100644 --- a/doc/src/fix_npt_sphere.rst +++ b/doc/src/fix_npt_sphere.rst @@ -9,7 +9,7 @@ Accelerator Variants: *npt/sphere/omp* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID npt/sphere keyword value ... diff --git a/doc/src/fix_numdiff.rst b/doc/src/fix_numdiff.rst index b5fdfb12e6..9b3d3bf7da 100644 --- a/doc/src/fix_numdiff.rst +++ b/doc/src/fix_numdiff.rst @@ -6,7 +6,7 @@ fix numdiff command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID numdiff Nevery delta diff --git a/doc/src/fix_numdiff_virial.rst b/doc/src/fix_numdiff_virial.rst index f909d41111..2075d1d05f 100644 --- a/doc/src/fix_numdiff_virial.rst +++ b/doc/src/fix_numdiff_virial.rst @@ -6,7 +6,7 @@ fix numdiff/virial command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID numdiff/virial Nevery delta diff --git a/doc/src/fix_nve.rst b/doc/src/fix_nve.rst index c50bc4d62f..3757233bcc 100644 --- a/doc/src/fix_nve.rst +++ b/doc/src/fix_nve.rst @@ -12,7 +12,7 @@ Accelerator Variants: *nve/gpu*, *nve/intel*, *nve/kk*, *nve/omp* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve diff --git a/doc/src/fix_nve_asphere.rst b/doc/src/fix_nve_asphere.rst index fbba2bc8dd..cf956bd0c4 100644 --- a/doc/src/fix_nve_asphere.rst +++ b/doc/src/fix_nve_asphere.rst @@ -10,7 +10,7 @@ Accelerator Variants: *nve/asphere/gpu*, *nve/asphere/intel* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/asphere diff --git a/doc/src/fix_nve_asphere_noforce.rst b/doc/src/fix_nve_asphere_noforce.rst index 7d904bef1c..9e6f35b56b 100644 --- a/doc/src/fix_nve_asphere_noforce.rst +++ b/doc/src/fix_nve_asphere_noforce.rst @@ -6,7 +6,7 @@ fix nve/asphere/noforce command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/asphere/noforce diff --git a/doc/src/fix_nve_awpmd.rst b/doc/src/fix_nve_awpmd.rst index c716a94a84..f835758e00 100644 --- a/doc/src/fix_nve_awpmd.rst +++ b/doc/src/fix_nve_awpmd.rst @@ -6,7 +6,7 @@ fix nve/awpmd command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/awpmd diff --git a/doc/src/fix_nve_body.rst b/doc/src/fix_nve_body.rst index 45beee0659..9f562ef59e 100644 --- a/doc/src/fix_nve_body.rst +++ b/doc/src/fix_nve_body.rst @@ -6,7 +6,7 @@ fix nve/body command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/body diff --git a/doc/src/fix_nve_bpm_sphere.rst b/doc/src/fix_nve_bpm_sphere.rst index ef170605a4..fb3bd9e466 100644 --- a/doc/src/fix_nve_bpm_sphere.rst +++ b/doc/src/fix_nve_bpm_sphere.rst @@ -6,7 +6,7 @@ fix nve/bpm/sphere command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/bpm/sphere diff --git a/doc/src/fix_nve_dot.rst b/doc/src/fix_nve_dot.rst index 0a99e11452..0d6e0ab5c3 100644 --- a/doc/src/fix_nve_dot.rst +++ b/doc/src/fix_nve_dot.rst @@ -6,7 +6,7 @@ fix nve/dot command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/dot diff --git a/doc/src/fix_nve_dotc_langevin.rst b/doc/src/fix_nve_dotc_langevin.rst index e47e8f4a2a..51efa06a02 100644 --- a/doc/src/fix_nve_dotc_langevin.rst +++ b/doc/src/fix_nve_dotc_langevin.rst @@ -6,7 +6,7 @@ fix nve/dotc/langevin command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/dotc/langevin Tstart Tstop damp seed keyword value diff --git a/doc/src/fix_nve_eff.rst b/doc/src/fix_nve_eff.rst index 60bece43d0..1cf954a88d 100644 --- a/doc/src/fix_nve_eff.rst +++ b/doc/src/fix_nve_eff.rst @@ -6,7 +6,7 @@ fix nve/eff command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/eff diff --git a/doc/src/fix_nve_limit.rst b/doc/src/fix_nve_limit.rst index 0c572c6c6a..b00a5d64ca 100644 --- a/doc/src/fix_nve_limit.rst +++ b/doc/src/fix_nve_limit.rst @@ -6,7 +6,7 @@ fix nve/limit command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/limit xmax diff --git a/doc/src/fix_nve_line.rst b/doc/src/fix_nve_line.rst index 5bb6fd4213..7574110041 100644 --- a/doc/src/fix_nve_line.rst +++ b/doc/src/fix_nve_line.rst @@ -6,7 +6,7 @@ fix nve/line command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/line diff --git a/doc/src/fix_nve_manifold_rattle.rst b/doc/src/fix_nve_manifold_rattle.rst index 63632ebac0..6adf72ac55 100644 --- a/doc/src/fix_nve_manifold_rattle.rst +++ b/doc/src/fix_nve_manifold_rattle.rst @@ -6,7 +6,7 @@ fix nve/manifold/rattle command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/manifold/rattle tol maxit manifold manifold-args keyword value ... diff --git a/doc/src/fix_nve_noforce.rst b/doc/src/fix_nve_noforce.rst index ed13123403..9b9c30d325 100644 --- a/doc/src/fix_nve_noforce.rst +++ b/doc/src/fix_nve_noforce.rst @@ -6,7 +6,7 @@ fix nve/noforce command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve diff --git a/doc/src/fix_nve_sphere.rst b/doc/src/fix_nve_sphere.rst index df177a2eca..9340e4af22 100644 --- a/doc/src/fix_nve_sphere.rst +++ b/doc/src/fix_nve_sphere.rst @@ -10,7 +10,7 @@ Accelerator Variants: *nve/sphere/omp*, *nve/sphere/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/sphere diff --git a/doc/src/fix_nve_spin.rst b/doc/src/fix_nve_spin.rst index e35647aef4..6edc9da09a 100644 --- a/doc/src/fix_nve_spin.rst +++ b/doc/src/fix_nve_spin.rst @@ -6,7 +6,7 @@ fix nve/spin command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/spin keyword values diff --git a/doc/src/fix_nve_tri.rst b/doc/src/fix_nve_tri.rst index b511d9b318..1bcecb71db 100644 --- a/doc/src/fix_nve_tri.rst +++ b/doc/src/fix_nve_tri.rst @@ -6,7 +6,7 @@ fix nve/tri command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nve/tri diff --git a/doc/src/fix_nvk.rst b/doc/src/fix_nvk.rst index 0d83a4b1be..d74ec1639c 100644 --- a/doc/src/fix_nvk.rst +++ b/doc/src/fix_nvk.rst @@ -6,7 +6,7 @@ fix nvk command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nvk diff --git a/doc/src/fix_nvt_asphere.rst b/doc/src/fix_nvt_asphere.rst index 7ce3aec125..b456516e3c 100644 --- a/doc/src/fix_nvt_asphere.rst +++ b/doc/src/fix_nvt_asphere.rst @@ -9,7 +9,7 @@ Accelerator Variants: *nvt/asphere/omp* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nvt/asphere keyword value ... diff --git a/doc/src/fix_nvt_body.rst b/doc/src/fix_nvt_body.rst index 7b9e996a5b..4397159515 100644 --- a/doc/src/fix_nvt_body.rst +++ b/doc/src/fix_nvt_body.rst @@ -6,7 +6,7 @@ fix nvt/body command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nvt/body keyword value ... diff --git a/doc/src/fix_nvt_manifold_rattle.rst b/doc/src/fix_nvt_manifold_rattle.rst index 91a5f28649..921022d743 100644 --- a/doc/src/fix_nvt_manifold_rattle.rst +++ b/doc/src/fix_nvt_manifold_rattle.rst @@ -6,7 +6,7 @@ fix nvt/manifold/rattle command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nvt/manifold/rattle tol maxit manifold manifold-args keyword value ... diff --git a/doc/src/fix_nvt_sllod.rst b/doc/src/fix_nvt_sllod.rst index 48d0bb5946..430ed31c14 100644 --- a/doc/src/fix_nvt_sllod.rst +++ b/doc/src/fix_nvt_sllod.rst @@ -11,7 +11,7 @@ Accelerator Variants: *nvt/sllod/intel*, *nvt/sllod/omp*, *nvt/sllod/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nvt/sllod keyword value ... diff --git a/doc/src/fix_nvt_sllod_eff.rst b/doc/src/fix_nvt_sllod_eff.rst index dd4dd469ef..71a7e75b80 100644 --- a/doc/src/fix_nvt_sllod_eff.rst +++ b/doc/src/fix_nvt_sllod_eff.rst @@ -6,7 +6,7 @@ fix nvt/sllod/eff command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nvt/sllod/eff keyword value ... diff --git a/doc/src/fix_nvt_sphere.rst b/doc/src/fix_nvt_sphere.rst index f107940af9..6baa79532c 100644 --- a/doc/src/fix_nvt_sphere.rst +++ b/doc/src/fix_nvt_sphere.rst @@ -9,7 +9,7 @@ Accelerator Variants: *nvt/sphere/omp* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID nvt/sphere keyword value ... diff --git a/doc/src/fix_oneway.rst b/doc/src/fix_oneway.rst index 272797fa17..b4a55e9968 100644 --- a/doc/src/fix_oneway.rst +++ b/doc/src/fix_oneway.rst @@ -6,7 +6,7 @@ fix oneway command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID oneway N region-ID direction diff --git a/doc/src/fix_orient.rst b/doc/src/fix_orient.rst index 68522209b7..7e30b7bb01 100644 --- a/doc/src/fix_orient.rst +++ b/doc/src/fix_orient.rst @@ -10,7 +10,7 @@ fix orient/bcc command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID orient/fcc nstats dir alat dE cutlo cuthi file0 file1 fix ID group-ID orient/bcc nstats dir alat dE cutlo cuthi file0 file1 diff --git a/doc/src/fix_pafi.rst b/doc/src/fix_pafi.rst index c8830316a2..a57fc658fc 100644 --- a/doc/src/fix_pafi.rst +++ b/doc/src/fix_pafi.rst @@ -6,7 +6,7 @@ fix pafi command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID pafi compute-ID Temp Tdamp seed keyword values... diff --git a/doc/src/fix_pair.rst b/doc/src/fix_pair.rst index 07e934d1c0..ec4a5bcb3f 100644 --- a/doc/src/fix_pair.rst +++ b/doc/src/fix_pair.rst @@ -6,7 +6,7 @@ fix pair command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID pair N pstyle name flag ... diff --git a/doc/src/fix_phonon.rst b/doc/src/fix_phonon.rst index 527498bb21..e99d2b6891 100644 --- a/doc/src/fix_phonon.rst +++ b/doc/src/fix_phonon.rst @@ -6,7 +6,7 @@ fix phonon command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID phonon N Noutput Nwait map_file prefix keyword values ... diff --git a/doc/src/fix_pimd.rst b/doc/src/fix_pimd.rst index c08a4005f5..5b51b97c52 100644 --- a/doc/src/fix_pimd.rst +++ b/doc/src/fix_pimd.rst @@ -10,7 +10,7 @@ fix pimd/nvt command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style keyword value ... diff --git a/doc/src/fix_planeforce.rst b/doc/src/fix_planeforce.rst index d0f1b8102e..f4032cf829 100644 --- a/doc/src/fix_planeforce.rst +++ b/doc/src/fix_planeforce.rst @@ -6,7 +6,7 @@ fix planeforce command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID planeforce x y z diff --git a/doc/src/fix_plumed.rst b/doc/src/fix_plumed.rst index c562ecc81d..ca56f83958 100644 --- a/doc/src/fix_plumed.rst +++ b/doc/src/fix_plumed.rst @@ -6,7 +6,7 @@ fix plumed command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID plumed keyword value ... diff --git a/doc/src/fix_poems.rst b/doc/src/fix_poems.rst index 7ecb4eef7d..a43e552fbb 100644 --- a/doc/src/fix_poems.rst +++ b/doc/src/fix_poems.rst @@ -6,7 +6,7 @@ fix poems command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID poems keyword values diff --git a/doc/src/fix_polarize.rst b/doc/src/fix_polarize.rst index dd8a0c7d75..93ef1e4276 100644 --- a/doc/src/fix_polarize.rst +++ b/doc/src/fix_polarize.rst @@ -14,7 +14,7 @@ fix polarize/functional command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style nevery tolerance @@ -130,10 +130,23 @@ Fix *polarize/functional* employs the energy functional variation approach as described in :ref:`(Jadhao) ` to solve :math:`\sigma_b`. +The induced charges computed by these fixes are stored in the *q_scaled* field, +and can be accessed as in the following example: + +.. code-block:: LAMMPS + + compute qs all property/atom q_scaled + dump 1 all custom 1000 all.txt id type q x y z c_qs + +Note that the *q* field is the regular atom charges, which do not change +during the simulation. For interface particles, *q_scaled* is the sum +of the real charge, divided by the local dielectric constant *epsilon*, +and their induced charges. For non-interface particles, *q_scaled* is +the real charge, divided by the local dielectric constant *epsilon*. + More details on the implementation of these fixes and their recommended use are described in :ref:`(NguyenTD) `. - Restart, fix_modify, output, run start/stop, minimize info """""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/doc/src/fix_pour.rst b/doc/src/fix_pour.rst index 6ef18ea800..eca1f70c41 100644 --- a/doc/src/fix_pour.rst +++ b/doc/src/fix_pour.rst @@ -6,7 +6,7 @@ fix pour command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID pour N type seed keyword values ... @@ -123,15 +123,17 @@ command which also appears in your input script. .. note:: - If you wish the new rigid molecules (and other rigid molecules) - to be thermostatted correctly via :doc:`fix rigid/small/nvt ` - or :doc:`fix rigid/small/npt `, then you need to use the - "fix_modify dynamic/dof yes" command for the rigid fix. This is to - inform that fix that the molecule count will vary dynamically. + If you wish the new rigid molecules (and other rigid molecules) to be + thermostatted correctly via :doc:`fix rigid/small/nvt ` or + :doc:`fix rigid/small/npt `, then you need to use the + :doc:`fix_modify dynamic/dof yes ` command for the rigid + fix. This is to inform that fix that the molecule count will vary + dynamically. If you wish to insert molecules via the *mol* keyword, that will have their bonds or angles constrained via SHAKE, use the *shake* keyword, -specifying as its value the ID of a separate :doc:`fix shake ` command which also appears in your input script. +specifying as its value the ID of a separate :doc:`fix shake +` command which also appears in your input script. Each timestep particles are inserted, they are placed randomly inside the insertion volume so as to mimic a stream of poured particles. If @@ -148,10 +150,10 @@ many timesteps until the desired # of particles has been inserted. .. note:: - If you are monitoring the temperature of a system where the - particle count is changing due to adding particles, you typically - should use the :doc:`compute_modify dynamic yes ` - command for the temperature compute you are using. + If you are monitoring the temperature of a system where the particle + count is changing due to adding particles, you typically should use + the :doc:`compute_modify dynamic/dof yes ` command + for the temperature compute you are using. ---------- diff --git a/doc/src/fix_press_berendsen.rst b/doc/src/fix_press_berendsen.rst index dee93c5b8b..09ec44e673 100644 --- a/doc/src/fix_press_berendsen.rst +++ b/doc/src/fix_press_berendsen.rst @@ -6,7 +6,7 @@ fix press/berendsen command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID press/berendsen keyword value ... diff --git a/doc/src/fix_print.rst b/doc/src/fix_print.rst index 05abbe3c98..1ec643a635 100644 --- a/doc/src/fix_print.rst +++ b/doc/src/fix_print.rst @@ -6,7 +6,7 @@ fix print command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID print N string keyword value ... diff --git a/doc/src/fix_propel_self.rst b/doc/src/fix_propel_self.rst index 863d43b6f2..0b932c7316 100644 --- a/doc/src/fix_propel_self.rst +++ b/doc/src/fix_propel_self.rst @@ -6,7 +6,7 @@ fix propel/self command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID propel/self mode magnitude keyword values diff --git a/doc/src/fix_property_atom.rst b/doc/src/fix_property_atom.rst index d09c15d192..b177fe9a96 100644 --- a/doc/src/fix_property_atom.rst +++ b/doc/src/fix_property_atom.rst @@ -9,7 +9,7 @@ Accelerator Variants: *property/atom/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID property/atom name1 name2 ... keyword value ... diff --git a/doc/src/fix_python_invoke.rst b/doc/src/fix_python_invoke.rst index c82fb91a27..ad55882270 100644 --- a/doc/src/fix_python_invoke.rst +++ b/doc/src/fix_python_invoke.rst @@ -6,7 +6,7 @@ fix python/invoke command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID python/invoke N callback function_name diff --git a/doc/src/fix_python_move.rst b/doc/src/fix_python_move.rst index b338dcbfac..63898f3aa1 100644 --- a/doc/src/fix_python_move.rst +++ b/doc/src/fix_python_move.rst @@ -6,7 +6,7 @@ fix python/move command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix python/move pymodule.CLASS diff --git a/doc/src/fix_qbmsst.rst b/doc/src/fix_qbmsst.rst index 5428eeb637..3234335b6b 100644 --- a/doc/src/fix_qbmsst.rst +++ b/doc/src/fix_qbmsst.rst @@ -6,7 +6,7 @@ fix qbmsst command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID qbmsst dir shockvel keyword value ... diff --git a/doc/src/fix_qeq.rst b/doc/src/fix_qeq.rst index 73cf013fb9..bace7af0ca 100644 --- a/doc/src/fix_qeq.rst +++ b/doc/src/fix_qeq.rst @@ -22,7 +22,7 @@ fix qeq/fire command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style Nevery cutoff tolerance maxiter qfile keyword ... diff --git a/doc/src/fix_qeq_comb.rst b/doc/src/fix_qeq_comb.rst index 0c04a8c4a7..f93a650c17 100644 --- a/doc/src/fix_qeq_comb.rst +++ b/doc/src/fix_qeq_comb.rst @@ -9,7 +9,7 @@ Accelerator Variants: *qeq/comb/omp* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID qeq/comb Nevery precision keyword value ... diff --git a/doc/src/fix_qeq_reaxff.rst b/doc/src/fix_qeq_reaxff.rst index 00cfb6d3ce..e90842ea6a 100644 --- a/doc/src/fix_qeq_reaxff.rst +++ b/doc/src/fix_qeq_reaxff.rst @@ -10,7 +10,7 @@ Accelerator Variants: *qeq/reaxff/kk*, *qeq/reaxff/omp* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID qeq/reaxff Nevery cutlo cuthi tolerance params args diff --git a/doc/src/fix_qmmm.rst b/doc/src/fix_qmmm.rst index 546635520c..eabbdbba03 100644 --- a/doc/src/fix_qmmm.rst +++ b/doc/src/fix_qmmm.rst @@ -6,7 +6,7 @@ fix qmmm command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID qmmm diff --git a/doc/src/fix_qtb.rst b/doc/src/fix_qtb.rst index c41a58a8f4..2112a0f14b 100644 --- a/doc/src/fix_qtb.rst +++ b/doc/src/fix_qtb.rst @@ -6,7 +6,7 @@ fix qtb command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID qtb keyword value ... diff --git a/doc/src/fix_reaxff_bonds.rst b/doc/src/fix_reaxff_bonds.rst index 15b2eb6da9..15fd9abafa 100644 --- a/doc/src/fix_reaxff_bonds.rst +++ b/doc/src/fix_reaxff_bonds.rst @@ -9,7 +9,7 @@ Accelerator Variants: *reaxff/bonds/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID reaxff/bonds Nevery filename diff --git a/doc/src/fix_reaxff_species.rst b/doc/src/fix_reaxff_species.rst index 6a171ede5e..9bf1a82933 100644 --- a/doc/src/fix_reaxff_species.rst +++ b/doc/src/fix_reaxff_species.rst @@ -9,7 +9,7 @@ Accelerator Variants: *reaxff/species/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID reaxff/species Nevery Nrepeat Nfreq filename keyword value ... diff --git a/doc/src/fix_recenter.rst b/doc/src/fix_recenter.rst index 520564677a..9991904b37 100644 --- a/doc/src/fix_recenter.rst +++ b/doc/src/fix_recenter.rst @@ -6,7 +6,7 @@ fix recenter command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID recenter x y z keyword value ... diff --git a/doc/src/fix_rhok.rst b/doc/src/fix_rhok.rst index 9d6114328f..7ac40e1bed 100644 --- a/doc/src/fix_rhok.rst +++ b/doc/src/fix_rhok.rst @@ -6,7 +6,7 @@ fix rhok command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID rhok nx ny nz K a diff --git a/doc/src/fix_rigid.rst b/doc/src/fix_rigid.rst index 884d883f5a..89759da817 100644 --- a/doc/src/fix_rigid.rst +++ b/doc/src/fix_rigid.rst @@ -60,7 +60,7 @@ fix rigid/nph/small command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style bodystyle args keyword values ... @@ -610,10 +610,12 @@ such attributes: the total mass of the rigid body, its center-of-mass position, its 6 moments of inertia, its center-of-mass velocity, and the 3 image flags of the center-of-mass position. For rigid bodies consisting of point particles or non-overlapping finite-size -particles, LAMMPS can compute these values accurately. However, for -rigid bodies consisting of finite-size particles which overlap each -other, LAMMPS will ignore the overlaps when computing these 4 -attributes. The amount of error this induces depends on the amount of +particles, LAMMPS can compute these values accurately. + +However, for rigid bodies consisting of finite-size particles which +overlap each other, LAMMPS will ignore the overlaps when computing +these 4 attributes, which means the dynamics of the bodies will be +incorrect. The amount of error this induces depends on the amount of overlap. To avoid this issue, the values can be pre-computed (e.g. using Monte Carlo integration). @@ -677,6 +679,28 @@ cross periodic boundaries during the simulation. auxiliary file will contain one line for every rigid body, even if the original file only listed a subset of the rigid bodies. +If the system has rigid bodies with finite-size overlapping particles +and the model uses the :doc:`fix gravity ` command to +apply a gravitational force to the rigid bodies, then the *gravity* +keyword should be used in the following manner. + +First, the group specified for the :doc:`fix gravity ` +command should not include any atoms in rigid bodies which have +overlapping particles. It can be empty (see the :doc:`group empty +` command) or only contain single particles not in rigid +bodies, e.g. background particles. + +Second, the *infile* keyword should be used to specify the total mass +and other properties of the rigid bodies with overlaps, so that their +dynamics will be modeled correctly, as explained above. + +Third, the *gravity* keyword should be used the with the ID of the +:doc:`fix gravity ` command as its argument. The rigid +fixes will access the gravity fix to extract the current direction of +the gravity vector at each timestep (which can be static or dynamic). +A gravity force will then be applied to each rigid body at its +center-of-mass position using its total mass. + ---------- If you use a :doc:`temperature compute ` with a group that diff --git a/doc/src/fix_rigid_meso.rst b/doc/src/fix_rigid_meso.rst index 1c70092092..c8c994fd26 100644 --- a/doc/src/fix_rigid_meso.rst +++ b/doc/src/fix_rigid_meso.rst @@ -6,7 +6,7 @@ fix rigid/meso command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID rigid/meso bodystyle args keyword values ... diff --git a/doc/src/fix_rx.rst b/doc/src/fix_rx.rst index 4028a4e7e1..631b227449 100644 --- a/doc/src/fix_rx.rst +++ b/doc/src/fix_rx.rst @@ -9,7 +9,7 @@ Accelerator Variants: *rx/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID rx file localTemp matrix solver minSteps ... diff --git a/doc/src/fix_saed_vtk.rst b/doc/src/fix_saed_vtk.rst index cd3cad7c72..e0cf251780 100644 --- a/doc/src/fix_saed_vtk.rst +++ b/doc/src/fix_saed_vtk.rst @@ -6,7 +6,7 @@ fix saed/vtk command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID saed/vtk Nevery Nrepeat Nfreak c_ID attribute args ... keyword args ... diff --git a/doc/src/fix_setforce.rst b/doc/src/fix_setforce.rst index e115c52991..e194ad4c11 100644 --- a/doc/src/fix_setforce.rst +++ b/doc/src/fix_setforce.rst @@ -13,7 +13,7 @@ fix setforce/spin command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID setforce fx fy fz keyword value ... diff --git a/doc/src/fix_sgcmc.rst b/doc/src/fix_sgcmc.rst index fd6f8beab4..63cfaf22da 100644 --- a/doc/src/fix_sgcmc.rst +++ b/doc/src/fix_sgcmc.rst @@ -6,7 +6,7 @@ fix sgcmc command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID sgcmc every_nsteps swap_fraction temperature deltamu ... diff --git a/doc/src/fix_shake.rst b/doc/src/fix_shake.rst index 2483b9431a..73caa9c668 100644 --- a/doc/src/fix_shake.rst +++ b/doc/src/fix_shake.rst @@ -13,7 +13,7 @@ fix rattle command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style tol iter N constraint values ... keyword value ... diff --git a/doc/src/fix_shardlow.rst b/doc/src/fix_shardlow.rst index 468985be1b..bc2684af53 100644 --- a/doc/src/fix_shardlow.rst +++ b/doc/src/fix_shardlow.rst @@ -9,7 +9,7 @@ Accelerator Variants: *shardlow/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID shardlow diff --git a/doc/src/fix_smd.rst b/doc/src/fix_smd.rst index 4c682e66c0..14892227fd 100644 --- a/doc/src/fix_smd.rst +++ b/doc/src/fix_smd.rst @@ -6,7 +6,7 @@ fix smd command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID smd type values keyword values diff --git a/doc/src/fix_smd_setvel.rst b/doc/src/fix_smd_setvel.rst index 9dcc3c636c..31b92491ab 100644 --- a/doc/src/fix_smd_setvel.rst +++ b/doc/src/fix_smd_setvel.rst @@ -6,7 +6,7 @@ fix smd/setvel command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID smd/setvel vx vy vz keyword value ... diff --git a/doc/src/fix_sph.rst b/doc/src/fix_sph.rst index 1133142f05..4932485b03 100644 --- a/doc/src/fix_sph.rst +++ b/doc/src/fix_sph.rst @@ -6,7 +6,7 @@ fix sph command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID sph diff --git a/doc/src/fix_sph_stationary.rst b/doc/src/fix_sph_stationary.rst index 4496a10eca..07bedad4c3 100644 --- a/doc/src/fix_sph_stationary.rst +++ b/doc/src/fix_sph_stationary.rst @@ -6,7 +6,7 @@ fix sph/stationary command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID sph/stationary diff --git a/doc/src/fix_spring.rst b/doc/src/fix_spring.rst index 007f2cd278..b85fe26813 100644 --- a/doc/src/fix_spring.rst +++ b/doc/src/fix_spring.rst @@ -6,7 +6,7 @@ fix spring command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID spring keyword values diff --git a/doc/src/fix_spring_chunk.rst b/doc/src/fix_spring_chunk.rst index 3d3069c53e..63a225e878 100644 --- a/doc/src/fix_spring_chunk.rst +++ b/doc/src/fix_spring_chunk.rst @@ -6,7 +6,7 @@ fix spring/chunk command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID spring/chunk K chunkID comID diff --git a/doc/src/fix_spring_rg.rst b/doc/src/fix_spring_rg.rst index aba35c8134..e615771d2a 100644 --- a/doc/src/fix_spring_rg.rst +++ b/doc/src/fix_spring_rg.rst @@ -6,7 +6,7 @@ fix spring/rg command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID spring/rg K RG0 diff --git a/doc/src/fix_spring_self.rst b/doc/src/fix_spring_self.rst index 6cf0a9e0e7..3383f27ebb 100644 --- a/doc/src/fix_spring_self.rst +++ b/doc/src/fix_spring_self.rst @@ -6,7 +6,7 @@ fix spring/self command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID spring/self K dir diff --git a/doc/src/fix_srd.rst b/doc/src/fix_srd.rst index 04eaeed251..1fc574a7ad 100644 --- a/doc/src/fix_srd.rst +++ b/doc/src/fix_srd.rst @@ -6,7 +6,7 @@ fix srd command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID srd N groupbig-ID Tsrd hgrid seed keyword value ... diff --git a/doc/src/fix_store_force.rst b/doc/src/fix_store_force.rst index f6bed4d4af..487d4f0352 100644 --- a/doc/src/fix_store_force.rst +++ b/doc/src/fix_store_force.rst @@ -6,7 +6,7 @@ fix store/force command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID store/force diff --git a/doc/src/fix_store_state.rst b/doc/src/fix_store_state.rst index b47b6900aa..4a0bef2f74 100644 --- a/doc/src/fix_store_state.rst +++ b/doc/src/fix_store_state.rst @@ -6,7 +6,7 @@ fix store/state command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID store/state N input1 input2 ... keyword value ... diff --git a/doc/src/fix_temp_berendsen.rst b/doc/src/fix_temp_berendsen.rst index 473c30aced..67e496e6c5 100644 --- a/doc/src/fix_temp_berendsen.rst +++ b/doc/src/fix_temp_berendsen.rst @@ -6,7 +6,7 @@ fix temp/berendsen command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID temp/berendsen Tstart Tstop Tdamp diff --git a/doc/src/fix_temp_csvr.rst b/doc/src/fix_temp_csvr.rst index 5fc6e8eae7..781ce97d96 100644 --- a/doc/src/fix_temp_csvr.rst +++ b/doc/src/fix_temp_csvr.rst @@ -10,7 +10,7 @@ fix temp/csld command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID temp/csvr Tstart Tstop Tdamp seed fix ID group-ID temp/csld Tstart Tstop Tdamp seed diff --git a/doc/src/fix_temp_rescale.rst b/doc/src/fix_temp_rescale.rst index 41ad8709cc..bfdcaa90f8 100644 --- a/doc/src/fix_temp_rescale.rst +++ b/doc/src/fix_temp_rescale.rst @@ -6,7 +6,7 @@ fix temp/rescale command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID temp/rescale N Tstart Tstop window fraction diff --git a/doc/src/fix_temp_rescale_eff.rst b/doc/src/fix_temp_rescale_eff.rst index ea3996e9b6..b92feccfed 100644 --- a/doc/src/fix_temp_rescale_eff.rst +++ b/doc/src/fix_temp_rescale_eff.rst @@ -6,7 +6,7 @@ fix temp/rescale/eff command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID temp/rescale/eff N Tstart Tstop window fraction diff --git a/doc/src/fix_tfmc.rst b/doc/src/fix_tfmc.rst index 7eb4d24935..f3379c1e2f 100644 --- a/doc/src/fix_tfmc.rst +++ b/doc/src/fix_tfmc.rst @@ -6,7 +6,7 @@ fix tfmc command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID tfmc Delta Temp seed keyword value diff --git a/doc/src/fix_tgnh_drude.rst b/doc/src/fix_tgnh_drude.rst index d1f5cf19a4..0a67af291f 100644 --- a/doc/src/fix_tgnh_drude.rst +++ b/doc/src/fix_tgnh_drude.rst @@ -11,7 +11,7 @@ fix tgnpt/drude command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style_name keyword values ... diff --git a/doc/src/fix_thermal_conductivity.rst b/doc/src/fix_thermal_conductivity.rst index 0652810267..041fde8be5 100644 --- a/doc/src/fix_thermal_conductivity.rst +++ b/doc/src/fix_thermal_conductivity.rst @@ -6,7 +6,7 @@ fix thermal/conductivity command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID thermal/conductivity N edim Nbin keyword value ... diff --git a/doc/src/fix_ti_spring.rst b/doc/src/fix_ti_spring.rst index d519f36157..6273164d52 100644 --- a/doc/src/fix_ti_spring.rst +++ b/doc/src/fix_ti_spring.rst @@ -6,7 +6,7 @@ fix ti/spring command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID ti/spring k t_s t_eq keyword value ... diff --git a/doc/src/fix_tmd.rst b/doc/src/fix_tmd.rst index ccebb35823..3ee7f2a5c8 100644 --- a/doc/src/fix_tmd.rst +++ b/doc/src/fix_tmd.rst @@ -6,7 +6,7 @@ fix tmd command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID tmd rho_final file1 N file2 diff --git a/doc/src/fix_ttm.rst b/doc/src/fix_ttm.rst index 413c5f5c3c..ccf7f16554 100644 --- a/doc/src/fix_ttm.rst +++ b/doc/src/fix_ttm.rst @@ -14,7 +14,7 @@ fix ttm/mod command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID ttm seed C_e rho_e kappa_e gamma_p gamma_s v_0 Nx Ny Nz keyword value ... fix ID group-ID ttm/mod seed init_file Nx Ny Nz keyword value ... diff --git a/doc/src/fix_tune_kspace.rst b/doc/src/fix_tune_kspace.rst index 6a3cba16e4..17e0710be8 100644 --- a/doc/src/fix_tune_kspace.rst +++ b/doc/src/fix_tune_kspace.rst @@ -6,7 +6,7 @@ fix tune/kspace command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID tune/kspace N diff --git a/doc/src/fix_vector.rst b/doc/src/fix_vector.rst index f4eee41269..95ec350e12 100644 --- a/doc/src/fix_vector.rst +++ b/doc/src/fix_vector.rst @@ -6,7 +6,7 @@ fix vector command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID vector Nevery value1 value2 ... diff --git a/doc/src/fix_viscosity.rst b/doc/src/fix_viscosity.rst index c99196e09b..187d723d68 100644 --- a/doc/src/fix_viscosity.rst +++ b/doc/src/fix_viscosity.rst @@ -6,7 +6,7 @@ fix viscosity command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID viscosity N vdim pdim Nbin keyword value ... diff --git a/doc/src/fix_viscous.rst b/doc/src/fix_viscous.rst index d5fd794020..68d2568529 100644 --- a/doc/src/fix_viscous.rst +++ b/doc/src/fix_viscous.rst @@ -9,7 +9,7 @@ Accelerator Variants: *viscous/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID viscous gamma keyword values ... diff --git a/doc/src/fix_viscous_sphere.rst b/doc/src/fix_viscous_sphere.rst index 13463c8c11..678cb9904f 100644 --- a/doc/src/fix_viscous_sphere.rst +++ b/doc/src/fix_viscous_sphere.rst @@ -6,7 +6,7 @@ fix viscous/sphere command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID viscous/sphere gamma keyword values ... diff --git a/doc/src/fix_wall.rst b/doc/src/fix_wall.rst index 42cd94978d..eb8219e157 100644 --- a/doc/src/fix_wall.rst +++ b/doc/src/fix_wall.rst @@ -37,7 +37,7 @@ fix wall/table command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style [tabstyle] [N] face args ... keyword value ... diff --git a/doc/src/fix_wall_body_polygon.rst b/doc/src/fix_wall_body_polygon.rst index ac0a58f55c..504ded6aaf 100644 --- a/doc/src/fix_wall_body_polygon.rst +++ b/doc/src/fix_wall_body_polygon.rst @@ -6,7 +6,7 @@ fix wall/body/polygon command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID wall/body/polygon k_n c_n c_t wallstyle args keyword values ... diff --git a/doc/src/fix_wall_body_polyhedron.rst b/doc/src/fix_wall_body_polyhedron.rst index 9930c10f74..86bd35ae02 100644 --- a/doc/src/fix_wall_body_polyhedron.rst +++ b/doc/src/fix_wall_body_polyhedron.rst @@ -6,7 +6,7 @@ fix wall/body/polyhedron command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID wall/body/polyhedron k_n c_n c_t wallstyle args keyword values ... diff --git a/doc/src/fix_wall_ees.rst b/doc/src/fix_wall_ees.rst index 9c7f82e015..7bcfc830e2 100644 --- a/doc/src/fix_wall_ees.rst +++ b/doc/src/fix_wall_ees.rst @@ -10,7 +10,7 @@ fix wall/region/ees command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID style args diff --git a/doc/src/fix_wall_gran.rst b/doc/src/fix_wall_gran.rst index 27d19d60b5..f6465d1159 100644 --- a/doc/src/fix_wall_gran.rst +++ b/doc/src/fix_wall_gran.rst @@ -9,7 +9,7 @@ Accelerator Variants: *wall/gran/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID wall/gran fstyle fstyle_params wallstyle args keyword values ... diff --git a/doc/src/fix_wall_gran_region.rst b/doc/src/fix_wall_gran_region.rst index 94edebbcf1..0a4343493b 100644 --- a/doc/src/fix_wall_gran_region.rst +++ b/doc/src/fix_wall_gran_region.rst @@ -6,7 +6,7 @@ fix wall/gran/region command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID wall/gran/region fstyle fstyle_params wallstyle regionID keyword values ... diff --git a/doc/src/fix_wall_piston.rst b/doc/src/fix_wall_piston.rst index 1237d1ac7c..d60d8cb731 100644 --- a/doc/src/fix_wall_piston.rst +++ b/doc/src/fix_wall_piston.rst @@ -6,7 +6,7 @@ fix wall/piston command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID wall/piston face ... keyword value ... diff --git a/doc/src/fix_wall_reflect.rst b/doc/src/fix_wall_reflect.rst index 8bb895280c..c2f4c3a6ab 100644 --- a/doc/src/fix_wall_reflect.rst +++ b/doc/src/fix_wall_reflect.rst @@ -9,7 +9,7 @@ Accelerator Variants: *wall/reflect/kk* Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID wall/reflect face arg ... keyword value ... diff --git a/doc/src/fix_wall_reflect_stochastic.rst b/doc/src/fix_wall_reflect_stochastic.rst index 64e3d759c1..5a93950a5d 100644 --- a/doc/src/fix_wall_reflect_stochastic.rst +++ b/doc/src/fix_wall_reflect_stochastic.rst @@ -6,7 +6,7 @@ fix wall/reflect/stochastic command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID wall/reflect/stochastic rstyle seed face args ... keyword value ... diff --git a/doc/src/fix_wall_region.rst b/doc/src/fix_wall_region.rst index adfd8402c6..466319c12e 100644 --- a/doc/src/fix_wall_region.rst +++ b/doc/src/fix_wall_region.rst @@ -6,7 +6,7 @@ fix wall/region command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID wall/region region-ID style args ... cutoff diff --git a/doc/src/fix_wall_srd.rst b/doc/src/fix_wall_srd.rst index a8cbdd1619..dfb6560ffd 100644 --- a/doc/src/fix_wall_srd.rst +++ b/doc/src/fix_wall_srd.rst @@ -6,7 +6,7 @@ fix wall/srd command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID wall/srd face arg ... keyword value ... diff --git a/doc/src/fix_widom.rst b/doc/src/fix_widom.rst index 5be93100b3..ff66095db5 100644 --- a/doc/src/fix_widom.rst +++ b/doc/src/fix_widom.rst @@ -6,7 +6,7 @@ fix widom command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS fix ID group-ID widom N M type seed T keyword values ... diff --git a/doc/src/group2ndx.rst b/doc/src/group2ndx.rst index e465c4629f..077f88e3e8 100644 --- a/doc/src/group2ndx.rst +++ b/doc/src/group2ndx.rst @@ -10,13 +10,13 @@ ndx2group command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS - group2ndx file group-ID ... - ndx2group file group-ID ... + group2ndx file args + ndx2group file args * file = name of index file to write out or read in -* zero or more group IDs may be appended +* args = zero or more group IDs may be appended Examples """""""" diff --git a/doc/src/hyper.rst b/doc/src/hyper.rst index 9266a95523..c707c6b3fc 100644 --- a/doc/src/hyper.rst +++ b/doc/src/hyper.rst @@ -6,7 +6,7 @@ hyper command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS hyper N Nevent fix-ID compute-ID keyword values ... diff --git a/doc/src/include.rst b/doc/src/include.rst index 6d146061db..5e19f4a377 100644 --- a/doc/src/include.rst +++ b/doc/src/include.rst @@ -6,7 +6,7 @@ include command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS include file diff --git a/doc/src/info.rst b/doc/src/info.rst index 853e5020fc..958542e3c8 100644 --- a/doc/src/info.rst +++ b/doc/src/info.rst @@ -6,7 +6,7 @@ info command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS info args diff --git a/doc/src/jump.rst b/doc/src/jump.rst index e8047222ef..bf56934d8f 100644 --- a/doc/src/jump.rst +++ b/doc/src/jump.rst @@ -6,7 +6,7 @@ jump command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS jump file label diff --git a/doc/src/label.rst b/doc/src/label.rst index 430587135f..bf232431d7 100644 --- a/doc/src/label.rst +++ b/doc/src/label.rst @@ -6,7 +6,7 @@ label command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS label ID diff --git a/doc/src/lattice.rst b/doc/src/lattice.rst index d4d69c7af0..7dc9c579e5 100644 --- a/doc/src/lattice.rst +++ b/doc/src/lattice.rst @@ -6,7 +6,7 @@ lattice command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS lattice style scale keyword values ... diff --git a/doc/src/log.rst b/doc/src/log.rst index 5d4036dc06..46784f6ea6 100644 --- a/doc/src/log.rst +++ b/doc/src/log.rst @@ -6,7 +6,7 @@ log command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS log file keyword diff --git a/doc/src/mass.rst b/doc/src/mass.rst index f359ccf3a5..88bd14950c 100644 --- a/doc/src/mass.rst +++ b/doc/src/mass.rst @@ -6,7 +6,7 @@ mass command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS mass I value diff --git a/doc/src/min_style.rst b/doc/src/min_style.rst index 2f43308610..b89ae6d398 100644 --- a/doc/src/min_style.rst +++ b/doc/src/min_style.rst @@ -27,7 +27,7 @@ min_style fire command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS min_style style diff --git a/doc/src/minimize.rst b/doc/src/minimize.rst index 6221d33aad..56efa12f44 100644 --- a/doc/src/minimize.rst +++ b/doc/src/minimize.rst @@ -1,15 +1,15 @@ .. index:: minimize +.. index:: minimize/kk minimize command ================ -minimize/kk command -=================== +Accelerator Variant: minimize/kk Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS minimize etol ftol maxiter maxeval diff --git a/doc/src/molecule.rst b/doc/src/molecule.rst index b42bece327..480e175e7b 100644 --- a/doc/src/molecule.rst +++ b/doc/src/molecule.rst @@ -6,7 +6,7 @@ molecule command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS molecule ID file1 keyword values ... file2 keyword values ... fileN ... diff --git a/doc/src/neb.rst b/doc/src/neb.rst index a959eee01b..0bc5de010b 100644 --- a/doc/src/neb.rst +++ b/doc/src/neb.rst @@ -6,7 +6,7 @@ neb command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS neb etol ftol N1 N2 Nevery file-style arg keyword values diff --git a/doc/src/neb_spin.rst b/doc/src/neb_spin.rst index 9f714096dc..1d42ff884c 100644 --- a/doc/src/neb_spin.rst +++ b/doc/src/neb_spin.rst @@ -6,7 +6,7 @@ neb/spin command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS neb/spin etol ttol N1 N2 Nevery file-style arg keyword diff --git a/doc/src/neighbor.rst b/doc/src/neighbor.rst index 9dcdd1daf2..12d6d91fde 100644 --- a/doc/src/neighbor.rst +++ b/doc/src/neighbor.rst @@ -6,7 +6,7 @@ neighbor command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS neighbor skin style diff --git a/doc/src/newton.rst b/doc/src/newton.rst index c1a015c3e6..f77c8c54c4 100644 --- a/doc/src/newton.rst +++ b/doc/src/newton.rst @@ -6,7 +6,7 @@ newton command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS newton flag newton flag1 flag2 diff --git a/doc/src/next.rst b/doc/src/next.rst index 46d39660eb..d86c15c5fb 100644 --- a/doc/src/next.rst +++ b/doc/src/next.rst @@ -6,7 +6,7 @@ next command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS next variables diff --git a/doc/src/package.rst b/doc/src/package.rst index 0f28598029..63a7f095ad 100644 --- a/doc/src/package.rst +++ b/doc/src/package.rst @@ -6,7 +6,7 @@ package command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS package style args diff --git a/doc/src/pair_granular.rst b/doc/src/pair_granular.rst index 37ff8fcbfe..bc469412d9 100644 --- a/doc/src/pair_granular.rst +++ b/doc/src/pair_granular.rst @@ -641,22 +641,36 @@ The optional *heat* keyword enables heat conduction. The options currently supported are: 1. *none* -2. *area* : :math:`k_{s}` +2. *radius* : :math:`k_{s}` +3. *area* : :math:`h_{s}` If the *heat* keyword is not specified, the model defaults to *none*. +For *heat* *radius*, the heat +:math:`Q` conducted between two particles is given by + +.. math:: + + Q = 2 k_{s} a \Delta T + +where :math:`\Delta T` is the difference in the two particles' temperature, +:math:`k_{s}` is a non-negative numeric value for the conductivity (in units +of power/(length*temperature)), and :math:`a` is the radius of the contact and +depends on the normal force model. This is the model proposed by +:ref:`Vargas and McCarthy `. + For *heat* *area*, the heat :math:`Q` conducted between two particles is given by .. math:: - Q = k_{s} A \Delta T - + Q = h_{s} A \Delta T where :math:`\Delta T` is the difference in the two particles' temperature, -:math:`k_{s}` is a non-negative numeric value for the conductivity, and -:math:`A` is the area of the contact and depends on the normal force model. +:math:`h_{s}` is a non-negative numeric value for the heat transfer +coefficient (in units of power/(area*temperature)), and :math:`A=\pi a^2` is +the area of the contact and depends on the normal force model. Note that the option *none* must either be used in all or none of of the *pair_coeff* calls. See :doc:`fix heat/flow ` and @@ -749,15 +763,17 @@ The single() function of these pair styles returns 0.0 for the energy of a pairwise interaction, since energy is not conserved in these dissipative potentials. It also returns only the normal component of the pairwise interaction force. However, the single() function also -calculates 12 extra pairwise quantities. The first 3 are the +calculates 13 extra pairwise quantities. The first 3 are the components of the tangential force between particles I and J, acting on particle I. The fourth is the magnitude of this tangential force. The next 3 (5-7) are the components of the rolling torque acting on particle I. The next entry (8) is the magnitude of the rolling torque. The next entry (9) is the magnitude of the twisting torque acting about the vector connecting the two particle centers. -The last 3 (10-12) are the components of the vector connecting -the centers of the two particles (x_I - x_J). +The next 3 (10-12) are the components of the vector connecting +the centers of the two particles (x_I - x_J). The last quantity (13) +is the heat flow between the two particles, set to 0 if no heat model +is active. These extra quantities can be accessed by the :doc:`compute pair/local ` command, as *p1*, *p2*, ..., *p12*\ . @@ -894,3 +910,10 @@ J. Appl. Mech., ASME 20, 327-344. **(Agnolin and Roux 2007)** Agnolin, I. & Roux, J-N. (2007). Internal states of model isotropic granular packings. I. Assembling process, geometry, and contact networks. Phys. Rev. E, 76, 061302. + +.. _VargasMcCarthy2001: + +**(Vargas and McCarthy 2001)** Vargas, W.L. and McCarthy, J.J. (2001). +Heat conduction in granular materials. +AIChE Journal, 47(5), 1052-1059. + diff --git a/doc/src/partition.rst b/doc/src/partition.rst index f05c3fa446..6b1866d8d8 100644 --- a/doc/src/partition.rst +++ b/doc/src/partition.rst @@ -6,7 +6,7 @@ partition command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS partition style N command ... diff --git a/doc/src/plugin.rst b/doc/src/plugin.rst index 41e2621fef..f8f668789d 100644 --- a/doc/src/plugin.rst +++ b/doc/src/plugin.rst @@ -6,7 +6,7 @@ plugin command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS plugin command args diff --git a/doc/src/prd.rst b/doc/src/prd.rst index 7c6af3abb5..fd20fa4a3b 100644 --- a/doc/src/prd.rst +++ b/doc/src/prd.rst @@ -6,7 +6,7 @@ prd command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS prd N t_event n_dephase t_dephase t_correlate compute-ID seed keyword value ... diff --git a/doc/src/print.rst b/doc/src/print.rst index a221ed04b6..f5ba16d8b5 100644 --- a/doc/src/print.rst +++ b/doc/src/print.rst @@ -6,7 +6,7 @@ print command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS print string keyword value diff --git a/doc/src/processors.rst b/doc/src/processors.rst index 676f339725..921bbcc667 100644 --- a/doc/src/processors.rst +++ b/doc/src/processors.rst @@ -6,7 +6,7 @@ processors command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS processors Px Py Pz keyword args ... diff --git a/doc/src/python.rst b/doc/src/python.rst index b05de7094d..99f32e7c80 100644 --- a/doc/src/python.rst +++ b/doc/src/python.rst @@ -6,7 +6,7 @@ python command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS python mode keyword args ... diff --git a/doc/src/quit.rst b/doc/src/quit.rst index ba6b4037be..2355fb238b 100644 --- a/doc/src/quit.rst +++ b/doc/src/quit.rst @@ -6,7 +6,7 @@ quit command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS quit status diff --git a/doc/src/region.rst b/doc/src/region.rst index 4589e6deb1..36c7c799dc 100644 --- a/doc/src/region.rst +++ b/doc/src/region.rst @@ -6,7 +6,7 @@ region command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS region ID style args keyword arg ... diff --git a/doc/src/replicate.rst b/doc/src/replicate.rst index ed4e844c35..6bfbeab891 100644 --- a/doc/src/replicate.rst +++ b/doc/src/replicate.rst @@ -6,7 +6,7 @@ replicate command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS replicate nx ny nz *keyword* diff --git a/doc/src/rerun.rst b/doc/src/rerun.rst index cfed2e2872..1c1b4fb570 100644 --- a/doc/src/rerun.rst +++ b/doc/src/rerun.rst @@ -6,7 +6,7 @@ rerun command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS rerun file1 file2 ... keyword args ... diff --git a/doc/src/restart.rst b/doc/src/restart.rst index 5de2d3d75c..10394de80e 100644 --- a/doc/src/restart.rst +++ b/doc/src/restart.rst @@ -6,7 +6,7 @@ restart command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS restart 0 restart N root keyword value ... diff --git a/doc/src/run.rst b/doc/src/run.rst index 8bcf469052..c3dd171f6b 100644 --- a/doc/src/run.rst +++ b/doc/src/run.rst @@ -6,7 +6,7 @@ run command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS run N keyword values ... diff --git a/doc/src/set.rst b/doc/src/set.rst index 2ba1057ef5..8a6510f88f 100644 --- a/doc/src/set.rst +++ b/doc/src/set.rst @@ -6,7 +6,7 @@ set command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS set style ID keyword values ... diff --git a/doc/src/shell.rst b/doc/src/shell.rst index fb9baffe08..378ebdc479 100644 --- a/doc/src/shell.rst +++ b/doc/src/shell.rst @@ -6,7 +6,7 @@ shell command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS shell command args diff --git a/doc/src/suffix.rst b/doc/src/suffix.rst index 4789229800..6c723657a5 100644 --- a/doc/src/suffix.rst +++ b/doc/src/suffix.rst @@ -6,7 +6,7 @@ suffix command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS suffix style args diff --git a/doc/src/tad.rst b/doc/src/tad.rst index cc6d52d415..b35bc3dfbb 100644 --- a/doc/src/tad.rst +++ b/doc/src/tad.rst @@ -6,7 +6,7 @@ tad command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS tad N t_event T_lo T_hi delta tmax compute-ID keyword value ... diff --git a/doc/src/temper.rst b/doc/src/temper.rst index 363e0102fc..d8bbcb959b 100644 --- a/doc/src/temper.rst +++ b/doc/src/temper.rst @@ -6,7 +6,7 @@ temper command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS temper N M temp fix-ID seed1 seed2 index diff --git a/doc/src/temper_grem.rst b/doc/src/temper_grem.rst index 312df21254..0963ea98c1 100644 --- a/doc/src/temper_grem.rst +++ b/doc/src/temper_grem.rst @@ -6,7 +6,7 @@ temper/grem command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS temper/grem N M lambda fix-ID thermostat-ID seed1 seed2 index diff --git a/doc/src/temper_npt.rst b/doc/src/temper_npt.rst index a8f5999dbe..0659ba2c03 100644 --- a/doc/src/temper_npt.rst +++ b/doc/src/temper_npt.rst @@ -6,7 +6,7 @@ temper/npt command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS temper/npt N M temp fix-ID seed1 seed2 pressure index diff --git a/doc/src/thermo.rst b/doc/src/thermo.rst index 5621b554c8..f918810cc2 100644 --- a/doc/src/thermo.rst +++ b/doc/src/thermo.rst @@ -6,7 +6,7 @@ thermo command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS thermo N diff --git a/doc/src/third_order.rst b/doc/src/third_order.rst index 2635c92f84..bbbf424c44 100644 --- a/doc/src/third_order.rst +++ b/doc/src/third_order.rst @@ -4,7 +4,7 @@ third_order command =================== -Accelerator Variants: third_order/kk +Accelerator Variant: third_order/kk Syntax """""" diff --git a/doc/src/timer.rst b/doc/src/timer.rst index a604cc2212..13d5a92473 100644 --- a/doc/src/timer.rst +++ b/doc/src/timer.rst @@ -6,7 +6,7 @@ timer command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS timer args diff --git a/doc/src/timestep.rst b/doc/src/timestep.rst index 3142509611..037b3f8642 100644 --- a/doc/src/timestep.rst +++ b/doc/src/timestep.rst @@ -6,7 +6,7 @@ timestep command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS timestep dt diff --git a/doc/src/uncompute.rst b/doc/src/uncompute.rst index 24b7c028d5..e65cbb2038 100644 --- a/doc/src/uncompute.rst +++ b/doc/src/uncompute.rst @@ -6,7 +6,7 @@ uncompute command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS uncompute compute-ID diff --git a/doc/src/undump.rst b/doc/src/undump.rst index 9320338854..89874457b0 100644 --- a/doc/src/undump.rst +++ b/doc/src/undump.rst @@ -6,7 +6,7 @@ undump command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS undump dump-ID diff --git a/doc/src/unfix.rst b/doc/src/unfix.rst index 419559a118..aeb640201d 100644 --- a/doc/src/unfix.rst +++ b/doc/src/unfix.rst @@ -6,7 +6,7 @@ unfix command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS unfix fix-ID diff --git a/doc/src/units.rst b/doc/src/units.rst index 2554806fb5..3f0904f162 100644 --- a/doc/src/units.rst +++ b/doc/src/units.rst @@ -6,7 +6,7 @@ units command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS units style diff --git a/doc/src/variable.rst b/doc/src/variable.rst index 67600af62d..28c0d29799 100644 --- a/doc/src/variable.rst +++ b/doc/src/variable.rst @@ -6,7 +6,7 @@ variable command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS variable name style args ... @@ -1441,7 +1441,7 @@ timestep that the variable needs the tallies. An input script can also request variables be evaluated before or after or in between runs, e.g. by including them in a :doc:`print ` command. -LAMMPS keeps track of all of this as it performs a doc:`run ` or +LAMMPS keeps track of all of this as it performs a :doc:`run ` or :doc:`minimize ` simulation, as well as in between simulations. An error will be generated if you attempt to evaluate a variable when LAMMPS knows it cannot produce accurate values. For @@ -1453,7 +1453,7 @@ command, then an error will occur. However, there are two special cases to be aware when a variable requires invocation of a compute (directly or indirectly). The first -is if the variable is evaluated before the first doc:`run ` or +is if the variable is evaluated before the first :doc:`run ` or :doc:`minimize ` command in the input script. In this case, LAMMPS will generate an error. This is because many computes require initializations which have not yet taken place. One example is the @@ -1463,10 +1463,10 @@ energy or virial quantities; these values are not tallied until the first simulation begins. The second special case is when a variable that depends on a compute -is evaluated in between doc:`run ` or :doc:`minimize ` +is evaluated in between :doc:`run ` or :doc:`minimize ` commands. It is possible for other input script commands issued following the previous run, but before the variable is evaluated, to -change the system. For example, the doc:`delete_atoms ` +change the system. For example, the :doc:`delete_atoms ` command could be used to remove atoms. Since the compute will not re-initialize itself until the next simulation or it may depend on energy/virial computations performed before the system was changed, it diff --git a/doc/src/velocity.rst b/doc/src/velocity.rst index ee1d546d79..48b0526df9 100644 --- a/doc/src/velocity.rst +++ b/doc/src/velocity.rst @@ -6,7 +6,7 @@ velocity command Syntax """""" -.. parsed-literal:: +.. code-block:: LAMMPS velocity group-ID style args keyword value ... diff --git a/doc/utils/requirements.txt b/doc/utils/requirements.txt index 3f7bc065d0..5b298c2975 100644 --- a/doc/utils/requirements.txt +++ b/doc/utils/requirements.txt @@ -1,8 +1,8 @@ -Sphinx >= 5.3.0, <7.1.0 +Sphinx >= 5.3.0, <7.2.0 sphinxcontrib-spelling sphinxcontrib-jquery git+https://github.com/akohlmey/sphinx-fortran@parallel-read -git+https://github.com/executablebooks/sphinx-tabs@v3.4.1 +sphinx-tabs>=3.4.1 breathe Pygments six diff --git a/doc/utils/sphinx-config/LAMMPSLexer.py b/doc/utils/sphinx-config/LAMMPSLexer.py index c8826a9ed6..a7ba5d92a8 100644 --- a/doc/utils/sphinx-config/LAMMPSLexer.py +++ b/doc/utils/sphinx-config/LAMMPSLexer.py @@ -2,14 +2,15 @@ from pygments.lexer import RegexLexer, words, include, default from pygments.token import * LAMMPS_COMMANDS = ("angle_coeff", "angle_style", "atom_modify", - "atom_style", "balance", "bond_coeff", "bond_style", - "bond_write", "boundary", "clear", "comm_modify", - "comm_style", "compute_modify", "create_atoms", - "create_bonds", "create_box", "delete_atoms", - "delete_bonds", "dielectric", "dihedral_coeff", - "dihedral_style", "dimension", "displace_atoms", - "dump_modify", "dynamical_matrix", "echo", "elif", - "else", "fix_modify", "group2ndx", "hyper", "if", + "atom_style", "angle_write", "balance", "bond_coeff", + "bond_style", "bond_write", "boundary", "clear", + "comm_modify", "comm_style", "compute_modify", + "create_atoms", "create_bonds", "create_box", + "delete_atoms", "delete_bonds", "dielectric", + "dihedral_coeff", "dihedral_style", "dihedral_write", + "dimension", "displace_atoms", "dump_modify", + "dynamical_matrix", "echo", "fitpod", + "fix_modify", "group2ndx", "hyper", "improper_coeff", "improper_style", "include", "info", "jump", "kim", "kspace_modify", "kspace_style", "label", "labelmap", "lattice", @@ -23,7 +24,7 @@ LAMMPS_COMMANDS = ("angle_coeff", "angle_style", "atom_modify", "read_restart", "replicate", "rerun", "reset_atoms", "reset_timestep", "restart", "run", "run_style", "server", "set", "shell", "special_bonds", "suffix", - "tad", "temper", "temper/grem", "temper/npt", "then", + "tad", "temper", "temper/grem", "temper/npt", "thermo", "thermo_modify", "thermo_style", "third_order", "timer", "timestep", "units", "velocity", "write_coeff", "write_data", @@ -45,16 +46,34 @@ class LAMMPSLexer(RegexLexer): tokens = { 'root': [ (r'fix\s+', Keyword, 'fix'), + (r'fix_modify\s+', Keyword, 'modify_cmd'), (r'compute\s+', Keyword, 'compute'), + (r'compute_modify\s+', Keyword, 'modify_cmd'), (r'dump\s+', Keyword, 'dump'), + (r'dump_modify\s+', Keyword, 'modify_cmd'), (r'region\s+', Keyword, 'region'), - (r'^\s*variable\s+', Keyword, 'variable_cmd'), + (r'variable\s+', Keyword, 'variable_cmd'), (r'group\s+', Keyword, 'group'), (r'change_box\s+', Keyword, 'change_box'), - (r'uncompute\s+', Keyword, 'uncompute'), - (r'unfix\s+', Keyword, 'unfix'), - (r'undump\s+', Keyword, 'undump'), + (r'create_box\s+', Keyword, 'create_box'), + (r'delete_bonds\s+', Keyword, 'id_cmd'), + (r'displace_atoms\s+', Keyword, 'id_cmd'), + (r'dynamical_matrix\s+', Keyword, 'id_cmd'), + (r'group2ndx\s+', Keyword, 'ndx_cmd'), + (r'ndx2group\s+', Keyword, 'ndx_cmd'), + (r'jump\s+', Keyword, 'jump_cmd'), + (r'label\s+', Keyword, 'jump_cmd'), + (r'next\s+', Keyword, 'id_cmd'), + (r'kim\s+', Keyword, 'kim_cmd'), + (r'uncompute\s+', Keyword, 'id_cmd'), + (r'unfix\s+', Keyword, 'id_cmd'), + (r'undump\s+', Keyword, 'id_cmd'), + (r'velocity\s+', Keyword, 'id_cmd'), + (r'write_coeff\s+', Keyword, 'ndx_cmd'), + (r'write_data\s+', Keyword, 'ndx_cmd'), (r'write_dump\s+', Keyword, 'write_dump'), + (r'write_restart\s+', Keyword, 'ndx_cmd'), + include('conditionals'), include('keywords'), (r'#.*?\n', Comment), ('"', String, 'string'), @@ -69,8 +88,12 @@ class LAMMPSLexer(RegexLexer): (r'[\+\-\*\^\|\/\!%&=<>]', Operator), (r'[\~\.\w_:,@\-\/\\0-9]+', Text), ], + 'conditionals' : [ + (words(('if','else','elif','then'), suffix=r'\b', prefix=r'\b'), Keyword) + ] + , 'keywords' : [ - (words(LAMMPS_COMMANDS, suffix=r'\b', prefix=r'^'), Keyword) + (words(LAMMPS_COMMANDS, suffix=r'\b', prefix=r'^\s*'), Keyword) ] , 'variable' : [ @@ -90,6 +113,10 @@ class LAMMPSLexer(RegexLexer): ('\(', Name.Variable, 'expression'), ('\)', Name.Variable, '#pop'), ], + 'modify_cmd' : [ + (r'[\w_\-\.\[\]]+', Name.Variable.Identifier), + default('#pop') + ], 'fix' : [ (r'[\w_\-\.\[\]]+', Name.Variable.Identifier), (r'\s+', Whitespace, 'group_id'), @@ -121,16 +148,25 @@ class LAMMPSLexer(RegexLexer): (r'[\w_\-\.\[\]]+', Name.Variable.Identifier), default('#pop') ], - 'unfix' : [ + 'create_box' : [ + (r'[\w_\-\.\[\]]+', Name.Variable.Identifier), + (r'\s+', Whitespace, 'group_id'), + default('#pop') + ], + 'id_cmd' : [ (r'[\w_\-\.\[\]]+', Name.Variable.Identifier), default('#pop') ], - 'undump' : [ + 'ndx_cmd' : [ (r'[\w_\-\.\[\]]+', Name.Variable.Identifier), default('#pop') ], - 'uncompute' : [ - (r'[\w_\-\.\[\]]+', Name.Variable.Identifier), + 'jump_cmd' : [ + (r'[\w_\-\.\[\]]+', Literal.String.Char), + default('#pop') + ], + 'kim_cmd' : [ + (r'[\w_\-\.\[\]]+', Literal.String.Single), default('#pop') ], 'write_dump' : [ diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index 5791288a06..b7edd05ea7 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -1528,6 +1528,7 @@ inhomogeneous init initialdelay initialisms +initializer initializations InitiatorIDs initio @@ -1559,6 +1560,7 @@ intramolecular ints inumeric inv +invariance invariants inversed invertible @@ -3487,6 +3489,7 @@ supercell superset supersphere Supinski +Sur Surblys surfactant surfactants @@ -3832,6 +3835,7 @@ vectorized Vegt vel Velázquez +Ventura venv Verlag verlet diff --git a/examples/ASPHERE/ellipsoid/in.ellipsoid b/examples/ASPHERE/ellipsoid/in.ellipsoid index 5e9a20f6e0..1ee59597da 100644 --- a/examples/ASPHERE/ellipsoid/in.ellipsoid +++ b/examples/ASPHERE/ellipsoid/in.ellipsoid @@ -1,23 +1,23 @@ # SRD diffusion demo - ellipsoids -units lj -atom_style ellipsoid -atom_modify first big -dimension 2 +units lj +atom_style ellipsoid +atom_modify first big +dimension 2 # create big ellipsoidal particles -lattice sq 0.14 -region box block 0 10 0 10 -0.5 0.5 -create_box 2 box -create_atoms 1 region box +lattice sq 0.14 +region box block 0 10 0 10 -0.5 0.5 +create_box 2 box +create_atoms 1 region box -set type 1 mass 1.0 -set type 1 shape 3.0 1.0 1.0 -group big type 1 -set group big quat/random 29898 +set type 1 mass 1.0 +set type 1 shape 3.0 1.0 1.0 +group big type 1 +set group big quat/random 29898 -velocity big create 1.44 87287 loop geom +velocity big create 1.44 87287 loop geom # equilibrate big particles @@ -26,57 +26,59 @@ 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 +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes -fix 1 big nve/asphere -fix 2 all enforce2d +fix 1 big nve/asphere +fix 2 all enforce2d -compute rot big temp/asphere +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 & -# quatw quati quatj quatk +#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 +thermo_style custom step temp c_rot epair etotal press +thermo 100 -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 120.0 -create_atoms 2 region plane +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 120.0 +create_atoms 2 region plane -set type 2 mass 0.01 -group small type 2 -velocity small create 1.0 593849 loop geom +set type 2 mass 0.01 +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 2.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 2.0 -neigh_modify one 10000 +neigh_modify one 10000 -delete_atoms overlap 1.6 small big +delete_atoms overlap 1.6 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 @@ -88,29 +90,30 @@ 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 +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 +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] +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 -thermo 1000 +thermo_modify temp tbig +thermo 1000 -#dump 1 all custom 1000 dump.ellipsoid id type x y z & -# quatw quati quatj quatk +#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 1 all image 1000 image.*.jpg type type zoom 1.6 -#dump_modify 1 pad 6 adiam 1 1 adiam 2 0.2 +#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 100000 diff --git a/examples/ASPHERE/ellipsoid/in.ellipsoid.mp b/examples/ASPHERE/ellipsoid/in.ellipsoid.mp index 7ce01ad4e1..31fe79eb58 100644 --- a/examples/ASPHERE/ellipsoid/in.ellipsoid.mp +++ b/examples/ASPHERE/ellipsoid/in.ellipsoid.mp @@ -1,23 +1,23 @@ # SRD viscosity demo - ellipsoids -units lj -atom_style ellipsoid -atom_modify first big -dimension 2 +units lj +atom_style ellipsoid +atom_modify first big +dimension 2 # create big ellipsoidal particles -lattice sq 0.14 -region box block 0 10 0 10 -0.5 0.5 -create_box 2 box -create_atoms 1 region box +lattice sq 0.14 +region box block 0 10 0 10 -0.5 0.5 +create_box 2 box +create_atoms 1 region box -set type 1 mass 1.0 -set type 1 shape 3.0 1.0 1.0 -group big type 1 -set group big quat/random 29898 +set type 1 mass 1.0 +set type 1 shape 3.0 1.0 1.0 +group big type 1 +set group big quat/random 29898 -velocity big create 1.44 87287 loop geom +velocity big create 1.44 87287 loop geom # equilibrate big particles @@ -26,57 +26,59 @@ 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 +neighbor 0.3 bin +neigh_modify delay 0 every 1 check yes -fix 1 big nve/asphere -fix 2 all enforce2d +fix 1 big nve/asphere +fix 2 all enforce2d -compute rot big temp/asphere +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 & -# quatw quati quatj quatk +#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 +thermo_style custom step temp c_rot epair etotal press +thermo 100 -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 120.0 -create_atoms 2 region plane +region plane block INF INF INF INF -0.001 0.001 units box +lattice sq 120.0 +create_atoms 2 region plane -set type 2 mass 0.01 -group small type 2 -velocity small create 1.0 593849 loop geom +set type 2 mass 0.01 +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 2.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 2.0 -neigh_modify one 10000 +neigh_modify one 10000 -delete_atoms overlap 1.6 small big +delete_atoms overlap 1.6 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 @@ -88,30 +90,31 @@ 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 +timestep 0.0005 -fix 1 big nve/asphere -fix 2 small srd 20 big 1.0 0.25 49894 shift yes 54979 & +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 +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] +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 -thermo 1000 +thermo_modify temp tbig +thermo 1000 -#dump 1 all custom 500 dump.ellipsoid.mp id type x y z & -# quatw quati quatj quatk +#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 +#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 50000 diff --git a/examples/COUPLE/plugin/liblammpsplugin.h b/examples/COUPLE/plugin/liblammpsplugin.h index 1520ef638d..271f6b9b20 100644 --- a/examples/COUPLE/plugin/liblammpsplugin.h +++ b/examples/COUPLE/plugin/liblammpsplugin.h @@ -239,7 +239,7 @@ struct _liblammpsplugin { void (*free)(void *); - void (*is_running)(void *); + int (*is_running)(void *); void (*force_timeout)(void *); int (*has_error)(void *); diff --git a/examples/COUPLE/simple/simple.f90 b/examples/COUPLE/simple/simple.f90 index 3aafbee01b..d9505fff4d 100644 --- a/examples/COUPLE/simple/simple.f90 +++ b/examples/COUPLE/simple/simple.f90 @@ -30,7 +30,7 @@ PROGRAM f_driver REAL (kind=8), ALLOCATABLE :: x(:) REAL (kind=8), PARAMETER :: epsilon=0.1 - CHARACTER (len=64) :: arg + CHARACTER (len=1024) :: arg CHARACTER (len=1024) :: line ! setup MPI and various communicators diff --git a/examples/PACKAGES/atc/cauchy_born/in.flying_cube b/examples/PACKAGES/atc/cauchy_born/in.flying_cube index 23bd7a5ae0..9b81fcf6a0 100644 --- a/examples/PACKAGES/atc/cauchy_born/in.flying_cube +++ b/examples/PACKAGES/atc/cauchy_born/in.flying_cube @@ -1,11 +1,11 @@ # This test evaluates Hardy fields for a small block of LJ material -# that's undergoing translation in the x-direction through the +# that's undergoing translation in the x-direction through the # periodic boundary. echo both -log log.flying_cube +log log.flying_cube units real atom_style atomic -variable lattice_constant equal 5.256227487 +variable lattice_constant equal 5.256227487 variable c equal 6 variable L equal (${lattice_constant}*$c) variable V equal $L*$L*$L @@ -23,15 +23,15 @@ create_box 1 box create_atoms 1 region box mass 1 $m group all region box -pair_style lj/cut 13.5 -pair_coeff 1 1 0.238 3.405 +pair_style lj/cut 13.5 +pair_coeff 1 1 0.238 3.405 # define region neighbor 1.0 bin neigh_modify delay 0 every 200 check no # neigh_modify delay 0 every $n reset_timestep 0 thermo $s -compute_modify thermo_temp extra 0 +compute_modify thermo_temp extra/dof 0 thermo_style custom step temp pxx pyy pzz etotal lx ly lz timestep ${dt} min_modify line quadratic @@ -46,10 +46,10 @@ variable zHI equal zhi # region BOX block ${xLO} ${xHI} ${yLO} ${yHI} ${zLO} ${zHI} units box region BOX block ${xLO} ${xHI} -0.5 31.7 -0.5 31.7 units box fix ATC all atc field -fix_modify ATC mesh create 1 1 1 box p p p +fix_modify ATC mesh create 1 1 1 box p p p fix_modify ATC fields add stress velocity displacement fix_modify ATC fields add temperature kinetic_temperature -fix_modify ATC fields add internal_energy energy +fix_modify ATC fields add internal_energy energy fix_modify ATC output flying_cubeFE $s text binary tensor_components # fix_modify ATC atomic_output flying_cubeMD $m text binary tensor_components dump dumpfc all atom $s flying_cube.dmp diff --git a/examples/PACKAGES/atc/cauchy_born/in.ftcb_constV b/examples/PACKAGES/atc/cauchy_born/in.ftcb_constV index 431fe15ddd..2b54a50739 100644 --- a/examples/PACKAGES/atc/cauchy_born/in.ftcb_constV +++ b/examples/PACKAGES/atc/cauchy_born/in.ftcb_constV @@ -1,34 +1,34 @@ # This test compares Hardy and Cauchy-Born metrics of energy density and stress # for an Ar system undergoing dynamics at a finite temperature. echo both -log ftcb_constV.log +log ftcb_constV.log units real atom_style atomic -variable lattice_constant equal 5.256227487 +variable lattice_constant equal 5.256227487 variable c equal 6 variable L equal (${lattice_constant}*$c) variable V equal $L*$L*$L print "Volume : $V" -variable Ti equal 0.0001 +variable Ti equal 0.0001 variable dT equal 0.2 variable n equal 10000 variable m equal 200 variable dt equal 0.1 # create system -lattice fcc ${lattice_constant} +lattice fcc ${lattice_constant} region box block 0 $c 0 $c 0 $c boundary p p p -pair_style lj/cut 13.5 +pair_style lj/cut 13.5 read_data ftcb_constV_setup.init mass 1 39.95 -pair_coeff 1 1 0.238 3.405 +pair_coeff 1 1 0.238 3.405 # define region neighbor 1.0 bin neigh_modify delay 0 every 2000 check no reset_timestep 0 thermo $m -compute_modify thermo_temp extra 0 -variable nrepeat equal $n/$m +compute_modify thermo_temp extra/dof 0 +variable nrepeat equal $n/$m variable sxx equal -pxx variable intenergy equal etotal fix TDAVE all ave/time $m ${nrepeat} $n c_thermo_temp v_sxx v_intenergy ave one file ftcb_constV.profile @@ -37,7 +37,7 @@ timestep ${dt} # filtered fix ATCFILT all atc field Ar_CauchyBorn.mat #fix_modify ATCFILT reset_atomic_reference_positions ftcb_constV_setup.data -fix_modify ATCFILT mesh create 1 1 1 box p p p +fix_modify ATCFILT mesh create 1 1 1 box p p p fix_modify ATCFILT fields none fix_modify ATCFILT fields add internal_energy stress cauchy_born_energy cauchy_born_stress fix_modify ATCFILT fields add temperature displacement @@ -51,7 +51,7 @@ fix_modify ATCFILT filter type step # not filtered fix ATC all atc field Ar_CauchyBorn.mat #fix_modify ATC reset_atomic_reference_positions ftcb_constV_setup.data -fix_modify ATC mesh create 1 1 1 box p p p +fix_modify ATC mesh create 1 1 1 box p p p fix_modify ATC fields none fix_modify ATC fields add internal_energy stress cauchy_born_energy cauchy_born_stress fix_modify ATC fields add temperature displacement @@ -59,7 +59,7 @@ fix_modify ATC gradients add displacement fix_modify ATC output ftcb_constVFE $m text binary tensor_components velocity all create ${Ti} 102486 mom yes rot yes dist gaussian # step iu T,V space -variable i loop 1 +variable i loop 1 label loop_i print ">>> step $i, T: ${Ti}, V: $V" variable Tf equal ${Ti}+${dT} @@ -69,6 +69,6 @@ label loop_i fix NVT all nvt temp ${Tf} ${Tf} 20 drag 0.5 tchain 1 run $n unfix NVT - variable Ti equal ${Tf} + variable Ti equal ${Tf} next i jump in.ftcb_constV loop_i diff --git a/examples/PACKAGES/atc/fluids/in.bar1d_fluids b/examples/PACKAGES/atc/fluids/in.bar1d_fluids index 79a6c8a4c2..69a2df6900 100644 --- a/examples/PACKAGES/atc/fluids/in.bar1d_fluids +++ b/examples/PACKAGES/atc/fluids/in.bar1d_fluids @@ -5,50 +5,50 @@ # out # to the FEM on the right. Insufficient time is captured to reach the # linear # steady state, but heat crossing both boundaries should be observed. log bar1d_fluids.log -units real -atom_style atomic +units real +atom_style atomic # create domain -#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) +#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) # NOTE following 3 lines added for restart boundary f p p pair_style lj/cut 13.5 read_data temp.init -#read_restart post_eq.dat +#read_restart post_eq.dat lattice fcc 5.405 origin 0.25 0.25 0.25 # create atoms, NOTE commented out for restart -#region mdRegion block -7 7 -3 3 -3 3 -#boundary f p p -#create_box 2 mdRegion -#create_atoms 1 region mdRegion -#mass * 39.95 +#region mdRegion block -7 7 -3 3 -3 3 +#boundary f p p +#create_box 2 mdRegion +#create_atoms 1 region mdRegion +#mass * 39.95 # specify interal/ghost atoms -#region mdInternal block -6 6 -3 3 -3 3 -#region mdGhost block -6 6 -3 3 -3 3 side out +#region mdInternal block -6 6 -3 3 -3 3 +#region mdGhost block -6 6 -3 3 -3 3 side out #create_atoms 1 region mdGhost #lattice fcc 6.5 origin 0.25 0.25 0.25 -#create_atoms 2 region mdInternal -group internal type 2 -group ghost type 1 +#create_atoms 2 region mdInternal +group internal type 2 +group ghost type 1 # velocities have Vcm = 0, NOTE next four lines commented out for restart -#velocity internal create 100. 87287 mom yes loop geom -#pair_style lj/cut 13.5 -##pair_coeff 1 1 0.010323166 3.405 13.5 -#pair_coeff * * .238 3.405 13.5 -neighbor 5. bin -neigh_modify every 10 delay 0 check no -#write_restart tinit.dat +#velocity internal create 100. 87287 mom yes loop geom +#pair_style lj/cut 13.5 +##pair_coeff 1 1 0.010323166 3.405 13.5 +#pair_coeff * * .238 3.405 13.5 +neighbor 5. bin +neigh_modify every 10 delay 0 check no +#write_restart tinit.dat # ID group atc PhysicsType ParameterFile lattice fcc 5.405 origin 0.25 0.25 0.25 -region atcRegion block -6.25 6.25 -3 3 -3 3 +region atcRegion block -6.25 6.25 -3 3 -3 3 fix AtC internal atc thermal Ar_thermal.mat # ID part keywords nx ny nz region periodicity fix_modify AtC mesh create 6 1 1 atcRegion f p p fix_modify AtC time_integration fractional_step -fix_modify AtC atom_element_map eulerian 10 # NOTE this introduces a minor amount of time integration error tracking the atomic temperature +fix_modify AtC atom_element_map eulerian 10 # NOTE this introduces a minor amount of time integration error tracking the atomic temperature fix_modify AtC internal_quadrature off -#fix_modify AtC mass_matrix fe +#fix_modify AtC mass_matrix fe # fix a temperature -fix_modify AtC fix temperature all 100. +fix_modify AtC fix temperature all 100. # add nodesets # ID mesh create_nodeset tag xmin xmax ymin ymax zmin zmax fix_modify AtC mesh create_nodeset lbc -6.3 -6.2 -INF INF -INF INF @@ -56,43 +56,43 @@ fix_modify AtC mesh create_nodeset rbc 6.2 6.3 -INF INF -INF INF #fix_modify AtC fix temperature lbc 120. #fix_modify AtC fix temperature rbc 100. #used for restarting -#fix_modify AtC consistent_fe_initialization on +#fix_modify AtC consistent_fe_initialization on #fix_modify AtC initial temperature all 100. # turn on thermostat -fix_modify AtC control thermal rescale 10 +fix_modify AtC control thermal rescale 10 # equilibrate MD field variable xdof equal 3*count(ghost) -compute_modify thermo_temp extra ${xdof} +compute_modify thermo_temp extra/dof ${xdof} thermo_style custom step cpu etotal pe f_AtC[1] temp f_AtC[2] thermo_modify format 1 %6i format 2 %7.2g #fix_modify AtC output bar1d_fluids_eqFE 200 text binary #dump D1 all atom 200 dump_eq.bar1d -timestep 2 -thermo 200 -run 2000 -#write_restart post_eq.dat +timestep 2 +thermo 200 +run 2000 +#write_restart post_eq.dat # change thermostat to hoover reset_timestep 0 -fix_modify AtC reset_time +fix_modify AtC reset_time fix_modify AtC unfix temperature all variable deltaT equal 2.*2000. fix_modify AtC fix temperature lbc temporal_ramp 100. 120. ${deltaT} -#fix_modify AtC fix temperature lbc 100. +#fix_modify AtC fix temperature lbc 100. fix_modify AtC fix temperature rbc 100. fix_modify AtC control thermal flux no_boundary -fix_modify AtC control tolerance 1.e-14 -fix_modify AtC control localized_lambda on +fix_modify AtC control tolerance 1.e-14 +fix_modify AtC control localized_lambda on fix_modify AtC filter type exponential fix_modify AtC filter scale 1000.0 fix_modify AtC filter on # output commands fix_modify AtC output bar1d_fluidsFE 100 text #undump D1 -#dump D2 all atom 200 dump.bar1d -#dump D2 all custom 200 dump.bar1d id type xs ys zs vx vy vz +#dump D2 all atom 200 dump.bar1d +#dump D2 all custom 200 dump.bar1d id type xs ys zs vx vy vz # set-up non-equilibrium IC -thermo 100 -run 2000 +thermo 100 +run 2000 # run non-equilibrium condition -fix_modify AtC fix temperature lbc 120. -run 4000 +fix_modify AtC fix temperature lbc 120. +run 4000 diff --git a/examples/PACKAGES/atc/fluids/in.concentration b/examples/PACKAGES/atc/fluids/in.concentration index 255524bc0a..f5c2a37cbb 100644 --- a/examples/PACKAGES/atc/fluids/in.concentration +++ b/examples/PACKAGES/atc/fluids/in.concentration @@ -1,10 +1,10 @@ echo both -units real +units real atom_style full # charge ### NOTE p p p is required for both lammps & atc since periodic images are employed in ExtrinsicModelElectrostatic::correct_electrostatic_forces ########### BEGIN PARAMETERS #################################### -variable T equal 300 -variable a equal 1.0 # 5.719025032 +variable T equal 300 +variable a equal 1.0 # 5.719025032 variable i equal 10 # thermo variable f equal 50 # neighbor & conc interval variable s equal 100 # 10 # 100 # output @@ -12,18 +12,18 @@ variable n equal 800 # 20 # 200 # 300 # duration variable x equal 4 # 40 # 2 # 4 # exchanges variable e equal 100. # 1. # 100. # 10. # energy variable h equal 5 # nelems -variable dt equal 4. #1. # 0 # 4.0 +variable dt equal 4. #1. # 0 # 4.0 ############## END PARAMETERS ################################# -dimension 3 -boundary p p p -pair_style lj/cut/coul/cut 13.0 -lattice sc $a +dimension 3 +boundary p p p +pair_style lj/cut/coul/cut 13.0 +lattice sc $a read_data concentration_init.data atom_modify sort 0 1 mass * 39.948 pair_coeff * * 0.2381 3.405 pair_coeff 1 * 0.4 3.405 -dielectric 80.0 +dielectric 80.0 variable xlo equal xlo variable xhi equal xhi variable xmid equal 0.5*(${xhi}+${xlo}) @@ -37,9 +37,9 @@ region FLUID block ${xlo} ${xhi} ${ylo} ${yhi} ${zlo} ${zhi} units box region R block ${xmid} ${xhi} ${ylo} ${yhi} ${zlo} ${zhi} units box group SOLID type 1 variable xdof equal 3*count(SOLID) -compute_modify thermo_temp extra ${xdof} -#set group SOLID charge 0 -group NEUTRAL type 2 +compute_modify thermo_temp extra/dof ${xdof} +#set group SOLID charge 0 +group NEUTRAL type 2 group FLUID type 2 3 4 group NION type 3 group PION type 4 @@ -72,16 +72,16 @@ compute PMIN PION reduce min x compute PMAX PION reduce max x compute NMIN NION reduce min x compute NMAX NION reduce max x -timestep ${dt} +timestep ${dt} #neighbor 13 bin neigh_modify every $i check no # coulombic interactions -fix ATC FLUID atc species_electrostatic Ar_electrostatic.mat +fix ATC FLUID atc species_electrostatic Ar_electrostatic.mat #fix_modify ATC parallel_consistency off fix_modify ATC extrinsic short_range off #fix_modify ATC boundary SOLID fix_modify ATC atom_element_map eulerian $i -fix_modify ATC internal_quadrature off +fix_modify ATC internal_quadrature off fix_modify ATC consistent_fe_initialization on fix_modify ATC filter type exponential fix_modify ATC filter scale $i @@ -97,31 +97,31 @@ fix_modify ATC mesh create_elementset BOX BOX fix_modify ATC mass_matrix fe fix_modify ATC include atomic_charge fix_modify ATC add_species N type 3 -fix_modify ATC add_species P type 4 +fix_modify ATC add_species P type 4 fix_modify ATC add_species Nt type 5 -fix_modify ATC add_species Pt type 6 +fix_modify ATC add_species Pt type 6 ## CC fix_modify ATC control concentration N R 0.001 Nt # deletions R -fix_modify ATC control concentration N frequency $f -fix_modify ATC control concentration N max_energy $e +fix_modify ATC control concentration N frequency $f +fix_modify ATC control concentration N max_energy $e fix_modify ATC control concentration N max_attempts 100 fix_modify ATC control concentration N max_exchanges $x #- fix_modify ATC control concentration P R 0.002 Pt # addtions R -fix_modify ATC control concentration P frequency $f +fix_modify ATC control concentration P frequency $f fix_modify ATC control concentration P max_energy $e -fix_modify ATC control concentration P max_attempts 100 +fix_modify ATC control concentration P max_attempts 100 fix_modify ATC control concentration P max_exchanges $x fix_modify ATC output volume_integral all mass_density fix_modify ATC output volume_integral all charge_density # data reduction fix PP all atc field -#fix_modify PP add_species ions type 3 4 +#fix_modify PP add_species ions type 3 4 #fix_modify PP add_species IONS type 3 4 1 2 -fix_modify PP add_species n type 3 -fix_modify PP add_species p type 4 -fix_modify PP add_species s type 1 -fix_modify PP add_species o type 2 +fix_modify PP add_species n type 3 +fix_modify PP add_species p type 4 +fix_modify PP add_species s type 1 +fix_modify PP add_species o type 2 fix_modify PP fields add species_concentration mass_density charge_density temperature fix_modify PP fields add charge_flux species_flux fix_modify PP output volume_integral all mass_density @@ -129,7 +129,7 @@ fix_modify PP output volume_integral all charge_density fix_modify PP mesh create $h 1 1 BOX f p p fix_modify PP atom_element_map eulerian $i # output -thermo $i +thermo $i variable dN equal f_ATC[1] variable dP equal f_ATC[2] variable Nc equal f_ATC[3] @@ -141,19 +141,19 @@ variable Nu equal f_ATC[7] variable Pu equal f_ATC[8] variable Ng equal f_ATC[9] variable Pg equal f_ATC[10] -thermo_style custom step temp etotal & +thermo_style custom step temp etotal & atoms v_F v_P v_N v_dP v_dN v_Pc v_Nc v_Pr v_Nr v_Pt v_Nt & c_PMIN c_NMIN c_PMAX c_NMAX c_Q c_M c_Qf c_Mf v_Pu v_Nu v_Pg v_Ng -# NOTE this doesn't seem to work -#thermo_modify format 4 %5d format 5 %5d format 6 %5d format 7 %5d format 8 %5d -#thermo_modify format 4 %5d -#thermo_modify format 5 %5d -#thermo_modify format 6 %5d -#thermo_modify format 7 %5d -#thermo_modify format 8 %5d -#thermo_modify format 9 %5d -#thermo_modify format 10 %5d -#thermo_modify format 11 %5d +# NOTE this doesn't seem to work +#thermo_modify format 4 %5d format 5 %5d format 6 %5d format 7 %5d format 8 %5d +#thermo_modify format 4 %5d +#thermo_modify format 5 %5d +#thermo_modify format 6 %5d +#thermo_modify format 7 %5d +#thermo_modify format 8 %5d +#thermo_modify format 9 %5d +#thermo_modify format 10 %5d +#thermo_modify format 11 %5d log concentration.log fix_modify ATC output concentrationFE $s text binary fix_modify PP output concentrationPP $s text diff --git a/examples/PACKAGES/atc/fluids/in.shear_flow b/examples/PACKAGES/atc/fluids/in.shear_flow index 3c06676c64..29327dfb1c 100644 --- a/examples/PACKAGES/atc/fluids/in.shear_flow +++ b/examples/PACKAGES/atc/fluids/in.shear_flow @@ -2,42 +2,42 @@ # This benchmark tests momentum flux as a BC to the MD region to generate shear flow. # Currently heat will be generated as it will have no where to go. log shear_flow.log -units real -atom_style atomic +units real +atom_style atomic # create domain -#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) +#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) # NOTE following 3 lines added for restart boundary f p p pair_style lj/cut 13.5 #read_data temp.init -read_data post_eq.init +read_data post_eq.init lattice fcc 5.405 origin 0.25 0.25 0.25 # create atoms, NOTE commented out for restart -#region mdRegion block -8 8 -3 3 -3 3 -#boundary f p p -#create_box 2 mdRegion -#create_atoms 1 region mdRegion -#mass * 39.95 +#region mdRegion block -8 8 -3 3 -3 3 +#boundary f p p +#create_box 2 mdRegion +#create_atoms 1 region mdRegion +#mass * 39.95 # specify interal/ghost atoms -#region mdInternal block -6 6 -3 3 -3 3 -#region mdGhost block -6 6 -3 3 -3 3 side out +#region mdInternal block -6 6 -3 3 -3 3 +#region mdGhost block -6 6 -3 3 -3 3 side out #create_atoms 1 region mdGhost #lattice fcc 6.5 origin 0.25 0.25 0.25 -#create_atoms 2 region mdInternal -group internal type 2 -group ghost type 1 +#create_atoms 2 region mdInternal +group internal type 2 +group ghost type 1 # velocities have Vcm = 0, NOTE next four lines commented out for restart -#velocity internal create 100. 87287 mom yes loop geom -#pair_style lj/cut 13.5 -##pair_coeff 1 1 0.010323166 3.405 13.5 -#pair_coeff * * .238 3.405 13.5 +#velocity internal create 100. 87287 mom yes loop geom +#pair_style lj/cut 13.5 +##pair_coeff 1 1 0.010323166 3.405 13.5 +#pair_coeff * * .238 3.405 13.5 #write_restart tinit.dat -neighbor 5. bin -neigh_modify every 10 delay 0 check no +neighbor 5. bin +neigh_modify every 10 delay 0 check no # equilibrate MD field variable xdof equal 3*count(ghost) -compute_modify thermo_temp extra ${xdof} +compute_modify thermo_temp extra/dof ${xdof} thermo_style custom step cpu etotal pe temp thermo_modify format 1 %6i format 2 %7.2g #fix NVT internal nvt temp 100 100 10 drag 0.2 @@ -49,28 +49,28 @@ timestep 2 # ID group atc PhysicsType ParameterFile lattice fcc 5.405 origin 0.25 0.25 0.25 -region atcRegion block -6.25 6.25 -3 3 -3 3 +region atcRegion block -6.25 6.25 -3 3 -3 3 fix AtC internal atc shear Ar_viscosity.mat # ID part keywords nx ny nz region periodicity fix_modify AtC mesh create 6 1 1 atcRegion f p p #fix_modify AtC time_integration fractional_step -##fix_modify AtC atom_element_map eulerian 10 # NOTE this introduces a minor amount of time integration error tracking the atomic temperature +##fix_modify AtC atom_element_map eulerian 10 # NOTE this introduces a minor amount of time integration error tracking the atomic temperature fix_modify AtC internal_quadrature off -#fix_modify AtC mass_matrix fe +#fix_modify AtC mass_matrix fe # add nodesets # ID mesh create_nodeset tag xmin xmax ymin ymax zmin zmax fix_modify AtC mesh create_elementset rbc 4.12 6.3 -INF INF -INF INF #used for restarting -fix_modify AtC consistent_fe_initialization on +fix_modify AtC consistent_fe_initialization on #fix_modify AtC initial velocity x all 0. # turn on kinetostat reset_timestep 0 -fix_modify AtC reset_time -fix_modify AtC source velocity y rbc .0000001 +fix_modify AtC reset_time +fix_modify AtC source velocity y rbc .0000001 fix_modify AtC control momentum flux no_boundary -fix_modify AtC control tolerance 1.e-14 -fix_modify AtC control localized_lambda on +fix_modify AtC control tolerance 1.e-14 +fix_modify AtC control localized_lambda on #fix_modify AtC filter type exponential #fix_modify AtC filter scale 1000.0 #fix_modify AtC filter on @@ -78,7 +78,7 @@ fix_modify AtC control localized_lambda on # output commands fix_modify AtC output shear_flowFE 100 text #binary #undump D1 -#dump D1 all custom 100 shear_flow.dmp id type xs ys zs vx vy vz +#dump D1 all custom 100 shear_flow.dmp id type xs ys zs vx vy vz # set-up non-equilibrium IC -thermo 100 -run 2000 +thermo 100 +run 2000 diff --git a/examples/PACKAGES/atc/hardy/in.eshelby_static b/examples/PACKAGES/atc/hardy/in.eshelby_static index b0ccc94af5..b00dcd1185 100644 --- a/examples/PACKAGES/atc/hardy/in.eshelby_static +++ b/examples/PACKAGES/atc/hardy/in.eshelby_static @@ -1,4 +1,4 @@ -# This test calculates the J-integral for a sequence of different loads +# This test calculates the J-integral for a sequence of different loads # for a system with a crack tip. # # loops around crack and one around undefected material @@ -7,17 +7,17 @@ # loop 2 - medium contour around left crack tip # loop 3 - largest contour around left crack tip # loop 4 - medium contour around right crack tip -#for Lennard-Jones potential for gold: -# surface energy (gamma) of 0.1599 eV/Å^2 = 2.56191 J/m2. +#for Lennard-Jones potential for gold: +# surface energy (gamma) of 0.1599 eV/Å^2 = 2.56191 J/m2. # 2*gamma = 0.3198 eV/Å^2 = 5.12382 J/m2 -# using the internal nktv2p conversion factor, +# using the internal nktv2p conversion factor, # the units of eshelby_stress are eV/Å^3, and # the resulting boundary integral is eV/Å since we also include thickness (a # boundary surface area rather than a periphery). If we multiply the 2*gamma # quantity times the thickness t = 3*4.08 = 12.24 Å, we obtain 2*gamma*t = -# 3.914352 eV/Å, which agrees with the mesh calculation. +# 3.914352 eV/Å, which agrees with the mesh calculation. echo both -log eshelby_static.log +log eshelby_static.log units metal dimension 3 boundary p p p @@ -29,12 +29,12 @@ lattice fcc 4.08 origin 0.25 0.25 0.25 region SYSTEM block -10 10 -10 10 0 3 region UPPER block -10 10 0 10 0 3 region LOWER block -10 0 -10 10 0 3 -create_box 1 SYSTEM +create_box 1 SYSTEM create_atoms 1 region SYSTEM mass 1 63.55 -group internal region SYSTEM -group upper region UPPER -group lower region LOWER +group internal region SYSTEM +group upper region UPPER +group lower region LOWER #pair_style eam #pair_coeff * * ../../../../potentials/Cu_u3.eam #pair_style lj/smooth 8.0 10.0 @@ -42,27 +42,27 @@ group lower region LOWER pair_style lj/smooth/linear 5.456108274435118 pair_coeff * * 0.7242785984051078 2.598146797350056 # define region -region abovecrack block -2.01 2.01 0 8 INF INF units lattice +region abovecrack block -2.01 2.01 0 8 INF INF units lattice group abovecrack region abovecrack -region belowcrack block -2.01 2.01 -8 0 INF INF units lattice +region belowcrack block -2.01 2.01 -8 0 INF INF units lattice group belowcrack region belowcrack neighbor 1.0 bin neigh_modify delay 1000000 -neigh_modify exclude group abovecrack belowcrack +neigh_modify exclude group abovecrack belowcrack thermo 10 -compute_modify thermo_temp extra 0 +compute_modify thermo_temp extra/dof 0 region FORCECHECK block -6 0 6 10 0 3 group FORCECHECK region FORCECHECK compute fxsum FORCECHECK reduce sum fx compute fysum FORCECHECK reduce sum fy compute fzsum FORCECHECK reduce sum fz thermo_style custom step ke pe press c_fxsum c_fysum c_fzsum -thermo_modify format 1 %4i format 2 %3.1g format 3 %20.16g +thermo_modify format 1 %4i format 2 %3.1g format 3 %20.16g timestep 0.0 # (1) minimize the system to get a relaxed configuration min_modify line quadratic variable tol equal 1.e-11 -minimize 0.0 ${tol} 100000 1000000 +minimize 0.0 ${tol} 100000 1000000 write_restart eshelby.restart # (2) pull crack apart reset_timestep 0 @@ -70,13 +70,13 @@ fix PK1 internal atc field # NOTE tune this relative to lattice size fix_modify PK1 mesh create 10 10 1 SYSTEM p f p fix_modify PK1 fields none -fix_modify PK1 fields add mass_density internal_energy temperature stress displacement -fix_modify PK1 fields add eshelby_stress transformed_stress -fix_modify PK1 gradients add displacement +fix_modify PK1 fields add mass_density internal_energy temperature stress displacement +fix_modify PK1 fields add eshelby_stress transformed_stress +fix_modify PK1 gradients add displacement fix_modify PK1 set reference_potential_energy fix_modify PK1 output eshelby_staticFE 1 text binary tensor_components -#fix_modify PK1 on_the_fly -#-- make concentric loops around one/both of the crack tips +#fix_modify PK1 on_the_fly +#-- make concentric loops around one/both of the crack tips #-- & another around undefected material (loop0) fix_modify PK1 mesh create_faceset loop0 box -6 0 6 10 -INF INF outward fix_modify PK1 output boundary_integral eshelby_stress faceset loop0 diff --git a/examples/PACKAGES/atc/hardy/in.nvt b/examples/PACKAGES/atc/hardy/in.nvt index 68ba2eba17..c6de0842f9 100644 --- a/examples/PACKAGES/atc/hardy/in.nvt +++ b/examples/PACKAGES/atc/hardy/in.nvt @@ -5,12 +5,12 @@ atom_style atomic echo both dimension 3 boundary p p p -lattice fcc 5.376 orient x 1 0 0 orient y 0 1 0 orient z 0 0 1 -region box block 0 5 0 5 0 5 -read_data nvt.init +lattice fcc 5.376 orient x 1 0 0 orient y 0 1 0 orient z 0 0 1 +region box block 0 5 0 5 0 5 +read_data nvt.init pair_style lj/cut 13.0 -pair_coeff 1 1 0.2381 3.405 -group internal region box +pair_coeff 1 1 0.2381 3.405 +group internal region box fix ATC internal atc field fix_modify ATC mesh create 1 1 1 box p p p @@ -27,12 +27,12 @@ fix_modify PP atom_element_map eulerian 100 fix_modify PP fields add mass_density energy stress temperature kinetic_temperature fix_modify PP fields add velocity thermal_energy kinetic_energy fix_modify PP output nvtPP 100 text -thermo 100 -compute_modify thermo_temp extra 0 -thermo_style custom step temp etotal ke pe press vol -timestep 4.0 -reset_timestep 0 +thermo 100 +compute_modify thermo_temp extra/dof 0 +thermo_style custom step temp etotal ke pe press vol +timestep 4.0 +reset_timestep 0 # NOTE fixes performing time integration (init_integrate/final_integrate) should be defined after atc -fix NVT all nvt temp 30 30 10.0 drag 0.2 tchain 1 -log nvt.log -run 1000 +fix NVT all nvt temp 30 30 10.0 drag 0.2 tchain 1 +log nvt.log +run 1000 diff --git a/examples/PACKAGES/atc/thermal/in.bar1d b/examples/PACKAGES/atc/thermal/in.bar1d index 3f70577ec3..9fe5617ec3 100644 --- a/examples/PACKAGES/atc/thermal/in.bar1d +++ b/examples/PACKAGES/atc/thermal/in.bar1d @@ -1,38 +1,38 @@ #AtC Thermal Coupling # This benchmark tests heat conducting into and out of the MD region. The # temperature is initially 20 everywhere and the left boundary BC is fixed at 40. -# The result should show heat diffusing through the FEM to the MD and back out -# to the FEM on the right. Insufficient time is captured to reach the linear +# The result should show heat diffusing through the FEM to the MD and back out +# to the FEM on the right. Insufficient time is captured to reach the linear # steady state, but heat crossing both boundaries should be observed. - -units real -atom_style atomic + +units real +atom_style atomic echo both # create domain -#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) +#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) # NOTE following 3 lines added for restart boundary f p p pair_style lj/cut 13.5 read_data temp.init lattice fcc 5.405 origin 0.25 0.25 0.25 -region simRegion block -12 12 -3 3 -3 3 +region simRegion block -12 12 -3 3 -3 3 # create atoms, NOTE commented out for restart -#region mdRegion block -5 5 -3 3 -3 3 -#boundary f p p -#create_box 1 mdRegion -#create_atoms 1 region mdRegion -#mass 1 39.95 +#region mdRegion block -5 5 -3 3 -3 3 +#boundary f p p +#create_box 1 mdRegion +#create_atoms 1 region mdRegion +#mass 1 39.95 # specify interal/ghost atoms -region mdInternal block -4 4 -3 3 -3 3 -group internal region mdInternal -group ghost subtract all internal +region mdInternal block -4 4 -3 3 -3 3 +group internal region mdInternal +group ghost subtract all internal # velocities have Vcm = 0, NOTE next four lines commented out for restart -#velocity internal create 40. 87287 mom yes loop geom -#pair_style lj/cut 13.5 -##pair_coeff 1 1 0.010323166 3.405 13.5 -#pair_coeff 1 1 .238 3.405 13.5 -neighbor 5. bin -neigh_modify every 10 delay 0 check no +#velocity internal create 40. 87287 mom yes loop geom +#pair_style lj/cut 13.5 +##pair_coeff 1 1 0.010323166 3.405 13.5 +#pair_coeff 1 1 .238 3.405 13.5 +neighbor 5. bin +neigh_modify every 10 delay 0 check no # ID group atc PhysicsType ParameterFile fix AtC internal atc thermal Ar_thermal.mat fix_modify AtC boundary ghost @@ -40,26 +40,26 @@ fix_modify AtC boundary ghost fix_modify AtC mesh create 12 1 1 simRegion f p p fix_modify AtC internal_quadrature off # fix a temperature -fix_modify AtC fix temperature all 20. +fix_modify AtC fix temperature all 20. # turn on thermostat -fix_modify AtC control thermal rescale 10 +fix_modify AtC control thermal rescale 10 # equilibrate MD field #dump D1 all atom 100 dump.bar1d #fix_modify AtC output bar1dfe 100 -timestep 5 +timestep 5 variable xdof equal 3*count(ghost) -compute_modify thermo_temp extra ${xdof} -thermo_style custom step cpu etotal pe f_AtC[1] temp f_AtC[2] +compute_modify thermo_temp extra/dof ${xdof} +thermo_style custom step cpu etotal pe f_AtC[1] temp f_AtC[2] thermo_modify format 1 %6i format 2 %7.2g -thermo 100 -run 400 +thermo 100 +run 400 # change thermostat to hoover -fix_modify AtC unfix temperature all -fix_modify AtC control thermal hoover -#fix_modify AtC localized_lambda on -fix_modify AtC filter type exponential -fix_modify AtC filter scale 10000.0 -fix_modify AtC filter on +fix_modify AtC unfix temperature all +fix_modify AtC control thermal hoover +#fix_modify AtC localized_lambda on +fix_modify AtC filter type exponential +fix_modify AtC filter scale 10000.0 +fix_modify AtC filter on # add nodesets # ID mesh create_nodeset tag xmin xmax ymin ymax zmin zmax fix_modify AtC mesh create_nodeset lbc -12.1 -11.9 -INF INF -INF INF @@ -67,13 +67,13 @@ fix_modify AtC mesh create_nodeset rbc 11.9 12.1 -INF INF -INF INF fix_modify AtC fix temperature lbc 40. fix_modify AtC fix temperature rbc 20. # initialize filter -thermo 1 -run 100 +thermo 1 +run 100 # set up output, should be before a "run" fix_modify AtC output bar1dFE 100 text binary # output command #dump D1 all atom 1000 dump.bar1d # run with FE reset_timestep 0 -thermo 100 -run 10000 +thermo 100 +run 10000 diff --git a/examples/PACKAGES/atc/thermal/in.bar1d_all_atoms b/examples/PACKAGES/atc/thermal/in.bar1d_all_atoms index 2219b803ec..1faf24427d 100644 --- a/examples/PACKAGES/atc/thermal/in.bar1d_all_atoms +++ b/examples/PACKAGES/atc/thermal/in.bar1d_all_atoms @@ -4,33 +4,33 @@ # 40.# The result should show heat diffusing through the FEM to the MD and back # out # to the FEM on the right. Insufficient time is captured to reach the # linear # steady state, but heat crossing both boundaries should be observed. -units real -atom_style atomic +units real +atom_style atomic # create domain -#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) +#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) # NOTE following 3 lines added for restart boundary f p p pair_style lj/cut 13.5 read_data all_atoms.init lattice fcc 5.405 origin 0.25 0.25 0.25 -region simRegion block -7 7 -3 3 -3 3 +region simRegion block -7 7 -3 3 -3 3 # create atoms, NOTE commented out for restart -#boundary f p p -#create_box 1 simRegion -#create_atoms 1 region simRegion -#mass 1 39.95 +#boundary f p p +#create_box 1 simRegion +#create_atoms 1 region simRegion +#mass 1 39.95 # specify interal/ghost atoms -region mdInternal block -6 6 -3 3 -3 3 -group internal region mdInternal -group ghost subtract all internal +region mdInternal block -6 6 -3 3 -3 3 +group internal region mdInternal +group ghost subtract all internal # velocities have Vcm = 0, NOTE next four lines commented out for restart -#velocity internal create 40. 87287 mom yes loop geom -#pair_style lj/cut 13.5 -##pair_coeff 1 1 0.010323166 3.405 13.5 -#pair_coeff 1 1 .238 3.405 13.5 -#write_restart all_atoms.init -neighbor 5. bin -neigh_modify every 10 delay 0 check no +#velocity internal create 40. 87287 mom yes loop geom +#pair_style lj/cut 13.5 +##pair_coeff 1 1 0.010323166 3.405 13.5 +#pair_coeff 1 1 .238 3.405 13.5 +#write_restart all_atoms.init +neighbor 5. bin +neigh_modify every 10 delay 0 check no # ID group atc PhysicsType ParameterFile fix AtC internal atc thermal Ar_thermal.mat # ID part keywords nx ny nz region @@ -39,34 +39,34 @@ fix_modify AtC mesh create_faceset obndy box -6.0 6.0 -INF INF -INF INF out fix_modify AtC mesh create_faceset lbndy box -6.0 16.0 -INF INF -INF INF outward fix_modify AtC mesh create_faceset rbndy box -16.0 6.0 -INF INF -INF INF outward # fix a temperature -fix_modify AtC fix temperature all 20. +fix_modify AtC fix temperature all 20. # turn on thermostat -fix_modify AtC control thermal rescale 10 +fix_modify AtC control thermal rescale 10 fix_modify AtC internal_quadrature off # equilibrate MD field #dump D1 all atom 100 dump.bar1d #fix_modify AtC output bar1dfe 100 -#fix_modify AtC time_integration frac_step -timestep 5 +#fix_modify AtC time_integration frac_step +timestep 5 variable xdof equal 3*count(ghost) -compute_modify thermo_temp extra ${xdof} +compute_modify thermo_temp extra/dof ${xdof} thermo_style custom step cpu etotal pe f_AtC[1] temp f_AtC[2] thermo_modify format 1 %6i format 2 %7.2g -thermo 100 -run 400 +thermo 100 +run 400 # change thermostat to hoover -fix_modify AtC control thermal hoover -#fix_modify AtC thermal control flux interpolate -#fix_modify AtC thermal control flux faceset obndy -fix_modify AtC filter scale 1000.0 -#fix_modify AtC filter equilibrate -#fix_modify AtC filter on -#fix_modify AtC localized_lambda on +fix_modify AtC control thermal hoover +#fix_modify AtC thermal control flux interpolate +#fix_modify AtC thermal control flux faceset obndy +fix_modify AtC filter scale 1000.0 +#fix_modify AtC filter equilibrate +#fix_modify AtC filter on +#fix_modify AtC localized_lambda on fix_modify AtC boundary_faceset is obndy # initialize filter #fix_modify AtC output bar1d_all_atoms_preqFE 1 reset_timestep 0 -thermo 1 +thermo 1 #run 5000 # add nodesets and ramp temperature # ID mesh create_nodeset tag xmin xmax ymin ymax zmin zmax @@ -76,26 +76,26 @@ thermo 1 #fix_modify AtC fix temperature rbc 20. # initialize filter #fix_modify AtC output bar1d_all_atoms_eqFE 200 -reset_timestep 0 -fix_modify AtC reset_time +reset_timestep 0 +fix_modify AtC reset_time #run 5000 # release and let run -#fix_modify AtC filter on -fix_modify AtC unfix temperature all +#fix_modify AtC filter on +fix_modify AtC unfix temperature all #fix_modify AtC localized_lambda on -fix_modify AtC control lumped_lambda_solve on +fix_modify AtC control lumped_lambda_solve on # dirichlet boundaries #fix_modify AtC fix temperature lbc 40. #fix_modify AtC fix temperature rbc 20. # neumann boundaries fix_modify AtC control thermal flux no_boundary -fix_modify AtC fix_flux temperature lbndy 0.0000000001 +fix_modify AtC fix_flux temperature lbndy 0.0000000001 fix_modify AtC fix_flux temperature rbndy -0.0000000001 # set up output, should be before a "run" fix_modify AtC output bar1d_all_atomsFE 200 text binary # output command #dump D1 all atom 1000 dump.bar1d # run with FE -reset_timestep 0 -thermo 200 -run 5000 +reset_timestep 0 +thermo 200 +run 5000 diff --git a/examples/PACKAGES/atc/thermal/in.bar1d_combined b/examples/PACKAGES/atc/thermal/in.bar1d_combined index 70dafe72be..23b01139f2 100644 --- a/examples/PACKAGES/atc/thermal/in.bar1d_combined +++ b/examples/PACKAGES/atc/thermal/in.bar1d_combined @@ -6,62 +6,62 @@ # linear # steady state, but heat crossing the boundaries should be observed, # as should the interaction of the two themostat types. #echo both -units real -atom_style atomic +units real +atom_style atomic # create domain -#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) +#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) # NOTE following 3 lines added for restart -boundary f p p -pair_style lj/cut 13.5 +boundary f p p +pair_style lj/cut 13.5 read_data temp.init lattice fcc 5.405 origin 0.25 0.25 0.25 -region simRegion block -16 4 -3 3 -3 3 +region simRegion block -16 4 -3 3 -3 3 # create atoms, NOTE commented out for restart -#region mdRegion block -5 5 -3 3 -3 3 -#boundary f p p -#create_box 1 mdRegion -#create_atoms 1 region mdRegion -#mass 1 39.95 +#region mdRegion block -5 5 -3 3 -3 3 +#boundary f p p +#create_box 1 mdRegion +#create_atoms 1 region mdRegion +#mass 1 39.95 # specify interal/ghost atoms -region mdInternal block -4 4 -3 3 -3 3 -group internal region mdInternal -region mdGhost block -5 -4 -3 3 -3 3 -group ghost region mdGhost +region mdInternal block -4 4 -3 3 -3 3 +group internal region mdInternal +region mdGhost block -5 -4 -3 3 -3 3 +group ghost region mdGhost # velocities have Vcm = 0, NOTE next four lines commented out for restart -#velocity internal create 40. 87287 mom yes loop geom -#pair_style lj/cut 13.5 -##pair_coeff 1 1 0.010323166 3.405 13.5 -#pair_coeff 1 1 .238 3.405 13.5 -neighbor 5. bin -neigh_modify every 10 delay 0 check no -#write_restart tinit.dat +#velocity internal create 40. 87287 mom yes loop geom +#pair_style lj/cut 13.5 +##pair_coeff 1 1 0.010323166 3.405 13.5 +#pair_coeff 1 1 .238 3.405 13.5 +neighbor 5. bin +neigh_modify every 10 delay 0 check no +#write_restart tinit.dat # ID group atc PhysicsType ParameterFile fix AtC internal atc thermal Ar_thermal.mat fix_modify AtC boundary ghost fix_modify AtC time_integration fractional_step -fix_modify AtC internal_quadrature off +fix_modify AtC internal_quadrature off # ID part keywords nx ny nz region fix_modify AtC mesh create 10 1 1 simRegion f p p fix_modify AtC mesh create_faceset ibndy box -4.0 40.0 -INF INF -INF INF in fix_modify AtC mesh create_faceset obndy box -4.0 40.0 -INF INF -INF INF outward # fix a temperature -fix_modify AtC fix temperature all 20. +fix_modify AtC fix temperature all 20. # turn on thermostat -fix_modify AtC control thermal rescale 10 +fix_modify AtC control thermal rescale 10 variable xdof equal 3*count(ghost) -compute_modify thermo_temp extra ${xdof} +compute_modify thermo_temp extra/dof ${xdof} thermo_style custom step cpu etotal pe f_AtC[1] temp f_AtC[2] thermo_modify format 1 %6i format 2 %7.2g # equilibrate MD field #fix_modify AtC output bar1dfe_combined_init 100 -timestep 5 -thermo 10 -run 400 +timestep 5 +thermo 10 +run 400 # change thermostat to flux -fix_modify AtC unfix temperature all -fix_modify AtC control thermal flux faceset obndy -#fix_modify AtC control thermal hoover -fix_modify AtC control localized_lambda on +fix_modify AtC unfix temperature all +fix_modify AtC control thermal flux faceset obndy +#fix_modify AtC control thermal hoover +fix_modify AtC control localized_lambda on #fix_modify AtC control tolerance 1.e-16 # this tolerance seems necessary to prevent noticeable drift # add nodesets # ID mesh create_nodeset tag xmin xmax ymin ymax zmin zmax @@ -74,8 +74,8 @@ fix_modify AtC fix temperature rbc 20. fix_modify AtC filter type exponential fix_modify AtC filter scale 1000.0 #fix_modify AtC filter on -thermo 100 -#run 100 +thermo 100 +#run 100 # set up output, should be before a "run" fix_modify AtC output bar1d_combinedFE 100 text @@ -83,5 +83,5 @@ fix_modify AtC output bar1d_combinedFE 100 text #dump D1 all atom 100 dump.bar1d_combined # run with FE reset_timestep 0 -thermo 100 -run 5000 +thermo 100 +run 5000 diff --git a/examples/PACKAGES/atc/thermal/in.bar1d_flux b/examples/PACKAGES/atc/thermal/in.bar1d_flux index 2b79aa6339..6f7fdcca21 100644 --- a/examples/PACKAGES/atc/thermal/in.bar1d_flux +++ b/examples/PACKAGES/atc/thermal/in.bar1d_flux @@ -5,34 +5,34 @@ # out # to the FEM on the right. Insufficient time is captured to reach the # linear # steady state, but heat crossing both boundaries should be observed. #echo both -units real -atom_style atomic +units real +atom_style atomic # create domain -#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) +#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) # NOTE following 3 lines added for restart -boundary f p p -pair_style lj/cut 13.5 +boundary f p p +pair_style lj/cut 13.5 read_data temp.init lattice fcc 5.405 origin 0.25 0.25 0.25 -region simRegion block -12 12 -3 3 -3 3 +region simRegion block -12 12 -3 3 -3 3 # create atoms, NOTE commented out for restart -#region mdRegion block -5 5 -3 3 -3 3 -#boundary f p p -#create_box 1 mdRegion -#create_atoms 1 region mdRegion -#mass 1 39.95 +#region mdRegion block -5 5 -3 3 -3 3 +#boundary f p p +#create_box 1 mdRegion +#create_atoms 1 region mdRegion +#mass 1 39.95 # specify interal/ghost atoms -region mdInternal block -4 4 -3 3 -3 3 -group internal region mdInternal -group ghost subtract all internal +region mdInternal block -4 4 -3 3 -3 3 +group internal region mdInternal +group ghost subtract all internal # velocities have Vcm = 0, NOTE next four lines commented out for restart -#velocity internal create 40. 87287 mom yes loop geom -#pair_style lj/cut 13.5 -##pair_coeff 1 1 0.010323166 3.405 13.5 -#pair_coeff 1 1 .238 3.405 13.5 -neighbor 5. bin -neigh_modify every 10 delay 0 check no -#write_restart tinit.dat +#velocity internal create 40. 87287 mom yes loop geom +#pair_style lj/cut 13.5 +##pair_coeff 1 1 0.010323166 3.405 13.5 +#pair_coeff 1 1 .238 3.405 13.5 +neighbor 5. bin +neigh_modify every 10 delay 0 check no +#write_restart tinit.dat # ID group atc PhysicsType ParameterFile fix AtC internal atc thermal Ar_thermal.mat fix_modify AtC boundary ghost @@ -42,25 +42,25 @@ fix_modify AtC mesh create 12 1 1 simRegion f p p fix_modify AtC mesh create_faceset ibndy box -4.0 4.0 -INF INF -INF INF in fix_modify AtC mesh create_faceset obndy box -4.0 4.0 -INF INF -INF INF outward # fix a temperature -fix_modify AtC fix temperature all 20. -#fix_modify AtC fix temperature all linear 0 0 0 -0.154 0 0 30. +fix_modify AtC fix temperature all 20. +#fix_modify AtC fix temperature all linear 0 0 0 -0.154 0 0 30. # turn on thermostat -fix_modify AtC control thermal rescale 10 +fix_modify AtC control thermal rescale 10 variable xdof equal 3*count(ghost) -compute_modify thermo_temp extra ${xdof} +compute_modify thermo_temp extra/dof ${xdof} thermo_style custom step cpu etotal pe f_AtC[1] temp f_AtC[2] thermo_modify format 1 %6i format 2 %7.2g # equilibrate MD field #fix_modify AtC output bar1dfe_flux_init 100 -timestep 5 -thermo 10 -run 400 +timestep 5 +thermo 10 +run 400 # change thermostat to hoover -fix_modify AtC unfix temperature all -fix_modify AtC control thermal flux faceset obndy +fix_modify AtC unfix temperature all +fix_modify AtC control thermal flux faceset obndy fix_modify AtC filter type exponential -fix_modify AtC filter scale 10000.0 -#fix_modify AtC filter on +fix_modify AtC filter scale 10000.0 +#fix_modify AtC filter on # add nodesets # ID mesh create_nodeset tag xmin xmax ymin ymax zmin zmax fix_modify AtC mesh create_nodeset lbc -12.1 -11.9 -INF INF -INF INF @@ -68,12 +68,12 @@ fix_modify AtC mesh create_nodeset rbc 11.9 12.1 -INF INF -INF INF fix_modify AtC fix temperature lbc 40. fix_modify AtC fix temperature rbc 20. # initialize filter -run 100 +run 100 # set up output, should be before a "run" fix_modify AtC output bar1d_fluxFE 100 text binary # output command #dump D1 all atom 1000 dump.bar1d # run with FE reset_timestep 0 -thermo 100 -run 10000 +thermo 100 +run 10000 diff --git a/examples/PACKAGES/atc/thermal/in.bar1d_frac_step b/examples/PACKAGES/atc/thermal/in.bar1d_frac_step index e8540d9151..09295cab24 100644 --- a/examples/PACKAGES/atc/thermal/in.bar1d_frac_step +++ b/examples/PACKAGES/atc/thermal/in.bar1d_frac_step @@ -4,33 +4,33 @@ # 40.# The result should show heat diffusing through the FEM to the MD and back # out # to the FEM on the right. Insufficient time is captured to reach the # linear # steady state, but heat crossing both boundaries should be observed. -units real -atom_style atomic +units real +atom_style atomic # create domain -#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) +#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) # NOTE following 3 lines added for restart boundary f p p pair_style lj/cut 13.5 read_data temp.init lattice fcc 5.405 origin 0.25 0.25 0.25 -region simRegion block -12 12 -3 3 -3 3 +region simRegion block -12 12 -3 3 -3 3 # create atoms, NOTE commented out for restart -#region mdRegion block -5 5 -3 3 -3 3 -#boundary f p p -#create_box 1 mdRegion -#create_atoms 1 region mdRegion -#mass 1 39.95 +#region mdRegion block -5 5 -3 3 -3 3 +#boundary f p p +#create_box 1 mdRegion +#create_atoms 1 region mdRegion +#mass 1 39.95 # specify interal/ghost atoms -region mdInternal block -4 4 -3 3 -3 3 -group internal region mdInternal -group ghost subtract all internal +region mdInternal block -4 4 -3 3 -3 3 +group internal region mdInternal +group ghost subtract all internal # velocities have Vcm = 0, NOTE next four lines commented out for restart -#velocity internal create 40. 87287 mom yes loop geom -#pair_style lj/cut 13.5 -##pair_coeff 1 1 0.010323166 3.405 13.5 -#pair_coeff 1 1 .238 3.405 13.5 -neighbor 5. bin -neigh_modify every 10 delay 0 check no +#velocity internal create 40. 87287 mom yes loop geom +#pair_style lj/cut 13.5 +##pair_coeff 1 1 0.010323166 3.405 13.5 +#pair_coeff 1 1 .238 3.405 13.5 +neighbor 5. bin +neigh_modify every 10 delay 0 check no # ID group atc PhysicsType ParameterFile fix AtC internal atc thermal Ar_thermal.mat # ID part keywords nx ny nz region @@ -40,7 +40,7 @@ fix_modify AtC internal_atom_integrate off fix iNVE internal nve fix_modify AtC internal_quadrature off # fix a temperature -fix_modify AtC fix temperature all 20. +fix_modify AtC fix temperature all 20. # add nodesets # ID mesh create_nodeset tag xmin xmax ymin ymax zmin zmax fix_modify AtC mesh create_nodeset lbc -4.1 -3.9 -INF INF -INF INF @@ -48,25 +48,25 @@ fix_modify AtC mesh create_nodeset rbc 3.9 4.1 -INF INF -INF INF fix_modify AtC fix temperature lbc 40. fix_modify AtC fix temperature rbc 20. # turn on thermostat -fix_modify AtC control thermal rescale 10 +fix_modify AtC control thermal rescale 10 # equilibrate MD field #dump D1 all atom 100 dump.bar1d #fix_modify AtC output bar1dfe 100 text -timestep 5 +timestep 5 variable xdof equal 3*count(ghost) -compute_modify thermo_temp extra ${xdof} +compute_modify thermo_temp extra/dof ${xdof} thermo_style custom step cpu etotal pe f_AtC[1] temp f_AtC[2] thermo_modify format 1 %6i format 2 %7.2g -thermo 100 -run 400 +thermo 100 +run 400 # change thermostat to hoover fix_modify AtC unfix temperature all fix_modify AtC fix temperature lbc 40. fix_modify AtC fix temperature rbc 20. fix_modify AtC control thermal flux no_boundary -fix_modify AtC control tolerance 1.e-9 # this is to remove looser benchmark tolerance because the lambda solution was reacting to numerical noise, but it results in a slight drift in the constraints -#fix_modify AtC thermal control none -fix_modify AtC control localized_lambda on +fix_modify AtC control tolerance 1.e-9 # this is to remove looser benchmark tolerance because the lambda solution was reacting to numerical noise, but it results in a slight drift in the constraints +#fix_modify AtC thermal control none +fix_modify AtC control localized_lambda on fix_modify AtC filter type exponential fix_modify AtC filter scale 1000.0 fix_modify AtC filter on @@ -76,5 +76,5 @@ fix_modify AtC output bar1d_frac_stepFE 200 text #dump D1 all atom 1000 dump.bar1d # run with FE reset_timestep 0 -thermo 100 -run 10000 +thermo 100 +run 10000 diff --git a/examples/PACKAGES/atc/thermal/in.bar1d_hoover b/examples/PACKAGES/atc/thermal/in.bar1d_hoover index 2f0518d0d2..477a2bf08d 100644 --- a/examples/PACKAGES/atc/thermal/in.bar1d_hoover +++ b/examples/PACKAGES/atc/thermal/in.bar1d_hoover @@ -4,35 +4,35 @@ # 40.# The result should show heat diffusing through the FEM to the MD and back # out # to the FEM on the right. Insufficient time is captured to reach the # linear # steady state, but heat crossing both boundaries should be observed. -units real -atom_style atomic +units real +atom_style atomic log bar1d_hoover.log # create domain -#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) +#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) # NOTE following 3 lines added for restart boundary f p p pair_style lj/cut 13.5 read_data all_atoms.init lattice fcc 5.405 origin 0.25 0.25 0.25 -region simRegion block -7 7 -3 3 -3 3 +region simRegion block -7 7 -3 3 -3 3 # create atoms, NOTE commented out for restart -#boundary f p p -#create_box 1 simRegion -#create_atoms 1 region simRegion -#mass 1 39.95 -#atom_modify sort 0 0 +#boundary f p p +#create_box 1 simRegion +#create_atoms 1 region simRegion +#mass 1 39.95 +#atom_modify sort 0 0 # specify interal/ghost atoms -region mdInternal block -6 6 -3 3 -3 3 -group internal region mdInternal -group ghost subtract all internal +region mdInternal block -6 6 -3 3 -3 3 +group internal region mdInternal +group ghost subtract all internal # velocities have Vcm = 0, NOTE next four lines commented out for restart -#velocity internal create 40. 87287 mom yes loop geom -#pair_style lj/cut 13.5 -##pair_coeff 1 1 0.010323166 3.405 13.5 -#pair_coeff 1 1 .238 3.405 13.5 -#write_restart all_atoms.init -neighbor 5. bin -neigh_modify every 10 delay 0 check no +#velocity internal create 40. 87287 mom yes loop geom +#pair_style lj/cut 13.5 +##pair_coeff 1 1 0.010323166 3.405 13.5 +#pair_coeff 1 1 .238 3.405 13.5 +#write_restart all_atoms.init +neighbor 5. bin +neigh_modify every 10 delay 0 check no # ID group atc PhysicsType ParameterFile fix AtC internal atc thermal Ar_thermal.mat # ID part keywords nx ny nz region @@ -40,9 +40,9 @@ fix AtC internal atc thermal Ar_thermal.mat # switch depending on application of BCs or coupling #variable nEls equal 6 # for boundary conditions variable nEls equal 12 # for coupling -fix_modify AtC boundary ghost # for coupling +fix_modify AtC boundary ghost # for coupling -region atcRegion block -${nEls} ${nEls} -3 3 -3 3 +region atcRegion block -${nEls} ${nEls} -3 3 -3 3 fix_modify AtC mesh create ${nEls} 1 1 atcRegion f p p fix_modify AtC mesh create_faceset obndy box -6.0 6.0 -INF INF -INF INF outward fix_modify AtC mesh create_faceset lbndy box -6.0 16.0 -INF INF -INF INF outward @@ -50,39 +50,39 @@ fix_modify AtC mesh create_faceset rbndy box -16.0 6.0 -INF INF -INF INF ou variable tol equal 0.1 variable uBnd equal ${nEls}+${tol} variable lBnd equal ${nEls}-${tol} -fix_modify AtC mesh create_nodeset lbc -${uBnd} -${lBnd} -INF INF -INF INF +fix_modify AtC mesh create_nodeset lbc -${uBnd} -${lBnd} -INF INF -INF INF fix_modify AtC mesh create_nodeset rbc ${lBnd} ${uBnd} -INF INF -INF INF # fix a temperature -fix_modify AtC fix temperature all 20. -#fix_modify AtC initial temperature all 20. -#fix_modify AtC consistent_fe_initialization on +fix_modify AtC fix temperature all 20. +#fix_modify AtC initial temperature all 20. +#fix_modify AtC consistent_fe_initialization on # turn on thermostat -fix_modify AtC control thermal rescale 10 +fix_modify AtC control thermal rescale 10 fix_modify AtC internal_quadrature off # equilibrate MD field #dump D1 all atom 100 dump.bar1d_hoover_init #fix_modify AtC output bar1d_hoover_init 100 text binary -fix_modify AtC time_integration fractional_step -fix_modify AtC temperature_definition total -timestep 5 +fix_modify AtC time_integration fractional_step +fix_modify AtC temperature_definition total +timestep 5 variable xdof equal 3*count(ghost) -compute_modify thermo_temp extra ${xdof} +compute_modify thermo_temp extra/dof ${xdof} thermo_style custom step cpu etotal pe f_AtC[1] temp f_AtC[2] thermo_modify format 1 %6i format 2 %7.2g -thermo 100 -run 400 +thermo 100 +run 400 -fix_modify AtC unfix temperature all +fix_modify AtC unfix temperature all -fix_modify AtC filter type exponential +fix_modify AtC filter type exponential fix_modify AtC filter scale 1000.0 fix_modify AtC filter on # boundary conditions------------------------ # dirichlet with ramp (unstable when filtered due to instantaneous change in rate) -#fix_modify AtC fix temperature lbc temporal_ramp 20. 40. 25000. -#fix_modify AtC fix temperature rbc 20. +#fix_modify AtC fix temperature lbc temporal_ramp 20. 40. 25000. +#fix_modify AtC fix temperature rbc 20. #fix_modify AtC localized_lambda on #fix_modify AtC control thermal flux no_boundary #fix_modify AtC output test_rampFE 200 text binary @@ -94,7 +94,7 @@ fix_modify AtC filter on #fix_modify AtC fix temperature lbc 40. # dirichlet with rescaling -#fix_modify AtC filter off +#fix_modify AtC filter off #fix_modify AtC fix temperature all 20. #fix_modify AtC fix temperature lbc 40. #fix_modify AtC output test_rampFE 200 text binary @@ -126,13 +126,13 @@ fix_modify AtC fix temperature rbc 20. #fix_modify AtC lumped_lambda_solve on # hoover -fix_modify AtC control thermal hoover +fix_modify AtC control thermal hoover fix_modify AtC control localized_lambda on -fix_modify AtC control tolerance 1.e-14 +fix_modify AtC control tolerance 1.e-14 fix_modify AtC output bar1d_hooverFE 200 text binary #dump D1 all atom 200 dump.bar1d_hoover reset_timestep 0 fix_modify AtC reset_time -thermo 100 +thermo 100 run 5000 diff --git a/examples/PACKAGES/atc/thermal/in.bar1d_interpolate b/examples/PACKAGES/atc/thermal/in.bar1d_interpolate index 0333bf117d..7e1d6295b4 100644 --- a/examples/PACKAGES/atc/thermal/in.bar1d_interpolate +++ b/examples/PACKAGES/atc/thermal/in.bar1d_interpolate @@ -4,65 +4,65 @@ # 40.# The result should show heat diffusing through the FEM to the MD and back # out # to the FEM on the right. Insufficient time is captured to reach the # linear # steady state, but heat crossing both boundaries should be observed. -units real -atom_style atomic +units real +atom_style atomic # create domain -#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) +#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) # NOTE following 3 lines added for restart boundary f p p pair_style lj/cut 13.5 read_data temp.init lattice fcc 5.405 origin 0.25 0.25 0.25 -region simRegion block -12 12 -3 3 -3 3 +region simRegion block -12 12 -3 3 -3 3 # create atoms, NOTE commented out for restart -#region mdRegion block -5 5 -3 3 -3 3 -#boundary f p p -#create_box 1 mdRegion -#create_atoms 1 region mdRegion -#mass 1 39.95 +#region mdRegion block -5 5 -3 3 -3 3 +#boundary f p p +#create_box 1 mdRegion +#create_atoms 1 region mdRegion +#mass 1 39.95 # specify interal/ghost atoms -region mdInternal block -4 4 -3 3 -3 3 -group internal region mdInternal -group ghost subtract all internal +region mdInternal block -4 4 -3 3 -3 3 +group internal region mdInternal +group ghost subtract all internal # velocities have Vcm = 0, NOTE next three lines commented out for restart -#velocity internal create 40. 87287 mom yes loop geom -#pair_style lj/cut 13.5 -#pair_coeff 1 1 .238 3.405 13.5 -neighbor 5. bin -neigh_modify every 10 delay 0 check no +#velocity internal create 40. 87287 mom yes loop geom +#pair_style lj/cut 13.5 +#pair_coeff 1 1 .238 3.405 13.5 +neighbor 5. bin +neigh_modify every 10 delay 0 check no # ID group atc PhysicsType ParameterFile fix AtC internal atc thermal Ar_thermal.mat fix_modify AtC boundary ghost # numerical parameters -fix_modify AtC time_integration fractional_step +fix_modify AtC time_integration fractional_step # ID part keywords nx ny nz region fix_modify AtC mesh create 12 1 1 simRegion f p p fix_modify AtC mesh create_faceset ibndy box -4.0 4.0 -INF INF -INF INF in fix_modify AtC mesh create_faceset obndy box -4.0 4.0 -INF INF -INF INF outward # fix a temperature -fix_modify AtC fix temperature all 20. -#fix_modify AtC fix temperature all linear 0 0 0 -0.154 0 0 30. -#fix_modify AtC fix temperature all quadratic 0 0 0 -0.154 0 0 30. 0.01 0.0 0.0 0 0 0 +fix_modify AtC fix temperature all 20. +#fix_modify AtC fix temperature all linear 0 0 0 -0.154 0 0 30. +#fix_modify AtC fix temperature all quadratic 0 0 0 -0.154 0 0 30. 0.01 0.0 0.0 0 0 0 # turn on thermostat -fix_modify AtC control thermal rescale 10 +fix_modify AtC control thermal rescale 10 # equilibrate MD field #fix_modify AtC output bar1dfe_flux_init 100 -timestep 5 +timestep 5 variable xdof equal 3*count(ghost) -compute_modify thermo_temp extra ${xdof} +compute_modify thermo_temp extra/dof ${xdof} thermo_style custom step cpu etotal pe f_AtC[1] temp f_AtC[2] thermo_modify format 1 %6i format 2 %7.2g -thermo 100 -run 400 +thermo 100 +run 400 # change thermostat to hoover -fix_modify AtC unfix temperature all -fix_modify AtC control thermal none -fix_modify AtC control thermal flux interpolate -fix_modify AtC control localized_lambda on -#fix_modify AtC thermal control flux faceset obndy +fix_modify AtC unfix temperature all +fix_modify AtC control thermal none +fix_modify AtC control thermal flux interpolate +fix_modify AtC control localized_lambda on +#fix_modify AtC thermal control flux faceset obndy fix_modify AtC filter type exponential -fix_modify AtC filter scale 10000.0 -fix_modify AtC filter on +fix_modify AtC filter scale 10000.0 +fix_modify AtC filter on # add nodesets # ID mesh create_nodeset tag xmin xmax ymin ymax zmin zmax fix_modify AtC mesh create_nodeset lbc -12.1 -11.9 -INF INF -INF INF @@ -70,11 +70,11 @@ fix_modify AtC mesh create_nodeset rbc 11.9 12.1 -INF INF -INF INF fix_modify AtC fix temperature lbc 40. fix_modify AtC fix temperature rbc 20. # initialize filter -run 100 +run 100 # set up output, should be before a "run" fix_modify AtC output bar1d_interpolateFE 100 text # run with FE reset_timestep 0 -thermo 100 -#run 10 -run 10000 +thermo 100 +#run 10 +run 10000 diff --git a/examples/PACKAGES/atc/thermal/in.bar1d_lumped b/examples/PACKAGES/atc/thermal/in.bar1d_lumped index 153f7b632d..5321c45eb4 100644 --- a/examples/PACKAGES/atc/thermal/in.bar1d_lumped +++ b/examples/PACKAGES/atc/thermal/in.bar1d_lumped @@ -5,32 +5,32 @@ # out # to the FEM on the right. Insufficient time is captured to reach the # linear # steady state, but heat crossing both boundaries should be observed. echo both -units real -atom_style atomic +units real +atom_style atomic # create domain -#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) +#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) # NOTE following 3 lines added for restart boundary f p p pair_style lj/cut 13.5 read_data temp.init lattice fcc 5.405 origin 0.25 0.25 0.25 -region simRegion block -12 12 -3 3 -3 3 +region simRegion block -12 12 -3 3 -3 3 # create atoms, NOTE commented out for restart -#region mdRegion block -5 5 -3 3 -3 3 -#boundary f p p -#create_box 1 mdRegion -#create_atoms 1 region mdRegion -#mass 1 39.95 +#region mdRegion block -5 5 -3 3 -3 3 +#boundary f p p +#create_box 1 mdRegion +#create_atoms 1 region mdRegion +#mass 1 39.95 # specify interal/ghost atoms -region mdInternal block -4 4 -3 3 -3 3 -group internal region mdInternal -group ghost subtract all internal +region mdInternal block -4 4 -3 3 -3 3 +group internal region mdInternal +group ghost subtract all internal # velocities have Vcm = 0, NOTE next three lines commented out for restart -#velocity internal create 40. 87287 mom yes loop geom -#pair_style lj/cut 13.5 -#pair_coeff 1 1 .238 3.405 13.5 -neighbor 5. bin -neigh_modify every 10 delay 0 check no +#velocity internal create 40. 87287 mom yes loop geom +#pair_style lj/cut 13.5 +#pair_coeff 1 1 .238 3.405 13.5 +neighbor 5. bin +neigh_modify every 10 delay 0 check no # ID group atc PhysicsType ParameterFile fix AtC internal atc thermal Ar_thermal.mat fix_modify AtC boundary ghost @@ -42,30 +42,30 @@ fix_modify AtC mesh create 12 1 1 simRegion f p p fix_modify AtC mesh create_faceset ibndy box -4.0 4.0 -INF INF -INF INF in fix_modify AtC mesh create_faceset obndy box -4.0 4.0 -INF INF -INF INF outward # fix a temperature -fix_modify AtC fix temperature all 20. -#fix_modify AtC fix temperature all linear 0 0 0 -0.154 0 0 30. -#fix_modify AtC fix temperature all quadratic 0 0 0 -0.154 0 0 30. 0.01 0.0 0.0 0 0 0 +fix_modify AtC fix temperature all 20. +#fix_modify AtC fix temperature all linear 0 0 0 -0.154 0 0 30. +#fix_modify AtC fix temperature all quadratic 0 0 0 -0.154 0 0 30. 0.01 0.0 0.0 0 0 0 # turn on thermostat -fix_modify AtC control thermal rescale 10 +fix_modify AtC control thermal rescale 10 # output -thermo 100 +thermo 100 variable xdof equal 3*count(ghost) -compute_modify thermo_temp extra ${xdof} +compute_modify thermo_temp extra/dof ${xdof} thermo_style custom step cpu etotal pe f_AtC[1] temp f_AtC[2] thermo_modify format 1 %6i format 2 %7.2g # equilibrate MD field #fix_modify AtC output bar1d_lumped_initFE 1 text -timestep 5 -run 400 -#run 100 +timestep 5 +run 400 +#run 100 # change thermostat to hoover -fix_modify AtC unfix temperature all -#fix_modify AtC thermal control flux interpolate -fix_modify AtC control thermal flux faceset obndy -fix_modify AtC control localized_lambda on +fix_modify AtC unfix temperature all +#fix_modify AtC thermal control flux interpolate +fix_modify AtC control thermal flux faceset obndy +fix_modify AtC control localized_lambda on fix_modify AtC filter type exponential -fix_modify AtC filter scale 10000.0 -fix_modify AtC filter on +fix_modify AtC filter scale 10000.0 +fix_modify AtC filter on # add nodesets # ID mesh create_nodeset tag xmin xmax ymin ymax zmin zmax fix_modify AtC mesh create_nodeset lbc -12.1 -11.9 -INF INF -INF INF @@ -73,13 +73,13 @@ fix_modify AtC mesh create_nodeset rbc 11.9 12.1 -INF INF -INF INF fix_modify AtC fix temperature lbc 80. fix_modify AtC fix temperature rbc 80. # initialize -thermo 10 -run 100 +thermo 10 +run 100 # relax fix_modify AtC unfix temperature all # output fix_modify AtC output bar1d_lumpedFE 100 text # run with FE reset_timestep 0 -thermo 100 -run 10000 +thermo 100 +run 10000 diff --git a/examples/PACKAGES/atc/two_temperature/in.uniform_heating b/examples/PACKAGES/atc/two_temperature/in.uniform_heating index 0565fe8449..81a649e847 100644 --- a/examples/PACKAGES/atc/two_temperature/in.uniform_heating +++ b/examples/PACKAGES/atc/two_temperature/in.uniform_heating @@ -1,41 +1,41 @@ # needs description #AtC Thermal Coupling echo both -units real -atom_style atomic -boundary f p p +units real +atom_style atomic +boundary f p p # create domain -#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) -pair_style lj/cut 13.5 -read_data uniform_heating.init +#lattice type reduced density rho* = 4*(sigma/a)^3, where N=4 for fcc, s = 3.405 A (Wagner) and a = 5.25 A (Ashcroft & Mermin, p. 70) +pair_style lj/cut 13.5 +read_data uniform_heating.init lattice fcc 5.405 origin 0.25 0.25 0.25 -region mdRegion block -8 8 -3 3 -3 3 -region mdInternal block -6 6 -3 3 -3 3 -group internal region mdInternal -neighbor 5. bin -neigh_modify every 10 delay 0 check no +region mdRegion block -8 8 -3 3 -3 3 +region mdInternal block -6 6 -3 3 -3 3 +group internal region mdInternal +neighbor 5. bin +neigh_modify every 10 delay 0 check no # ID group atc PhysicsType ParameterFile fix AtC internal atc two_temperature Ar_ttm.mat # ID part keywords nx ny nz region fix_modify AtC mesh create 6 1 1 mdInternal f p p fix_modify AtC internal_quadrature on # fix a temperature -fix_modify AtC initial temperature all 20. -fix_modify AtC fix temperature all 20. -fix_modify AtC initial electron_temperature all 20. -fix_modify AtC fix electron_temperature all 20. +fix_modify AtC initial temperature all 20. +fix_modify AtC fix temperature all 20. +fix_modify AtC initial electron_temperature all 20. +fix_modify AtC fix electron_temperature all 20. # turn on thermostat -fix_modify AtC control thermal rescale 10 +fix_modify AtC control thermal rescale 10 # output thermo_style custom step cpu pe etotal temp f_AtC[1] f_AtC[2] -thermo 100 +thermo 100 log uniform_heating.log # make thermo output the correct temperature by removing ghost dof # variable xdof equal 3*count(ghost) -# compute_modify thermo_temp extra ${xdof} +# compute_modify thermo_temp extra/dof ${xdof} # equilibrate MD field -timestep 5 -run 400 +timestep 5 +run 400 # change thermostat fix_modify AtC output uniform_heatingFE 100 text fix_modify AtC unfix temperature all @@ -50,4 +50,4 @@ fix_modify AtC fix temperature rbc 20. fix_modify AtC source temperature all 6.3363e-10 # run with FE reset_timestep 0 -run 1000 +run 1000 diff --git a/examples/PACKAGES/charge_regulation/in.chreg-acid b/examples/PACKAGES/charge_regulation/in.chreg-acid index 68ef5e1b7c..30ae13c6da 100644 --- a/examples/PACKAGES/charge_regulation/in.chreg-acid +++ b/examples/PACKAGES/charge_regulation/in.chreg-acid @@ -25,7 +25,7 @@ pair_modify shift yes ######### VERLET INTEGRATION WITH LANGEVIN THERMOSTAT ########### fix fnve all nve compute dtemp all temp -compute_modify dtemp dynamic yes +compute_modify dtemp dynamic/dof yes fix fT all langevin 1.0 1.0 1.0 123 fix_modify fT temp dtemp diff --git a/examples/PACKAGES/charge_regulation/in.chreg-acid-real b/examples/PACKAGES/charge_regulation/in.chreg-acid-real index d7225f33ea..361027c596 100644 --- a/examples/PACKAGES/charge_regulation/in.chreg-acid-real +++ b/examples/PACKAGES/charge_regulation/in.chreg-acid-real @@ -6,12 +6,12 @@ neighbor 10.0 bin read_data data.chreg-acid-real #real units -variable sigma equal 7.2 # particle diameter 0.72 nm -variable temperature equal 298 # temperature 298 K +variable sigma equal 7.2 # particle diameter 0.72 nm +variable temperature equal 298 # temperature 298 K variable kb index 0.0019872067 # kB in Kcal/mol/K -variable epsilon equal ${kb}*${temperature} -variable tunit equal 2000 # time unit is 2000 fs -variable timestep equal 0.005*${tunit} +variable epsilon equal ${kb}*${temperature} +variable tunit equal 2000 # time unit is 2000 fs +variable timestep equal 0.005*${tunit} variable cut_long equal 12.5*${sigma} variable nevery equal 100 @@ -27,13 +27,13 @@ velocity all create ${temperature} 8008 loop geom pair_style lj/cut/coul/long ${cut_lj} ${cut_long} pair_coeff * * ${epsilon} ${sigma} kspace_style pppm 1.0e-3 -dielectric 78 +dielectric 78 pair_modify shift yes ######### VERLET INTEGRATION WITH LANGEVIN THERMOSTAT ########### fix fnve all nve compute dtemp all temp -compute_modify dtemp dynamic yes +compute_modify dtemp dynamic/dof yes fix fT all langevin $(v_temperature) $(v_temperature) $(v_tunit) 123 fix_modify fT temp dtemp diff --git a/examples/PACKAGES/charge_regulation/in.chreg-polymer b/examples/PACKAGES/charge_regulation/in.chreg-polymer index 055032c018..068fe35c90 100644 --- a/examples/PACKAGES/charge_regulation/in.chreg-polymer +++ b/examples/PACKAGES/charge_regulation/in.chreg-polymer @@ -17,7 +17,7 @@ dielectric 1.0 ######### VERLET INTEGRATION WITH LANGEVIN THERMOSTAT ########### fix fnve all nve compute dtemp all temp -compute_modify dtemp dynamic yes +compute_modify dtemp dynamic/dof yes fix fT all langevin 1.0 1.0 1.0 123 fix_modify fT temp dtemp diff --git a/examples/QUANTUM/LATTE/latte_mdi.py b/examples/QUANTUM/LATTE/latte_mdi.py index 0170feee1f..ba1a83120a 100644 --- a/examples/QUANTUM/LATTE/latte_mdi.py +++ b/examples/QUANTUM/LATTE/latte_mdi.py @@ -153,7 +153,7 @@ def mdi_engine(other_options): # engine --> driver - mdi.MDI_Register_Command("@DEFAULT","LATTICE_FORCES") mdi.MDI_Register_Command("@DEFAULT"," driver - mdi.MDI_Register_Command("@DEFAULT","LATTICE_FORCES") #mdi.MDI_Register_Command("@DEFAULT"," driver - mdi.MDI_Register_Command("@DEFAULT",">>>> hey!") + #elems = self.as_tensor(data.elems).type(torch.int64).reshape(1, data.ntotal) + + """ + elems = self.as_tensor(data.elems).type(torch.int64) + 1 + #z_vals = self.species_set[elems+1] + pair_i = self.as_tensor(data.pair_i).type(torch.int64) + pair_j = self.as_tensor(data.pair_j).type(torch.int64) + rij = self.as_tensor(data.rij).type(torch.float64).requires_grad_(True) + nlocal = self.as_tensor(data.nlistatoms) + """ + + rij = data.rij + + #(total_energy, fij) = self.network(rij, None, None, None, nlocal, elems, pair_i, pair_j, "cpu", dtype=torch.float64, mode="lammps") + + test = self.model(rij) + + #data.update_pair_forces(fij) + #data.energy = total_energy.item() + + pass + +def setup_LAMMPS(energy): + """ + + :param energy: energy node for lammps interface + :return: graph for computing from lammps MLIAP unified inputs. + """ + + model = TheModelClass(*args, **kwargs) + + save_state_dict = torch.load("Ta_Pytorch.pt") + model.load_state_dict(save_state_dict["model_state_dict"]) + + + #model.load_state_dict(torch.load(PATH)) + model.eval() + + #model.eval() + return model \ No newline at end of file diff --git a/fortran/lammps.f90 b/fortran/lammps.f90 index ba3997ac8e..28e40bca44 100644 --- a/fortran/lammps.f90 +++ b/fortran/lammps.f90 @@ -20,7 +20,7 @@ ! University of Missouri, 2012-2020 ! ! Contributing authors: -! - Axel Kohlmeyer , Temple University, 2020-2022 +! - Axel Kohlmeyer , Temple University, 2020-2023 ! - Karl D. Hammond , University of Missouri, 2022 ! ! The Fortran module tries to follow the API of the C library interface diff --git a/lib/gpu/lal_amoeba.cu b/lib/gpu/lal_amoeba.cu index 82a42cff6c..e7c313301e 100644 --- a/lib/gpu/lal_amoeba.cu +++ b/lib/gpu/lal_amoeba.cu @@ -585,7 +585,12 @@ __kernel void k_amoeba_multipole(const __global numtyp4 *restrict x_, numtyp ralpha = aewald * r; numtyp exp2a = ucl_exp(-ralpha*ralpha); numtyp bn[6]; +#ifdef INTEL_OCL + numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*ralpha); + bn[0] = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * exp2a * rinv; +#else bn[0] = ucl_erfc(ralpha) * rinv; +#endif numtyp alsq2 = (numtyp)2.0 * aewald*aewald; numtyp alsq2n = (numtyp)0.0; @@ -802,7 +807,12 @@ __kernel void k_amoeba_udirect2b(const __global numtyp4 *restrict x_, numtyp ralpha = aewald * r; numtyp exp2a = ucl_exp(-ralpha*ralpha); numtyp bn[4], bcn[3]; +#ifdef INTEL_OCL + numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*ralpha); + bn[0] = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * exp2a * rinv; +#else bn[0] = ucl_erfc(ralpha) * rinv; +#endif numtyp aefac = aesq2n; for (int m = 1; m <= 3; m++) { @@ -976,7 +986,12 @@ __kernel void k_amoeba_umutual2b(const __global numtyp4 *restrict x_, numtyp ralpha = aewald * r; numtyp exp2a = ucl_exp(-ralpha*ralpha); numtyp bn[4]; +#ifdef INTEL_OCL + numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*ralpha); + bn[0] = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * exp2a * rinv; +#else bn[0] = ucl_erfc(ralpha) * rinv; +#endif numtyp aefac = aesq2n; for (int m = 1; m <= 3; m++) { @@ -992,7 +1007,8 @@ __kernel void k_amoeba_umutual2b(const __global numtyp4 *restrict x_, numtyp damp = pdi * coeff[jtype].x; // pdamp[jtype] if (damp != (numtyp)0.0) { numtyp pgamma = MIN(pti,coeff[jtype].y); // thole[jtype] - damp = pgamma * ucl_powr(r/damp,(numtyp)3.0); + numtyp rdamp = r/damp; + damp = pgamma * rdamp*rdamp*rdamp; if (damp < (numtyp)50.0) { numtyp expdamp = ucl_exp(-damp); scale3 = (numtyp)1.0 - expdamp; @@ -1230,7 +1246,12 @@ __kernel void k_amoeba_polar(const __global numtyp4 *restrict x_, numtyp ralpha = aewald * r; numtyp exp2a = ucl_exp(-ralpha*ralpha); numtyp bn[5]; +#ifdef INTEL_OCL + numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*ralpha); + bn[0] = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * exp2a * rinv; +#else bn[0] = ucl_erfc(ralpha) * rinv; +#endif numtyp alsq2 = (numtyp)2.0 * aewald*aewald; numtyp alsq2n = (numtyp)0.0; diff --git a/lib/gpu/lal_base_amoeba.cpp b/lib/gpu/lal_base_amoeba.cpp index 0821a33b06..c41c66fb5f 100644 --- a/lib/gpu/lal_base_amoeba.cpp +++ b/lib/gpu/lal_base_amoeba.cpp @@ -420,6 +420,11 @@ void BaseAmoebaT::compute_udirect2b(int *host_amtype, int *host_amgroup, double cast_extra_data(host_amtype, host_amgroup, host_rpole, host_uind, host_uinp, host_pval); atom->add_extra_data(); + if (_max_tep_size>_max_fieldp_size) { + _max_fieldp_size = _max_tep_size; + _fieldp.resize(_max_fieldp_size*6); + } + *fieldp_ptr=_fieldp.host.begin(); // specify the correct cutoff and alpha values diff --git a/lib/gpu/lal_base_amoeba.h b/lib/gpu/lal_base_amoeba.h index 0eaaafeb1e..f415b30334 100644 --- a/lib/gpu/lal_base_amoeba.h +++ b/lib/gpu/lal_base_amoeba.h @@ -203,7 +203,7 @@ class BaseAmoeba { virtual void update_fieldp(void **fieldp_ptr) { *fieldp_ptr=_fieldp.host.begin(); // _fieldp store both arrays, one after another - _fieldp.update_host(_max_fieldp_size*8,false); + _fieldp.update_host(_max_fieldp_size*6,false); } /// setup a plan for FFT, where size is the number of elements diff --git a/lib/gpu/lal_device.cpp b/lib/gpu/lal_device.cpp index cbf3f5f885..70ba373a65 100644 --- a/lib/gpu/lal_device.cpp +++ b/lib/gpu/lal_device.cpp @@ -29,7 +29,7 @@ const char *ocl_prefetch_test = " #if (NBOR_PREFETCH == 1) \n"\ " inline void ucl_prefetch(const __global int *p) { prefetch(p, 1); } \n"\ -" #else \n"\ +" #elif (NBOR_PREFETCH == 2) \n"\ " enum LSC_LDCC {LSC_LDCC_DEFAULT, LSC_LDCC_L1UC_L3UC, LSC_LDCC_L1UC_L3C, \n"\ " LSC_LDCC_L1C_L3UC, LSC_LDCC_L1C_L3C, LSC_LDCC_L1S_L3UC, \n"\ " LSC_LDCC_L1S_L3C, LSC_LDCC_L1IAR_L3C, }; \n"\ @@ -745,7 +745,14 @@ void DeviceT::estimate_gpu_overhead(const int kernel_calls, gpu_overhead=0.0; gpu_driver_overhead=0.0; - for (int z=0; z<11; z++) { + // TODO: XXX + // The following estimation currently fails on Intel GPUs + // that do not support double precision with OpenCL error code -5. + // Until we have a better solution, we just skip this test in this case. + int zloops = 11; + if (!gpu->double_precision()) zloops = 0; + + for (int z=0; z < zloops; z++) { gpu->sync(); gpu_barrier(); over_timer.start(); diff --git a/lib/gpu/lal_hippo.cpp b/lib/gpu/lal_hippo.cpp index 24ffae8de2..8d6ad5dfb2 100644 --- a/lib/gpu/lal_hippo.cpp +++ b/lib/gpu/lal_hippo.cpp @@ -211,7 +211,7 @@ void HippoT::compute_repulsion(const int /*ago*/, const int inum_full, if (inum_full>this->_max_tep_size) { this->_max_tep_size=static_cast(static_cast(inum_full)*1.10); - this->_tep.resize(this->_max_tep_size*4); + this->_tep.resize(this->_max_tep_size*3); } *tep_ptr=this->_tep.host.begin(); @@ -226,7 +226,7 @@ void HippoT::compute_repulsion(const int /*ago*/, const int inum_full, repulsion(this->_eflag,this->_vflag); // copy tep from device to host - this->_tep.update_host(this->_max_tep_size*4,false); + this->_tep.update_host(this->_max_tep_size*3,false); } // --------------------------------------------------------------------------- @@ -366,7 +366,7 @@ void HippoT::compute_multipole_real(const int /*ago*/, const int inum_full, if (inum_full>this->_max_tep_size) { this->_max_tep_size=static_cast(static_cast(inum_full)*1.10); - this->_tep.resize(this->_max_tep_size*4); + this->_tep.resize(this->_max_tep_size*3); } *tep_ptr=this->_tep.host.begin(); @@ -376,7 +376,7 @@ void HippoT::compute_multipole_real(const int /*ago*/, const int inum_full, multipole_real(this->_eflag,this->_vflag); // copy tep from device to host - this->_tep.update_host(this->_max_tep_size*4,false); + this->_tep.update_host(this->_max_tep_size*3,false); } // --------------------------------------------------------------------------- @@ -434,6 +434,10 @@ void HippoT::compute_udirect2b(int * /*host_amtype*/, int * /*host_amgroup*/, do this->cast_extra_data(nullptr, nullptr, nullptr, host_uind, host_uinp, host_pval); this->atom->add_extra_data(); + if (this->_max_tep_size>this->_max_fieldp_size) { + this->_max_fieldp_size = this->_max_tep_size; + this->_fieldp.resize(this->_max_fieldp_size*6); + } *fieldp_ptr=this->_fieldp.host.begin(); this->_off2_polar = off2_polar; @@ -442,7 +446,7 @@ void HippoT::compute_udirect2b(int * /*host_amtype*/, int * /*host_amgroup*/, do // copy field and fieldp from device to host (_fieldp store both arrays, one after another) - this->_fieldp.update_host(this->_max_fieldp_size*8,false); + this->_fieldp.update_host(this->_max_fieldp_size*6,false); } // --------------------------------------------------------------------------- @@ -580,7 +584,7 @@ void HippoT::compute_polar_real(int * /*host_amtype*/, int * /*host_amgroup*/, d this->device->add_ans_object(this->ans); // copy tep from device to host - this->_tep.update_host(this->_max_tep_size*4,false); + this->_tep.update_host(this->_max_tep_size*3,false); } // --------------------------------------------------------------------------- diff --git a/lib/gpu/lal_hippo.cu b/lib/gpu/lal_hippo.cu index 0a0f4f02be..7de7bd594f 100644 --- a/lib/gpu/lal_hippo.cu +++ b/lib/gpu/lal_hippo.cu @@ -845,7 +845,7 @@ __kernel void k_hippo_dispersion(const __global numtyp4 *restrict x_, numtyp scale = factor_disp * damp*damp; scale = scale - (numtyp)1.0; numtyp e = -ci * ck * (expa+scale) / r6; - numtyp rterm = -ucl_powr(ralpha2,(numtyp)3.0) * expterm / r; + numtyp rterm = -ralpha2*ralpha2*ralpha2 * expterm / r; numtyp de = (numtyp)-6.0*e/r2 - ci*ck*rterm/r7 - (numtyp)2.0*ci*ck*factor_disp*damp*ddamp/r7; energy+= e; @@ -1072,7 +1072,12 @@ __kernel void k_hippo_multipole(const __global numtyp4 *restrict x_, numtyp ralpha = aewald * r; numtyp exp2a = ucl_exp(-ralpha*ralpha); numtyp bn[6]; +#ifdef INTEL_OCL + numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*ralpha); + bn[0] = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * exp2a * rinv; +#else bn[0] = ucl_erfc(ralpha) * rinv; +#endif numtyp alsq2 = (numtyp)2.0 * aewald*aewald; numtyp alsq2n = (numtyp)0.0; @@ -1319,7 +1324,12 @@ __kernel void k_hippo_udirect2b(const __global numtyp4 *restrict x_, numtyp ralpha = aewald * r; numtyp exp2a = ucl_exp(-ralpha*ralpha); numtyp bn[4]; +#ifdef INTEL_OCL + numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*ralpha); + bn[0] = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * exp2a * rinv; +#else bn[0] = ucl_erfc(ralpha) * rinv; +#endif numtyp aefac = aesq2n; for (int m = 1; m <= 3; m++) { @@ -1477,7 +1487,12 @@ __kernel void k_hippo_umutual2b(const __global numtyp4 *restrict x_, numtyp ralpha = aewald * r; numtyp exp2a = ucl_exp(-ralpha*ralpha); numtyp bn[4]; +#ifdef INTEL_OCL + numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*ralpha); + bn[0] = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * exp2a * rinv; +#else bn[0] = ucl_erfc(ralpha) * rinv; +#endif numtyp aefac = aesq2n; for (int m = 1; m <= 3; m++) { @@ -1702,7 +1717,12 @@ __kernel void k_hippo_polar(const __global numtyp4 *restrict x_, numtyp ralpha = aewald * r; numtyp exp2a = ucl_exp(-ralpha*ralpha); numtyp bn[5]; +#ifdef INTEL_OCL + numtyp t = ucl_recip((numtyp)1.0 + EWALD_P*ralpha); + bn[0] = t * (A1+t*(A2+t*(A3+t*(A4+t*A5)))) * exp2a * rinv; +#else bn[0] = ucl_erfc(ralpha) * rinv; +#endif numtyp alsq2 = (numtyp)2.0 * aewald*aewald; numtyp alsq2n = (numtyp)0.0; diff --git a/lib/gpu/lal_pre_ocl_config.h b/lib/gpu/lal_pre_ocl_config.h index a854b223ba..d5cd66feca 100644 --- a/lib/gpu/lal_pre_ocl_config.h +++ b/lib/gpu/lal_pre_ocl_config.h @@ -43,7 +43,7 @@ const char * ocl_config_strings[] = "NVIDIA_GPU,203,32,32,1,1,4,8,2,256,256,128,64,128,8,128,11,128,8,0", "AMD_GPU,403,64,64,0,1,4,8,2,256,256,128,64,128,8,128,11,128,8,0", #ifdef _SINGLE_SINGLE - "INTEL_GPU,500,8,32,1,1,4,8,2,128,128,128,128,64,8,128,8,128,8,2", + "INTEL_GPU,500,8,32,1,1,4,8,2,128,128,128,128,64,8,128,8,128,8,0", "APPLE_GPU,600,16,16,0,1,4,8,1,64,64,64,64,64,8,128,8,128,8,0", #else "INTEL_GPU,500,8,32,1,1,2,8,2,128,128,128,128,64,8,128,8,128,8,2", diff --git a/lib/gpu/lal_preprocessor.h b/lib/gpu/lal_preprocessor.h index d3e2481646..93d6936f38 100644 --- a/lib/gpu/lal_preprocessor.h +++ b/lib/gpu/lal_preprocessor.h @@ -333,12 +333,12 @@ inline void ucl_prefetch(const __global int *p) { struct _lgpu_float3 { float x; float y; float z; }; -struct _lgpu_double3 { - double x; double y; double z; -}; #ifdef _SINGLE_SINGLE #define acctyp3 struct _lgpu_float3 #else +struct _lgpu_double3 { + double x; double y; double z; +}; #define acctyp3 struct _lgpu_double3 #endif diff --git a/lib/molfile/molfile_plugin.h b/lib/molfile/molfile_plugin.h index 491cd375bb..a417b82e96 100644 --- a/lib/molfile/molfile_plugin.h +++ b/lib/molfile/molfile_plugin.h @@ -987,4 +987,3 @@ typedef struct { } molfile_plugin_t; #endif - diff --git a/lib/molfile/vmdplugin.h b/lib/molfile/vmdplugin.h index 7afc358e97..9336d3e24f 100644 --- a/lib/molfile/vmdplugin.h +++ b/lib/molfile/vmdplugin.h @@ -11,7 +11,7 @@ * * $RCSfile: vmdplugin.h,v $ * $Author: johns $ $Locker: $ $State: Exp $ - * $Revision: 1.34 $ $Date: 2018/05/02 03:12:56 $ + * $Revision: 1.35 $ $Date: 2020/10/16 07:50:56 $ * ***************************************************************************/ @@ -58,8 +58,8 @@ /*@}*/ -/** "WIN32" is defined on both WIN32 and WIN64 platforms... */ -#if (defined(WIN32)) +/** Detect compilations targeting Windows x86 and x64 platforms */ +#if (defined(WIN32) || defined(WIN64) || defined(_MSC_VER)) #define WIN32_LEAN_AND_MEAN #include diff --git a/python/install.py b/python/install.py index 25784791b4..853479e9f6 100644 --- a/python/install.py +++ b/python/install.py @@ -11,7 +11,7 @@ independently and used to build the wheel without installing it. """ from __future__ import print_function -import sys,os,shutil,glob,subprocess +import sys, os, shutil, glob, subprocess from argparse import ArgumentParser parser = ArgumentParser(prog='install.py', @@ -105,12 +105,12 @@ os.system(sys.executable + ' makewheel.py') for wheel in glob.glob('lammps-*.whl'): if args.wheeldir: shutil.copy(wheel, args.wheeldir) - -print('wheel = ', wheel) + else: + shutil.copy(wheel, olddir) # remove temporary folders and files os.chdir(olddir) -shutil.rmtree('build-python',True) +shutil.rmtree('build-python', True) # stop here if we were asked not to install the wheel we created if args.noinstall: diff --git a/src/.gitignore b/src/.gitignore index 2cb2fd315b..6e2a8b92c9 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -60,6 +60,8 @@ /pair_lepton.h /pair_lepton_coul.cpp /pair_lepton_coul.h +/pair_lepton_sphere.cpp +/pair_lepton_sphere.h /bond_lepton.cpp /bond_lepton.h /angle_lepton.cpp diff --git a/src/BODY/pair_body_rounded_polyhedron.cpp b/src/BODY/pair_body_rounded_polyhedron.cpp index d9a79abad0..9425707ef1 100644 --- a/src/BODY/pair_body_rounded_polyhedron.cpp +++ b/src/BODY/pair_body_rounded_polyhedron.cpp @@ -1910,7 +1910,7 @@ void PairBodyRoundedPolyhedron::inside_polygon(int ibody, int face_index, iffirst = facfirst[ibody]; rradi = rounded_radius[ibody]; double rradsq = rradi*rradi; - anglesum1 = anglesum2 = 0;; + anglesum1 = anglesum2 = 0; for (i = 0; i < MAX_FACE_SIZE; i++) { npi1 = static_cast(face[iffirst+face_index][i]); if (npi1 < 0) break; diff --git a/src/BPM/atom_vec_bpm_sphere.cpp b/src/BPM/atom_vec_bpm_sphere.cpp index 375a33c28d..2820a74c8a 100644 --- a/src/BPM/atom_vec_bpm_sphere.cpp +++ b/src/BPM/atom_vec_bpm_sphere.cpp @@ -17,7 +17,6 @@ #include "comm.h" #include "error.h" #include "fix.h" -#include "fix_adapt.h" #include "math_const.h" #include "modify.h" @@ -33,6 +32,7 @@ AtomVecBPMSphere::AtomVecBPMSphere(LAMMPS *_lmp) : AtomVec(_lmp) mass_type = PER_ATOM; molecular = Atom::MOLECULAR; bonds_allow = 1; + radvary = 0; atom->molecule_flag = 1; atom->sphere_flag = 1; @@ -98,16 +98,12 @@ void AtomVecBPMSphere::init() // check if optional radvary setting should have been set to 1 - for (auto ifix : modify->get_fix_by_style("^adapt")) { - if (radvary == 0) { - if ((strcmp(ifix->style, "adapt") == 0) && (dynamic_cast(ifix)->diamflag)) - error->all(FLERR, "Fix adapt changes atom radii but atom_style bpm/sphere is not dynamic"); - // cannot properly check for fix adapt/fep since its header is optional - if ((strcmp(ifix->style, "adapt/fep") == 0) && (comm->me == 0)) - error->warning( - FLERR, "Fix adapt/fep may change atom radii but atom_style bpm/sphere is not dynamic"); + if (radvary == 0) + for (const auto &ifix : modify->get_fix_by_style("^adapt")) { + if (ifix->diam_flag) + error->all(FLERR, "Fix {} changes atom radii but atom_style bpm/sphere is not dynamic", + ifix->style); } - } } /* ---------------------------------------------------------------------- diff --git a/src/BPM/bond_bpm.cpp b/src/BPM/bond_bpm.cpp index da189ccaf5..3ebeed3f1d 100644 --- a/src/BPM/bond_bpm.cpp +++ b/src/BPM/bond_bpm.cpp @@ -94,10 +94,10 @@ void BondBPM::init_style() } if (overlay_flag) { - if (force->special_lj[1] != 1.0) + if (force->special_lj[1] != 1.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0 || + force->special_coul[1] != 1.0 || force->special_coul[2] != 1.0 || force->special_coul[3] != 1.0) error->all(FLERR, - "With overlay/pair, BPM bond styles require special_bonds weight of 1.0 for " - "first neighbors"); + "With overlay/pair yes, BPM bond styles require a value of 1.0 for all special_bonds weights"); if (id_fix_update) { modify->delete_fix(id_fix_update); delete[] id_fix_update; @@ -106,18 +106,18 @@ void BondBPM::init_style() } else { // Require atoms know about all of their bonds and if they break if (force->newton_bond && break_flag) - error->all(FLERR, "Without overlay/pair or break/no, BPM bond styles require Newton bond off"); + error->all(FLERR, "With overlay/pair no, or break yes, BPM bond styles require Newton bond off"); // special lj must be 0 1 1 to censor pair forces between bonded particles - // special coulomb must be 1 1 1 to ensure all pairs are included in the - // neighbor list and 1-3 and 1-4 special bond lists are skipped if (force->special_lj[1] != 0.0 || force->special_lj[2] != 1.0 || force->special_lj[3] != 1.0) error->all(FLERR, - "Without overlay/pair, BPM bond styles requires special LJ weights = 0,1,1"); - if (force->special_coul[1] != 1.0 || force->special_coul[2] != 1.0 || - force->special_coul[3] != 1.0) + "With overlay/pair no, BPM bond styles require special LJ weights = 0,1,1"); + // if bonds can break, special coulomb must be 1 1 1 to ensure all pairs are included in the + // neighbor list and 1-3 and 1-4 special bond lists are skipped + if (break_flag && (force->special_coul[1] != 1.0 || force->special_coul[2] != 1.0 || + force->special_coul[3] != 1.0)) error->all(FLERR, - "Without overlay/pair, BPM bond styles requires special Coulomb weights = 1,1,1"); + "With overlay/pair no, and break yes, BPM bond styles requires special Coulomb weights = 1,1,1"); if (id_fix_dummy && break_flag) { id_fix_update = utils::strdup("BPM_UPDATE_SPECIAL_BONDS"); @@ -189,11 +189,11 @@ void BondBPM::settings(int narg, char **arg) } else if (strcmp(arg[iarg], "overlay/pair") == 0) { if (iarg + 1 > narg) error->all(FLERR, "Illegal bond bpm command, missing option for overlay/pair"); overlay_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp); - iarg++; + iarg += 2; } else if (strcmp(arg[iarg], "break") == 0) { if (iarg + 1 > narg) error->all(FLERR, "Illegal bond bpm command, missing option for break"); break_flag = utils::logical(FLERR, arg[iarg + 1], false, lmp); - iarg++; + iarg += 2; } else { leftover_iarg.push_back(iarg); iarg++; @@ -335,7 +335,7 @@ void BondBPM::read_restart(FILE *fp) void BondBPM::process_broken(int i, int j) { if (!break_flag) - error->one(FLERR, "BPM bond broke with break/no option"); + error->one(FLERR, "BPM bond broke with break no option"); if (fix_store_local) { for (int n = 0; n < nvalues; n++) (this->*pack_choice[n])(n, i, j); diff --git a/src/CG-DNA/bond_oxdna_fene.cpp b/src/CG-DNA/bond_oxdna_fene.cpp index 2d471cbbe6..780b71e44c 100644 --- a/src/CG-DNA/bond_oxdna_fene.cpp +++ b/src/CG-DNA/bond_oxdna_fene.cpp @@ -146,7 +146,7 @@ void BondOxdnaFene::ev_tally_xyz(int i, int j, int nlocal, int newton_bond, doub void BondOxdnaFene::compute(int eflag, int vflag) { int a, b, in, type; - double delf[3], delta[3], deltb[3]; // force, torque increment;; + double delf[3], delta[3], deltb[3]; // force, torque increment double delr[3], ebond, fbond; double rsq, Deltasq, rlogarg; double r, rr0, rr0sq; diff --git a/src/CG-DNA/pair_oxdna2_coaxstk.cpp b/src/CG-DNA/pair_oxdna2_coaxstk.cpp index 844ba56577..527020076c 100644 --- a/src/CG-DNA/pair_oxdna2_coaxstk.cpp +++ b/src/CG-DNA/pair_oxdna2_coaxstk.cpp @@ -612,7 +612,7 @@ void PairOxdna2Coaxstk::coeff(int narg, char **arg) (0.5 * (cut_cxst_lo_one - cut_cxst_0_one) * (cut_cxst_lo_one - cut_cxst_0_one) - k_cxst_one * 0.5 * (cut_cxst_0_one -cut_cxst_c_one) * (cut_cxst_0_one - cut_cxst_c_one)/k_cxst_one); - cut_cxst_lc_one = cut_cxst_lo_one - 0.5 * (cut_cxst_lo_one - cut_cxst_0_one)/b_cxst_lo_one;; + cut_cxst_lc_one = cut_cxst_lo_one - 0.5 * (cut_cxst_lo_one - cut_cxst_0_one)/b_cxst_lo_one; b_cxst_hi_one = 0.25 * (cut_cxst_hi_one - cut_cxst_0_one) * (cut_cxst_hi_one - cut_cxst_0_one)/ (0.5 * (cut_cxst_hi_one - cut_cxst_0_one) * (cut_cxst_hi_one - cut_cxst_0_one) - diff --git a/src/CG-DNA/pair_oxdna2_dh.cpp b/src/CG-DNA/pair_oxdna2_dh.cpp index dcfe3f9ea1..a8114c84d7 100644 --- a/src/CG-DNA/pair_oxdna2_dh.cpp +++ b/src/CG-DNA/pair_oxdna2_dh.cpp @@ -79,7 +79,7 @@ void PairOxdna2Dh::compute_interaction_sites(double e1[3], void PairOxdna2Dh::compute(int eflag, int vflag) { - double delf[3],delta[3],deltb[3]; // force, torque increment;; + double delf[3],delta[3],deltb[3]; // force, torque increment double rtmp_s[3],delr[3]; double evdwl,fpair,factor_lj; double r,rsq,rinv; diff --git a/src/CG-DNA/pair_oxdna_coaxstk.cpp b/src/CG-DNA/pair_oxdna_coaxstk.cpp index b9b34338fe..679bfbf18d 100644 --- a/src/CG-DNA/pair_oxdna_coaxstk.cpp +++ b/src/CG-DNA/pair_oxdna_coaxstk.cpp @@ -749,7 +749,7 @@ void PairOxdnaCoaxstk::coeff(int narg, char **arg) (0.5 * (cut_cxst_lo_one - cut_cxst_0_one) * (cut_cxst_lo_one - cut_cxst_0_one) - k_cxst_one * 0.5 * (cut_cxst_0_one -cut_cxst_c_one) * (cut_cxst_0_one - cut_cxst_c_one)/k_cxst_one); - cut_cxst_lc_one = cut_cxst_lo_one - 0.5 * (cut_cxst_lo_one - cut_cxst_0_one)/b_cxst_lo_one;; + cut_cxst_lc_one = cut_cxst_lo_one - 0.5 * (cut_cxst_lo_one - cut_cxst_0_one)/b_cxst_lo_one; b_cxst_hi_one = 0.25 * (cut_cxst_hi_one - cut_cxst_0_one) * (cut_cxst_hi_one - cut_cxst_0_one)/ (0.5 * (cut_cxst_hi_one - cut_cxst_0_one) * (cut_cxst_hi_one - cut_cxst_0_one) - diff --git a/src/CG-DNA/pair_oxdna_xstk.cpp b/src/CG-DNA/pair_oxdna_xstk.cpp index d95004f537..6ef6091889 100644 --- a/src/CG-DNA/pair_oxdna_xstk.cpp +++ b/src/CG-DNA/pair_oxdna_xstk.cpp @@ -696,7 +696,7 @@ void PairOxdnaXstk::coeff(int narg, char **arg) (0.5 * (cut_xst_lo_one - cut_xst_0_one) * (cut_xst_lo_one - cut_xst_0_one) - k_xst_one * 0.5 * (cut_xst_0_one -cut_xst_c_one) * (cut_xst_0_one - cut_xst_c_one)/k_xst_one); - cut_xst_lc_one = cut_xst_lo_one - 0.5 * (cut_xst_lo_one - cut_xst_0_one)/b_xst_lo_one;; + cut_xst_lc_one = cut_xst_lo_one - 0.5 * (cut_xst_lo_one - cut_xst_0_one)/b_xst_lo_one; b_xst_hi_one = 0.25 * (cut_xst_hi_one - cut_xst_0_one) * (cut_xst_hi_one - cut_xst_0_one)/ (0.5 * (cut_xst_hi_one - cut_xst_0_one) * (cut_xst_hi_one - cut_xst_0_one) - diff --git a/src/CG-DNA/pair_oxrna2_xstk.cpp b/src/CG-DNA/pair_oxrna2_xstk.cpp index cdba56e33a..e28b6573bf 100644 --- a/src/CG-DNA/pair_oxrna2_xstk.cpp +++ b/src/CG-DNA/pair_oxrna2_xstk.cpp @@ -639,7 +639,7 @@ void PairOxrna2Xstk::coeff(int narg, char **arg) (0.5 * (cut_xst_lo_one - cut_xst_0_one) * (cut_xst_lo_one - cut_xst_0_one) - k_xst_one * 0.5 * (cut_xst_0_one -cut_xst_c_one) * (cut_xst_0_one - cut_xst_c_one)/k_xst_one); - cut_xst_lc_one = cut_xst_lo_one - 0.5 * (cut_xst_lo_one - cut_xst_0_one)/b_xst_lo_one;; + cut_xst_lc_one = cut_xst_lo_one - 0.5 * (cut_xst_lo_one - cut_xst_0_one)/b_xst_lo_one; b_xst_hi_one = 0.25 * (cut_xst_hi_one - cut_xst_0_one) * (cut_xst_hi_one - cut_xst_0_one)/ (0.5 * (cut_xst_hi_one - cut_xst_0_one) * (cut_xst_hi_one - cut_xst_0_one) - diff --git a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp index b11ac7e482..40f7d0c853 100644 --- a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp +++ b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp @@ -350,7 +350,6 @@ void FixPolarizeBEMGMRES::compute_induced_charges() double *ed = atom->ed; double *em = atom->em; double *epsilon = atom->epsilon; - int *mask = atom->mask; int nlocal = atom->nlocal; int eflag = 1; int vflag = 0; @@ -445,31 +444,7 @@ void FixPolarizeBEMGMRES::compute_induced_charges() comm->forward_comm(this); - // compute the total induced charges of the interface particles - // for interface particles: set the charge to be the sum of unscaled (free) charges and induced charges - - double tmp = 0; - for (int i = 0; i < nlocal; i++) { - if (!(mask[i] & groupbit)) continue; - - double q_bound = q_scaled[i] - q[i]; - tmp += q_bound; - q[i] = q_scaled[i]; - } - if (first) first = 0; - - // ensure sum of all induced charges being zero - - int ncount = group->count(igroup); - double sum = 0; - MPI_Allreduce(&tmp, &sum, 1, MPI_DOUBLE, MPI_SUM, world); - double qboundave = sum / (double) ncount; - - for (int i = 0; i < nlocal; i++) { - if (!(mask[i] & groupbit)) continue; - q[i] -= qboundave; - } } /* ---------------------------------------------------------------------- */ diff --git a/src/DIELECTRIC/fix_polarize_bem_icc.cpp b/src/DIELECTRIC/fix_polarize_bem_icc.cpp index 697d45f416..4dc7dd2669 100644 --- a/src/DIELECTRIC/fix_polarize_bem_icc.cpp +++ b/src/DIELECTRIC/fix_polarize_bem_icc.cpp @@ -361,30 +361,6 @@ void FixPolarizeBEMICC::compute_induced_charges() } iterations = itr; - - // compute the total induced charges of the interface particles - // for interface particles: set the charge to be the sum of unscaled (free) charges and induced charges - - double tmp = 0; - for (int i = 0; i < nlocal; i++) { - if (!(mask[i] & groupbit)) continue; - - double q_bound = q_scaled[i] - q[i]; - tmp += q_bound; - q[i] = q_scaled[i]; - } - - // ensure sum of all induced charges being zero - - int ncount = group->count(igroup); - double sum = 0; - MPI_Allreduce(&tmp, &sum, 1, MPI_DOUBLE, MPI_SUM, world); - double qboundave = sum / (double) ncount; - - for (int i = 0; i < nlocal; i++) { - if (!(mask[i] & groupbit)) continue; - q[i] -= qboundave; - } } /* ---------------------------------------------------------------------- */ @@ -479,6 +455,7 @@ void FixPolarizeBEMICC::set_dielectric_params(double ediff, double emean, double double *ed = atom->ed; double *em = atom->em; double *q = atom->q; + double *q_scaled = atom->q_scaled; double *epsilon = atom->epsilon; int *mask = atom->mask; int nlocal = atom->nlocal; @@ -490,6 +467,7 @@ void FixPolarizeBEMICC::set_dielectric_params(double ediff, double emean, double if (areai > 0) area[i] = areai; if (epsiloni > 0) epsilon[i] = epsiloni; if (set_charge) q[i] = qvalue; + q_scaled[i] = q[i] / epsilon[i]; } } } diff --git a/src/DIELECTRIC/fix_polarize_functional.cpp b/src/DIELECTRIC/fix_polarize_functional.cpp index a0dc034818..dd0c0eb648 100644 --- a/src/DIELECTRIC/fix_polarize_functional.cpp +++ b/src/DIELECTRIC/fix_polarize_functional.cpp @@ -55,9 +55,9 @@ using namespace LAMMPS_NS; using namespace FixConst; -using namespace MathExtra; -using namespace MathConst; -using namespace MathSpecial; +using MathConst::MY_PI; +using MathConst::MY_PIS; +using MathSpecial::square; //#define _POLARIZE_DEBUG @@ -378,26 +378,12 @@ void FixPolarizeFunctional::update_induced_charges() // assign charges to the particles in the group double *q_scaled = atom->q_scaled; - double *q = atom->q; - double *epsilon = atom->epsilon; int nlocal = atom->nlocal; - double tmp = 0; for (int i = 0; i < nlocal; i++) { if (induced_charge_idx[i] < 0) continue; int idx = induced_charge_idx[i]; - q[i] = -induced_charges[idx] / (4 * MY_PI); - q_scaled[i] = q[i] / epsilon[i]; - tmp += q_scaled[i]; - } - - double sum = 0; - MPI_Allreduce(&tmp, &sum, 1, MPI_DOUBLE, MPI_SUM, world); - double qboundave = sum/(double)num_induced_charges; - - for (int i = 0; i < nlocal; i++) { - if (induced_charge_idx[i] < 0) continue; - q_scaled[i] -= qboundave; + q_scaled[i] = -induced_charges[idx] / (4 * MY_PI); } // revert to scaled charges to calculate forces diff --git a/src/DIELECTRIC/pppm_dielectric.cpp b/src/DIELECTRIC/pppm_dielectric.cpp index b9ae1d65ff..e308cb0826 100644 --- a/src/DIELECTRIC/pppm_dielectric.cpp +++ b/src/DIELECTRIC/pppm_dielectric.cpp @@ -575,7 +575,7 @@ void PPPMDielectric::slabcorr() int nlocal = atom->nlocal; double dipole = 0.0; - for (int i = 0; i < nlocal; i++) dipole += q[i]*x[i][2]; + for (int i = 0; i < nlocal; i++) dipole += eps[i]*q[i]*x[i][2]; // sum local contributions to get global dipole moment @@ -588,7 +588,7 @@ void PPPMDielectric::slabcorr() double dipole_r2 = 0.0; if (eflag_atom || fabs(qsum) > SMALL) { for (int i = 0; i < nlocal; i++) - dipole_r2 += q[i]*x[i][2]*x[i][2]; + dipole_r2 += eps[i]*q[i]*x[i][2]*x[i][2]; // sum local contributions @@ -621,6 +621,6 @@ void PPPMDielectric::slabcorr() for (int i = 0; i < nlocal; i++) { f[i][2] += ffact * eps[i]*q[i]*(dipole_all - qsum*x[i][2]); - efield[i][2] += ffact * eps[i]*(dipole_all - qsum*x[i][2]); + efield[i][2] += ffact * (dipole_all - qsum*x[i][2]); } } diff --git a/src/DIPOLE/angle_dipole.cpp b/src/DIPOLE/angle_dipole.cpp index f6508022db..6ad4a0fb4c 100644 --- a/src/DIPOLE/angle_dipole.cpp +++ b/src/DIPOLE/angle_dipole.cpp @@ -31,6 +31,8 @@ using namespace LAMMPS_NS; using namespace MathConst; +static constexpr double SMALL = 1.0e-100; + /* ---------------------------------------------------------------------- */ AngleDipole::AngleDipole(LAMMPS *lmp) : Angle(lmp) @@ -72,7 +74,7 @@ void AngleDipole::compute(int eflag, int vflag) double **f = atom->f; double delTx, delTy, delTz; - double fx, fy, fz, fmod, fmod_sqrtff; + double fx, fy, fz, fmod, fmod_len, len; if (!newton_bond) error->all(FLERR, "'newton' flag for bonded interactions must be 'on'"); @@ -87,6 +89,7 @@ void AngleDipole::compute(int eflag, int vflag) delz = x[iRef][2] - x[iDip][2]; r = sqrt(delx * delx + dely * dely + delz * delz); + if (r < SMALL) continue; rmu = r * mu[iDip][3]; cosGamma = (mu[iDip][0] * delx + mu[iDip][1] * dely + mu[iDip][2] * delz) / rmu; @@ -111,11 +114,13 @@ void AngleDipole::compute(int eflag, int vflag) fz = delx * delTy - dely * delTx; fmod = sqrt(delTx * delTx + delTy * delTy + delTz * delTz) / r; // magnitude - fmod_sqrtff = fmod / sqrt(fx * fx + fy * fy + fz * fz); + len = sqrt(fx * fx + fy * fy + fz * fz); + if (len < SMALL) continue; + fmod_len = fmod / len; - fi[0] = fx * fmod_sqrtff; - fi[1] = fy * fmod_sqrtff; - fi[2] = fz * fmod_sqrtff; + fi[0] = fx * fmod_len; + fi[1] = fy * fmod_len; + fi[2] = fz * fmod_len; fj[0] = -fi[0]; fj[1] = -fi[1]; @@ -249,6 +254,8 @@ double AngleDipole::single(int type, int iRef, int iDip, int /*iDummy*/) domain->minimum_image(delx, dely, delz); double r = sqrt(delx * delx + dely * dely + delz * delz); + if (r < SMALL) return 0.0; + double rmu = r * mu[iDip][3]; double cosGamma = (mu[iDip][0] * delx + mu[iDip][1] * dely + mu[iDip][2] * delz) / rmu; double deltaGamma = cosGamma - cos(gamma0[type]); diff --git a/src/EFF/pair_eff_cut.cpp b/src/EFF/pair_eff_cut.cpp index 1cfe5cd1dd..5f32de9912 100644 --- a/src/EFF/pair_eff_cut.cpp +++ b/src/EFF/pair_eff_cut.cpp @@ -921,13 +921,13 @@ void PairEffCut::coeff(int narg, char **arg) } else { int ecp; ecp = utils::inumeric(FLERR,arg[0],false,lmp); - if (strcmp(arg[1],"s") ==0) { + if (strcmp(arg[1],"s") == 0) { PAULI_CORE_A[ecp_type[ecp]] = utils::numeric(FLERR,arg[2],false,lmp); PAULI_CORE_B[ecp_type[ecp]] = utils::numeric(FLERR,arg[3],false,lmp); PAULI_CORE_C[ecp_type[ecp]] = utils::numeric(FLERR,arg[4],false,lmp); PAULI_CORE_D[ecp_type[ecp]] = 0.0; PAULI_CORE_E[ecp_type[ecp]] = 0.0; - } else if (strcmp(arg[1],"p") ==0) { + } else if (strcmp(arg[1],"p") == 0) { PAULI_CORE_A[ecp_type[ecp]] = utils::numeric(FLERR,arg[2],false,lmp); PAULI_CORE_B[ecp_type[ecp]] = utils::numeric(FLERR,arg[3],false,lmp); PAULI_CORE_C[ecp_type[ecp]] = utils::numeric(FLERR,arg[4],false,lmp); diff --git a/src/ELECTRODE/fix_electrode_conp.cpp b/src/ELECTRODE/fix_electrode_conp.cpp index 85f59127f1..1b6c0a37d4 100644 --- a/src/ELECTRODE/fix_electrode_conp.cpp +++ b/src/ELECTRODE/fix_electrode_conp.cpp @@ -417,7 +417,7 @@ void FixElectrodeConp::post_constructor() input->variable->set(fmt::format("{} equal f_{}[{}]", var_vtop, fixname, 1 + top_group)); input->variable->set(fmt::format("{} equal (v_{}-v_{})/lz", var_efield, var_vbot, var_vtop)); // check for other efields and warn if found - if (modify->get_fix_by_style("efield").size() > 0 && comm->me == 0) + if (modify->get_fix_by_style("^efield").size() > 0 && comm->me == 0) error->warning(FLERR, "Other efield fixes found -- please make sure this is intended!"); // call fix command: // fix [varstem]_efield all efield 0.0 0.0 [var_vdiff]/lz diff --git a/src/EXTRA-COMPUTE/compute_ackland_atom.cpp b/src/EXTRA-COMPUTE/compute_ackland_atom.cpp index d8a77b9c2f..fd7a5fb05c 100644 --- a/src/EXTRA-COMPUTE/compute_ackland_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_ackland_atom.cpp @@ -357,7 +357,7 @@ void ComputeAcklandAtom::select(int k, int n, double *arr) arr--; l = 1; ir = n; - for (;;) { + while (true) { if (ir <= l+1) { if (ir == l+1 && arr[ir] < arr[l]) { SWAP(arr[l],arr[ir]) @@ -378,7 +378,7 @@ void ComputeAcklandAtom::select(int k, int n, double *arr) i = l+1; j = ir; a = arr[l+1]; - for (;;) { + while (true) { do i++; while (arr[i] < a); do j--; while (arr[j] > a); if (j < i) break; @@ -403,7 +403,7 @@ void ComputeAcklandAtom::select2(int k, int n, double *arr, int *iarr) iarr--; l = 1; ir = n; - for (;;) { + while (true) { if (ir <= l+1) { if (ir == l+1 && arr[ir] < arr[l]) { SWAP(arr[l],arr[ir]) @@ -430,7 +430,7 @@ void ComputeAcklandAtom::select2(int k, int n, double *arr, int *iarr) j = ir; a = arr[l+1]; ia = iarr[l+1]; - for (;;) { + while (true) { do i++; while (arr[i] < a); do j--; while (arr[j] > a); if (j < i) break; diff --git a/src/EXTRA-COMPUTE/compute_adf.cpp b/src/EXTRA-COMPUTE/compute_adf.cpp index fc74cb8037..35ff8bfd33 100644 --- a/src/EXTRA-COMPUTE/compute_adf.cpp +++ b/src/EXTRA-COMPUTE/compute_adf.cpp @@ -288,7 +288,7 @@ void ComputeADF::init() rcutinnerk[0] = 0.0; rcutouterj[0] = force->pair->cutforce; rcutouterk[0] = force->pair->cutforce; - maxouter = force->pair->cutforce;; + maxouter = force->pair->cutforce; } else { for (int m = 0; m < ntriples; m++) { maxouter = MAX(rcutouterj[m],maxouter); diff --git a/src/EXTRA-COMPUTE/compute_basal_atom.cpp b/src/EXTRA-COMPUTE/compute_basal_atom.cpp index b149746fb4..8b65917111 100644 --- a/src/EXTRA-COMPUTE/compute_basal_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_basal_atom.cpp @@ -442,7 +442,7 @@ void ComputeBasalAtom::select(int k, int n, double *arr) arr--; l = 1; ir = n; - for (;;) { + while (true) { if (ir <= l+1) { if (ir == l+1 && arr[ir] < arr[l]) { SWAP(arr[l],arr[ir]) @@ -463,7 +463,7 @@ void ComputeBasalAtom::select(int k, int n, double *arr) i = l+1; j = ir; a = arr[l+1]; - for (;;) { + while (true) { do i++; while (arr[i] < a); do j--; while (arr[j] > a); if (j < i) break; @@ -488,7 +488,7 @@ void ComputeBasalAtom::select2(int k, int n, double *arr, int *iarr) iarr--; l = 1; ir = n; - for (;;) { + while (true) { if (ir <= l+1) { if (ir == l+1 && arr[ir] < arr[l]) { SWAP(arr[l],arr[ir]) @@ -515,7 +515,7 @@ void ComputeBasalAtom::select2(int k, int n, double *arr, int *iarr) j = ir; a = arr[l+1]; ia = iarr[l+1]; - for (;;) { + while (true) { do i++; while (arr[i] < a); do j--; while (arr[j] > a); if (j < i) break; diff --git a/src/EXTRA-COMPUTE/compute_hexorder_atom.cpp b/src/EXTRA-COMPUTE/compute_hexorder_atom.cpp index a10e810e82..dc04c6b650 100644 --- a/src/EXTRA-COMPUTE/compute_hexorder_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_hexorder_atom.cpp @@ -281,7 +281,7 @@ void ComputeHexOrderAtom::select2(int k, int n, double *arr, int *iarr) iarr--; l = 1; ir = n; - for (;;) { + while (true) { if (ir <= l+1) { if (ir == l+1 && arr[ir] < arr[l]) { SWAP(arr[l],arr[ir]) @@ -308,7 +308,7 @@ void ComputeHexOrderAtom::select2(int k, int n, double *arr, int *iarr) j = ir; a = arr[l+1]; ia = iarr[l+1]; - for (;;) { + while (true) { do i++; while (arr[i] < a); do j--; while (arr[j] > a); if (j < i) break; diff --git a/src/EXTRA-COMPUTE/compute_stress_mop.cpp b/src/EXTRA-COMPUTE/compute_stress_mop.cpp index 98e3bf7043..fc9de602a7 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop.cpp @@ -41,11 +41,9 @@ using namespace LAMMPS_NS; enum { X, Y, Z }; enum { TOTAL, CONF, KIN, PAIR, BOND, ANGLE }; -// clang-format off /* ---------------------------------------------------------------------- */ -ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) +ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg) { if (narg < 6) utils::missing_cmd_args(FLERR, "compute stress/mop", error); @@ -54,37 +52,40 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : // set compute mode and direction of plane(s) for pressure calculation - if (strcmp(arg[3],"x") == 0) { + if (strcmp(arg[3], "x") == 0) { dir = X; - } else if (strcmp(arg[3],"y") == 0) { + } else if (strcmp(arg[3], "y") == 0) { dir = Y; - } else if (strcmp(arg[3],"z") == 0) { + } else if (strcmp(arg[3], "z") == 0) { dir = Z; - } else error->all(FLERR,"Illegal compute stress/mop command"); + } else + error->all(FLERR, "Illegal compute stress/mop command"); // Position of the plane - if (strcmp(arg[4],"lower") == 0) { + if (strcmp(arg[4], "lower") == 0) { pos = domain->boxlo[dir]; - } else if (strcmp(arg[4],"upper") == 0) { + } else if (strcmp(arg[4], "upper") == 0) { pos = domain->boxhi[dir]; - } else if (strcmp(arg[4],"center") == 0) { - pos = 0.5*(domain->boxlo[dir]+domain->boxhi[dir]); - } else pos = utils::numeric(FLERR,arg[4],false,lmp); + } else if (strcmp(arg[4], "center") == 0) { + pos = 0.5 * (domain->boxlo[dir] + domain->boxhi[dir]); + } else + pos = utils::numeric(FLERR, arg[4], false, lmp); // plane inside the box + if ((pos > domain->boxhi[dir]) || (pos < domain->boxlo[dir])) { error->warning(FLERR, "The specified initial plane lies outside of the simulation box"); double dx[3] = {0.0, 0.0, 0.0}; - dx[dir] = pos - 0.5*(domain->boxhi[dir] + domain->boxlo[dir]); + dx[dir] = pos - 0.5 * (domain->boxhi[dir] + domain->boxlo[dir]); domain->minimum_image(dx[0], dx[1], dx[2]); - pos = 0.5*(domain->boxhi[dir] + domain->boxlo[dir]) + dx[dir]; + pos = 0.5 * (domain->boxhi[dir] + domain->boxlo[dir]) + dx[dir]; if ((pos > domain->boxhi[dir]) || (pos < domain->boxlo[dir])) error->all(FLERR, "Plane for compute stress/mop is out of bounds"); } - if (pos < (domain->boxlo[dir]+domain->prd_half[dir])) { + if (pos < (domain->boxlo[dir] + domain->prd_half[dir])) { pos1 = pos + domain->prd[dir]; } else { pos1 = pos - domain->prd[dir]; @@ -92,52 +93,53 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : // parse values until one isn't recognized - which = new int[3*(narg-5)]; + which = new int[3 * (narg - 5)]; nvalues = 0; int i; - int iarg=5; + int iarg = 5; while (iarg < narg) { - if (strcmp(arg[iarg],"conf") == 0) { - for (i=0; i<3; i++) { + if (strcmp(arg[iarg], "conf") == 0) { + for (i = 0; i < 3; i++) { which[nvalues] = CONF; nvalues++; } - } else if (strcmp(arg[iarg],"kin") == 0) { - for (i=0; i<3; i++) { + } else if (strcmp(arg[iarg], "kin") == 0) { + for (i = 0; i < 3; i++) { which[nvalues] = KIN; nvalues++; } - } else if (strcmp(arg[iarg],"total") == 0) { - for (i=0; i<3; i++) { + } else if (strcmp(arg[iarg], "total") == 0) { + for (i = 0; i < 3; i++) { which[nvalues] = TOTAL; nvalues++; } - } else if (strcmp(arg[iarg],"pair") == 0) { - for (i=0; i<3; i++) { + } else if (strcmp(arg[iarg], "pair") == 0) { + for (i = 0; i < 3; i++) { which[nvalues] = PAIR; nvalues++; } - } else if (strcmp(arg[iarg],"bond") == 0) { - for (i=0; i<3; i++) { + } else if (strcmp(arg[iarg], "bond") == 0) { + for (i = 0; i < 3; i++) { which[nvalues] = BOND; nvalues++; } - } else if (strcmp(arg[iarg],"angle") == 0) { - for (i=0; i<3; i++) { + } else if (strcmp(arg[iarg], "angle") == 0) { + for (i = 0; i < 3; i++) { which[nvalues] = ANGLE; nvalues++; } - } else error->all(FLERR, "Illegal compute stress/mop command"); //break; + } else + error->all(FLERR, "Illegal compute stress/mop command"); //break; iarg++; } - // Error checks + // Error checks: + // 3D only - if (domain->dimension != 3) - error->all(FLERR, "Compute stress/mop requires a 3d system"); + if (domain->dimension != 3) error->all(FLERR, "Compute stress/mop requires a 3d system"); // orthogonal simulation box if (domain->triclinic != 0) @@ -153,18 +155,17 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : // this fix produces a global vector - memory->create(vector,nvalues,"stress/mop:vector"); - memory->create(values_local,nvalues,"stress/mop:values_local"); - memory->create(values_global,nvalues,"stress/mop:values_global"); - memory->create(bond_local,nvalues,"stress/mop:bond_local"); - memory->create(bond_global,nvalues,"stress/mop:bond_global"); - memory->create(angle_local,nvalues,"stress/mop:angle_local"); - memory->create(angle_global,nvalues,"stress/mop:angle_global"); + memory->create(vector, nvalues, "stress/mop:vector"); + memory->create(values_local, nvalues, "stress/mop:values_local"); + memory->create(values_global, nvalues, "stress/mop:values_global"); + memory->create(bond_local, nvalues, "stress/mop:bond_local"); + memory->create(bond_global, nvalues, "stress/mop:bond_global"); + memory->create(angle_local, nvalues, "stress/mop:angle_local"); + memory->create(angle_global, nvalues, "stress/mop:angle_global"); size_vector = nvalues; vector_flag = 1; extvector = 0; - } /* ---------------------------------------------------------------------- */ @@ -196,8 +197,8 @@ void ComputeStressMop::init() area = 1; int i; - for (i=0; i<3; i++) { - if (i!=dir) area = area*domain->prd[i]; + for (i = 0; i < 3; i++) { + if (i != dir) area = area * domain->prd[i]; } // Timestep Value @@ -212,10 +213,9 @@ void ComputeStressMop::init() // This compute requires a pair style with pair_single method implemented - if (!force->pair) - error->all(FLERR,"No pair style is defined for compute stress/mop"); + if (!force->pair) error->all(FLERR, "No pair style is defined for compute stress/mop"); if (force->pair->single_enable == 0) - error->all(FLERR,"Pair style does not support compute stress/mop"); + error->all(FLERR, "Pair style does not support compute stress/mop"); // Errors @@ -227,21 +227,23 @@ void ComputeStressMop::init() if (force->angle) { if (force->angle->born_matrix_enable == 0) { if ((strcmp(force->angle_style, "zero") != 0) && (strcmp(force->angle_style, "none") != 0)) - error->all(FLERR,"compute stress/mop does not account for angle potentials"); + error->all(FLERR, "compute stress/mop does not account for angle potentials"); } else { - angleflag = 1; + angleflag = 1; } } if (force->dihedral) { - if ((strcmp(force->dihedral_style, "zero") != 0) && (strcmp(force->dihedral_style, "none") != 0)) - error->all(FLERR,"compute stress/mop does not account for dihedral potentials"); + if ((strcmp(force->dihedral_style, "zero") != 0) && + (strcmp(force->dihedral_style, "none") != 0)) + error->all(FLERR, "compute stress/mop does not account for dihedral potentials"); } if (force->improper) { - if ((strcmp(force->improper_style, "zero") != 0) && (strcmp(force->improper_style, "none") != 0)) - error->all(FLERR,"compute stress/mop does not account for improper potentials"); + if ((strcmp(force->improper_style, "zero") != 0) && + (strcmp(force->improper_style, "none") != 0)) + error->all(FLERR, "compute stress/mop does not account for improper potentials"); } if (force->kspace) - error->warning(FLERR,"compute stress/mop does not account for kspace contributions"); + error->warning(FLERR, "compute stress/mop does not account for kspace contributions"); } // need an occasional half neighbor list @@ -255,7 +257,6 @@ void ComputeStressMop::init_list(int /* id */, NeighList *ptr) list = ptr; } - /* ---------------------------------------------------------------------- compute output vector ------------------------------------------------------------------------- */ @@ -264,38 +265,43 @@ void ComputeStressMop::compute_vector() { invoked_array = update->ntimestep; - //Compute pressures on separate procs + // Compute pressures on separate procs + compute_pairs(); // sum pressure contributions over all procs - MPI_Allreduce(values_local,values_global,nvalues,MPI_DOUBLE,MPI_SUM,world); + + MPI_Allreduce(values_local, values_global, nvalues, MPI_DOUBLE, MPI_SUM, world); + + // Compute bond contribution on separate procs if (bondflag) { - //Compute bond contribution on separate procs compute_bonds(); } else { - for (int i=0; imass; double *rmass = atom->rmass; @@ -317,7 +323,6 @@ void ComputeStressMop::compute_pairs() double *special_lj = force->special_lj; int newton_pair = force->newton_pair; - // zero out arrays for one sample for (i = 0; i < nvalues; i++) values_local[i] = 0.0; @@ -373,7 +378,7 @@ void ComputeStressMop::compute_pairs() delx = xi[0] - xj[0]; dely = xi[1] - xj[1]; delz = xi[2] - xj[2]; - rsq = delx*delx + dely*dely + delz*delz; + rsq = delx * delx + dely * dely + delz * delz; jtype = type[j]; if (rsq >= cutsq[itype][jtype]) continue; @@ -381,29 +386,29 @@ void ComputeStressMop::compute_pairs() //check if ij pair is across plane, add contribution to pressure if (((xi[dir] > pos) && (xj[dir] < pos)) || ((xi[dir] > pos1) && (xj[dir] < pos1))) { - pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); - values_local[m] += fpair*(xi[0]-xj[0])/area*nktv2p; - values_local[m+1] += fpair*(xi[1]-xj[1])/area*nktv2p; - values_local[m+2] += fpair*(xi[2]-xj[2])/area*nktv2p; - } else if (((xi[dir] < pos) && (xj[dir] > pos)) || ((xi[dir] < pos1) && (xj[dir] > pos1))) { - pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); - values_local[m] -= fpair*(xi[0]-xj[0])/area*nktv2p; - values_local[m+1] -= fpair*(xi[1]-xj[1])/area*nktv2p; - values_local[m+2] -= fpair*(xi[2]-xj[2])/area*nktv2p; + pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair); + values_local[m] += fpair * (xi[0] - xj[0]) / area * nktv2p; + values_local[m + 1] += fpair * (xi[1] - xj[1]) / area * nktv2p; + values_local[m + 2] += fpair * (xi[2] - xj[2]) / area * nktv2p; + } else if (((xi[dir] < pos) && (xj[dir] > pos)) || + ((xi[dir] < pos1) && (xj[dir] > pos1))) { + pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair); + values_local[m] -= fpair * (xi[0] - xj[0]) / area * nktv2p; + values_local[m + 1] -= fpair * (xi[1] - xj[1]) / area * nktv2p; + values_local[m + 2] -= fpair * (xi[2] - xj[2]) / area * nktv2p; } } else { if (((xi[dir] > pos) && (xj[dir] < pos)) || ((xi[dir] > pos1) && (xj[dir] < pos1))) { - pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); - values_local[m] += fpair*(xi[0]-xj[0])/area*nktv2p; - values_local[m+1] += fpair*(xi[1]-xj[1])/area*nktv2p; - values_local[m+2] += fpair*(xi[2]-xj[2])/area*nktv2p; + pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair); + values_local[m] += fpair * (xi[0] - xj[0]) / area * nktv2p; + values_local[m + 1] += fpair * (xi[1] - xj[1]) / area * nktv2p; + values_local[m + 2] += fpair * (xi[2] - xj[2]) / area * nktv2p; } } } } } - // Compute kinetic contribution to pressure // counts local particles transfers across the plane @@ -413,63 +418,61 @@ void ComputeStressMop::compute_pairs() for (int i = 0; i < nlocal; i++) { // skip if I is not in group + if (mask[i] & groupbit) { itype = type[i]; - //coordinates at t + // coordinates at t + xi[0] = atom->x[i][0]; xi[1] = atom->x[i][1]; xi[2] = atom->x[i][2]; - //velocities at t + // velocities at t + vi[0] = atom->v[i][0]; vi[1] = atom->v[i][1]; vi[2] = atom->v[i][2]; - //forces at t + // forces at t + fi[0] = atom->f[i][0]; fi[1] = atom->f[i][1]; fi[2] = atom->f[i][2]; - //coordinates at t-dt (based on Velocity-Verlet alg.) - if (rmass) { - xj[0] = xi[0]-vi[0]*dt+fi[0]/2.0/rmass[i]*dt*dt*ftm2v; - xj[1] = xi[1]-vi[1]*dt+fi[1]/2.0/rmass[i]*dt*dt*ftm2v; - xj[2] = xi[2]-vi[2]*dt+fi[2]/2.0/rmass[i]*dt*dt*ftm2v; - } else { - xj[0] = xi[0]-vi[0]*dt+fi[0]/2.0/mass[itype]*dt*dt*ftm2v; - xj[1] = xi[1]-vi[1]*dt+fi[1]/2.0/mass[itype]*dt*dt*ftm2v; - xj[2] = xi[2]-vi[2]*dt+fi[2]/2.0/mass[itype]*dt*dt*ftm2v; - } + const double imass = (rmass) ? rmass[i] : mass[itype]; + const double iterm = 0.5 / imass * dt * ftm2v; + + // coordinates at t-dt (based on Velocity-Verlet alg.) + + xj[0] = xi[0] - vi[0] * dt + fi[0] * iterm * dt; + xj[1] = xi[1] - vi[1] * dt + fi[1] * iterm * dt; + xj[2] = xi[2] - vi[2] * dt + fi[2] * iterm * dt; // because LAMMPS does not put atoms back in the box // at each timestep, must check atoms going through the // image of the plane that is closest to the box - double pos_temp = pos+copysign(1.0,domain->prd_half[dir]-pos)*domain->prd[dir]; - if (fabs(xi[dir]-pos)prd_half[dir] - pos) * domain->prd[dir]; + if (fabs(xi[dir] - pos) < fabs(xi[dir] - pos_temp)) pos_temp = pos; - if (((xi[dir]-pos_temp)*(xj[dir]-pos_temp)) < 0) { + if (((xi[dir] - pos_temp) * (xj[dir] - pos_temp)) < 0) { // sgn = copysign(1.0,vi[dir]-vcm[dir]); - sgn = copysign(1.0,vi[dir]); + + sgn = copysign(1.0, vi[dir]); // approximate crossing velocity by v(t-dt/2) (based on Velocity-Verlet alg.) - double vcross[3]; - if (rmass) { - vcross[0] = vi[0]-fi[0]/rmass[i]/2.0*ftm2v*dt; - vcross[1] = vi[1]-fi[1]/rmass[i]/2.0*ftm2v*dt; - vcross[2] = vi[2]-fi[2]/rmass[i]/2.0*ftm2v*dt; - } else { - vcross[0] = vi[0]-fi[0]/mass[itype]/2.0*ftm2v*dt; - vcross[1] = vi[1]-fi[1]/mass[itype]/2.0*ftm2v*dt; - vcross[2] = vi[2]-fi[2]/mass[itype]/2.0*ftm2v*dt; - } - values_local[m] += mass[itype]*vcross[0]*sgn/dt/area*nktv2p/ftm2v; - values_local[m+1] += mass[itype]*vcross[1]*sgn/dt/area*nktv2p/ftm2v; - values_local[m+2] += mass[itype]*vcross[2]*sgn/dt/area*nktv2p/ftm2v; + double vcross[3]; + vcross[0] = vi[0] - fi[0] * iterm; + vcross[1] = vi[1] - fi[1] * iterm; + vcross[2] = vi[2] - fi[2] * iterm; + + values_local[m] += imass * vcross[0] * sgn / dt / area * nktv2p / ftm2v; + values_local[m + 1] += imass * vcross[1] * sgn / dt / area * nktv2p / ftm2v; + values_local[m + 2] += imass * vcross[2] * sgn / dt / area * nktv2p / ftm2v; } } } @@ -511,9 +514,11 @@ void ComputeStressMop::compute_bonds() double local_contribution[3] = {0.0, 0.0, 0.0}; // initialization + for (int i = 0; i < nvalues; i++) bond_local[i] = 0.0; // loop over all bonded atoms in the current proc + for (atom1 = 0; atom1 < nlocal; atom1++) { if (!(mask[atom1] & groupbit)) continue; @@ -541,6 +546,7 @@ void ComputeStressMop::compute_bonds() if (btype <= 0) continue; // minimum image of atom1 with respect to the plane of interest + dx[0] = x[atom1][0]; dx[1] = x[atom1][1]; dx[2] = x[atom1][2]; @@ -552,6 +558,7 @@ void ComputeStressMop::compute_bonds() x_bond_1[dir] += pos; // minimum image of atom2 with respect to atom1 + dx[0] = x[atom2][0] - x_bond_1[0]; dx[1] = x[atom2][1] - x_bond_1[1]; dx[2] = x[atom2][2] - x_bond_1[2]; @@ -561,6 +568,7 @@ void ComputeStressMop::compute_bonds() x_bond_2[2] = x_bond_1[2] + dx[2]; // check if the bond vector crosses the plane of interest + double tau = (x_bond_1[dir] - pos) / (x_bond_1[dir] - x_bond_2[dir]); if ((tau <= 1) && (tau >= 0)) { dx[0] = x_bond_1[0] - x_bond_2[0]; @@ -570,20 +578,21 @@ void ComputeStressMop::compute_bonds() bond->single(btype, rsq, atom1, atom2, fpair); double sgn = copysign(1.0, x_bond_1[dir] - pos); - local_contribution[0] += sgn*fpair*dx[0]/area*nktv2p; - local_contribution[1] += sgn*fpair*dx[1]/area*nktv2p; - local_contribution[2] += sgn*fpair*dx[2]/area*nktv2p; + local_contribution[0] += sgn * fpair * dx[0] / area * nktv2p; + local_contribution[1] += sgn * fpair * dx[1] / area * nktv2p; + local_contribution[2] += sgn * fpair * dx[2] / area * nktv2p; } } } // loop over the keywords and if necessary add the bond contribution + int m = 0; - while (m=0) && (tau_right <= 1)); - bool left_cross = ((tau_left >=0) && (tau_left <= 1)); + bool right_cross = ((tau_right >= 0) && (tau_right <= 1)); + bool left_cross = ((tau_left >= 0) && (tau_left <= 1)); // no bonds crossing the plane + if (!right_cross && !left_cross) continue; // compute the cos(theta) of the angle - r1 = sqrt(dx_left[0]*dx_left[0] + dx_left[1]*dx_left[1] + dx_left[2]*dx_left[2]); - r2 = sqrt(dx_right[0]*dx_right[0] + dx_right[1]*dx_right[1] + dx_right[2]*dx_right[2]); - cos_theta = -(dx_right[0]*dx_left[0] + dx_right[1]*dx_left[1] + dx_right[2]*dx_left[2])/(r1*r2); - if (cos_theta > 1.0) cos_theta = 1.0; + r1 = sqrt(dx_left[0] * dx_left[0] + dx_left[1] * dx_left[1] + dx_left[2] * dx_left[2]); + r2 = sqrt(dx_right[0] * dx_right[0] + dx_right[1] * dx_right[1] + dx_right[2] * dx_right[2]); + cos_theta = + -(dx_right[0] * dx_left[0] + dx_right[1] * dx_left[1] + dx_right[2] * dx_left[2]) / + (r1 * r2); + + if (cos_theta > 1.0) cos_theta = 1.0; if (cos_theta < -1.0) cos_theta = -1.0; // The method returns derivative with regards to cos(theta) + angle->born_matrix(atype, atom1, atom2, atom3, duang, du2ang); + // only right bond crossing the plane - if (right_cross && !left_cross) - { + + if (right_cross && !left_cross) { double sgn = copysign(1.0, x_angle_right[dir] - pos); - dcos_theta[0] = sgn*(dx_right[0]*cos_theta/r2 + dx_left[0]/r1)/r2; - dcos_theta[1] = sgn*(dx_right[1]*cos_theta/r2 + dx_left[1]/r1)/r2; - dcos_theta[2] = sgn*(dx_right[2]*cos_theta/r2 + dx_left[2]/r1)/r2; + dcos_theta[0] = sgn * (dx_right[0] * cos_theta / r2 + dx_left[0] / r1) / r2; + dcos_theta[1] = sgn * (dx_right[1] * cos_theta / r2 + dx_left[1] / r1) / r2; + dcos_theta[2] = sgn * (dx_right[2] * cos_theta / r2 + dx_left[2] / r1) / r2; } // only left bond crossing the plane - if (!right_cross && left_cross) - { + + 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; - dcos_theta[2] = -sgn*(dx_left[2]*cos_theta/r1 + dx_right[2]/r2)/r1; + 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; + dcos_theta[2] = -sgn * (dx_left[2] * cos_theta / r1 + dx_right[2] / r2) / r1; } // both bonds crossing the plane - if (right_cross && left_cross) - { + + if (right_cross && left_cross) { + // due to right bond + double sgn = copysign(1.0, x_angle_middle[dir] - pos); - dcos_theta[0] = -sgn*(dx_right[0]*cos_theta/r2 + dx_left[0]/r1)/r2; - dcos_theta[1] = -sgn*(dx_right[1]*cos_theta/r2 + dx_left[1]/r1)/r2; - dcos_theta[2] = -sgn*(dx_right[2]*cos_theta/r2 + dx_left[2]/r1)/r2; + dcos_theta[0] = -sgn * (dx_right[0] * cos_theta / r2 + dx_left[0] / r1) / r2; + dcos_theta[1] = -sgn * (dx_right[1] * cos_theta / r2 + dx_left[1] / r1) / r2; + dcos_theta[2] = -sgn * (dx_right[2] * cos_theta / r2 + dx_left[2] / r1) / r2; // due to left bond - 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; - dcos_theta[2] += sgn*(dx_left[2]*cos_theta/r1 + dx_right[2]/r2)/r1; + + 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; + dcos_theta[2] += sgn * (dx_left[2] * cos_theta / r1 + dx_right[2] / r2) / r1; } // final contribution of the given angle term - local_contribution[0] += duang*dcos_theta[0]/area*nktv2p; - local_contribution[1] += duang*dcos_theta[1]/area*nktv2p; - local_contribution[2] += duang*dcos_theta[2]/area*nktv2p; + + local_contribution[0] += duang * dcos_theta[0] / area * nktv2p; + local_contribution[1] += duang * dcos_theta[1] / area * nktv2p; + local_contribution[2] += duang * dcos_theta[2] / area * nktv2p; } } + // loop over the keywords and if necessary add the angle contribution + int m = 0; while (m < nvalues) { if (which[m] == CONF || which[m] == TOTAL || which[m] == ANGLE) { angle_local[m] = local_contribution[0]; - angle_local[m+1] = local_contribution[1]; - angle_local[m+2] = local_contribution[2]; + angle_local[m + 1] = local_contribution[1]; + angle_local[m + 2] = local_contribution[2]; } m += 3; } diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index 1f1dc30733..cc201fdbaa 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -41,11 +41,10 @@ enum { X, Y, Z }; enum { LOWER, CENTER, UPPER, COORD }; enum { TOTAL, CONF, KIN, PAIR, BOND }; -// clang-format off /* ---------------------------------------------------------------------- */ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) + Compute(lmp, narg, arg) { if (narg < 7) utils::missing_cmd_args(FLERR, "compute stress/mop/profile", error); @@ -53,58 +52,64 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a // set compute mode and direction of plane(s) for pressure calculation - if (strcmp(arg[3],"x") == 0) { + if (strcmp(arg[3], "x") == 0) { dir = X; - } else if (strcmp(arg[3],"y") == 0) { + } else if (strcmp(arg[3], "y") == 0) { dir = Y; - } else if (strcmp(arg[3],"z") == 0) { + } else if (strcmp(arg[3], "z") == 0) { dir = Z; - } else error->all(FLERR,"Illegal compute stress/mop/profile command"); + } else + error->all(FLERR, "Illegal compute stress/mop/profile command"); // bin parameters - if (strcmp(arg[4],"lower") == 0) originflag = LOWER; - else if (strcmp(arg[4],"center") == 0) originflag = CENTER; - else if (strcmp(arg[4],"upper") == 0) originflag = UPPER; - else originflag = COORD; - if (originflag == COORD) origin = utils::numeric(FLERR,arg[4],false,lmp); - delta = utils::numeric(FLERR,arg[5],false,lmp); - invdelta = 1.0/delta; + if (strcmp(arg[4], "lower") == 0) + originflag = LOWER; + else if (strcmp(arg[4], "center") == 0) + originflag = CENTER; + else if (strcmp(arg[4], "upper") == 0) + originflag = UPPER; + else + originflag = COORD; + if (originflag == COORD) origin = utils::numeric(FLERR, arg[4], false, lmp); + delta = utils::numeric(FLERR, arg[5], false, lmp); + invdelta = 1.0 / delta; // parse values until one isn't recognized - which = new int[3*(narg-6)]; + which = new int[3 * (narg - 6)]; nvalues = 0; int i; - int iarg=6; + int iarg = 6; while (iarg < narg) { - if (strcmp(arg[iarg],"conf") == 0) { - for (i=0; i<3; i++) { + if (strcmp(arg[iarg], "conf") == 0) { + for (i = 0; i < 3; i++) { which[nvalues] = CONF; nvalues++; } - } else if (strcmp(arg[iarg],"kin") == 0) { - for (i=0; i<3; i++) { + } else if (strcmp(arg[iarg], "kin") == 0) { + for (i = 0; i < 3; i++) { which[nvalues] = KIN; nvalues++; } - } else if (strcmp(arg[iarg],"total") == 0) { - for (i=0; i<3; i++) { + } else if (strcmp(arg[iarg], "total") == 0) { + for (i = 0; i < 3; i++) { which[nvalues] = TOTAL; nvalues++; } - } else if (strcmp(arg[iarg],"pair") == 0) { - for (i=0; i<3; i++) { + } else if (strcmp(arg[iarg], "pair") == 0) { + for (i = 0; i < 3; i++) { which[nvalues] = PAIR; nvalues++; } - } else if (strcmp(arg[iarg],"bond") == 0) { - for (i=0; i<3; i++) { + } else if (strcmp(arg[iarg], "bond") == 0) { + for (i = 0; i < 3; i++) { which[nvalues] = BOND; nvalues++; } - } else error->all(FLERR, "Illegal compute stress/mop/profile command"); //break; + } else + error->all(FLERR, "Illegal compute stress/mop/profile command"); //break; iarg++; } @@ -136,7 +141,7 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a // this fix produces a global array - memory->create(array,nbins,1+nvalues,"stress/mop/profile:array"); + memory->create(array, nbins, 1 + nvalues, "stress/mop/profile:array"); size_array_rows = nbins; size_array_cols = 1 + nvalues; @@ -173,47 +178,49 @@ void ComputeStressMopProfile::init() area = 1; int i; - for (i=0; i<3; i++) { - if (i!=dir) area = area*domain->prd[i]; + for (i = 0; i < 3; i++) { + if (i != dir) area = area * domain->prd[i]; } // timestep Value dt = update->dt; - // Error check + // Error checks: + // Compute stress/mop/profile requires fixed simulation box if (domain->box_change_size || domain->box_change_shape || domain->deform_flag) error->all(FLERR, "Compute stress/mop/profile requires a fixed simulation box"); - //This compute requires a pair style with pair_single method implemented + // This compute requires a pair style with pair_single method implemented - if (!force->pair) - error->all(FLERR,"No pair style is defined for compute stress/mop/profile"); + if (!force->pair) error->all(FLERR, "No pair style is defined for compute stress/mop/profile"); if (force->pair->single_enable == 0) - error->all(FLERR,"Pair style does not support compute stress/mop/profile"); + error->all(FLERR, "Pair style does not support compute stress/mop/profile"); // Errors if (comm->me == 0) { - //Compute stress/mop/profile only accounts for pair interactions. + // Compute stress/mop/profile only accounts for pair interactions. // issue an error if any intramolecular potential or Kspace is defined. if (force->bond) bondflag = 1; if (force->angle) if ((strcmp(force->angle_style, "zero") != 0) && (strcmp(force->angle_style, "none") != 0)) - error->all(FLERR,"compute stress/mop/profile does not account for angle potentials"); + error->all(FLERR, "compute stress/mop/profile does not account for angle potentials"); if (force->dihedral) - if ((strcmp(force->dihedral_style, "zero") != 0) && (strcmp(force->dihedral_style, "none") != 0)) - error->all(FLERR,"compute stress/mop/profile does not account for dihedral potentials"); + if ((strcmp(force->dihedral_style, "zero") != 0) && + (strcmp(force->dihedral_style, "none") != 0)) + error->all(FLERR, "compute stress/mop/profile does not account for dihedral potentials"); if (force->improper) - if ((strcmp(force->improper_style, "zero") != 0) && (strcmp(force->improper_style, "none") != 0)) - error->all(FLERR,"compute stress/mop/profile does not account for improper potentials"); + if ((strcmp(force->improper_style, "zero") != 0) && + (strcmp(force->improper_style, "none") != 0)) + error->all(FLERR, "compute stress/mop/profile does not account for improper potentials"); if (force->kspace) - error->warning(FLERR,"compute stress/mop/profile does not account for kspace contributions"); + error->warning(FLERR, "compute stress/mop/profile does not account for kspace contributions"); } // need an occasional half neighbor list @@ -228,7 +235,6 @@ void ComputeStressMopProfile::init_list(int /* id */, NeighList *ptr) list = ptr; } - /* ---------------------------------------------------------------------- compute output array ------------------------------------------------------------------------- */ @@ -237,39 +243,41 @@ void ComputeStressMopProfile::compute_array() { invoked_array = update->ntimestep; - //Compute pressures on separate procs + // Compute pressures on separate procs + compute_pairs(); // sum pressure contributions over all procs - MPI_Allreduce(&values_local[0][0],&values_global[0][0],nbins*nvalues,MPI_DOUBLE,MPI_SUM,world); + + MPI_Allreduce(&values_local[0][0], &values_global[0][0], nbins * nvalues, MPI_DOUBLE, MPI_SUM, + world); + + // Compute bond contribution on separate procs if (bondflag) { - //Compute bond contribution on separate procs compute_bonds(); } else { for (int m = 0; m < nbins; m++) { - for (int i = 0; i < nvalues; i++) { - bond_local[m][i] = 0.0; - } + for (int i = 0; i < nvalues; i++) { bond_local[m][i] = 0.0; } } } // sum bond contribution over all procs - MPI_Allreduce(&bond_local[0][0],&bond_global[0][0],nbins*nvalues,MPI_DOUBLE,MPI_SUM,world); - for (int ibin=0; ibinmass; double *rmass = atom->rmass; @@ -292,8 +300,8 @@ void ComputeStressMopProfile::compute_pairs() double *special_lj = force->special_lj; int newton_pair = force->newton_pair; - // zero out arrays for one sample + for (m = 0; m < nbins; m++) { for (i = 0; i < nvalues; i++) values_local[m][i] = 0.0; } @@ -351,53 +359,51 @@ void ComputeStressMopProfile::compute_pairs() delx = xi[0] - xj[0]; dely = xi[1] - xj[1]; delz = xi[2] - xj[2]; - rsq = delx*delx + dely*dely + delz*delz; + rsq = delx * delx + dely * dely + delz * delz; jtype = type[j]; if (rsq >= cutsq[itype][jtype]) continue; if (newton_pair || j < nlocal) { - for (ibin=0;ibinpos) && (xj[dir]pos1) && (xj[dir] pos) && (xj[dir] < pos)) || ((xi[dir] > pos1) && (xj[dir] < pos1))) { - pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); + pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair); - values_local[ibin][m] += fpair*(xi[0]-xj[0])/area*nktv2p; - values_local[ibin][m+1] += fpair*(xi[1]-xj[1])/area*nktv2p; - values_local[ibin][m+2] += fpair*(xi[2]-xj[2])/area*nktv2p; + values_local[ibin][m] += fpair * (xi[0] - xj[0]) / area * nktv2p; + values_local[ibin][m + 1] += fpair * (xi[1] - xj[1]) / area * nktv2p; + values_local[ibin][m + 2] += fpair * (xi[2] - xj[2]) / area * nktv2p; - } else if ( ((xi[dir]pos)) - || ((xi[dir]pos1))) { + } else if (((xi[dir] < pos) && (xj[dir] > pos)) || + ((xi[dir] < pos1) && (xj[dir] > pos1))) { - pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); + pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair); - values_local[ibin][m] -= fpair*(xi[0]-xj[0])/area*nktv2p; - values_local[ibin][m+1] -= fpair*(xi[1]-xj[1])/area*nktv2p; - values_local[ibin][m+2] -= fpair*(xi[2]-xj[2])/area*nktv2p; + values_local[ibin][m] -= fpair * (xi[0] - xj[0]) / area * nktv2p; + values_local[ibin][m + 1] -= fpair * (xi[1] - xj[1]) / area * nktv2p; + values_local[ibin][m + 2] -= fpair * (xi[2] - xj[2]) / area * nktv2p; } } } else { - for (ibin=0;ibinpos) && (xj[dir]pos1) && (xj[dir] pos) && (xj[dir] < pos)) || ((xi[dir] > pos1) && (xj[dir] < pos1))) { - pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,fpair); + pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair); - values_local[ibin][m] += fpair*(xi[0]-xj[0])/area*nktv2p; - values_local[ibin][m+1] += fpair*(xi[1]-xj[1])/area*nktv2p; - values_local[ibin][m+2] += fpair*(xi[2]-xj[2])/area*nktv2p; + values_local[ibin][m] += fpair * (xi[0] - xj[0]) / area * nktv2p; + values_local[ibin][m + 1] += fpair * (xi[1] - xj[1]) / area * nktv2p; + values_local[ibin][m + 2] += fpair * (xi[2] - xj[2]) / area * nktv2p; } } } @@ -420,66 +426,57 @@ void ComputeStressMopProfile::compute_pairs() itype = type[i]; - //coordinates at t + // coordinates at t + xi[0] = atom->x[i][0]; xi[1] = atom->x[i][1]; xi[2] = atom->x[i][2]; - //velocities at t + // velocities at t + vi[0] = atom->v[i][0]; vi[1] = atom->v[i][1]; vi[2] = atom->v[i][2]; - //forces at t + // forces at t + fi[0] = atom->f[i][0]; fi[1] = atom->f[i][1]; fi[2] = atom->f[i][2]; - //coordinates at t-dt (based on Velocity-Verlet alg.) - if (rmass) { - xj[0] = xi[0]-vi[0]*dt+fi[0]/2/rmass[i]*dt*dt*ftm2v; - xj[1] = xi[1]-vi[1]*dt+fi[1]/2/rmass[i]*dt*dt*ftm2v; - xj[2] = xi[2]-vi[2]*dt+fi[2]/2/rmass[i]*dt*dt*ftm2v; - } else { - xj[0] = xi[0]-vi[0]*dt+fi[0]/2/mass[itype]*dt*dt*ftm2v; - xj[1] = xi[1]-vi[1]*dt+fi[1]/2/mass[itype]*dt*dt*ftm2v; - xj[2] = xi[2]-vi[2]*dt+fi[2]/2/mass[itype]*dt*dt*ftm2v; - } + const double imass = (rmass) ? rmass[i] : mass[itype]; + const double iterm = 0.5 / imass * dt * ftm2v; + + // coordinates at t-dt (based on Velocity-Verlet alg.) + + xj[0] = xi[0] - vi[0] * dt + fi[0] * iterm * dt; + xj[1] = xi[1] - vi[1] * dt + fi[1] * iterm * dt; + xj[2] = xi[2] - vi[2] * dt + fi[2] * iterm * dt; for (ibin = 0; ibin < nbins; ibin++) { pos = coord[ibin][0]; pos1 = coordp[ibin][0]; - if (((xi[dir]-pos)*(xj[dir]-pos)*(xi[dir]-pos1)*(xj[dir]-pos1)<0)) { + if (((xi[dir] - pos) * (xj[dir] - pos) * (xi[dir] - pos1) * (xj[dir] - pos1) < 0)) { - sgn = copysign(1.0,vi[dir]); + sgn = copysign(1.0, vi[dir]); - //approximate crossing velocity by v(t-dt/2) (based on Velocity-Verlet alg.) - if (rmass) { - double vcross[3]; - vcross[0] = vi[0]-fi[0]/rmass[i]/2*ftm2v*dt; - vcross[1] = vi[1]-fi[1]/rmass[i]/2*ftm2v*dt; - vcross[2] = vi[2]-fi[2]/rmass[i]/2*ftm2v*dt; + // approximate crossing velocity by v(t-dt/2) (based on Velocity-Verlet alg.) - values_local[ibin][m] += rmass[i]*vcross[0]*sgn/dt/area*nktv2p/ftm2v; - values_local[ibin][m+1] += rmass[i]*vcross[1]*sgn/dt/area*nktv2p/ftm2v; - values_local[ibin][m+2] += rmass[i]*vcross[2]*sgn/dt/area*nktv2p/ftm2v; - } else { - double vcross[3]; - vcross[0] = vi[0]-fi[0]/mass[itype]/2*ftm2v*dt; - vcross[1] = vi[1]-fi[1]/mass[itype]/2*ftm2v*dt; - vcross[2] = vi[2]-fi[2]/mass[itype]/2*ftm2v*dt; + double vcross[3]; + vcross[0] = vi[0] - fi[0] * iterm; + vcross[1] = vi[1] - fi[1] * iterm; + vcross[2] = vi[2] - fi[2] * iterm; - values_local[ibin][m] += mass[itype]*vcross[0]*sgn/dt/area*nktv2p/ftm2v; - values_local[ibin][m+1] += mass[itype]*vcross[1]*sgn/dt/area*nktv2p/ftm2v; - values_local[ibin][m+2] += mass[itype]*vcross[2]*sgn/dt/area*nktv2p/ftm2v; - } + values_local[ibin][m] += imass * vcross[0] * sgn / dt / area * nktv2p / ftm2v; + values_local[ibin][m + 1] += imass * vcross[1] * sgn / dt / area * nktv2p / ftm2v; + values_local[ibin][m + 2] += imass * vcross[2] * sgn / dt / area * nktv2p / ftm2v; } } } } } - m+=3; + m += 3; } } @@ -515,16 +512,16 @@ void ComputeStressMopProfile::compute_bonds() double x_bond_2[3] = {0.0, 0.0, 0.0}; // initialization + for (int m = 0; m < nbins; m++) { - for (int i = 0; i < nvalues; i++) { - bond_local[m][i] = 0.0; - } + for (int i = 0; i < nvalues; i++) { bond_local[m][i] = 0.0; } local_contribution[m][0] = 0.0; local_contribution[m][1] = 0.0; local_contribution[m][2] = 0.0; } // loop over all bonded atoms in the current proc + for (atom1 = 0; atom1 < nlocal; atom1++) { if (!(mask[atom1] & groupbit)) continue; @@ -551,10 +548,11 @@ void ComputeStressMopProfile::compute_bonds() if (newton_bond == 0 && tag[atom1] > tag[atom2]) continue; if (btype <= 0) continue; - for (int ibin = 0; ibin= 0)) { dx[0] = x_bond_1[0] - x_bond_2[0]; @@ -584,22 +584,23 @@ void ComputeStressMopProfile::compute_bonds() bond->single(btype, rsq, atom1, atom2, fpair); double sgn = copysign(1.0, x_bond_1[dir] - pos); - local_contribution[ibin][0] += sgn*fpair*dx[0]/area*nktv2p; - local_contribution[ibin][1] += sgn*fpair*dx[1]/area*nktv2p; - local_contribution[ibin][2] += sgn*fpair*dx[2]/area*nktv2p; + local_contribution[ibin][0] += sgn * fpair * dx[0] / area * nktv2p; + local_contribution[ibin][1] += sgn * fpair * dx[1] / area * nktv2p; + local_contribution[ibin][2] += sgn * fpair * dx[2] / area * nktv2p; } } } } // loop over the keywords and if necessary add the bond contribution + int m = 0; while (m < nvalues) { if ((which[m] == CONF) || (which[m] == TOTAL) || (which[m] == BOND)) { for (int ibin = 0; ibin < nbins; ibin++) { bond_local[ibin][m] = local_contribution[ibin][0]; - bond_local[ibin][m+1] = local_contribution[ibin][1]; - bond_local[ibin][m+2] = local_contribution[ibin][2]; + bond_local[ibin][m + 1] = local_contribution[ibin][1]; + bond_local[ibin][m + 2] = local_contribution[ibin][2]; } } m += 3; @@ -613,47 +614,51 @@ void ComputeStressMopProfile::compute_bonds() void ComputeStressMopProfile::setup_bins() { - int i,n; + int i, n; double lo = 0.0, hi = 0.0; - double *boxlo,*boxhi; + double *boxlo, *boxhi; boxlo = domain->boxlo; boxhi = domain->boxhi; - if (originflag == LOWER) origin = boxlo[dir]; - else if (originflag == UPPER) origin = boxhi[dir]; + if (originflag == LOWER) + origin = boxlo[dir]; + else if (originflag == UPPER) + origin = boxhi[dir]; else if (originflag == CENTER) origin = 0.5 * (boxlo[dir] + boxhi[dir]); if (origin < boxlo[dir]) { - error->all(FLERR,"Origin of bins for compute stress/mop/profile is out of bounds" ); + error->all(FLERR, "Origin of bins for compute stress/mop/profile is out of bounds"); } else { - n = static_cast ((origin - boxlo[dir]) * invdelta); - lo = origin - n*delta; + n = static_cast((origin - boxlo[dir]) * invdelta); + lo = origin - n * delta; } if (origin < boxhi[dir]) { - n = static_cast ((boxhi[dir] - origin) * invdelta); - hi = origin + n*delta; + n = static_cast((boxhi[dir] - origin) * invdelta); + hi = origin + n * delta; } else { - error->all(FLERR,"Origin of bins for compute stress/mop/profile is out of bounds" ); + error->all(FLERR, "Origin of bins for compute stress/mop/profile is out of bounds"); } offset = lo; - nbins = static_cast ((hi-lo) * invdelta + 1.5); + nbins = static_cast((hi - lo) * invdelta + 1.5); - //allocate bin arrays - memory->create(coord,nbins,1,"stress/mop/profile:coord"); - memory->create(coordp,nbins,1,"stress/mop/profile:coordp"); - memory->create(values_local,nbins,nvalues,"stress/mop/profile:values_local"); - memory->create(values_global,nbins,nvalues,"stress/mop/profile:values_global"); - memory->create(bond_local,nbins,nvalues,"stress/mop/profile:bond_local"); - memory->create(bond_global,nbins,nvalues,"stress/mop/profile:bond_global"); - memory->create(local_contribution,nbins,3,"stress/mop/profile:local_contribution"); + // allocate bin arrays + + memory->create(coord, nbins, 1, "stress/mop/profile:coord"); + memory->create(coordp, nbins, 1, "stress/mop/profile:coordp"); + memory->create(values_local, nbins, nvalues, "stress/mop/profile:values_local"); + memory->create(values_global, nbins, nvalues, "stress/mop/profile:values_global"); + memory->create(bond_local, nbins, nvalues, "stress/mop/profile:bond_local"); + memory->create(bond_global, nbins, nvalues, "stress/mop/profile:bond_global"); + memory->create(local_contribution, nbins, 3, "stress/mop/profile:local_contribution"); // set bin coordinates + for (i = 0; i < nbins; i++) { - coord[i][0] = offset + i*delta; - if (coord[i][0] < (domain->boxlo[dir]+domain->prd_half[dir])) { + coord[i][0] = offset + i * delta; + if (coord[i][0] < (domain->boxlo[dir] + domain->prd_half[dir])) { coordp[i][0] = coord[i][0] + domain->prd[dir]; } else { coordp[i][0] = coord[i][0] - domain->prd[dir]; diff --git a/src/EXTRA-DUMP/dump_xtc.cpp b/src/EXTRA-DUMP/dump_xtc.cpp index 6b0b97181b..798bdcb391 100644 --- a/src/EXTRA-DUMP/dump_xtc.cpp +++ b/src/EXTRA-DUMP/dump_xtc.cpp @@ -740,7 +740,7 @@ static void receiveints(int buf[], const int num_of_ints, int num_of_bits, } for (i = num_of_ints-1; i > 0; i--) { num = 0; - for (j = num_of_bytes-1; j >=0; j--) { + for (j = num_of_bytes-1; j >= 0; j--) { num = (num << 8) | bytes[j]; p = num / sizes[i]; bytes[j] = p; @@ -1046,7 +1046,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision) sizesmall[0] = sizesmall[1] = sizesmall[2] = magicints[smallidx]; } } - if (buf[1] != 0) buf[0]++;; + if (buf[1] != 0) buf[0]++; xdr_int(xdrs, &(buf[0])); /* buf[0] holds the length in bytes */ return errval * (xdr_opaque(xdrs, (caddr_t)&(buf[3]), (u_int)buf[0])); } else { diff --git a/src/EXTRA-FIX/fix_wall_ees.cpp b/src/EXTRA-FIX/fix_wall_ees.cpp index 230b8f6ac0..0e4d5aa1eb 100644 --- a/src/EXTRA-FIX/fix_wall_ees.cpp +++ b/src/EXTRA-FIX/fix_wall_ees.cpp @@ -116,7 +116,7 @@ void FixWallEES::wall_particle(int m, int which, double coord) nhat[(dim+2)%3] = 0 ; - double* shape = bonus[ellipsoid[i]].shape;; + double* shape = bonus[ellipsoid[i]].shape; MathExtra::quat_to_mat(bonus[ellipsoid[i]].quat,A); MathExtra::transpose_matvec(A,nhat,tempvec); for (int k = 0; k<3; k++) { diff --git a/src/EXTRA-FIX/fix_wall_reflect_stochastic.cpp b/src/EXTRA-FIX/fix_wall_reflect_stochastic.cpp index c0b44530e8..c435cc14ae 100644 --- a/src/EXTRA-FIX/fix_wall_reflect_stochastic.cpp +++ b/src/EXTRA-FIX/fix_wall_reflect_stochastic.cpp @@ -109,7 +109,7 @@ FixWallReflectStochastic(LAMMPS *lmp, int narg, char **arg) : for (int dir = 0; dir < 3; dir++) { wallvel[nwall][dir]= utils::numeric(FLERR,arg[iarg+dir+3],false,lmp); int dim = wallwhich[nwall] / 2; - if ((wallvel[nwall][dir] !=0) & (dir == dim)) + if ((wallvel[nwall][dir] != 0) & (dir == dim)) error->all(FLERR,"The wall velocity must be tangential"); // DIFFUSIVE = no accommodation coeffs diff --git a/src/EXTRA-PAIR/pair_lj_relres.cpp b/src/EXTRA-PAIR/pair_lj_relres.cpp index 85d0a04bf9..1826f3f1db 100644 --- a/src/EXTRA-PAIR/pair_lj_relres.cpp +++ b/src/EXTRA-PAIR/pair_lj_relres.cpp @@ -453,7 +453,7 @@ double PairLJRelRes::init_one(int i, int j) offset[i][j] = 0.0; } - if (epsilonf[i][j] != 0 ) { // fg (cut=cutf coefficients) + if (epsilonf[i][j] != 0) { // fg (cut=cutf coefficients) ljf1[i][j] = 48.0 * epsilonf[i][j] * pow(sigmaf[i][j],12.0); ljf2[i][j] = 24.0 * epsilonf[i][j] * pow(sigmaf[i][j],6.0); ljf3[i][j] = 4.0 * epsilonf[i][j] * pow(sigmaf[i][j],12.0); diff --git a/src/FEP/fix_adapt_fep.cpp b/src/FEP/fix_adapt_fep.cpp index 6e38c90ef2..e050b8cf21 100644 --- a/src/FEP/fix_adapt_fep.cpp +++ b/src/FEP/fix_adapt_fep.cpp @@ -82,7 +82,6 @@ FixAdaptFEP::FixAdaptFEP(LAMMPS *lmp, int narg, char **arg) : // parse keywords nadapt = 0; - diamflag = 0; chgflag = 0; iarg = 4; @@ -114,7 +113,7 @@ FixAdaptFEP::FixAdaptFEP(LAMMPS *lmp, int narg, char **arg) : adapt[nadapt].which = ATOM; if (strcmp(arg[iarg+1],"diameter") == 0) { adapt[nadapt].aparam = DIAMETER; - diamflag = 1; + diam_flag = 1; } else if (strcmp(arg[iarg+1],"charge") == 0) { adapt[nadapt].aparam = CHARGE; chgflag = 1; @@ -201,7 +200,7 @@ int FixAdaptFEP::setmask() void FixAdaptFEP::post_constructor() { if (!resetflag) return; - if (!diamflag && !chgflag) return; + if (!diam_flag && !chgflag) return; // new id = fix-ID + FIX_STORE_ATTRIBUTE // new fix group = group for this fix @@ -209,7 +208,7 @@ void FixAdaptFEP::post_constructor() id_fix_diam = nullptr; id_fix_chg = nullptr; - if (diamflag) { + if (diam_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]))); @@ -513,7 +512,7 @@ void FixAdaptFEP::restore_settings() *kspace_scale = 1.0; } else if (ad->which == ATOM) { - if (diamflag) { + if (diam_flag) { double density; double *vec = fix_diam->vstore; diff --git a/src/FEP/fix_adapt_fep.h b/src/FEP/fix_adapt_fep.h index 370a34a0f3..97749abcb6 100644 --- a/src/FEP/fix_adapt_fep.h +++ b/src/FEP/fix_adapt_fep.h @@ -26,7 +26,6 @@ namespace LAMMPS_NS { class FixAdaptFEP : public Fix { public: - int diamflag; // 1 if atom diameters will vary, for AtomVecGranular int chgflag; FixAdaptFEP(class LAMMPS *, int, char **); diff --git a/src/GPU/pair_amoeba_gpu.cpp b/src/GPU/pair_amoeba_gpu.cpp index b7e1f8e118..8b3cf2cfea 100644 --- a/src/GPU/pair_amoeba_gpu.cpp +++ b/src/GPU/pair_amoeba_gpu.cpp @@ -745,15 +745,15 @@ void PairAmoebaGPU::udirect2b(double **field, double **fieldp) auto field_ptr = (float *)fieldp_pinned; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; field[i][0] += field_ptr[idx]; field[i][1] += field_ptr[idx+1]; field[i][2] += field_ptr[idx+2]; } - field_ptr += 4*inum; + field_ptr += 3*inum; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; fieldp[i][0] += field_ptr[idx]; fieldp[i][1] += field_ptr[idx+1]; fieldp[i][2] += field_ptr[idx+2]; @@ -762,15 +762,15 @@ void PairAmoebaGPU::udirect2b(double **field, double **fieldp) auto field_ptr = (double *)fieldp_pinned; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; field[i][0] += field_ptr[idx]; field[i][1] += field_ptr[idx+1]; field[i][2] += field_ptr[idx+2]; } - field_ptr += 4*inum; + field_ptr += 3*inum; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; fieldp[i][0] += field_ptr[idx]; fieldp[i][1] += field_ptr[idx+1]; fieldp[i][2] += field_ptr[idx+2]; @@ -976,15 +976,15 @@ void PairAmoebaGPU::ufield0c(double **field, double **fieldp) auto field_ptr = (float *)fieldp_pinned; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; field[i][0] += field_ptr[idx]; field[i][1] += field_ptr[idx+1]; field[i][2] += field_ptr[idx+2]; } - field_ptr += 4*inum; + field_ptr += 3*inum; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; fieldp[i][0] += field_ptr[idx]; fieldp[i][1] += field_ptr[idx+1]; fieldp[i][2] += field_ptr[idx+2]; @@ -993,15 +993,15 @@ void PairAmoebaGPU::ufield0c(double **field, double **fieldp) auto field_ptr = (double *)fieldp_pinned; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; field[i][0] += field_ptr[idx]; field[i][1] += field_ptr[idx+1]; field[i][2] += field_ptr[idx+2]; } - field_ptr += 4*inum; + field_ptr += 3*inum; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; fieldp[i][0] += field_ptr[idx]; fieldp[i][1] += field_ptr[idx+1]; fieldp[i][2] += field_ptr[idx+2]; @@ -2029,9 +2029,9 @@ void PairAmoebaGPU::compute_force_from_torque(const numtyp* tq_ptr, int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { - _tq[0] = tq_ptr[4*i]; - _tq[1] = tq_ptr[4*i+1]; - _tq[2] = tq_ptr[4*i+2]; + _tq[0] = tq_ptr[3*i]; + _tq[1] = tq_ptr[3*i+1]; + _tq[2] = tq_ptr[3*i+2]; torque2force(i,_tq,fix,fiy,fiz,force_comp); iz = zaxis2local[i]; diff --git a/src/GPU/pair_hippo_gpu.cpp b/src/GPU/pair_hippo_gpu.cpp index f87676ec08..256b4088d8 100644 --- a/src/GPU/pair_hippo_gpu.cpp +++ b/src/GPU/pair_hippo_gpu.cpp @@ -859,15 +859,15 @@ void PairHippoGPU::udirect2b(double **field, double **fieldp) auto field_ptr = (float *)fieldp_pinned; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; field[i][0] += field_ptr[idx]; field[i][1] += field_ptr[idx+1]; field[i][2] += field_ptr[idx+2]; } - field_ptr += 4*inum; + field_ptr += 3*inum; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; fieldp[i][0] += field_ptr[idx]; fieldp[i][1] += field_ptr[idx+1]; fieldp[i][2] += field_ptr[idx+2]; @@ -877,15 +877,15 @@ void PairHippoGPU::udirect2b(double **field, double **fieldp) auto field_ptr = (double *)fieldp_pinned; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; field[i][0] += field_ptr[idx]; field[i][1] += field_ptr[idx+1]; field[i][2] += field_ptr[idx+2]; } - field_ptr += 4*inum; + field_ptr += 3*inum; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; fieldp[i][0] += field_ptr[idx]; fieldp[i][1] += field_ptr[idx+1]; fieldp[i][2] += field_ptr[idx+2]; @@ -1087,15 +1087,15 @@ void PairHippoGPU::ufield0c(double **field, double **fieldp) auto *field_ptr = (float *)fieldp_pinned; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; field[i][0] += field_ptr[idx]; field[i][1] += field_ptr[idx+1]; field[i][2] += field_ptr[idx+2]; } - field_ptr += 4*inum; + field_ptr += 3*inum; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; fieldp[i][0] += field_ptr[idx]; fieldp[i][1] += field_ptr[idx+1]; fieldp[i][2] += field_ptr[idx+2]; @@ -1105,15 +1105,15 @@ void PairHippoGPU::ufield0c(double **field, double **fieldp) auto *field_ptr = (double *)fieldp_pinned; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; field[i][0] += field_ptr[idx]; field[i][1] += field_ptr[idx+1]; field[i][2] += field_ptr[idx+2]; } - field_ptr += 4*inum; + field_ptr += 3*inum; for (int i = 0; i < nlocal; i++) { - int idx = 4*i; + int idx = 3*i; fieldp[i][0] += field_ptr[idx]; fieldp[i][1] += field_ptr[idx+1]; fieldp[i][2] += field_ptr[idx+2]; @@ -1456,9 +1456,9 @@ void PairHippoGPU::compute_force_from_torque(const numtyp* tq_ptr, int nlocal = atom->nlocal; for (i = 0; i < nlocal; i++) { - _tq[0] = tq_ptr[4*i]; - _tq[1] = tq_ptr[4*i+1]; - _tq[2] = tq_ptr[4*i+2]; + _tq[0] = tq_ptr[3*i]; + _tq[1] = tq_ptr[3*i+1]; + _tq[2] = tq_ptr[3*i+2]; torque2force(i,_tq,fix,fiy,fiz,force_comp); iz = zaxis2local[i]; diff --git a/src/GRANULAR/fix_heat_flow.cpp b/src/GRANULAR/fix_heat_flow.cpp index a9c110a2e7..d0d7a73ce6 100644 --- a/src/GRANULAR/fix_heat_flow.cpp +++ b/src/GRANULAR/fix_heat_flow.cpp @@ -1,4 +1,3 @@ -// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -26,39 +25,37 @@ using namespace LAMMPS_NS; using namespace FixConst; -enum {NONE, CONSTANT, TYPE}; +enum { NONE, CONSTANT, TYPE }; /* ---------------------------------------------------------------------- */ -FixHeatFlow::FixHeatFlow(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg) +FixHeatFlow::FixHeatFlow(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg < 4) error->all(FLERR,"Illegal fix command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "fix heat/flow", error); cp_style = NONE; comm_forward = 1; comm_reverse = 1; int ntypes = atom->ntypes; - if (strcmp(arg[3],"constant") == 0) { - if (narg != 5) error->all(FLERR,"Illegal fix command"); + if (strcmp(arg[3], "constant") == 0) { + if (narg != 5) error->all(FLERR, "Illegal fix heat/flow constant command"); cp_style = CONSTANT; - cp = utils::numeric(FLERR,arg[4],false,lmp); - if (cp < 0.0) error->all(FLERR,"Illegal fix command"); - } else if (strcmp(arg[3],"type") == 0) { - if (narg != 4 + ntypes) error->all(FLERR,"Illegal fix command"); + cp = utils::numeric(FLERR, arg[4], false, lmp); + if (cp < 0.0) error->all(FLERR, "Illegal fix heat/flow constant command value"); + } else if (strcmp(arg[3], "type") == 0) { + if (narg != 4 + ntypes) error->all(FLERR, "Illegal fix heat/flow type command"); cp_style = TYPE; - memory->create(cp_type,ntypes+1,"fix/temp/integrate:cp_type"); + memory->create(cp_type, ntypes + 1, "fix_heat_flow:cp_type"); for (int i = 1; i <= ntypes; i++) { - cp_type[i] = utils::numeric(FLERR,arg[3+i],false,lmp); - if (cp_type[i] < 0.0) error->all(FLERR,"Illegal fix command"); + cp_type[i] = utils::numeric(FLERR, arg[3 + i], false, lmp); + if (cp_type[i] < 0.0) error->all(FLERR, "Illegal fix heat/flow type command value"); } } else { - error->all(FLERR,"Illegal fix command"); + error->all(FLERR, "Unknown fix heat/flow keyword {}", arg[3]); } - if (cp_style == NONE) - error->all(FLERR, "Must specify specific heat in fix temp/integrate"); + if (cp_style == NONE) error->all(FLERR, "Must specify specific heat in fix heat/flow"); dynamic_group_allow = 1; } @@ -80,32 +77,24 @@ void FixHeatFlow::init() dt = update->dt; if (!atom->temperature_flag) - error->all(FLERR,"Fix temp/integrate requires atom style with temperature property"); + error->all(FLERR, "Fix heat/flow requires atom style with temperature property"); if (!atom->heatflow_flag) - error->all(FLERR,"Fix temp/integrate requires atom style with heatflow property"); -} - -/* ---------------------------------------------------------------------- */ - -void FixHeatFlow::setup(int /*vflag*/) -{ - // Identify whether this is the first instance of fix heat/flow - first_flag = 0; - - int i = 0; - auto fixlist = modify->get_fix_by_style("heat/flow"); - for (const auto &ifix : fixlist) { - if (strcmp(ifix->id, id) == 0) break; - i++; - } - - if (i == 0) first_flag = 1; + error->all(FLERR, "Fix heat/flow requires atom style with heatflow property"); } /* ---------------------------------------------------------------------- */ void FixHeatFlow::setup_pre_force(int /*vflag*/) { + // Identify whether this is the first instance of fix heat/flow + first_flag = 0; + int i = 0; + auto fixlist = modify->get_fix_by_style("heat/flow"); + for (const auto &ifix : fixlist) { + if (strcmp(ifix->id, id) == 0) break; + i++; + } + if (i == 0) first_flag = 1; pre_force(0); } @@ -138,19 +127,14 @@ void FixHeatFlow::final_integrate() if (igroup == atom->firstgroup) nlocal = atom->nfirst; // add ghost contributions to heatflow if first instance of fix - if (first_flag) - comm->reverse_comm(this); + if (first_flag) comm->reverse_comm(this); if (rmass) { for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit) { - temperature[i] += dt * heatflow[i] / (calc_cp(i) * rmass[i]); - } + if (mask[i] & groupbit) temperature[i] += dt * heatflow[i] / (calc_cp(i) * rmass[i]); } else { for (int i = 0; i < nlocal; i++) - if (mask[i] & groupbit) { - temperature[i] += dt * heatflow[i] / (calc_cp(i) * mass[type[i]]); - } + if (mask[i] & groupbit) temperature[i] += dt * heatflow[i] / (calc_cp(i) * mass[type[i]]); } } @@ -219,9 +203,7 @@ int FixHeatFlow::pack_reverse_comm(int n, int first, double *buf) int last = first + n; double *heatflow = atom->heatflow; - for (int i = first; i < last; i++) { - buf[m++] = heatflow[i]; - } + for (int i = first; i < last; i++) { buf[m++] = heatflow[i]; } return m; } @@ -233,6 +215,5 @@ void FixHeatFlow::unpack_reverse_comm(int n, int *list, double *buf) int m = 0; double *heatflow = atom->heatflow; - for (int i = 0; i < n; i++) - heatflow[list[i]] += buf[m++]; + for (int i = 0; i < n; i++) heatflow[list[i]] += buf[m++]; } diff --git a/src/GRANULAR/fix_heat_flow.h b/src/GRANULAR/fix_heat_flow.h index 5a06eed4d3..89fabc5a4d 100644 --- a/src/GRANULAR/fix_heat_flow.h +++ b/src/GRANULAR/fix_heat_flow.h @@ -30,7 +30,6 @@ class FixHeatFlow : public Fix { int setmask() override; void init() override; - void setup(int) override; void setup_pre_force(int) override; void pre_force(int) override; void final_integrate() override; diff --git a/src/GRANULAR/gran_sub_mod_heat.cpp b/src/GRANULAR/gran_sub_mod_heat.cpp index 75dcd30b73..5378a72fd4 100644 --- a/src/GRANULAR/gran_sub_mod_heat.cpp +++ b/src/GRANULAR/gran_sub_mod_heat.cpp @@ -41,6 +41,34 @@ double GranSubModHeatNone::calculate_heat() return 0.0; } +/* ---------------------------------------------------------------------- + Radius-based heat conduction +------------------------------------------------------------------------- */ + +GranSubModHeatRadius::GranSubModHeatRadius(GranularModel *gm, LAMMPS *lmp) : GranSubModHeat(gm, lmp) +{ + num_coeffs = 1; + contact_radius_flag = 1; + conductivity = 0.0; +} + +/* ---------------------------------------------------------------------- */ + +void GranSubModHeatRadius::coeffs_to_local() +{ + conductivity = coeffs[0]; + + if (conductivity < 0.0) error->all(FLERR, "Illegal radius heat model"); +} + +/* ---------------------------------------------------------------------- */ + +double GranSubModHeatRadius::calculate_heat() +{ + return 2 * conductivity * gm->contact_radius * (gm->Tj - gm->Ti); +} + + /* ---------------------------------------------------------------------- Area-based heat conduction ------------------------------------------------------------------------- */ @@ -49,20 +77,21 @@ GranSubModHeatArea::GranSubModHeatArea(GranularModel *gm, LAMMPS *lmp) : GranSub { num_coeffs = 1; contact_radius_flag = 1; + heat_transfer_coeff = 0.0; } /* ---------------------------------------------------------------------- */ void GranSubModHeatArea::coeffs_to_local() { - conductivity = coeffs[0]; + heat_transfer_coeff = coeffs[0]; - if (conductivity < 0.0) error->all(FLERR, "Illegal area heat model"); + if (heat_transfer_coeff < 0.0) error->all(FLERR, "Illegal area heat model"); } /* ---------------------------------------------------------------------- */ double GranSubModHeatArea::calculate_heat() { - return conductivity * MY_PI * gm->contact_radius * gm->contact_radius * (gm->Tj - gm->Ti); + return heat_transfer_coeff * MY_PI * gm->contact_radius * gm->contact_radius * (gm->Tj - gm->Ti); } diff --git a/src/GRANULAR/gran_sub_mod_heat.h b/src/GRANULAR/gran_sub_mod_heat.h index 8e5dc2693d..5f264cb913 100644 --- a/src/GRANULAR/gran_sub_mod_heat.h +++ b/src/GRANULAR/gran_sub_mod_heat.h @@ -14,6 +14,7 @@ #ifdef GRAN_SUB_MOD_CLASS // clang-format off GranSubModStyle(none,GranSubModHeatNone,HEAT); +GranSubModStyle(radius,GranSubModHeatRadius,HEAT); GranSubModStyle(area,GranSubModHeatArea,HEAT); // clang-format on #else @@ -42,9 +43,9 @@ namespace Granular_NS { /* ---------------------------------------------------------------------- */ - class GranSubModHeatArea : public GranSubModHeat { + class GranSubModHeatRadius : public GranSubModHeat { public: - GranSubModHeatArea(class GranularModel *, class LAMMPS *); + GranSubModHeatRadius(class GranularModel *, class LAMMPS *); void coeffs_to_local() override; double calculate_heat() override; @@ -52,6 +53,18 @@ namespace Granular_NS { double conductivity; }; + /* ---------------------------------------------------------------------- */ + + class GranSubModHeatArea : public GranSubModHeat { + public: + GranSubModHeatArea(class GranularModel *, class LAMMPS *); + void coeffs_to_local() override; + double calculate_heat() override; + + protected: + double heat_transfer_coeff; + }; + } // namespace Granular_NS } // namespace LAMMPS_NS diff --git a/src/GRANULAR/pair_granular.cpp b/src/GRANULAR/pair_granular.cpp index 0b6bd537e5..30f272791e 100644 --- a/src/GRANULAR/pair_granular.cpp +++ b/src/GRANULAR/pair_granular.cpp @@ -767,10 +767,10 @@ double PairGranular::single(int i, int j, int itype, int jtype, model->history = history; model->calculate_forces(); - double *forces = model->forces; // apply forces & torques - fforce = MathExtra::len3(forces); + // Calculate normal component, normalized by r + fforce = model->Fnormal * model->rinv; // set single_extra quantities svector[0] = model->fs[0]; diff --git a/src/INTEL/fix_intel.cpp b/src/INTEL/fix_intel.cpp index 4c46608677..0a3d27a978 100644 --- a/src/INTEL/fix_intel.cpp +++ b/src/INTEL/fix_intel.cpp @@ -430,7 +430,7 @@ void FixIntel::pair_init_check(const bool cdmessage) double *time1 = off_watch_pair(); double *time2 = off_watch_neighbor(); int *overflow = get_off_overflow_flag(); - if (_offload_balance !=0.0) { + if (_offload_balance != 0.0) { #pragma offload_transfer target(mic:_cop) \ nocopy(time1,time2:length(1) alloc_if(1) free_if(0)) \ in(overflow:length(5) alloc_if(1) free_if(0)) diff --git a/src/INTEL/intel_intrinsics_airebo.h b/src/INTEL/intel_intrinsics_airebo.h index 5a7959c683..04cc78f3d2 100644 --- a/src/INTEL/intel_intrinsics_airebo.h +++ b/src/INTEL/intel_intrinsics_airebo.h @@ -749,7 +749,7 @@ struct intr_types { #include #include -#include // requires C++-11 +#include #define VEC_INLINE __attribute__((always_inline)) diff --git a/src/INTEL/npair_full_bin_intel.cpp b/src/INTEL/npair_full_bin_intel.cpp index 2f8af4c8af..285ed35ec9 100644 --- a/src/INTEL/npair_full_bin_intel.cpp +++ b/src/INTEL/npair_full_bin_intel.cpp @@ -62,7 +62,7 @@ fbi(NeighList *list, IntelBuffers *buffers) { list->inum = nlocal; list->gnum = 0; - int host_start = _fix->host_start_neighbor();; + int host_start = _fix->host_start_neighbor(); const int off_end = _fix->offload_end_neighbor(); #ifdef _LMP_INTEL_OFFLOAD diff --git a/src/INTEL/pppm_disp_intel.cpp b/src/INTEL/pppm_disp_intel.cpp index cc4aa6ab93..6dac9fad99 100644 --- a/src/INTEL/pppm_disp_intel.cpp +++ b/src/INTEL/pppm_disp_intel.cpp @@ -1478,7 +1478,7 @@ void PPPMDispIntel::fieldforce_c_ik(IntelBuffers * /*buffers*/) int nxsum = nx + nlower; int nysum = ny + nlower; - int nzsum = nz + nlower;; + int nzsum = nz + nlower; FFT_SCALAR dx = nx+fshiftone - (x[i][0]-lo0)*xi; FFT_SCALAR dy = ny+fshiftone - (x[i][1]-lo1)*yi; diff --git a/src/INTERLAYER/pair_ilp_tmd.cpp b/src/INTERLAYER/pair_ilp_tmd.cpp index fd3a2f8c6f..8b08de39c0 100644 --- a/src/INTERLAYER/pair_ilp_tmd.cpp +++ b/src/INTERLAYER/pair_ilp_tmd.cpp @@ -481,11 +481,11 @@ void PairILPTMD::calc_normal() jH2 = atom->map(tag[i] - 2); iH1 = map[type[jH1]]; iH2 = map[type[jH2]]; - if (strcmp(elements[iH1], "Ow") == 0 ) { + if (strcmp(elements[iH1], "Ow") == 0) { vect[0][0] = x[jH1][0] - xtp; vect[0][1] = x[jH1][1] - ytp; vect[0][2] = x[jH1][2] - ztp; - } else if (strcmp(elements[iH2], "Ow") == 0 ) { + } else if (strcmp(elements[iH2], "Ow") == 0) { vect[0][0] = x[jH2][0] - xtp; vect[0][1] = x[jH2][1] - ytp; vect[0][2] = x[jH2][2] - ztp; diff --git a/src/KIM/pair_kim.cpp b/src/KIM/pair_kim.cpp index ae2e6e6ea0..e0fc90ea46 100644 --- a/src/KIM/pair_kim.cpp +++ b/src/KIM/pair_kim.cpp @@ -198,8 +198,7 @@ PairKIM::~PairKIM() void PairKIM::set_contributing() { int const nall = atom->nlocal + atom->nghost; - for (int i = 0; i < nall; ++i) - kim_particleContributing[i] = ( (i < atom->nlocal) ? 1 : 0 ); + for (int i = 0; i < nall; ++i) kim_particleContributing[i] = (i < atom->nlocal) ? 1 : 0; } /* ---------------------------------------------------------------------- */ @@ -596,7 +595,7 @@ void PairKIM::init_style() if (kim_cutoff_values[i] <= neighbor->skin) error->all(FLERR,"Illegal neighbor request (force cutoff {:.3} <= skin {:.3})", kim_cutoff_values[i], neighbor->skin); - req->set_cutoff(kim_cutoff_values[i] + neighbor->skin); + req->set_cutoff(kim_cutoff_values[i]); } // increment instance_me in case of need to change the neighbor list // request settings diff --git a/src/KOKKOS/atom_vec_dpd_kokkos.cpp b/src/KOKKOS/atom_vec_dpd_kokkos.cpp index eda26a92dc..a8ce29f666 100644 --- a/src/KOKKOS/atom_vec_dpd_kokkos.cpp +++ b/src/KOKKOS/atom_vec_dpd_kokkos.cpp @@ -116,22 +116,22 @@ void AtomVecDPDKokkos::grow_pointers() d_dpdTheta = atomKK->k_dpdTheta.d_view; h_dpdTheta = atomKK->k_dpdTheta.h_view; uCond = atomKK->uCond; - d_uCond = atomKK->k_uCond.d_view;; + d_uCond = atomKK->k_uCond.d_view; h_uCond = atomKK->k_uCond.h_view; uMech = atomKK->uMech; - d_uMech = atomKK->k_uMech.d_view;; + d_uMech = atomKK->k_uMech.d_view; h_uMech = atomKK->k_uMech.h_view; uChem = atomKK->uChem; - d_uChem = atomKK->k_uChem.d_view;; + d_uChem = atomKK->k_uChem.d_view; h_uChem = atomKK->k_uChem.h_view; uCG = atomKK->uCG; - d_uCG = atomKK->k_uCG.d_view;; + d_uCG = atomKK->k_uCG.d_view; h_uCG = atomKK->k_uCG.h_view; uCGnew = atomKK->uCGnew; - d_uCGnew = atomKK->k_uCGnew.d_view;; + d_uCGnew = atomKK->k_uCGnew.d_view; h_uCGnew = atomKK->k_uCGnew.h_view; duChem = atomKK->duChem; - d_duChem = atomKK->k_duChem.d_view;; + d_duChem = atomKK->k_duChem.d_view; h_duChem = atomKK->k_duChem.h_view; } diff --git a/src/KOKKOS/atom_vec_sphere_kokkos.cpp b/src/KOKKOS/atom_vec_sphere_kokkos.cpp index a9b64fc835..5a1c2beee3 100644 --- a/src/KOKKOS/atom_vec_sphere_kokkos.cpp +++ b/src/KOKKOS/atom_vec_sphere_kokkos.cpp @@ -20,7 +20,6 @@ #include "domain.h" #include "error.h" #include "fix.h" -#include "fix_adapt.h" #include "math_const.h" #include "memory.h" #include "memory_kokkos.h" diff --git a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp index 157d41126f..263a070a3a 100644 --- a/src/KOKKOS/compute_orientorder_atom_kokkos.cpp +++ b/src/KOKKOS/compute_orientorder_atom_kokkos.cpp @@ -386,7 +386,7 @@ void ComputeOrientOrderAtomKokkos::select3(int k, int n, int ii) con l = 0; ir = n-1; - for (;;) { + while (true) { if (ir <= l+1) { if (ir == l+1 && arr[ir] < arr[l]) { SWAP(arr,l,ir); @@ -421,7 +421,7 @@ void ComputeOrientOrderAtomKokkos::select3(int k, int n, int ii) con a3[0] = arr3(l+1,0); a3[1] = arr3(l+1,1); a3[2] = arr3(l+1,2); - for (;;) { + while (true) { do i++; while (arr[i] < a); do j--; while (arr[j] > a); if (j < i) break; diff --git a/src/KOKKOS/dihedral_harmonic_kokkos.cpp b/src/KOKKOS/dihedral_harmonic_kokkos.cpp index 96287946ea..8ca0b368df 100644 --- a/src/KOKKOS/dihedral_harmonic_kokkos.cpp +++ b/src/KOKKOS/dihedral_harmonic_kokkos.cpp @@ -265,9 +265,9 @@ void DihedralHarmonicKokkos::operator()(TagDihedralHarmonicCompute::spectrum_dxdr(int nlocal, DAT::tdual_int_1d nu 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 ){ + 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); diff --git a/src/KOKKOS/mliap_unified_couple_kokkos.pyx b/src/KOKKOS/mliap_unified_couple_kokkos.pyx index 5e274d7f36..bd94b79eb4 100644 --- a/src/KOKKOS/mliap_unified_couple_kokkos.pyx +++ b/src/KOKKOS/mliap_unified_couple_kokkos.pyx @@ -346,6 +346,16 @@ cdef class MLIAPDataPy: return None return create_array(self.data.dev, self.data.rij, [self.npairs,3],False) + @property + def rij_max(self): + if self.data.rij is NULL: + return None + return create_array(self.data.dev, self.data.rij, [self.nneigh_max,3], False) + + @property + def nneigh_max(self): + return self.data.nneigh_max + @write_only_property def graddesc(self, value): if self.data.graddesc is NULL: diff --git a/src/KOKKOS/mliap_unified_kokkos.cpp b/src/KOKKOS/mliap_unified_kokkos.cpp index 1fdf039473..deb9cbc346 100644 --- a/src/KOKKOS/mliap_unified_kokkos.cpp +++ b/src/KOKKOS/mliap_unified_kokkos.cpp @@ -371,6 +371,25 @@ void LAMMPS_NS::update_pair_forces(MLIAPDataKokkosDevice *data, double *fij) } } +/* ---------------------------------------------------------------------- + set energy for i indexed atoms + ---------------------------------------------------------------------- */ + +void LAMMPS_NS::update_atom_energy(MLIAPDataKokkosDevice *data, double *ei) +{ + auto d_eatoms = data->eatoms; + const auto nlistatoms = data->nlistatoms; + + Kokkos::parallel_reduce(nlistatoms, 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 < nlistatoms) { + d_eatoms[i] = e; + local_sum += e; + } + },*data->energy); +} + namespace LAMMPS_NS { template class MLIAPDummyModelKokkos; template class MLIAPDummyDescriptorKokkos; diff --git a/src/KOKKOS/mliap_unified_kokkos.h b/src/KOKKOS/mliap_unified_kokkos.h index aad25891b0..1af7715dad 100644 --- a/src/KOKKOS/mliap_unified_kokkos.h +++ b/src/KOKKOS/mliap_unified_kokkos.h @@ -60,6 +60,7 @@ template MLIAPBuildUnifiedKokkos_t build_unified(char *, MLIAPDataKokkos *, LAMMPS *, char * = NULL); void update_pair_energy(MLIAPDataKokkosDevice *, double *); void update_pair_forces(MLIAPDataKokkosDevice *, double *); +void update_atom_energy(MLIAPDataKokkosDevice *, double *); } // namespace LAMMPS_NS diff --git a/src/KOKKOS/neigh_bond_kokkos.cpp b/src/KOKKOS/neigh_bond_kokkos.cpp index 9067284426..4cfe440b1f 100644 --- a/src/KOKKOS/neigh_bond_kokkos.cpp +++ b/src/KOKKOS/neigh_bond_kokkos.cpp @@ -266,7 +266,7 @@ void NeighBondKokkos::bond_all() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); - if (all && me ==0) + if (all && me == 0) error->warning(FLERR,"Bond atoms missing at step {}", update->ntimestep); k_bondlist.modify(); @@ -345,7 +345,7 @@ void NeighBondKokkos::bond_partial() int all; MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world); - if (all && me ==0) + if (all && me == 0) error->warning(FLERR,"Bond atoms missing at step {}", update->ntimestep); k_bondlist.modify(); diff --git a/src/KOKKOS/pair_meam_kokkos.cpp b/src/KOKKOS/pair_meam_kokkos.cpp index c2b03c2054..daf9c1e18b 100644 --- a/src/KOKKOS/pair_meam_kokkos.cpp +++ b/src/KOKKOS/pair_meam_kokkos.cpp @@ -980,7 +980,7 @@ void PairMEAMKokkos::update_meam_views() namespace LAMMPS_NS { template class PairMEAMKokkos; -#ifdef KOKKOS_ENABLE_CUDA +#ifdef LMP_KOKKOS_GPU template class PairMEAMKokkos; #endif } diff --git a/src/KOKKOS/pair_meam_ms_kokkos.cpp b/src/KOKKOS/pair_meam_ms_kokkos.cpp index 491fc0273c..eaa7d500b9 100644 --- a/src/KOKKOS/pair_meam_ms_kokkos.cpp +++ b/src/KOKKOS/pair_meam_ms_kokkos.cpp @@ -26,7 +26,7 @@ PairMEAMMSKokkos::PairMEAMMSKokkos(LAMMPS *lmp) : PairMEAMKokkos; -#ifdef KOKKOS_ENABLE_CUDA +#ifdef LMP_KOKKOS_GPU template class PairMEAMMSKokkos; #endif } diff --git a/src/KOKKOS/pppm_kokkos.h b/src/KOKKOS/pppm_kokkos.h index 2c6dcc4e15..d621313873 100644 --- a/src/KOKKOS/pppm_kokkos.h +++ b/src/KOKKOS/pppm_kokkos.h @@ -33,7 +33,7 @@ KSpaceStyle(pppm/kk/host,PPPMKokkos); // clang-format off -// fix up FFT defines for KOKKOS with CUDA +// fix up FFT defines for KOKKOS with CUDA and HIP #ifdef KOKKOS_ENABLE_CUDA # if defined(FFT_FFTW) @@ -48,6 +48,19 @@ KSpaceStyle(pppm/kk/host,PPPMKokkos); # 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" diff --git a/src/KSPACE/ewald.cpp b/src/KSPACE/ewald.cpp index b61a1d36c6..93470c60ac 100644 --- a/src/KSPACE/ewald.cpp +++ b/src/KSPACE/ewald.cpp @@ -857,7 +857,7 @@ void Ewald::coeffs() vg[kcount][3] = -vterm*unitk[0]*k*unitk[1]*l; vg[kcount][4] = 0.0; vg[kcount][5] = 0.0; - kcount++;; + kcount++; } } } diff --git a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp index fd76d2fc00..b7635c49c7 100644 --- a/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp +++ b/src/KSPACE/pair_lj_charmmfsw_coul_long.cpp @@ -230,7 +230,7 @@ void PairLJCharmmfswCoulLong::compute(int eflag, int vflag) evdwl12 = lj3[itype][jtype]*cut_lj6*denom_lj12 * (r6inv - cut_lj6inv)*(r6inv - cut_lj6inv); evdwl6 = -lj4[itype][jtype]*cut_lj3*denom_lj6 * - (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv);; + (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv); evdwl = evdwl12 + evdwl6; } else { evdwl12 = r6inv*lj3[itype][jtype]*r6inv - @@ -588,7 +588,7 @@ void PairLJCharmmfswCoulLong::compute_outer(int eflag, int vflag) evdwl12 = lj3[itype][jtype]*cut_lj6*denom_lj12 * (r6inv - cut_lj6inv)*(r6inv - cut_lj6inv); evdwl6 = -lj4[itype][jtype]*cut_lj3*denom_lj6 * - (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv);; + (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv); evdwl = evdwl12 + evdwl6; } else { evdwl12 = r6inv*lj3[itype][jtype]*r6inv - @@ -1015,7 +1015,7 @@ double PairLJCharmmfswCoulLong::single(int i, int j, int itype, int jtype, philj12 = lj3[itype][jtype]*cut_lj6*denom_lj12 * (r6inv - cut_lj6inv)*(r6inv - cut_lj6inv); philj6 = -lj4[itype][jtype]*cut_lj3*denom_lj6 * - (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv);; + (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv); philj = philj12 + philj6; } else { philj12 = r6inv*lj3[itype][jtype]*r6inv - diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index 70f7c8f6b7..2f5b4fc670 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -3004,7 +3004,7 @@ double PPPM::memory_usage() if (group_allocate_flag) { bytes += (double)2 * nbrick * sizeof(FFT_SCALAR); - bytes += (double)2 * nfft_both * sizeof(FFT_SCALAR);; + bytes += (double)2 * nfft_both * sizeof(FFT_SCALAR); } // two Grid3d bufs diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 78ebad512a..7ab76ad62a 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -4651,7 +4651,7 @@ void PPPMDisp::poisson_ik(FFT_SCALAR* wk1, FFT_SCALAR* wk2, for (j = nylo_i; j <= nyhi_i; j++) for (i = nxlo_i; i <= nxhi_i; i++) { vz_brick[k][j][i] = wk2[n++]; - u_pa[k][j][i] = -wk2[n++];; + u_pa[k][j][i] = -wk2[n++]; } } diff --git a/src/MAKE/MACHINES/Makefile.aurora_kokkos b/src/MAKE/MACHINES/Makefile.aurora_kokkos new file mode 100644 index 0000000000..a263d4cb8c --- /dev/null +++ b/src/MAKE/MACHINES/Makefile.aurora_kokkos @@ -0,0 +1,121 @@ +# aurora_kokkos = KOKKOS/SYCL, Intel Data Center Max (Ponte Vecchio) GPU, Intel Sapphire Rapids CPU, mpicxx compiler + +SHELL = /bin/sh + +# --------------------------------------------------------------------- +# compiler/linker settings +# specify flags and libraries needed for your compiler + +CC = mpicxx +CCFLAGS = -g -O3 -DNDEBUG +SHFLAGS = -fPIC +DEPFLAGS = -M + +LINK = mpicxx +LINKFLAGS = -g -O3 +LIB = +SIZE = size + +ARCHIVE = ar +ARFLAGS = -rc +SHLIBFLAGS = -shared +KOKKOS_DEVICES = SYCL +KOKKOS_ARCH = PVC,SPR + +# --------------------------------------------------------------------- +# LAMMPS-specific settings, all OPTIONAL +# specify settings for LAMMPS features you will use +# if you change any -D setting, do full re-compile after "make clean" + +# LAMMPS ifdef settings +# see possible settings in Section 3.5 of the manual + +LMP_INC = -DLAMMPS_GZIP + +# MPI library +# see discussion in Section 3.4 of the manual +# MPI wrapper compiler/linker can provide this info +# can point to dummy MPI library in src/STUBS as in Makefile.serial +# use -D MPICH and OMPI settings in INC to avoid C++ lib conflicts +# INC = path for mpi.h, MPI compiler settings +# PATH = path for MPI library +# LIB = name of MPI library + +MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 +MPI_PATH = +MPI_LIB = + +# FFT library +# see discussion in Section 3.5.2 of manual +# can be left blank to use provided KISS FFT library +# INC = -DFFT setting, e.g. -DFFT_FFTW, FFT compiler settings +# PATH = path for FFT library +# LIB = name of FFT library + +FFT_INC = +FFT_PATH = +FFT_LIB = + +# JPEG and/or PNG library +# see discussion in Section 3.5.4 of manual +# only needed if -DLAMMPS_JPEG or -DLAMMPS_PNG listed with LMP_INC +# INC = path(s) for jpeglib.h and/or png.h +# PATH = path(s) for JPEG library and/or PNG library +# LIB = name(s) of JPEG library and/or PNG library + +JPG_INC = +JPG_PATH = +JPG_LIB = + +# --------------------------------------------------------------------- +# build rules and dependencies +# do not edit this section + +include Makefile.package.settings +include Makefile.package + +EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) $(JPG_INC) $(PKG_SYSINC) +EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(JPG_PATH) $(PKG_SYSPATH) +EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(JPG_LIB) $(PKG_SYSLIB) +EXTRA_CPP_DEPENDS = $(PKG_CPP_DEPENDS) +EXTRA_LINK_DEPENDS = $(PKG_LINK_DEPENDS) + +# Path to src files + +vpath %.cpp .. +vpath %.h .. + +# Link target + +$(EXE): main.o $(LMPLIB) $(EXTRA_LINK_DEPENDS) + $(LINK) $(LINKFLAGS) main.o $(EXTRA_PATH) $(LMPLINK) $(EXTRA_LIB) $(LIB) -o $@ + $(SIZE) $@ + +# Library targets + +$(ARLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + @rm -f ../$(ARLIB) + $(ARCHIVE) $(ARFLAGS) ../$(ARLIB) $(OBJ) + @rm -f $(ARLIB) + @ln -s ../$(ARLIB) $(ARLIB) + +$(SHLIB): $(OBJ) $(EXTRA_LINK_DEPENDS) + $(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o ../$(SHLIB) \ + $(OBJ) $(EXTRA_LIB) $(LIB) + @rm -f $(SHLIB) + @ln -s ../$(SHLIB) $(SHLIB) + +# Compilation rules + +%.o:%.cpp + $(CC) $(CCFLAGS) $(SHFLAGS) $(EXTRA_INC) -c $< + +# Individual dependencies + +depend : fastdep.exe $(SRC) + @./fastdep.exe $(EXTRA_INC) -- $^ > .depend || exit 1 + +fastdep.exe: ../DEPEND/fastdep.c + cc -O -o $@ $< + +sinclude .depend diff --git a/src/MAKE/MACHINES/Makefile.crusher_kokkos b/src/MAKE/MACHINES/Makefile.frontier_kokkos similarity index 93% rename from src/MAKE/MACHINES/Makefile.crusher_kokkos rename to src/MAKE/MACHINES/Makefile.frontier_kokkos index d6332805f7..86cddd12b7 100644 --- a/src/MAKE/MACHINES/Makefile.crusher_kokkos +++ b/src/MAKE/MACHINES/Makefile.frontier_kokkos @@ -1,4 +1,4 @@ -# crusher_kokkos = KOKKOS/HIP, AMD MI250X GPU and AMD EPYC 7A53 "Optimized 3rd Gen EPYC" CPU, Cray MPICH, hipcc compiler, hipFFT +# frontier_kokkos = KOKKOS/HIP, AMD MI250X GPU and AMD EPYC 7A53 "Optimized 3rd Gen EPYC" CPU, Cray MPICH, hipcc compiler, hipFFT SHELL = /bin/sh @@ -6,8 +6,6 @@ SHELL = /bin/sh # compiler/linker settings # specify flags and libraries needed for your compiler -KOKKOS_ABSOLUTE_PATH = $(shell cd $(KOKKOS_PATH); pwd) - CC = hipcc CCFLAGS = -g -O3 -munsafe-fp-atomics -DNDEBUG -DKOKKOS_ENABLE_HIP_MULTIPLE_KERNEL_INSTANTIATIONS SHFLAGS = -fPIC @@ -22,7 +20,7 @@ ARCHIVE = ar ARFLAGS = -rc SHLIBFLAGS = -shared KOKKOS_DEVICES = HIP -KOKKOS_ARCH = Zen3,Vega90A +KOKKOS_ARCH = Vega90A,Zen3 # --------------------------------------------------------------------- # LAMMPS-specific settings, all OPTIONAL diff --git a/src/MAKE/MACHINES/Makefile.spock_kokkos b/src/MAKE/MACHINES/Makefile.perlmutter_kokkos similarity index 83% rename from src/MAKE/MACHINES/Makefile.spock_kokkos rename to src/MAKE/MACHINES/Makefile.perlmutter_kokkos index 8f7e5bd63d..43162b88dd 100644 --- a/src/MAKE/MACHINES/Makefile.spock_kokkos +++ b/src/MAKE/MACHINES/Makefile.perlmutter_kokkos @@ -1,4 +1,4 @@ -# spock_kokkos = KOKKOS/HIP, AMD MI100 GPU and AMD EPYC 7662 "Rome" CPU, Cray MPICH, hipcc compiler, hipFFT +# perlmutter_kokkos = KOKKOS/CUDA, NVIDIA A100 GPU and AMD EPYC 7763 (Milan) CPU, Cray MPICH, nvcc compiler with gcc SHELL = /bin/sh @@ -8,12 +8,12 @@ SHELL = /bin/sh KOKKOS_ABSOLUTE_PATH = $(shell cd $(KOKKOS_PATH); pwd) -CC = hipcc -CCFLAGS = -g -O3 -DNDEBUG -DKOKKOS_ENABLE_HIP_MULTIPLE_KERNEL_INSTANTIATIONS +CC = $(KOKKOS_ABSOLUTE_PATH)/bin/nvcc_wrapper +CCFLAGS = -g -O3 -DNDEBUG -Xcudafe --diag_suppress=unrecognized_pragma SHFLAGS = -fPIC DEPFLAGS = -M -LINK = hipcc +LINK = $(KOKKOS_ABSOLUTE_PATH)/bin/nvcc_wrapper LINKFLAGS = -g -O3 LIB = SIZE = size @@ -21,8 +21,8 @@ SIZE = size ARCHIVE = ar ARFLAGS = -rc SHLIBFLAGS = -shared -KOKKOS_DEVICES = HIP -KOKKOS_ARCH = Zen2,Vega908 +KOKKOS_DEVICES = Cuda +KOKKOS_ARCH = Ampere80,Zen3 # --------------------------------------------------------------------- # LAMMPS-specific settings, all OPTIONAL @@ -44,8 +44,8 @@ LMP_INC = -DLAMMPS_GZIP # LIB = name of MPI library MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I${MPICH_DIR}/include -MPI_PATH = -MPI_LIB = -L${MPICH_DIR}/lib -lmpi -L${CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa +MPI_PATH = +MPI_LIB = -L${MPICH_DIR}/lib -lmpi -L${CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_cuda # FFT library # see discussion in Section 3.5.2 of manual @@ -54,12 +54,9 @@ MPI_LIB = -L${MPICH_DIR}/lib -lmpi -L${CRAY_MPICH_ROOTDIR}/gtl/lib -lmpi_gtl_hsa # PATH = path for FFT library # LIB = name of FFT library -MY_HIP_EXE = $(shell which hipcc) -MY_HIP_PATH = $(dir ${MY_HIP_EXE}) - -FFT_INC = -DFFT_HIPFFT -FFT_PATH = -FFT_LIB = -L${MY_HIP_PATH}../lib -lhipfft +FFT_INC = -DFFT_CUFFT +FFT_PATH = +FFT_LIB = ${CRAY_CUDATOOLKIT_POST_LINK_OPTS} -lcufft # JPEG and/or PNG library # see discussion in Section 3.5.4 of manual @@ -72,6 +69,11 @@ JPG_INC = JPG_PATH = JPG_LIB = +# library for loading shared objects (defaults to -ldl, should be empty on Windows) +# uncomment to change the default + +# override DYN_LIB = + # --------------------------------------------------------------------- # build rules and dependencies # do not edit this section @@ -81,7 +83,7 @@ include Makefile.package EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) $(JPG_INC) $(PKG_SYSINC) EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(JPG_PATH) $(PKG_SYSPATH) -EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(JPG_LIB) $(PKG_SYSLIB) +EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(JPG_LIB) $(PKG_SYSLIB) $(DYN_LIB) EXTRA_CPP_DEPENDS = $(PKG_CPP_DEPENDS) EXTRA_LINK_DEPENDS = $(PKG_LINK_DEPENDS) diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index ac1ac0ea62..a6a6ed37fd 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -593,9 +593,9 @@ void PairComb3::read_file(char *file) if (params[nparams].lambda < 0.0 || params[nparams].powern < 0.0 || params[nparams].beta < 0.0 || params[nparams].alpha1 < 0.0 || - params[nparams].bigB1< 0.0 || params[nparams].bigA< 0.0 || - params[nparams].bigB2< 0.0 || params[nparams].alpha2 <0.0 || - params[nparams].bigB3< 0.0 || params[nparams].alpha3 <0.0 || + params[nparams].bigB1 < 0.0 || params[nparams].bigA < 0.0 || + params[nparams].bigB2 < 0.0 || params[nparams].alpha2 < 0.0 || + params[nparams].bigB3 < 0.0 || params[nparams].alpha3 < 0.0 || params[nparams].bigr < 0.0 || params[nparams].bigd < 0.0 || params[nparams].bigd > params[nparams].bigr || params[nparams].powerm - params[nparams].powermint != 0.0 || diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index be2a1e41f3..1fd98b80f0 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -73,7 +73,8 @@ PairGW::~PairGW() void PairGW::compute(int eflag, int vflag) { int i,j,k,ii,jj,kk,inum,jnum; - int itag,jtag,itype,jtype,ktype,iparam_ij,iparam_ijk; + int itype,jtype,ktype,iparam_ij,iparam_ijk; + tagint itag,jtag; double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair; double rsq,rsq1,rsq2; double delr1[3],delr2[3],fi[3],fj[3],fk[3]; diff --git a/src/MANYBODY/pair_lcbop.cpp b/src/MANYBODY/pair_lcbop.cpp index 65191ae85e..ed085c4b98 100644 --- a/src/MANYBODY/pair_lcbop.cpp +++ b/src/MANYBODY/pair_lcbop.cpp @@ -115,7 +115,7 @@ void PairLCBOP::allocate() ------------------------------------------------------------------------- */ void PairLCBOP::settings(int narg, char **/*arg*/) { - if (narg != 0 ) error->all(FLERR,"Illegal pair_style command"); + if (narg != 0) error->all(FLERR,"Illegal pair_style command"); } /* ---------------------------------------------------------------------- diff --git a/src/MGPT/pair_mgpt.cpp b/src/MGPT/pair_mgpt.cpp index 5c4b889f8a..c924cbea84 100644 --- a/src/MGPT/pair_mgpt.cpp +++ b/src/MGPT/pair_mgpt.cpp @@ -589,8 +589,7 @@ 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,itag,jtag,p; - + int i,j,k,m,ix,jx,kx,mx,p; double e_single,e_pair,e_triplet,e_triplet_c,e_quad; double volvir2; diff --git a/src/MISC/fix_ipi.cpp b/src/MISC/fix_ipi.cpp index 9411fa763d..69e0f2a7f3 100644 --- a/src/MISC/fix_ipi.cpp +++ b/src/MISC/fix_ipi.cpp @@ -284,17 +284,17 @@ void FixIPI::initial_integrate(int /*vflag*/) // while i-PI just asks for status, signal we are ready and wait readbuffer(ipisock, header, MSGLEN, error); header[MSGLEN]=0; - if (strcmp(header,"STATUS ") == 0 ) + if (strcmp(header,"STATUS ") == 0) writebuffer(ipisock,"READY ",MSGLEN, error); else break; } - if (strcmp(header,"EXIT ") == 0 ) + if (strcmp(header,"EXIT ") == 0) error->one(FLERR, "Got EXIT message from i-PI. Now leaving!"); // when i-PI signals it has positions to evaluate new forces, // read positions and cell data - if (strcmp(header,"POSDATA ") == 0 ) { + if (strcmp(header,"POSDATA ") == 0) { readbuffer(ipisock, (char*) cellh, 9*8, error); readbuffer(ipisock, (char*) cellih, 9*8, error); readbuffer(ipisock, (char*) &nat, 4, error); @@ -454,15 +454,15 @@ void FixIPI::final_integrate() while (true) { readbuffer(ipisock, header, MSGLEN, error); header[MSGLEN]=0; - if (strcmp(header,"STATUS ") == 0 ) + if (strcmp(header,"STATUS ") == 0) writebuffer(ipisock,"HAVEDATA ",MSGLEN, error); else break; } - if (strcmp(header,"EXIT ") == 0 ) + if (strcmp(header,"EXIT ") == 0) error->one(FLERR, "Got EXIT message from i-PI. Now leaving!"); - if (strcmp(header,"GETFORCE ") == 0 ) { + if (strcmp(header,"GETFORCE ") == 0) { writebuffer(ipisock,"FORCEREADY ",MSGLEN, error); writebuffer(ipisock,(char*) &pot,8, error); writebuffer(ipisock,(char*) &nat,4, error); diff --git a/src/MISC/pair_agni.cpp b/src/MISC/pair_agni.cpp index 539c0ca00f..8597e5db93 100644 --- a/src/MISC/pair_agni.cpp +++ b/src/MISC/pair_agni.cpp @@ -347,7 +347,7 @@ void PairAGNI::read_file(char *filename) curparam = -1; } else error->warning(FLERR,"Ignoring unknown tag '{}' in AGNI potential file.",tag); } else { - if (params && wantdata >=0) { + if (params && wantdata >= 0) { if ((int)values.count() == params[wantdata].numeta + 2) { for (k = 0; k < params[wantdata].numeta; ++k) params[wantdata].xU[k][fp_counter] = values.next_double(); diff --git a/src/ML-IAP/mliap_unified_couple.pyx b/src/ML-IAP/mliap_unified_couple.pyx index 3fde99a25e..25852a1c5f 100644 --- a/src/ML-IAP/mliap_unified_couple.pyx +++ b/src/ML-IAP/mliap_unified_couple.pyx @@ -281,6 +281,16 @@ cdef class MLIAPDataPy: return None return np.asarray( &self.data.rij[0][0]) + @property + def rij_max(self): + if self.data.rij is NULL: + return None + return np.asarray( &self.data.rij[0][0]) + + @property + def nneigh_max(self): + return self.data.nneigh_max + @write_only_property def graddesc(self, value): if self.data.graddesc is NULL: @@ -357,6 +367,7 @@ cdef public object mliap_unified_connect(char *fname, MLIAPDummyModel * model, unified_int.descriptor = descriptor unified.interface = unified_int + #print(unified_int) if unified.ndescriptors is None: raise ValueError("no descriptors set") diff --git a/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp b/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp index 5063c402c6..65caa46153 100644 --- a/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp +++ b/src/MOLECULE/pair_lj_charmmfsw_coul_charmmfsh.cpp @@ -188,7 +188,7 @@ void PairLJCharmmfswCoulCharmmfsh::compute(int eflag, int vflag) evdwl12 = lj3[itype][jtype]*cut_lj6*denom_lj12 * (r6inv - cut_lj6inv)*(r6inv - cut_lj6inv); evdwl6 = -lj4[itype][jtype]*cut_lj3*denom_lj6 * - (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv);; + (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv); evdwl = evdwl12 + evdwl6; } else { evdwl12 = r6inv*lj3[itype][jtype]*r6inv - @@ -525,7 +525,7 @@ single(int i, int j, int itype, int jtype, philj12 = lj3[itype][jtype]*cut_lj6*denom_lj12 * (r6inv - cut_lj6inv)*(r6inv - cut_lj6inv); philj6 = -lj4[itype][jtype]*cut_lj3*denom_lj6 * - (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv);; + (r3inv - cut_lj3inv)*(r3inv - cut_lj3inv); philj = philj12 + philj6; } else { philj12 = r6inv*lj3[itype][jtype]*r6inv - diff --git a/src/MPIIO/dump_atom_mpiio.cpp b/src/MPIIO/dump_atom_mpiio.cpp index 4e0fd47a29..844d1a46e4 100644 --- a/src/MPIIO/dump_atom_mpiio.cpp +++ b/src/MPIIO/dump_atom_mpiio.cpp @@ -283,6 +283,8 @@ void DumpAtomMPIIO::init_style() void DumpAtomMPIIO::write_header(bigint ndump) { + if (!header_choice) error->all(FLERR, "Must not use 'run pre no' after creating a new dump"); + (this->*header_choice)(ndump); } diff --git a/src/MPIIO/dump_custom_mpiio.cpp b/src/MPIIO/dump_custom_mpiio.cpp index 32e09675a8..80adefa325 100644 --- a/src/MPIIO/dump_custom_mpiio.cpp +++ b/src/MPIIO/dump_custom_mpiio.cpp @@ -309,6 +309,8 @@ void DumpCustomMPIIO::init_style() void DumpCustomMPIIO::write_header(bigint ndump) { + if (!header_choice) error->all(FLERR, "Must not use 'run pre no' after creating a new dump"); + (this->*header_choice)(ndump); } diff --git a/src/OPENMP/npair_full_bin_ghost_omp.cpp b/src/OPENMP/npair_full_bin_ghost_omp.cpp index 5723a418f5..0825d61b49 100644 --- a/src/OPENMP/npair_full_bin_ghost_omp.cpp +++ b/src/OPENMP/npair_full_bin_ghost_omp.cpp @@ -114,7 +114,7 @@ void NPairFullBinGhostOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_full_bin_omp.cpp b/src/OPENMP/npair_full_bin_omp.cpp index 94668002a9..65af519850 100644 --- a/src/OPENMP/npair_full_bin_omp.cpp +++ b/src/OPENMP/npair_full_bin_omp.cpp @@ -108,7 +108,7 @@ void NPairFullBinOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_full_nsq_ghost_omp.cpp b/src/OPENMP/npair_full_nsq_ghost_omp.cpp index 05f402a99d..c1270d9fdc 100644 --- a/src/OPENMP/npair_full_nsq_ghost_omp.cpp +++ b/src/OPENMP/npair_full_nsq_ghost_omp.cpp @@ -108,7 +108,7 @@ void NPairFullNsqGhostOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_full_nsq_omp.cpp b/src/OPENMP/npair_full_nsq_omp.cpp index 6349906771..695cb1bc48 100644 --- a/src/OPENMP/npair_full_nsq_omp.cpp +++ b/src/OPENMP/npair_full_nsq_omp.cpp @@ -108,7 +108,7 @@ void NPairFullNsqOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_bin_newtoff_ghost_omp.cpp b/src/OPENMP/npair_half_bin_newtoff_ghost_omp.cpp index 2255033204..e10d181a8c 100644 --- a/src/OPENMP/npair_half_bin_newtoff_ghost_omp.cpp +++ b/src/OPENMP/npair_half_bin_newtoff_ghost_omp.cpp @@ -122,7 +122,7 @@ void NPairHalfBinNewtoffGhostOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_bin_newtoff_omp.cpp b/src/OPENMP/npair_half_bin_newtoff_omp.cpp index 36997d9bcb..9d32cc7e2b 100644 --- a/src/OPENMP/npair_half_bin_newtoff_omp.cpp +++ b/src/OPENMP/npair_half_bin_newtoff_omp.cpp @@ -113,7 +113,7 @@ void NPairHalfBinNewtoffOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_bin_newton_omp.cpp b/src/OPENMP/npair_half_bin_newton_omp.cpp index 1663a2f14c..d2da12962c 100644 --- a/src/OPENMP/npair_half_bin_newton_omp.cpp +++ b/src/OPENMP/npair_half_bin_newton_omp.cpp @@ -114,7 +114,7 @@ void NPairHalfBinNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); @@ -145,7 +145,7 @@ void NPairHalfBinNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_bin_newton_tri_omp.cpp b/src/OPENMP/npair_half_bin_newton_tri_omp.cpp index e754456ef1..4d93d06d75 100644 --- a/src/OPENMP/npair_half_bin_newton_tri_omp.cpp +++ b/src/OPENMP/npair_half_bin_newton_tri_omp.cpp @@ -119,7 +119,7 @@ void NPairHalfBinNewtonTriOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_multi_old_newtoff_omp.cpp b/src/OPENMP/npair_half_multi_old_newtoff_omp.cpp index ac5e9dae04..4447b4414e 100644 --- a/src/OPENMP/npair_half_multi_old_newtoff_omp.cpp +++ b/src/OPENMP/npair_half_multi_old_newtoff_omp.cpp @@ -120,7 +120,7 @@ void NPairHalfMultiOldNewtoffOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_multi_old_newton_omp.cpp b/src/OPENMP/npair_half_multi_old_newton_omp.cpp index baa9dd0724..29c551f17d 100644 --- a/src/OPENMP/npair_half_multi_old_newton_omp.cpp +++ b/src/OPENMP/npair_half_multi_old_newton_omp.cpp @@ -116,7 +116,7 @@ void NPairHalfMultiOldNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); @@ -153,7 +153,7 @@ void NPairHalfMultiOldNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_multi_old_newton_tri_omp.cpp b/src/OPENMP/npair_half_multi_old_newton_tri_omp.cpp index e4895ff1a9..1d906b1fa5 100644 --- a/src/OPENMP/npair_half_multi_old_newton_tri_omp.cpp +++ b/src/OPENMP/npair_half_multi_old_newton_tri_omp.cpp @@ -129,7 +129,7 @@ void NPairHalfMultiOldNewtonTriOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_nsq_newtoff_ghost_omp.cpp b/src/OPENMP/npair_half_nsq_newtoff_ghost_omp.cpp index 388e51e1af..54de8b9607 100644 --- a/src/OPENMP/npair_half_nsq_newtoff_ghost_omp.cpp +++ b/src/OPENMP/npair_half_nsq_newtoff_ghost_omp.cpp @@ -117,7 +117,7 @@ void NPairHalfNsqNewtoffGhostOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_nsq_newtoff_omp.cpp b/src/OPENMP/npair_half_nsq_newtoff_omp.cpp index 002ea37e6b..54a90d9f2b 100644 --- a/src/OPENMP/npair_half_nsq_newtoff_omp.cpp +++ b/src/OPENMP/npair_half_nsq_newtoff_omp.cpp @@ -109,7 +109,7 @@ void NPairHalfNsqNewtoffOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_nsq_newton_omp.cpp b/src/OPENMP/npair_half_nsq_newton_omp.cpp index cb08cb7f7a..c010a3b024 100644 --- a/src/OPENMP/npair_half_nsq_newton_omp.cpp +++ b/src/OPENMP/npair_half_nsq_newton_omp.cpp @@ -49,8 +49,8 @@ void NPairHalfNsqNewtonOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,n,itype,jtype,itag,jtag,which,imol,iatom; - tagint tagprev; + int i,j,n,itype,jtype,which,imol,iatom; + tagint itag,jtag,tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; @@ -127,7 +127,7 @@ void NPairHalfNsqNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_respa_bin_newtoff_omp.cpp b/src/OPENMP/npair_half_respa_bin_newtoff_omp.cpp index c6be04419d..e1d4ee59b1 100644 --- a/src/OPENMP/npair_half_respa_bin_newtoff_omp.cpp +++ b/src/OPENMP/npair_half_respa_bin_newtoff_omp.cpp @@ -144,7 +144,7 @@ void NPairHalfRespaBinNewtoffOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_respa_bin_newton_omp.cpp b/src/OPENMP/npair_half_respa_bin_newton_omp.cpp index 51fc7a2ed8..ce8a103170 100644 --- a/src/OPENMP/npair_half_respa_bin_newton_omp.cpp +++ b/src/OPENMP/npair_half_respa_bin_newton_omp.cpp @@ -146,7 +146,7 @@ void NPairHalfRespaBinNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); @@ -190,7 +190,7 @@ void NPairHalfRespaBinNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_respa_bin_newton_tri_omp.cpp b/src/OPENMP/npair_half_respa_bin_newton_tri_omp.cpp index c998f71290..73f2102dba 100644 --- a/src/OPENMP/npair_half_respa_bin_newton_tri_omp.cpp +++ b/src/OPENMP/npair_half_respa_bin_newton_tri_omp.cpp @@ -151,7 +151,7 @@ void NPairHalfRespaBinNewtonTriOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_respa_nsq_newtoff_omp.cpp b/src/OPENMP/npair_half_respa_nsq_newtoff_omp.cpp index 1167a7601b..428ca778e8 100644 --- a/src/OPENMP/npair_half_respa_nsq_newtoff_omp.cpp +++ b/src/OPENMP/npair_half_respa_nsq_newtoff_omp.cpp @@ -141,7 +141,7 @@ void NPairHalfRespaNsqNewtoffOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_respa_nsq_newton_omp.cpp b/src/OPENMP/npair_half_respa_nsq_newton_omp.cpp index 6604861f74..4bcba0fbef 100644 --- a/src/OPENMP/npair_half_respa_nsq_newton_omp.cpp +++ b/src/OPENMP/npair_half_respa_nsq_newton_omp.cpp @@ -55,8 +55,8 @@ void NPairHalfRespaNsqNewtonOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,n,itype,jtype,itag,jtag,n_inner,n_middle,imol,iatom; - tagint tagprev; + int i,j,n,itype,jtype,n_inner,n_middle,imol,iatom; + tagint itag,jtag,tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*neighptr_inner,*neighptr_middle; @@ -159,7 +159,7 @@ void NPairHalfRespaNsqNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_size_bin_newtoff_omp.cpp b/src/OPENMP/npair_half_size_bin_newtoff_omp.cpp index c205b67539..478e28a5f4 100644 --- a/src/OPENMP/npair_half_size_bin_newtoff_omp.cpp +++ b/src/OPENMP/npair_half_size_bin_newtoff_omp.cpp @@ -125,7 +125,7 @@ void NPairHalfSizeBinNewtoffOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_size_bin_newton_omp.cpp b/src/OPENMP/npair_half_size_bin_newton_omp.cpp index 628057d41d..dba392781e 100644 --- a/src/OPENMP/npair_half_size_bin_newton_omp.cpp +++ b/src/OPENMP/npair_half_size_bin_newton_omp.cpp @@ -126,7 +126,7 @@ void NPairHalfSizeBinNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); @@ -161,7 +161,7 @@ void NPairHalfSizeBinNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_size_bin_newton_tri_omp.cpp b/src/OPENMP/npair_half_size_bin_newton_tri_omp.cpp index c320296442..160cf64194 100644 --- a/src/OPENMP/npair_half_size_bin_newton_tri_omp.cpp +++ b/src/OPENMP/npair_half_size_bin_newton_tri_omp.cpp @@ -132,7 +132,7 @@ void NPairHalfSizeBinNewtonTriOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_size_multi_newtoff_omp.cpp b/src/OPENMP/npair_half_size_multi_newtoff_omp.cpp index 73564a150c..ba0dfc16be 100644 --- a/src/OPENMP/npair_half_size_multi_newtoff_omp.cpp +++ b/src/OPENMP/npair_half_size_multi_newtoff_omp.cpp @@ -124,7 +124,7 @@ void NPairHalfSizeMultiNewtoffOmp::build(NeighList *list) for (k = 0; k < ns; k++) { js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; j >=0; j = bins[j]) { + for (j = js; j >= 0; j = bins[j]) { if (j <= i) continue; jtype = type[j]; @@ -145,7 +145,7 @@ void NPairHalfSizeMultiNewtoffOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_size_multi_newton_omp.cpp b/src/OPENMP/npair_half_size_multi_newton_omp.cpp index 0ed843ea0b..4bc17f911c 100644 --- a/src/OPENMP/npair_half_size_multi_newton_omp.cpp +++ b/src/OPENMP/npair_half_size_multi_newton_omp.cpp @@ -155,7 +155,7 @@ void NPairHalfSizeMultiNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); @@ -198,7 +198,7 @@ void NPairHalfSizeMultiNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_size_multi_newton_tri_omp.cpp b/src/OPENMP/npair_half_size_multi_newton_tri_omp.cpp index 9a0ead482b..73e11a2745 100644 --- a/src/OPENMP/npair_half_size_multi_newton_tri_omp.cpp +++ b/src/OPENMP/npair_half_size_multi_newton_tri_omp.cpp @@ -160,7 +160,7 @@ void NPairHalfSizeMultiNewtonTriOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp b/src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp index c368e71095..e4169482bc 100644 --- a/src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp +++ b/src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp @@ -132,7 +132,7 @@ void NPairHalfSizeMultiOldNewtoffOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_size_multi_old_newton_omp.cpp b/src/OPENMP/npair_half_size_multi_old_newton_omp.cpp index 187efe04d1..7d6a3de871 100644 --- a/src/OPENMP/npair_half_size_multi_old_newton_omp.cpp +++ b/src/OPENMP/npair_half_size_multi_old_newton_omp.cpp @@ -127,7 +127,7 @@ void NPairHalfSizeMultiOldNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); @@ -170,7 +170,7 @@ void NPairHalfSizeMultiOldNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp b/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp index c74b191f66..caa993ed38 100644 --- a/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp +++ b/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp @@ -140,7 +140,7 @@ void NPairHalfSizeMultiOldNewtonTriOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_size_nsq_newtoff_omp.cpp b/src/OPENMP/npair_half_size_nsq_newtoff_omp.cpp index 020551bd8e..2982586a18 100644 --- a/src/OPENMP/npair_half_size_nsq_newtoff_omp.cpp +++ b/src/OPENMP/npair_half_size_nsq_newtoff_omp.cpp @@ -122,7 +122,7 @@ void NPairHalfSizeNsqNewtoffOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/OPENMP/npair_half_size_nsq_newton_omp.cpp b/src/OPENMP/npair_half_size_nsq_newton_omp.cpp index 35dc42ec5b..0a80da9422 100644 --- a/src/OPENMP/npair_half_size_nsq_newton_omp.cpp +++ b/src/OPENMP/npair_half_size_nsq_newton_omp.cpp @@ -58,8 +58,8 @@ void NPairHalfSizeNsqNewtonOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,jh,n,itag,jtag,which,imol,iatom; - tagint tagprev; + int i,j,jh,n,which,imol,iatom; + tagint itag,jtag,tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutsq; int *neighptr; @@ -140,7 +140,7 @@ void NPairHalfSizeNsqNewtonOmp::build(NeighList *list) if (molecular != Atom::ATOMIC) { if (!moltemplate) which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >=0) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); diff --git a/src/PHONON/dynamical_matrix.cpp b/src/PHONON/dynamical_matrix.cpp index 8e4f8557a2..c2ba34c4c2 100644 --- a/src/PHONON/dynamical_matrix.cpp +++ b/src/PHONON/dynamical_matrix.cpp @@ -365,7 +365,7 @@ void DynamicalMatrix::calculateMatrix() delete [] fdynmat[i]; delete [] fdynmat; - if (screen && me ==0 ) fprintf(screen,"Finished Calculating Dynamical Matrix\n"); + if (screen && me == 0) fprintf(screen,"Finished Calculating Dynamical Matrix\n"); } /* ---------------------------------------------------------------------- diff --git a/src/PHONON/third_order.cpp b/src/PHONON/third_order.cpp index 4a8948de77..c31aae0086 100644 --- a/src/PHONON/third_order.cpp +++ b/src/PHONON/third_order.cpp @@ -412,7 +412,7 @@ void ThirdOrder::calculateMatrix() delete [] dynmat; delete [] fdynmat; - if (screen && me ==0) + if (screen && me == 0) fprintf(screen,"Finished Calculating Third Order Tensor\n"); } diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index 83442ecb25..d124b06dc2 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -412,7 +412,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"modify_create") == 0) { if (iarg++ > narg) error->all(FLERR,"Illegal fix bond/react command: " "'modify_create' has too few arguments"); - while (iarg < narg && strcmp(arg[iarg],"react") != 0 ) { + while (iarg < narg && strcmp(arg[iarg],"react") != 0) { if (strcmp(arg[iarg],"fit") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix bond/react command: " "'modify_create' has too few arguments"); @@ -1394,7 +1394,7 @@ void FixBondReact::superimpose_algorithm() } for (int i = 0; i < onemol->natoms; i++) { - if (glove[i][0] !=0 && pioneer_count[i] < onemol_nxspecial[i][0] && edge[i][rxnID] == 0) { + if (glove[i][0] != 0 && pioneer_count[i] < onemol_nxspecial[i][0] && edge[i][rxnID] == 0) { pioneers[i] = 1; } } @@ -1837,7 +1837,7 @@ void FixBondReact::inner_crosscheck_loop() for (int i=1; i < num_choices; ++i) { tagint hold = tag_choices[i]; int j = i - 1; - while ((j >=0) && (tag_choices[j] > hold)) { + while ((j >= 0) && (tag_choices[j] > hold)) { tag_choices[j+1] = tag_choices[j]; --j; } @@ -2223,7 +2223,7 @@ note: currently uses global rxnID and onemol variables double FixBondReact::get_totalcharge() { - int j,jj,ilocal; + int j,jj; double *q = atom->q; double sim_total_charge = 0.0; for (j = 0; j < onemol->natoms; j++) { diff --git a/src/REAXFF/fix_reaxff_bonds.cpp b/src/REAXFF/fix_reaxff_bonds.cpp index 393e22930f..8bd7ed0020 100644 --- a/src/REAXFF/fix_reaxff_bonds.cpp +++ b/src/REAXFF/fix_reaxff_bonds.cpp @@ -295,7 +295,7 @@ void FixReaxFFBonds::RecvBuffer(double *buf, int nbuf, int nbuf_local, MPI_Isend(&buf[0],nbuf_local,MPI_DOUBLE,0,0,world,&irequest2); MPI_Wait(&irequest2,MPI_STATUS_IGNORE); } - if (me ==0) fputs("# \n",fp); + if (me == 0) fputs("# \n",fp); } diff --git a/src/REPLICA/fix_pimd_langevin.cpp b/src/REPLICA/fix_pimd_langevin.cpp index 75280fd3d5..7ba502d2e6 100644 --- a/src/REPLICA/fix_pimd_langevin.cpp +++ b/src/REPLICA/fix_pimd_langevin.cpp @@ -906,7 +906,10 @@ void FixPIMDLangevin::langevin_init() Lan_c[i] = cos(_omega_np_dt_half); Lan_s[i] = sin(_omega_np_dt_half); } + } else { + error->universe_all(FLERR, "Unknown fmmode setting; only physical and normal are supported!"); } + if (tau > 0) gamma = 1.0 / tau; else diff --git a/src/REPLICA/temper.cpp b/src/REPLICA/temper.cpp index 9e7e67d79d..adbdb4d742 100644 --- a/src/REPLICA/temper.cpp +++ b/src/REPLICA/temper.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; -// #define TEMPER_DEBUG 1 +#define TEMPER_DEBUG 0 /* ---------------------------------------------------------------------- */ @@ -50,10 +50,10 @@ Temper::~Temper() MPI_Comm_free(&roots); if (ranswap) delete ranswap; delete ranboltz; - delete [] set_temp; - delete [] temp2world; - delete [] world2temp; - delete [] world2root; + delete[] set_temp; + delete[] temp2world; + delete[] world2temp; + delete[] world2root; } /* ---------------------------------------------------------------------- @@ -63,11 +63,10 @@ Temper::~Temper() void Temper::command(int narg, char **arg) { if (universe->nworlds == 1) - error->all(FLERR,"Must have more than one processor partition to temper"); + error->universe_all(FLERR,"More than one processor partition required for temper command"); if (domain->box_exist == 0) - error->all(FLERR,"Temper command before simulation box is defined"); - if (narg != 6 && narg != 7) - error->universe_all(FLERR,"Illegal temper command"); + error->universe_all(FLERR,"Temper command before simulation box is defined"); + if (narg != 6 && narg != 7) error->universe_all(FLERR,"Illegal temper command"); int nsteps = utils::inumeric(FLERR,arg[0],false,lmp); nevery = utils::inumeric(FLERR,arg[1],false,lmp); @@ -77,10 +76,9 @@ void Temper::command(int narg, char **arg) if (timer->is_timeout()) return; - for (whichfix = 0; whichfix < modify->nfix; whichfix++) - if (strcmp(arg[3],modify->fix[whichfix]->id) == 0) break; - if (whichfix == modify->nfix) - error->universe_all(FLERR,"Tempering fix ID is not defined"); + whichfix = modify->get_fix_by_id(arg[3]); + if (!whichfix) + error->universe_all(FLERR,fmt::format("Tempering fix ID {} is not defined", arg[3])); seed_swap = utils::inumeric(FLERR,arg[4],false,lmp); seed_boltz = utils::inumeric(FLERR,arg[5],false,lmp); @@ -88,7 +86,7 @@ void Temper::command(int narg, char **arg) my_set_temp = universe->iworld; if (narg == 7) my_set_temp = utils::inumeric(FLERR,arg[6],false,lmp); if ((my_set_temp < 0) || (my_set_temp >= universe->nworlds)) - error->universe_one(FLERR,"Illegal temperature index"); + error->universe_one(FLERR,"Invalid temperature index value"); // swap frequency must evenly divide total # of timesteps @@ -101,11 +99,11 @@ void Temper::command(int narg, char **arg) // fix style must be appropriate for temperature control, i.e. it needs // to provide a working Fix::reset_target() and must not change the volume. - if ((!utils::strmatch(modify->fix[whichfix]->style,"^nvt")) && - (!utils::strmatch(modify->fix[whichfix]->style,"^langevin")) && - (!utils::strmatch(modify->fix[whichfix]->style,"^gl[de]$")) && - (!utils::strmatch(modify->fix[whichfix]->style,"^rigid/nvt")) && - (!utils::strmatch(modify->fix[whichfix]->style,"^temp/"))) + if ((!utils::strmatch(whichfix->style,"^nvt")) && + (!utils::strmatch(whichfix->style,"^langevin")) && + (!utils::strmatch(whichfix->style,"^gl[de]$")) && + (!utils::strmatch(whichfix->style,"^rigid/nvt")) && + (!utils::strmatch(whichfix->style,"^temp/"))) error->universe_all(FLERR,"Tempering temperature fix is not supported"); // setup for long tempering run @@ -116,8 +114,7 @@ void Temper::command(int narg, char **arg) update->nsteps = nsteps; update->beginstep = update->firststep = update->ntimestep; update->endstep = update->laststep = update->firststep + nsteps; - if (update->laststep < 0) - error->all(FLERR,"Too many timesteps"); + if (update->laststep < 0) error->all(FLERR,"Too many timesteps"); lmp->init(); @@ -132,9 +129,9 @@ void Temper::command(int narg, char **arg) // pe_compute = ptr to thermo_pe compute // notify compute it will be called at first swap - int id = modify->find_compute("thermo_pe"); - if (id < 0) error->all(FLERR,"Tempering could not find thermo_pe compute"); - Compute *pe_compute = modify->compute[id]; + Compute *pe_compute = modify->get_compute_by_id("thermo_pe"); + if (!pe_compute) error->all(FLERR,"Tempering could not find thermo_pe compute"); + pe_compute->addstep(update->ntimestep + nevery); // create MPI communicator for root proc from each world @@ -183,7 +180,7 @@ void Temper::command(int narg, char **arg) if (narg == 7) { double new_temp = set_temp[my_set_temp]; - modify->fix[whichfix]->reset_target(new_temp); + whichfix->reset_target(new_temp); } // setup tempering runs @@ -289,13 +286,12 @@ void Temper::command(int narg, char **arg) else MPI_Recv(&swap,1,MPI_INT,partner,0,universe->uworld,MPI_STATUS_IGNORE); -#ifdef TEMPER_DEBUG +#if TEMPER_DEBUG if (me_universe < partner) - printf("SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g\n", - me_universe,partner,swap,my_set_temp,partner_set_temp, - pe,pe_partner,boltz_factor,exp(boltz_factor)); + fprintf(universe->uscreen,"SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g\n", + me_universe,partner,swap,my_set_temp,partner_set_temp, + pe,pe_partner,boltz_factor,exp(boltz_factor)); #endif - } // bcast swap result to other procs in my world @@ -310,7 +306,7 @@ void Temper::command(int narg, char **arg) if (swap) { new_temp = set_temp[partner_set_temp]; - modify->fix[whichfix]->reset_target(new_temp); + whichfix->reset_target(new_temp); } // update my_set_temp and temp2world on every proc diff --git a/src/REPLICA/temper.h b/src/REPLICA/temper.h index b557e8ddd8..46a6666f07 100644 --- a/src/REPLICA/temper.h +++ b/src/REPLICA/temper.h @@ -40,8 +40,7 @@ class Temper : public Command { int nswaps; // # of tempering swaps to perform int seed_swap; // 0 = toggle swaps, n = RNG for swap direction int seed_boltz; // seed for Boltz factor comparison - int whichfix; // index of temperature fix to use - int fixstyle; // what kind of temperature fix is used + class Fix *whichfix; // temperature fix to use int my_set_temp; // which set temp I am simulating double *set_temp; // static list of replica set temperatures diff --git a/src/REPLICA/temper_grem.cpp b/src/REPLICA/temper_grem.cpp index 68fbb4eef6..303f502309 100644 --- a/src/REPLICA/temper_grem.cpp +++ b/src/REPLICA/temper_grem.cpp @@ -24,6 +24,7 @@ #include "finish.h" #include "fix.h" #include "fix_grem.h" +#include "fix_nh.h" #include "force.h" #include "integrate.h" #include "modify.h" @@ -37,7 +38,7 @@ using namespace LAMMPS_NS; -//#define TEMPER_DEBUG 1 +#define TEMPER_DEBUG 0 /* ---------------------------------------------------------------------- */ @@ -50,11 +51,10 @@ TemperGrem::~TemperGrem() MPI_Comm_free(&roots); if (ranswap) delete ranswap; delete ranboltz; - delete [] set_lambda; - delete [] lambda2world; - delete [] world2lambda; - delete [] world2root; - delete [] id_nh; + delete[] set_lambda; + delete[] lambda2world; + delete[] world2lambda; + delete[] world2root; } /* ---------------------------------------------------------------------- @@ -64,46 +64,50 @@ TemperGrem::~TemperGrem() void TemperGrem::command(int narg, char **arg) { if (universe->nworlds == 1) - error->all(FLERR,"Must have more than one processor partition to temper"); + error->universe_all(FLERR,"More than one processor partition required for temper/grem command"); if (domain->box_exist == 0) - error->all(FLERR,"Temper/gREM command before simulation box is defined"); - if (narg != 7 && narg != 8) - error->universe_all(FLERR,"Illegal temper command"); + error->universe_all(FLERR,"Temper/grem command before simulation box is defined"); + if (narg != 7 && narg != 8) error->universe_all(FLERR,"Illegal temper/grem command"); int nsteps = utils::inumeric(FLERR,arg[0],false,lmp); nevery = utils::inumeric(FLERR,arg[1],false,lmp); double lambda = utils::numeric(FLERR,arg[2],false,lmp); // ignore temper command, if walltime limit was already reached + if (timer->is_timeout()) return; - // Get and check if gREM fix exists - for (whichfix = 0; whichfix < modify->nfix; whichfix++) - if (strcmp(arg[3],modify->fix[whichfix]->id) == 0) break; - if (whichfix == modify->nfix) - error->universe_all(FLERR,"Tempering fix ID is not defined"); - fix_grem = dynamic_cast(modify->fix[whichfix]); + // Get and check if gREM fix exists and is correct style + + auto ifix = modify->get_fix_by_id(arg[3]); + if (!ifix) error->universe_all(FLERR,fmt::format("Tempering fix ID {} is not defined", arg[3])); + + fix_grem = dynamic_cast(ifix); + if (!fix_grem || (strcmp(ifix->style,"grem") != 0)) + error->universe_all(FLERR,"Tempering temperature fix is of incorrect style"); // Check input values lambdas should be equal, assign other gREM values if (lambda != fix_grem->lambda) - error->universe_all(FLERR,"Lambda from tempering and fix in the same world" - " must be the same"); + error->universe_all(FLERR,"Lambda from tempering and fix in the same world must be the same"); double eta = fix_grem->eta; double h0 = fix_grem->h0; double pressref = 0; // Get and check for nh fix - id_nh = utils::strdup(arg[4]); - int ifix = modify->find_fix(id_nh); - if (ifix < 0) - error->all(FLERR,"Fix id for nvt or npt fix does not exist"); - Fix *nh = modify->fix[ifix]; + + FixNH *nh = dynamic_cast(modify->get_fix_by_id(arg[4])); + if (!nh) + error->all(FLERR,fmt::format("Fix {} for Nose-Hoover fix does not exist", arg[4])); // get result from nvt vs npt check from fix_grem + int pressflag = fix_grem->pressflag; + // fix_grem does all the checking... + if (pressflag) { - auto p_start = (double *) nh->extract("p_start",ifix); + int dummy; + auto p_start = (double *) nh->extract("p_start",dummy); pressref = p_start[0]; } @@ -123,11 +127,6 @@ void TemperGrem::command(int narg, char **arg) if (nswaps*nevery != nsteps) error->universe_all(FLERR,"Non integer # of swaps in temper command"); - // Must be used with fix_grem - - if (strcmp(modify->fix[whichfix]->style,"grem") != 0) - error->universe_all(FLERR,"Tempering temperature fix is not supported"); - // setup for long tempering run update->whichflag = 1; @@ -136,8 +135,7 @@ void TemperGrem::command(int narg, char **arg) update->nsteps = nsteps; update->beginstep = update->firststep = update->ntimestep; update->endstep = update->laststep = update->firststep + nsteps; - if (update->laststep < 0) - error->all(FLERR,"Too many timesteps"); + if (update->laststep < 0) error->all(FLERR,"Too many timesteps"); lmp->init(); @@ -152,9 +150,9 @@ void TemperGrem::command(int narg, char **arg) // pe_compute = ptr to thermo_pe compute // notify compute it will be called at first swap - int id = modify->find_compute("thermo_pe"); - if (id < 0) error->all(FLERR,"Tempering could not find thermo_pe compute"); - Compute *pe_compute = modify->compute[id]; + Compute *pe_compute = modify->get_compute_by_id("thermo_pe"); + if (!pe_compute) error->all(FLERR,"Tempering could not find thermo_pe compute"); + pe_compute->addstep(update->ntimestep + nevery); // create MPI communicator for root proc from each world @@ -319,13 +317,12 @@ void TemperGrem::command(int narg, char **arg) else MPI_Recv(&swap,1,MPI_INT,partner,0,universe->uworld,MPI_STATUS_IGNORE); -#ifdef TEMPER_DEBUG +#if TEMPER_DEBUG if (me_universe < partner) - printf("SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g\n", - me_universe,partner,swap,my_set_lambda,partner_set_lambda, - weight,weight_partner,boltz_factor,exp(boltz_factor)); + fprintf(universe->uscreen,"SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g\n", + me_universe,partner,swap,my_set_lambda,partner_set_lambda, + weight,weight_partner,boltz_factor,exp(boltz_factor)); #endif - } // bcast swap result to other procs in my world diff --git a/src/REPLICA/temper_grem.h b/src/REPLICA/temper_grem.h index 3c41f9b082..8fe49ae804 100644 --- a/src/REPLICA/temper_grem.h +++ b/src/REPLICA/temper_grem.h @@ -40,8 +40,7 @@ class TemperGrem : public Command { int nswaps; // # of tempering swaps to perform int seed_swap; // 0 = toggle swaps, n = RNG for swap direction int seed_boltz; // seed for Boltz factor comparison - int whichfix; // index of temperature fix to use - int fixstyle; // what kind of temperature fix is used + class Fix *whichfix; // temperature fix to use int my_set_lambda; // which set lambda I am simulating double *set_lambda; // static list of replica set lambdas @@ -54,7 +53,6 @@ class TemperGrem : public Command { class FixGrem *fix_grem; protected: - char *id_nh; int pressflag; }; diff --git a/src/REPLICA/temper_npt.cpp b/src/REPLICA/temper_npt.cpp index 6567cb83e1..d814bf6725 100644 --- a/src/REPLICA/temper_npt.cpp +++ b/src/REPLICA/temper_npt.cpp @@ -52,10 +52,10 @@ TemperNPT::~TemperNPT() MPI_Comm_free(&roots); if (ranswap) delete ranswap; delete ranboltz; - delete [] set_temp; - delete [] temp2world; - delete [] world2temp; - delete [] world2root; + delete[] set_temp; + delete[] temp2world; + delete[] world2temp; + delete[] world2root; } /* ---------------------------------------------------------------------- @@ -65,11 +65,10 @@ TemperNPT::~TemperNPT() void TemperNPT::command(int narg, char **arg) { if (universe->nworlds == 1) - error->all(FLERR,"Must have more than one processor partition to temper"); + error->universe_all(FLERR,"More than one processor partition required for temper/npt command"); if (domain->box_exist == 0) - error->all(FLERR,"temper/npt command before simulation box is defined"); - if (narg != 7 && narg != 8) - error->universe_all(FLERR,"Illegal temper/npt command"); + error->universe_all(FLERR,"Temper/npt command before simulation box is defined"); + if (narg != 7 && narg != 8) error->universe_all(FLERR,"Illegal temper/npt command"); int nsteps = utils::inumeric(FLERR,arg[0],false,lmp); nevery = utils::inumeric(FLERR,arg[1],false,lmp); @@ -80,16 +79,17 @@ void TemperNPT::command(int narg, char **arg) if (timer->is_timeout()) return; - for (whichfix = 0; whichfix < modify->nfix; whichfix++) - if (strcmp(arg[3],modify->fix[whichfix]->id) == 0) break; - if (whichfix == modify->nfix) - error->universe_all(FLERR,"Tempering fix ID is not defined"); + whichfix = modify->get_fix_by_id(arg[3]); + if (!whichfix) + error->universe_all(FLERR,fmt::format("Tempering fix ID {} is not defined", arg[3])); seed_swap = utils::inumeric(FLERR,arg[4],false,lmp); seed_boltz = utils::inumeric(FLERR,arg[5],false,lmp); my_set_temp = universe->iworld; - if (narg == 8) my_set_temp = utils::inumeric(FLERR,arg[6],false,lmp); + if (narg == 8) my_set_temp = utils::inumeric(FLERR,arg[7],false,lmp); + if ((my_set_temp < 0) || (my_set_temp >= universe->nworlds)) + error->universe_one(FLERR,"Invalid temperature index value"); // swap frequency must evenly divide total # of timesteps @@ -104,8 +104,8 @@ void TemperNPT::command(int narg, char **arg) // change the volume. This currently only applies to fix npt and // fix rigid/npt variants - if ( (!utils::strmatch(modify->fix[whichfix]->style,"^npt")) && - (!utils::strmatch(modify->fix[whichfix]->style,"^rigid/npt")) ) + if ( (!utils::strmatch(whichfix->style,"^npt")) && + (!utils::strmatch(whichfix->style,"^rigid/npt")) ) error->universe_all(FLERR,"Tempering temperature and pressure fix is not supported"); // setup for long tempering run @@ -116,8 +116,7 @@ void TemperNPT::command(int narg, char **arg) update->nsteps = nsteps; update->beginstep = update->firststep = update->ntimestep; update->endstep = update->laststep = update->firststep + nsteps; - if (update->laststep < 0) - error->all(FLERR,"Too many timesteps"); + if (update->laststep < 0) error->all(FLERR,"Too many timesteps"); lmp->init(); @@ -133,9 +132,9 @@ void TemperNPT::command(int narg, char **arg) // pe_compute = ptr to thermo_pe compute // notify compute it will be called at first swap - int id = modify->find_compute("thermo_pe"); - if (id < 0) error->all(FLERR,"Tempering could not find thermo_pe compute"); - Compute *pe_compute = modify->compute[id]; + Compute *pe_compute = modify->get_compute_by_id("thermo_pe"); + if (!pe_compute) error->all(FLERR,"Tempering could not find thermo_pe compute"); + pe_compute->addstep(update->ntimestep + nevery); // create MPI communicator for root proc from each world @@ -184,7 +183,7 @@ void TemperNPT::command(int narg, char **arg) if (narg == 8) { double new_temp = set_temp[my_set_temp]; - modify->fix[whichfix]->reset_target(new_temp); + whichfix->reset_target(new_temp); } // setup tempering runs @@ -279,22 +278,23 @@ void TemperNPT::command(int narg, char **arg) swap = 0; if (partner != -1) { - if (me_universe > partner) { + if (me_universe > partner) MPI_Send(&pe,1,MPI_DOUBLE,partner,0,universe->uworld); - } - else { + else MPI_Recv(&pe_partner,1,MPI_DOUBLE,partner,0,universe->uworld,MPI_STATUS_IGNORE); - } - if (me_universe > partner) { + + if (me_universe > partner) MPI_Send(&vol,1, MPI_DOUBLE,partner,0,universe->uworld); - } - else { + else MPI_Recv(&vol_partner,1,MPI_DOUBLE,partner,0,universe->uworld,MPI_STATUS_IGNORE); - } - // Acceptance criteria changed for NPT ensemble + + // Acceptance criteria changed versus temper command for NPT ensemble if (me_universe < partner) { press_units = press_set/nktv2p; - delr = (pe_partner - pe)*(1.0/(boltz*set_temp[my_set_temp]) - 1.0/(boltz*set_temp[partner_set_temp])) + press_units*(1.0/(boltz*set_temp[my_set_temp]) - 1.0/(boltz*set_temp[partner_set_temp]))*(vol_partner - vol); + delr = (pe_partner - pe)*(1.0/(boltz*set_temp[my_set_temp]) + - 1.0/(boltz*set_temp[partner_set_temp])) + + press_units*(1.0/(boltz*set_temp[my_set_temp]) + - 1.0/(boltz*set_temp[partner_set_temp]))*(vol_partner - vol); boltz_factor = -delr; if (boltz_factor >= 0.0) swap = 1; else if (ranboltz->uniform() < exp(boltz_factor)) swap = 1; @@ -304,13 +304,13 @@ void TemperNPT::command(int narg, char **arg) MPI_Send(&swap,1,MPI_INT,partner,0,universe->uworld); else MPI_Recv(&swap,1,MPI_INT,partner,0,universe->uworld,MPI_STATUS_IGNORE); -#ifdef TEMPER_DEBUG + +#if TEMPER_DEBUG if (me_universe < partner) fprintf(universe->uscreen,"SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g, vol = %g %g\n", me_universe,partner,swap,my_set_temp,partner_set_temp, pe,pe_partner,boltz_factor,exp(boltz_factor), vol, vol_partner); #endif - } // bcast swap result to other procs in my world @@ -325,7 +325,7 @@ void TemperNPT::command(int narg, char **arg) if (swap) { new_temp = set_temp[partner_set_temp]; - modify->fix[whichfix]->reset_target(new_temp); + whichfix->reset_target(new_temp); } // update my_set_temp and temp2world on every proc diff --git a/src/REPLICA/temper_npt.h b/src/REPLICA/temper_npt.h index 3a51fc74e4..3ea29a21f6 100644 --- a/src/REPLICA/temper_npt.h +++ b/src/REPLICA/temper_npt.h @@ -42,8 +42,7 @@ class TemperNPT : public Command { int nswaps; // # of tempering swaps to perform int seed_swap; // 0 = toggle swaps, n = RNG for swap direction int seed_boltz; // seed for Boltz factor comparison - int whichfix; // index of temperature fix to use - int fixstyle; // what kind of temperature fix is used + class Fix *whichfix; // temperature fix to use int my_set_temp; // which set temp I am simulating double *set_temp; // static list of replica set temperatures diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 94c7668453..b2c65220bc 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -877,7 +877,7 @@ void FixShake::find_clusters() tagprev = tag[i] - iatom - 1; npartner[i] = atommols[imol]->nspecial[iatom][0]; for (j = 0; j < npartner[i]; j++) - partner_tag[i][j] = atommols[imol]->special[iatom][j] + tagprev;; + partner_tag[i][j] = atommols[imol]->special[iatom][j] + tagprev; } } diff --git a/src/SMTBQ/pair_smtbq.cpp b/src/SMTBQ/pair_smtbq.cpp index 15e5c2da5e..4f924a6fca 100644 --- a/src/SMTBQ/pair_smtbq.cpp +++ b/src/SMTBQ/pair_smtbq.cpp @@ -204,7 +204,7 @@ PairSMTBQ::~PairSMTBQ() memory->destroy(potcov); memory->destroy(nvsm); - memory->destroy(vsm);; + memory->destroy(vsm); memory->destroy(flag_QEq); memory->destroy(nQEqall); @@ -446,7 +446,7 @@ void PairSMTBQ::read_file(char *file) params[i].chi = values.next_double(); params[i].dj = values.next_double(); - if (strcmp(params[i].nom, "O") !=0) { + if (strcmp(params[i].nom, "O") != 0) { params[i].R = values.next_double(); if ((comm->me == 0) && VERBOSE) utils::logmesg(lmp, " {} {} {} {} {}\n",label,params[i].ne,params[i].chi, @@ -782,7 +782,7 @@ void PairSMTBQ::read_file(char *file) if (intparams[m].intsm == 0) continue; intparams[m].neig_cut = 1.2*intparams[m].r0; - if (strcmp(intparams[m].typepot,"second_moment") == 0 ) + if (strcmp(intparams[m].typepot,"second_moment") == 0) if ((comm->me == 0) && VERBOSE) utils::logmesg(lmp, " Rc 1er voisin, typepot {} -> {} Ang\n", intparams[m].typepot,intparams[m].neig_cut); @@ -1020,7 +1020,7 @@ void PairSMTBQ::compute(int eflag, int vflag) // ---------------------------------------------- if ( strcmp(intparams[m].typepot,"buck") == 0 || - strcmp(intparams[m].typepot,"buckPlusAttr") ==0) { + strcmp(intparams[m].typepot,"buckPlusAttr") == 0) { // ---------------------------------------------- evdwl = 0.0; fpair =0.0; @@ -1070,7 +1070,7 @@ void PairSMTBQ::compute(int eflag, int vflag) // ----------------------------------------------------------------- - if (strcmp(intparams[m].typepot,"second_moment") != 0 ) continue; + if (strcmp(intparams[m].typepot,"second_moment") != 0) continue; // ----------------------------------------------------------------- @@ -2575,7 +2575,7 @@ void PairSMTBQ::Charge() if (me == 0 && strcmp(Bavard,"false") != 0) { for (gp = 0; gp < nteam+1; gp++) { printf (" ++++ Groupe %d - Nox %d Ncat %d\n",gp,nQEqaall[gp],nQEqcall[gp]); - if (nQEqcall[gp] !=0 && nQEqaall[gp] !=0 ) + if (nQEqcall[gp] != 0 && nQEqaall[gp] !=0 ) printf (" neutralite des charges %f\n qtotc %f qtota %f\n", qtotll,qtotcll[gp]/nQEqcall[gp],qtotall[gp]/nQEqaall[gp]); printf (" ---------------------------- \n");} @@ -2641,7 +2641,7 @@ void PairSMTBQ::Charge() for (i = 0; i < nteam+1; i++) { - if (nQEqall[i] !=0) TransfAll[i] /= static_cast(nQEqall[i]); + if (nQEqall[i] != 0) TransfAll[i] /= static_cast(nQEqall[i]); enegchk[i] = enegmax[i] = 0.0; } @@ -2665,7 +2665,7 @@ void PairSMTBQ::Charge() for (gp = 0; gp < nteam+1; gp++) { - if (nQEqall[gp] !=0) { + if (nQEqall[gp] != 0) { enegchk[gp] = enegchkall[gp]/static_cast(nQEqall[gp]); enegmax[gp] = enegmaxall[gp]; } @@ -2729,7 +2729,7 @@ void PairSMTBQ::Charge() // Statistique (ecart type) // ------------------------ for (i=0; i(nQEqcall[i]) ; TransfAll[i+2*cluster] /= static_cast(nQEqaall[i]) ;} sigmaa[i] = sigmac[i] = 0.0; diff --git a/src/SPIN/min_spin_lbfgs.cpp b/src/SPIN/min_spin_lbfgs.cpp index c9c84239b6..ae9d33a705 100644 --- a/src/SPIN/min_spin_lbfgs.cpp +++ b/src/SPIN/min_spin_lbfgs.cpp @@ -378,7 +378,7 @@ void MinSpinLBFGS::calc_search_direction() scaling = maximum_rotation(g_cur); for (int i = 0; i < 3 * nlocal; i++) { - p_s[i] = -g_cur[i] * factor * scaling;; + p_s[i] = -g_cur[i] * factor * scaling; g_old[i] = g_cur[i] * factor; for (int k = 0; k < num_mem; k++) { ds[k][i] = 0.0; diff --git a/src/VTK/dump_vtk.cpp b/src/VTK/dump_vtk.cpp index 3667180bc9..172a092629 100644 --- a/src/VTK/dump_vtk.cpp +++ b/src/VTK/dump_vtk.cpp @@ -297,9 +297,10 @@ int DumpVTK::count() // cannot invoke before first run, otherwise invoke if necessary if (ncompute) { - if (update->first_update == 0) - error->all(FLERR,"Dump compute cannot be invoked before first run"); for (i = 0; i < ncompute; i++) { + if (!compute[i]->is_initialized()) + error->all(FLERR,"Dump compute ID {} cannot be invoked before initialization by a run", + compute[i]->id); if (!(compute[i]->invoked_flag & Compute::INVOKED_PERATOM)) { compute[i]->compute_peratom(); compute[i]->invoked_flag |= Compute::INVOKED_PERATOM; @@ -1933,7 +1934,7 @@ void DumpVTK::identify_vectors() // assume components are grouped together and in correct order if (name.count(it->first + 1) && name.count(it->first + 2)) { // more attributes? if (it->second.compare(0,it->second.length()-3,name[it->first + 1],0,it->second.length()-3) == 0 && // same attributes? - it->second.compare(0,it->second.length()-3,name[it->first + 2],0,it->second.length()-3) == 0 ) + it->second.compare(0,it->second.length()-3,name[it->first + 2],0,it->second.length()-3) == 0) { it->second.erase(it->second.length()-1); std::ostringstream oss; diff --git a/src/atom.cpp b/src/atom.cpp index 08e9639440..c4521a244e 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -966,10 +966,10 @@ void Atom::bonus_check() bigint local_bodies = 0, num_global; for (int i = 0; i < nlocal; ++i) { - if (ellipsoid && (ellipsoid[i] >=0)) ++local_ellipsoids; - if (line && (line[i] >=0)) ++local_lines; - if (tri && (tri[i] >=0)) ++local_tris; - if (body && (body[i] >=0)) ++local_bodies; + if (ellipsoid && (ellipsoid[i] >= 0)) ++local_ellipsoids; + if (line && (line[i] >= 0)) ++local_lines; + if (tri && (tri[i] >= 0)) ++local_tris; + if (body && (body[i] >= 0)) ++local_bodies; } MPI_Allreduce(&local_ellipsoids,&num_global,1,MPI_LMP_BIGINT,MPI_SUM,world); @@ -1818,17 +1818,16 @@ void Atom::data_bodies(int n, char *buf, AtomVec *avec_body, tagint id_offset) void Atom::data_fix_compute_variable(int nprev, int nnew) { - for (const auto &fix : modify->get_fix_list()) { - if (fix->create_attribute) + for (const auto &ifix : modify->get_fix_list()) { + if (ifix->create_attribute) for (int i = nprev; i < nnew; i++) - fix->set_arrays(i); + ifix->set_arrays(i); } - for (int m = 0; m < modify->ncompute; m++) { - Compute *compute = modify->compute[m]; - if (compute->create_attribute) + for (const auto &icompute : modify->get_compute_list()) { + if (icompute->create_attribute) for (int i = nprev; i < nnew; i++) - compute->set_arrays(i); + icompute->set_arrays(i); } for (int i = nprev; i < nnew; i++) diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index d2f9c51880..8769c316d9 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -16,7 +16,6 @@ #include "atom.h" #include "error.h" #include "fix.h" -#include "fix_adapt.h" #include "math_const.h" #include "modify.h" @@ -31,6 +30,7 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) { mass_type = PER_ATOM; molecular = Atom::ATOMIC; + radvary = 0; atom->sphere_flag = 1; atom->radius_flag = atom->rmass_flag = atom->omega_flag = atom->torque_flag = 1; @@ -88,11 +88,11 @@ void AtomVecSphere::init() // check if optional radvary setting should have been set to 1 - for (int i = 0; i < modify->nfix; i++) - if (strcmp(modify->fix[i]->style, "adapt") == 0) { - auto fix = dynamic_cast(modify->fix[i]); - if (fix->diamflag && radvary == 0) - error->all(FLERR, "Fix adapt changes particle radii but atom_style sphere is not dynamic"); + if (radvary == 0) + for (const auto &ifix : modify->get_fix_by_style("^adapt")) { + if (ifix->diam_flag) + error->all(FLERR, "Fix {} changes atom radii but atom_style sphere is not dynamic", + ifix->style); } } diff --git a/src/compute.cpp b/src/compute.cpp index dcad4954fc..2bd1544fd7 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -74,6 +74,7 @@ Compute::Compute(LAMMPS *lmp, int narg, char **arg) : dynamic = 0; dynamic_group_allow = 1; + initialized_flag = 0; invoked_scalar = invoked_vector = invoked_array = -1; invoked_peratom = invoked_local = -1; invoked_flag = INVOKED_NONE; @@ -111,6 +112,15 @@ Compute::~Compute() /* ---------------------------------------------------------------------- */ +void Compute::init_flags() +{ + initialized_flag = 1; + invoked_scalar = invoked_vector = invoked_array = -1; + invoked_peratom = invoked_local = -1; +} + +/* ---------------------------------------------------------------------- */ + void Compute::modify_params(int narg, char **arg) { if (narg == 0) error->all(FLERR,"Illegal compute_modify command"); diff --git a/src/compute.h b/src/compute.h index 72b0075fd6..8ae01a4469 100644 --- a/src/compute.h +++ b/src/compute.h @@ -62,7 +62,7 @@ class Compute : protected Pointers { int size_local_rows; // rows in local vector or array int size_local_cols; // 0 = vector, N = columns in local array - int pergrid_flag; // 0/1 if compute_pergrid() function exists + int pergrid_flag; // 0/1 if compute_pergrid() function exists int extscalar; // 0/1 if global scalar is intensive/extensive int extvector; // 0/1/-1 if global vector is all int/ext/extlist @@ -88,6 +88,7 @@ class Compute : protected Pointers { int maxtime; // max # of entries time list can hold bigint *tlist; // list of timesteps the Compute is called on + int initialized_flag; // 1 if compute is initialized, 0 if not int invoked_flag; // non-zero if invoked or accessed this step, 0 if not bigint invoked_scalar; // last timestep on which compute_scalar() was invoked bigint invoked_vector; // ditto for compute_vector() @@ -114,6 +115,7 @@ class Compute : protected Pointers { void modify_params(int, char **); virtual void reset_extra_dof(); + void init_flags(); virtual void init() = 0; virtual void init_list(int, class NeighList *) {} virtual void setup() {} @@ -161,6 +163,8 @@ class Compute : protected Pointers { int matchstep(bigint); void clearstep(); + bool is_initialized() const { return initialized_flag == 1; } + virtual double memory_usage() { return 0.0; } virtual void pair_setup_callback(int, int) {} diff --git a/src/compute_aggregate_atom.cpp b/src/compute_aggregate_atom.cpp index 05526494c0..e68062b73e 100644 --- a/src/compute_aggregate_atom.cpp +++ b/src/compute_aggregate_atom.cpp @@ -82,10 +82,8 @@ void ComputeAggregateAtom::init() 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, "aggregate/atom") == 0) count++; - if (count > 1 && comm->me == 0) error->warning(FLERR, "More than one compute aggregate/atom"); + if (modify->get_compute_by_style(style).size() > 1) + if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style); } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_centro_atom.cpp b/src/compute_centro_atom.cpp index ae6ef4901f..10d2a79c45 100644 --- a/src/compute_centro_atom.cpp +++ b/src/compute_centro_atom.cpp @@ -93,14 +93,12 @@ void ComputeCentroAtom::init() if (force->pair == nullptr) error->all(FLERR, "Compute centro/atom requires a pair style be defined"); - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "centro/atom") == 0) count++; - if (count > 1 && comm->me == 0) error->warning(FLERR, "More than one compute centro/atom"); - // need an occasional full neighbor list neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); + + if (modify->get_compute_by_style(style).size() > 1) + if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style); } /* ---------------------------------------------------------------------- */ @@ -338,7 +336,7 @@ void ComputeCentroAtom::select(int k, int n, double *arr) arr--; l = 1; ir = n; - for (;;) { + while (true) { if (ir <= l + 1) { if (ir == l + 1 && arr[ir] < arr[l]) { SWAP(arr[l], arr[ir]) } return; @@ -351,7 +349,7 @@ void ComputeCentroAtom::select(int k, int n, double *arr) i = l + 1; j = ir; a = arr[l + 1]; - for (;;) { + while (true) { do i++; while (arr[i] < a); do j--; @@ -378,7 +376,7 @@ void ComputeCentroAtom::select2(int k, int n, double *arr, int *iarr) iarr--; l = 1; ir = n; - for (;;) { + while (true) { if (ir <= l + 1) { if (ir == l + 1 && arr[ir] < arr[l]) { SWAP(arr[l], arr[ir]) @@ -405,7 +403,7 @@ void ComputeCentroAtom::select2(int k, int n, double *arr, int *iarr) j = ir; a = arr[l + 1]; ia = iarr[l + 1]; - for (;;) { + while (true) { do i++; while (arr[i] < a); do j--; diff --git a/src/compute_cluster_atom.cpp b/src/compute_cluster_atom.cpp index 0a0a36debd..ae44fbcd37 100644 --- a/src/compute_cluster_atom.cpp +++ b/src/compute_cluster_atom.cpp @@ -69,10 +69,8 @@ void ComputeClusterAtom::init() 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, "cluster/atom") == 0) count++; - if (count > 1 && comm->me == 0) error->warning(FLERR, "More than one compute cluster/atom"); + if (modify->get_compute_by_style(style).size() > 1) + if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style); } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_cna_atom.cpp b/src/compute_cna_atom.cpp index ccb4183707..a09a671c07 100644 --- a/src/compute_cna_atom.cpp +++ b/src/compute_cna_atom.cpp @@ -76,19 +76,15 @@ void ComputeCNAAtom::init() // cannot use neighbor->cutneighmax b/c neighbor has not yet been init - if (2.0 * sqrt(cutsq) > force->pair->cutforce + neighbor->skin && comm->me == 0) - error->warning(FLERR, - "Compute cna/atom cutoff may be too large to find " - "ghost atom neighbors"); - - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "cna/atom") == 0) count++; - if (count > 1 && comm->me == 0) error->warning(FLERR, "More than one compute cna/atom defined"); + if ((2.0 * sqrt(cutsq)) > (force->pair->cutforce + neighbor->skin) && (comm->me == 0)) + error->warning(FLERR, "Compute cna/atom cutoff may be too large to find ghost atom neighbors"); // need an occasional full neighbor list neighbor->add_request(this, NeighConst::REQ_FULL | NeighConst::REQ_OCCASIONAL); + + if (modify->get_compute_by_style(style).size() > 1) + if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style); } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_coord_atom.cpp b/src/compute_coord_atom.cpp index 0d56ea6573..ea19f01b91 100644 --- a/src/compute_coord_atom.cpp +++ b/src/compute_coord_atom.cpp @@ -82,10 +82,11 @@ ComputeCoordAtom::ComputeCoordAtom(LAMMPS *lmp, int narg, char **arg) : id_orientorder = utils::strdup(arg[4]); - int iorientorder = modify->find_compute(id_orientorder); - if (iorientorder < 0) error->all(FLERR, "Could not find compute coord/atom compute ID"); - if (!utils::strmatch(modify->compute[iorientorder]->style, "^orientorder/atom")) - error->all(FLERR, "Compute coord/atom compute ID is not orientorder/atom"); + auto iorientorder = modify->get_compute_by_id(id_orientorder); + if (!iorientorder) + error->all(FLERR, "Could not find compute coord/atom compute ID {}", id_orientorder); + if (!utils::strmatch(iorientorder->style, "^orientorder/atom")) + error->all(FLERR, "Compute coord/atom compute ID {} is not orientorder/atom", id_orientorder); threshold = utils::numeric(FLERR, arg[5], false, lmp); if (threshold <= -1.0 || threshold >= 1.0) @@ -128,8 +129,11 @@ ComputeCoordAtom::~ComputeCoordAtom() void ComputeCoordAtom::init() { if (cstyle == ORIENT) { - int iorientorder = modify->find_compute(id_orientorder); - c_orientorder = dynamic_cast(modify->compute[iorientorder]); + c_orientorder = + dynamic_cast(modify->get_compute_by_id(id_orientorder)); + if (!c_orientorder) + error->all(FLERR, "Could not find compute coord/atom compute ID {}", id_orientorder); + cutsq = c_orientorder->cutsq; l = c_orientorder->qlcomp; // communicate real and imaginary 2*l+1 components of the normalized vector diff --git a/src/compute_count_type.cpp b/src/compute_count_type.cpp index 3cb2e6bc3a..3d4815f9ff 100644 --- a/src/compute_count_type.cpp +++ b/src/compute_count_type.cpp @@ -159,6 +159,8 @@ void ComputeCountType::compute_vector() nvec = count_dihedrals(); else if (mode == IMPROPER) nvec = count_impropers(); + else + nvec = 0; // sum across procs as bigint, then convert to double // correct for multiple counting if newton_bond off diff --git a/src/compute_erotate_sphere_atom.cpp b/src/compute_erotate_sphere_atom.cpp index 9bfa0afaea..3ec0f402a8 100644 --- a/src/compute_erotate_sphere_atom.cpp +++ b/src/compute_erotate_sphere_atom.cpp @@ -57,11 +57,8 @@ ComputeErotateSphereAtom::~ComputeErotateSphereAtom() void ComputeErotateSphereAtom::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style,"erotate/sphere/atom") == 0) count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR,"More than one compute erotate/sphere/atom"); + if (modify->get_compute_by_style(style).size() > 1) + if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style); pfactor = 0.5 * force->mvv2e * INERTIA; } diff --git a/src/compute_fragment_atom.cpp b/src/compute_fragment_atom.cpp index 810ffa4d66..035f554c8d 100644 --- a/src/compute_fragment_atom.cpp +++ b/src/compute_fragment_atom.cpp @@ -84,11 +84,8 @@ void ComputeFragmentAtom::init() if (atom->molecular != Atom::MOLECULAR) error->all(FLERR,"Compute fragment/atom requires a molecular system"); - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style,"fragment/atom") == 0) count++; - if (count > 1 && comm->me == 0) - error->warning(FLERR,"More than one compute fragment/atom"); + if (modify->get_compute_by_style(style).size() > 1) + if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style); } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_ke_atom.cpp b/src/compute_ke_atom.cpp index aab687755e..9a329232b3 100644 --- a/src/compute_ke_atom.cpp +++ b/src/compute_ke_atom.cpp @@ -47,10 +47,8 @@ ComputeKEAtom::~ComputeKEAtom() void ComputeKEAtom::init() { - int count = 0; - for (int i = 0; i < modify->ncompute; i++) - if (strcmp(modify->compute[i]->style, "ke/atom") == 0) count++; - if (count > 1 && comm->me == 0) error->warning(FLERR, "More than one compute ke/atom"); + if (modify->get_compute_by_style(style).size() > 1) + if (comm->me == 0) error->warning(FLERR, "More than one compute {}", style); } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_orientorder_atom.cpp b/src/compute_orientorder_atom.cpp index 5682432c8e..6f1b2b4036 100644 --- a/src/compute_orientorder_atom.cpp +++ b/src/compute_orientorder_atom.cpp @@ -370,7 +370,7 @@ void ComputeOrientOrderAtom::select3(int k, int n, double *arr, int *iarr, doubl arr3--; l = 1; ir = n; - for (;;) { + while (true) { if (ir <= l + 1) { if (ir == l + 1 && arr[ir] < arr[l]) { SWAP(arr[l], arr[ir]); @@ -405,7 +405,7 @@ void ComputeOrientOrderAtom::select3(int k, int n, double *arr, int *iarr, doubl a3[0] = arr3[l + 1][0]; a3[1] = arr3[l + 1][1]; a3[2] = arr3[l + 1][2]; - for (;;) { + while (true) { do i++; while (arr[i] < a); do j--; diff --git a/src/compute_property_atom.cpp b/src/compute_property_atom.cpp index fc7089fa01..c3c101b995 100644 --- a/src/compute_property_atom.cpp +++ b/src/compute_property_atom.cpp @@ -376,7 +376,7 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) : index[i] = atom->avec->property_atom(arg[iarg]); if (index[i] < 0) error->all(FLERR,"Invalid keyword {} for atom style {} in compute property/atom command ", - atom->get_style(), arg[iarg]); + arg[iarg], atom->get_style()); pack_choice[i] = &ComputePropertyAtom::pack_atom_style; } } @@ -1268,7 +1268,7 @@ void ComputePropertyAtom::pack_shapex(int n) for (int i = 0; i < nlocal; i++) { if ((mask[i] & groupbit) && ellipsoid[i] >= 0) buf[n] = 2.0*bonus[ellipsoid[i]].shape[0]; - else buf[n] = 0.0; + else buf[n] = 1.0; n += nvalues; } } @@ -1285,7 +1285,7 @@ void ComputePropertyAtom::pack_shapey(int n) for (int i = 0; i < nlocal; i++) { if ((mask[i] & groupbit) && ellipsoid[i] >= 0) buf[n] = 2.0*bonus[ellipsoid[i]].shape[1]; - else buf[n] = 0.0; + else buf[n] = 1.0; n += nvalues; } } @@ -1302,7 +1302,7 @@ void ComputePropertyAtom::pack_shapez(int n) for (int i = 0; i < nlocal; i++) { if ((mask[i] & groupbit) && ellipsoid[i] >= 0) buf[n] = 2.0*bonus[ellipsoid[i]].shape[2]; - else buf[n] = 0.0; + else buf[n] = 1.0; n += nvalues; } } @@ -1320,7 +1320,7 @@ void ComputePropertyAtom::pack_quatw(int n) for (int i = 0; i < nlocal; i++) { if ((mask[i] & groupbit) && ellipsoid[i] >= 0) buf[n] = bonus[ellipsoid[i]].quat[0]; - else buf[n] = 0.0; + else buf[n] = 1.0; n += nvalues; } diff --git a/src/create_bonds.cpp b/src/create_bonds.cpp index 5355ce2b7c..13a99a182f 100644 --- a/src/create_bonds.cpp +++ b/src/create_bonds.cpp @@ -49,7 +49,7 @@ void CreateBonds::command(int narg, char **arg) if (atom->molecular != Atom::MOLECULAR) error->all(FLERR, "Cannot use create_bonds with non-molecular system"); - if (narg < 4) error->all(FLERR, "Illegal create_bonds command"); + if (narg < 4) utils::missing_cmd_args(FLERR, "create_bonds", error); // parse args @@ -58,38 +58,38 @@ void CreateBonds::command(int narg, char **arg) int iarg = 0; if (strcmp(arg[0], "many") == 0) { style = MANY; - if (narg != 6) error->all(FLERR, "Illegal create_bonds command"); + if (narg != 6) error->all(FLERR, "No optional keywords allowed with create_bonds many"); igroup = group->find(arg[1]); - if (igroup == -1) error->all(FLERR, "Cannot find create_bonds group ID"); + if (igroup == -1) error->all(FLERR, "Cannot find create_bonds first group ID {}", arg[1]); group1bit = group->bitmask[igroup]; igroup = group->find(arg[2]); - if (igroup == -1) error->all(FLERR, "Cannot find create_bonds group ID"); + if (igroup == -1) error->all(FLERR, "Cannot find create_bonds second group ID {}", arg[2]); group2bit = group->bitmask[igroup]; btype = utils::inumeric(FLERR, arg[3], false, lmp); rmin = utils::numeric(FLERR, arg[4], false, lmp); rmax = utils::numeric(FLERR, arg[5], false, lmp); - if (rmin > rmax) error->all(FLERR, "Illegal create_bonds command"); + if (rmin > rmax) error->all(FLERR, "Inconsistent cutoffs for create_bonds many"); iarg = 6; } else if (strcmp(arg[0], "single/bond") == 0) { style = SBOND; btype = utils::inumeric(FLERR, arg[1], false, lmp); batom1 = utils::tnumeric(FLERR, arg[2], false, lmp); batom2 = utils::tnumeric(FLERR, arg[3], false, lmp); - if (batom1 == batom2) error->all(FLERR, "Illegal create_bonds command"); + if (batom1 == batom2) error->all(FLERR, "Bond atoms must be different"); iarg = 4; } else if (strcmp(arg[0], "single/angle") == 0) { style = SANGLE; - if (narg < 5) error->all(FLERR, "Illegal create_bonds command"); + if (narg < 5) utils::missing_cmd_args(FLERR, "create_bonds single/angle", error); atype = utils::inumeric(FLERR, arg[1], false, lmp); aatom1 = utils::tnumeric(FLERR, arg[2], false, lmp); aatom2 = utils::tnumeric(FLERR, arg[3], false, lmp); aatom3 = utils::tnumeric(FLERR, arg[4], false, lmp); if ((aatom1 == aatom2) || (aatom1 == aatom3) || (aatom2 == aatom3)) - error->all(FLERR, "Illegal create_bonds command"); + error->all(FLERR, "Angle atoms must be different"); iarg = 5; } else if (strcmp(arg[0], "single/dihedral") == 0) { style = SDIHEDRAL; - if (narg < 6) error->all(FLERR, "Illegal create_bonds command"); + if (narg < 6) utils::missing_cmd_args(FLERR, "create_bonds single/dihedral", error); dtype = utils::inumeric(FLERR, arg[1], false, lmp); datom1 = utils::tnumeric(FLERR, arg[2], false, lmp); datom2 = utils::tnumeric(FLERR, arg[3], false, lmp); @@ -101,7 +101,7 @@ void CreateBonds::command(int narg, char **arg) iarg = 6; } else if (strcmp(arg[0], "single/improper") == 0) { style = SIMPROPER; - if (narg < 6) error->all(FLERR, "Illegal create_bonds command"); + if (narg < 6) utils::missing_cmd_args(FLERR, "create_bonds single/improper", error); dtype = utils::inumeric(FLERR, arg[1], false, lmp); datom1 = utils::tnumeric(FLERR, arg[2], false, lmp); datom2 = utils::tnumeric(FLERR, arg[3], false, lmp); @@ -197,6 +197,11 @@ void CreateBonds::many() if (rmax > neighbor->cutneighmin && comm->me == 0) error->warning(FLERR, "Create_bonds max distance > minimum neighbor cutoff"); + if ((domain->xperiodic && (rmax > domain->xprd)) || + (domain->yperiodic && (rmax > domain->yprd)) || + ((domain->dimension == 3) && domain->zperiodic && (rmax > domain->zprd))) + error->all(FLERR, "Bond creation cutoff is larger than periodic domain"); + // require special_bonds 1-2 weights = 0.0 and KSpace = nullptr // so that already bonded atom pairs do not appear in neighbor list // otherwise with newton_bond = 1, @@ -205,7 +210,7 @@ void CreateBonds::many() if (force->special_lj[1] != 0.0 || force->special_coul[1] != 0.0) error->all(FLERR, "Create_bonds command requires special_bonds 1-2 weights be 0.0"); - if (force->kspace) error->all(FLERR, "Create_bonds command requires no kspace_style be defined"); + if (force->kspace) error->all(FLERR, "Create_bonds command is incompatible with Kspace styles"); // setup domain, communication and neighboring // acquire ghosts and build standard neighbor lists diff --git a/src/dump.cpp b/src/dump.cpp index 372773bbb2..39d8989c41 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -41,14 +41,20 @@ Dump *Dump::dumpptr; #define BIG 1.0e20 #define EPSILON 1.0e-6 -enum{ASCEND,DESCEND}; +enum { ASCEND, DESCEND }; /* ---------------------------------------------------------------------- */ -Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp) +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), + 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), + imagepbc(nullptr), irregular(nullptr) { - MPI_Comm_rank(world,&me); - MPI_Comm_size(world,&nprocs); + MPI_Comm_rank(world, &me); + MPI_Comm_size(world, &nprocs); id = utils::strdup(arg[0]); @@ -64,17 +70,7 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp) first_flag = 0; flush_flag = 1; - 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; - refreshflag = 0; - refresh = nullptr; clearstep = 0; sort_flag = 0; @@ -92,25 +88,15 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp) has_id = 1; skipflag = 0; - skipvar = nullptr; maxfiles = -1; numfiles = 0; fileidx = 0; - nameslist = nullptr; maxbuf = maxids = maxsort = maxproc = 0; - buf = bufsort = nullptr; - ids = idsort = nullptr; - index = proclist = nullptr; - irregular = nullptr; - maxsbuf = 0; - sbuf = nullptr; maxpbc = -1; - xpbc = vpbc = nullptr; - imagepbc = nullptr; // parse filename for special syntax // if contains '%', write one file per proc and replace % with proc-ID @@ -120,18 +106,17 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp) // else if ends in .gz or other known extensions -> compressed text file // else ASCII text file - fp = nullptr; singlefile_opened = 0; compressed = 0; binary = 0; multifile = 0; + size_one = 0; multiproc = 0; nclusterprocs = nprocs; filewriter = 0; if (me == 0) filewriter = 1; fileproc = 0; - multiname = nullptr; char *ptr; if ((ptr = strchr(filename,'%'))) { diff --git a/src/dump_atom.cpp b/src/dump_atom.cpp index 1d3862ab26..2d047dc0a0 100644 --- a/src/dump_atom.cpp +++ b/src/dump_atom.cpp @@ -29,7 +29,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -DumpAtom::DumpAtom(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg) +DumpAtom::DumpAtom(LAMMPS *lmp, int narg, char **arg) : + Dump(lmp, narg, arg), header_choice(nullptr), pack_choice(nullptr) { if (narg != 5) error->all(FLERR,"Illegal dump atom command"); @@ -146,6 +147,8 @@ int DumpAtom::modify_param(int narg, char **arg) void DumpAtom::write_header(bigint ndump) { + if (!header_choice) error->all(FLERR, "Must not use 'run pre no' after creating a new dump"); + if (multiproc) (this->*header_choice)(ndump); else if (me == 0) (this->*header_choice)(ndump); } @@ -154,6 +157,8 @@ void DumpAtom::write_header(bigint ndump) void DumpAtom::pack(tagint *ids) { + if (!pack_choice) error->all(FLERR, "Must not use 'run pre no' after creating a new dump"); + (this->*pack_choice)(ids); } diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 33cfba2cef..1e60295bbe 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -53,13 +53,14 @@ enum{LT,LE,GT,GE,EQ,NEQ,XOR}; /* ---------------------------------------------------------------------- */ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) : - Dump(lmp, narg, arg), idregion(nullptr), thresh_array(nullptr), thresh_op(nullptr), - thresh_value(nullptr), thresh_last(nullptr), thresh_fix(nullptr), thresh_fixID(nullptr), - thresh_first(nullptr), earg(nullptr), vtype(nullptr), vformat(nullptr), columns(nullptr), - columns_default(nullptr), choose(nullptr), dchoose(nullptr), clist(nullptr), - field2index(nullptr), argindex(nullptr), id_compute(nullptr), compute(nullptr), id_fix(nullptr), - fix(nullptr), id_variable(nullptr), variable(nullptr), vbuf(nullptr), id_custom(nullptr), - custom(nullptr), custom_flag(nullptr), typenames(nullptr), pack_choice(nullptr) + Dump(lmp, narg, arg), idregion(nullptr), thresh_array(nullptr), thresh_op(nullptr), + thresh_value(nullptr), thresh_last(nullptr), thresh_fix(nullptr), thresh_fixID(nullptr), + thresh_first(nullptr), earg(nullptr), vtype(nullptr), vformat(nullptr), columns(nullptr), + columns_default(nullptr), choose(nullptr), dchoose(nullptr), clist(nullptr), + field2index(nullptr), argindex(nullptr), id_compute(nullptr), compute(nullptr), id_fix(nullptr), + fix(nullptr), id_variable(nullptr), variable(nullptr), vbuf(nullptr), id_custom(nullptr), + custom(nullptr), custom_flag(nullptr), typenames(nullptr), header_choice(nullptr), + pack_choice(nullptr) { if (narg == 5) error->all(FLERR,"No dump {} arguments specified", style); @@ -352,6 +353,8 @@ void DumpCustom::init_style() void DumpCustom::write_header(bigint ndump) { + if (!header_choice) error->all(FLERR, "Must not use 'run pre no' after creating a new dump"); + if (multiproc) (this->*header_choice)(ndump); else if (me == 0) (this->*header_choice)(ndump); } @@ -559,9 +562,10 @@ int DumpCustom::count() // cannot invoke before first run, otherwise invoke if necessary if (ncompute) { - if (update->first_update == 0) - error->all(FLERR,"Dump compute cannot be invoked before first run"); for (i = 0; i < ncompute; i++) { + if (!compute[i]->is_initialized()) + error->all(FLERR,"Dump compute ID {} cannot be invoked before initialization by a run", + compute[i]->id); if (!(compute[i]->invoked_flag & Compute::INVOKED_PERATOM)) { compute[i]->compute_peratom(); compute[i]->invoked_flag |= Compute::INVOKED_PERATOM; @@ -1461,10 +1465,14 @@ int DumpCustom::parse_fields(int narg, char **arg) switch (argi.get_type()) { case ArgInfo::UNKNOWN: - case ArgInfo::NONE: error->all(FLERR,"Invalid attribute {} in dump {} command",arg[iarg],style); break; + case ArgInfo::NONE: + // ignore because this may be a valid argument for a derived dump style class + return iarg; + break; + // compute value = c_ID // if no trailing [], then arg is set to 0, else arg is int between [] diff --git a/src/dump_grid.cpp b/src/dump_grid.cpp index 056cac1095..3c10aa9083 100644 --- a/src/dump_grid.cpp +++ b/src/dump_grid.cpp @@ -311,6 +311,8 @@ void DumpGrid::init_style() void DumpGrid::write_header(bigint ndump) { + if (!header_choice) error->all(FLERR, "Must not use 'run pre no' after creating a new dump"); + if (multiproc) (this->*header_choice)(ndump); else if (me == 0) (this->*header_choice)(ndump); } @@ -525,9 +527,10 @@ int DumpGrid::count() // cannot invoke before first run, otherwise invoke if necessary if (ncompute) { - if (update->first_update == 0) - error->all(FLERR,"Dump compute cannot be invoked before first run"); for (i = 0; i < ncompute; i++) { + if (!compute[i]->is_initialized()) + error->all(FLERR,"Dump compute ID {} cannot be invoked before initialization by a run", + compute[i]->id); if (!(compute[i]->invoked_flag & Compute::INVOKED_PERGRID)) { compute[i]->compute_pergrid(); compute[i]->invoked_flag |= Compute::INVOKED_PERGRID; diff --git a/src/dump_image.cpp b/src/dump_image.cpp index 0d54c60595..1ba433f93f 100644 --- a/src/dump_image.cpp +++ b/src/dump_image.cpp @@ -667,8 +667,9 @@ void DumpImage::write() // cannot invoke before first run, otherwise invoke if necessary if (grid_compute) { - if (update->first_update == 0) - error->all(FLERR,"Grid compute used in dump image cannot be invoked before first run"); + if (!grid_compute->is_initialized()) + error->all(FLERR,"Grid compute ID {} used in dump image cannot be invoked " + "before initialization by a run", grid_compute->id); if (!(grid_compute->invoked_flag & Compute::INVOKED_PERGRID)) { grid_compute->compute_pergrid(); grid_compute->invoked_flag |= Compute::INVOKED_PERGRID; diff --git a/src/dump_local.cpp b/src/dump_local.cpp index 097589ea41..9695e152b2 100644 --- a/src/dump_local.cpp +++ b/src/dump_local.cpp @@ -328,9 +328,10 @@ int DumpLocal::count() // cannot invoke before first run, otherwise invoke if necessary if (ncompute) { - if (update->first_update == 0) - error->all(FLERR,"Dump compute cannot be invoked before first run"); for (i = 0; i < ncompute; i++) { + if (!compute[i]->is_initialized()) + error->all(FLERR,"Dump compute ID {} cannot be invoked before initialization by a run", + compute[i]->id); if (!(compute[i]->invoked_flag & Compute::INVOKED_LOCAL)) { compute[i]->compute_local(); compute[i]->invoked_flag |= Compute::INVOKED_LOCAL; diff --git a/src/dump_xyz.cpp b/src/dump_xyz.cpp index 83c4d180d6..241ec1c059 100644 --- a/src/dump_xyz.cpp +++ b/src/dump_xyz.cpp @@ -130,6 +130,8 @@ int DumpXYZ::modify_param(int narg, char **arg) void DumpXYZ::write_header(bigint n) { if (me == 0) { + if (!fp) error->one(FLERR, "Must not use 'run pre no' after creating a new dump"); + auto header = fmt::format("{}\n Atoms. Timestep: {}", n, update->ntimestep); if (time_flag) header += fmt::format(" Time: {:.6f}", compute_time()); header += "\n"; @@ -177,9 +179,8 @@ int DumpXYZ::convert_string(int n, double *mybuf) memory->grow(sbuf,maxsbuf,"dump:sbuf"); } - offset += sprintf(&sbuf[offset],format, - typenames[static_cast (mybuf[m+1])], - mybuf[m+2],mybuf[m+3],mybuf[m+4]); + offset += sprintf(&sbuf[offset], format, typenames[static_cast (mybuf[m+1])], + mybuf[m+2], mybuf[m+3], mybuf[m+4]); m += size_one; } diff --git a/src/fix.cpp b/src/fix.cpp index 82389ba433..70e4133cdd 100644 --- a/src/fix.cpp +++ b/src/fix.cpp @@ -79,6 +79,7 @@ Fix::Fix(LAMMPS *lmp, int /*narg*/, char **arg) : maxexchange_dynamic = 0; pre_exchange_migrate = 0; stores_ids = 0; + diam_flag = 0; scalar_flag = vector_flag = array_flag = 0; peratom_flag = local_flag = pergrid_flag = 0; diff --git a/src/fix.h b/src/fix.h index 30373ab6f2..5d55048c28 100644 --- a/src/fix.h +++ b/src/fix.h @@ -79,6 +79,7 @@ class Fix : protected Pointers { int maxexchange_dynamic; // 1 if fix sets maxexchange dynamically int pre_exchange_migrate; // 1 if fix migrates atoms in pre_exchange() int stores_ids; // 1 if fix stores atom IDs + int diam_flag; // 1 if fix may change partical diameter int scalar_flag; // 0/1 if compute_scalar() function exists int vector_flag; // 0/1 if compute_vector() function exists diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 0b4ec9a638..660e3f6107 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -90,7 +90,6 @@ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : // parse keywords nadapt = 0; - diamflag = 0; chgflag = 0; iarg = 4; @@ -149,7 +148,7 @@ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : if (strcmp(arg[iarg+1],"diameter") == 0 || strcmp(arg[iarg+1],"diameter/disc") == 0) { adapt[nadapt].atomparam = DIAMETER; - diamflag = 1; + diam_flag = 1; discflag = 0; if (strcmp(arg[iarg+1],"diameter/disc") == 0) discflag = 1; } else if (strcmp(arg[iarg+1],"charge") == 0) { @@ -190,7 +189,7 @@ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : // then previous step scale factors are written to restart file // initialize them here in case one is used and other is never defined - if (scaleflag && (diamflag || chgflag)) restart_global = 1; + if (scaleflag && (diam_flag || chgflag)) restart_global = 1; previous_diam_scale = previous_chg_scale = 1.0; // allocate pair style arrays @@ -260,7 +259,7 @@ int FixAdapt::setmask() void FixAdapt::post_constructor() { if (!resetflag) return; - if (!diamflag && !chgflag) return; + if (!diam_flag && !chgflag) return; // new id = fix-ID + FIX_STORE_ATTRIBUTE // new fix group = group for this fix @@ -268,7 +267,7 @@ void FixAdapt::post_constructor() id_fix_diam = nullptr; id_fix_chg = nullptr; - if (diamflag && atom->radius_flag) { + 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]))); @@ -707,7 +706,7 @@ void FixAdapt::restore_settings() *kspace_scale = 1.0; } else if (ad->which == ATOM) { - if (diamflag) { + if (diam_flag) { double scale; double *vec = fix_diam->vstore; diff --git a/src/fix_adapt.h b/src/fix_adapt.h index f8477f7259..20964a8b12 100644 --- a/src/fix_adapt.h +++ b/src/fix_adapt.h @@ -26,7 +26,6 @@ namespace LAMMPS_NS { class FixAdapt : public Fix { public: - int diamflag; // 1 if atom diameters will vary, for AtomVecGranular int chgflag; FixAdapt(class LAMMPS *, int, char **); diff --git a/src/fix_ave_grid.cpp b/src/fix_ave_grid.cpp index 524def73a4..039c656fab 100644 --- a/src/fix_ave_grid.cpp +++ b/src/fix_ave_grid.cpp @@ -931,7 +931,7 @@ void FixAveGrid::atom2grid() vsq = v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]; if (rmass) one = rmass[i]; else one = mass[type[i]]; - array2d[bin[i][0]][bin[i][1]][m] += one*vsq;; + array2d[bin[i][0]][bin[i][1]][m] += one*vsq; } } } else { diff --git a/src/fix_ave_histo.cpp b/src/fix_ave_histo.cpp index 157e43610a..0a2975bb2e 100644 --- a/src/fix_ave_histo.cpp +++ b/src/fix_ave_histo.cpp @@ -590,7 +590,7 @@ void FixAveHisto::end_of_step() } else if (kind == PERATOM) { if (j == 0) bin_atoms(val.val.f->vector_atom,1); else if (val.val.f->array_atom) - bin_atoms(val.val.f->array_atom[j-1],val.val.f->size_peratom_cols); + bin_atoms(&val.val.f->array_atom[0][j-1],val.val.f->size_peratom_cols); } else if (kind == LOCAL) { if (j == 0) bin_vector(val.val.f->size_local_rows,val.val.f->vector_local,1); diff --git a/src/fix_ave_histo_weight.cpp b/src/fix_ave_histo_weight.cpp index 17dd00440e..181aa2a79d 100644 --- a/src/fix_ave_histo_weight.cpp +++ b/src/fix_ave_histo_weight.cpp @@ -212,7 +212,7 @@ void FixAveHistoWeight::end_of_step() weights = val.val.f->vector_atom; stride = 1; } else if (val.val.f->array_atom) { - weights = val.val.f->array_atom[j-1]; + weights = &val.val.f->array_atom[0][j-1]; stride = val.val.f->size_peratom_cols; } } else if (kind == LOCAL) { @@ -339,7 +339,7 @@ void FixAveHistoWeight::end_of_step() if (j == 0) bin_atoms_weights(val.val.f->vector_atom,1,weights,stride); else if (val.val.f->array_atom) - bin_atoms_weights(val.val.f->array_atom[j-1],val.val.f->size_peratom_cols, + bin_atoms_weights(&val.val.f->array_atom[0][j-1],val.val.f->size_peratom_cols, weights,stride); diff --git a/src/fix_wall_reflect.cpp b/src/fix_wall_reflect.cpp index 60a055fbd6..00ef968828 100644 --- a/src/fix_wall_reflect.cpp +++ b/src/fix_wall_reflect.cpp @@ -176,12 +176,11 @@ void FixWallReflect::init() } int nrigid = 0; - for (int i = 0; i < modify->nfix; i++) - if (modify->fix[i]->rigid_flag) nrigid++; + for (const auto &ifix : modify->get_fix_list()) + if (ifix->rigid_flag) nrigid++; - if (nrigid && comm->me == 0) - error->warning(FLERR,"Should not allow rigid bodies to bounce off " - "relecting walls"); + if (nrigid && (comm->me == 0)) + error->warning(FLERR,"Should not use reflecting walls with rigid bodies"); } /* ---------------------------------------------------------------------- */ diff --git a/src/grid2d.h b/src/grid2d.h index bb1bfb25e1..6c1cca5f9d 100644 --- a/src/grid2d.h +++ b/src/grid2d.h @@ -53,7 +53,7 @@ class Grid2d : protected Pointers { void read_file(int, void *, FILE *, int, int); void write_file(int, void *, int, int, int, MPI_Datatype); -protected: + protected: int me, nprocs; int layout; // not TILED or TILED, same as Comm class MPI_Comm gridcomm; // communicator for this class @@ -61,18 +61,18 @@ protected: // inputs from caller via constructor - int nx, ny; // size of global grid in both dims - double maxdist; // distance owned atoms can move outside subdomain - int stencil_atom_lo,stencil_atom_hi; // grid cells accessed beyond atom's cell - int stencil_grid_lo,stencil_grid_hi; // grid cells accessed beyond owned cell - double shift_grid; // location of grid point within grid cell - // only affects which proc owns grid cell - double shift_atom_lo,shift_atom_hi;; // max shift applied to atoms - // when mapped to grid cell by caller - // can be different in lo/hi directions - // only affects extent of ghost cells - int yextra; // 1 if extra grid cells in Y, 0 if not - double yfactor; // multiplier on extent of grid in Y direction + int nx, ny; // size of global grid in both dims + double maxdist; // distance owned atoms can move outside subdomain + int stencil_atom_lo, stencil_atom_hi; // grid cells accessed beyond atom's cell + int stencil_grid_lo, stencil_grid_hi; // grid cells accessed beyond owned cell + double shift_grid; // location of grid point within grid cell + // only affects which proc owns grid cell + double shift_atom_lo, shift_atom_hi; // max shift applied to atoms + // when mapped to grid cell by caller + // can be different in lo/hi directions + // only affects extent of ghost cells + int yextra; // 1 if extra grid cells in Y, 0 if not + double yfactor; // multiplier on extent of grid in Y direction // extent of my owned and ghost cells @@ -190,11 +190,11 @@ protected: // internal variables for OVERLAP operation // ------------------------------------------- - int *overlap_procs; // length of Nprocs in communicator + int *overlap_procs; // length of Nprocs in communicator // BRICK decomposition - double *xsplit,*ysplit,*zsplit; + double *xsplit, *ysplit, *zsplit; int ***grid2proc; // TILED decomposition diff --git a/src/grid3d.h b/src/grid3d.h index 97fcf5992a..e4a8e276f5 100644 --- a/src/grid3d.h +++ b/src/grid3d.h @@ -23,8 +23,8 @@ class Grid3d : protected Pointers { enum { KSPACE = 0, PAIR = 1, FIX = 2 }; // calling classes Grid3d(class LAMMPS *, MPI_Comm, int, int, int); - Grid3d(class LAMMPS *, MPI_Comm, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int); + Grid3d(class LAMMPS *, MPI_Comm, int, int, int, int, int, int, int, int, int, int, int, int, int, + int, int); ~Grid3d(); void set_distance(double); @@ -41,8 +41,8 @@ class Grid3d : protected Pointers { void get_bounds_owned(int &, int &, int &, int &, int &, int &); void get_bounds_ghost(int &, int &, int &, int &, int &, int &); - void setup_grid(int &, int &, int &, int &, int &, int &, - int &, int &, int &, int &, int &, int &); + void setup_grid(int &, int &, int &, int &, int &, int &, int &, int &, int &, int &, int &, + int &); void setup_comm(int &, int &); int ghost_adjacent(); @@ -63,18 +63,18 @@ class Grid3d : protected Pointers { // input from caller - int nx, ny, nz; // size of global grid in all 3 dims - double maxdist; // distance owned atoms can move outside subdomain - int stencil_atom_lo,stencil_atom_hi; // grid cells accessed beyond atom's cell - int stencil_grid_lo,stencil_grid_hi; // grid cells accessed beyond owned cell - double shift_grid; // location of grid point within grid cell - // only affects which proc owns grid cell - double shift_atom_lo,shift_atom_hi;; // max shift applied to atoms - // when mapped to grid cell by caller - // can be different in lo/hi directions - // only affects extent of ghost cells - int zextra; // 1 if extra grid cells in Z, 0 if not - double zfactor; // multiplier on extent of grid in Z direction + int nx, ny, nz; // size of global grid in all 3 dims + double maxdist; // distance owned atoms can move outside subdomain + int stencil_atom_lo, stencil_atom_hi; // grid cells accessed beyond atom's cell + int stencil_grid_lo, stencil_grid_hi; // grid cells accessed beyond owned cell + double shift_grid; // location of grid point within grid cell + // only affects which proc owns grid cell + double shift_atom_lo, shift_atom_hi; // max shift applied to atoms + // when mapped to grid cell by caller + // can be different in lo/hi directions + // only affects extent of ghost cells + int zextra; // 1 if extra grid cells in Z, 0 if not + double zfactor; // multiplier on extent of grid in Z direction // extent of my owned and ghost cells @@ -196,11 +196,11 @@ class Grid3d : protected Pointers { // internal variables for OVERLAP operation // ------------------------------------------- - int *overlap_procs; // length of Nprocs in communicator + int *overlap_procs; // length of Nprocs in communicator // BRICK decomposition - double *xsplit,*ysplit,*zsplit; + double *xsplit, *ysplit, *zsplit; int ***grid2proc; // TILED decomposition diff --git a/src/input.cpp b/src/input.cpp index 1dc2b00ebc..dbbc62df59 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -567,7 +567,7 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag) // else $x becomes x followed by null char // beyond = points to text following variable - int i,n,paren_count,nchars;; + int i,n,paren_count,nchars; char immediate[256]; char *var,*value,*beyond; int quoteflag = 0; diff --git a/src/lammps.cpp b/src/lammps.cpp index eb7915487b..3b137bf52e 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -135,7 +135,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : // append git descriptor info to update string when compiling development or maintenance version std::string update_string = UPDATE_STRING; - if (has_git_info() && (update_string == " - Development") || (update_string == " - Maintenance")) + if (has_git_info() && ((update_string == " - Development") || (update_string == " - Maintenance"))) update_string += fmt::format(" - {}", git_descriptor()); external_comm = 0; diff --git a/src/library.cpp b/src/library.cpp index 6ceaa28449..1f4117a489 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -58,6 +58,9 @@ #include #endif +/// string buffer for error messages of global errors +static std::string lammps_last_global_errormessage; + using namespace LAMMPS_NS; // for printing the non-null pointer argument warning only once @@ -168,17 +171,18 @@ void *lammps_open(int argc, char **argv, MPI_Comm comm, void **ptr) lammps_mpi_init(); if (ptr) ptr_argument_warning(); - try { + try { + lammps_last_global_errormessage.clear(); lmp = new LAMMPS(argc, argv, comm); if (ptr) *ptr = (void *) lmp; - } catch(LAMMPSException &e) { - fprintf(stderr, "LAMMPS Exception: %s\n", e.what()); - if (ptr) *ptr = nullptr; } catch (fmt::format_error &fe) { + lammps_last_global_errormessage = fe.what(); fprintf(stderr, "fmt::format_error: %s\n", fe.what()); if (ptr) *ptr = nullptr; - } catch (std::exception &e) { - fprintf(stderr, "Exception: %s\n", e.what()); + } catch(LAMMPSException &e) { + lammps_last_global_errormessage = e.what(); + + fmt::print(stderr, "LAMMPS Exception: {}", e.what()); if (ptr) *ptr = nullptr; } return (void *) lmp; @@ -2317,7 +2321,7 @@ void *lammps_extract_variable(void *handle, const char *name, const char *group) } else if (lmp->input->variable->vectorstyle(ivar)) { double *values = nullptr; int nvector = lmp->input->variable->compute_vector(ivar, &values); - if ( group != nullptr && strcmp(group,"LMP_SIZE_VECTOR") == 0 ) { + if (group != nullptr && strcmp(group,"LMP_SIZE_VECTOR") == 0) { int* nvecptr = (int *) malloc(sizeof(int)); *nvecptr = nvector; return (void *) nvecptr; @@ -2359,7 +2363,7 @@ int lammps_extract_variable_datatype(void *handle, const char *name) BEGIN_CAPTURE { int ivar = lmp->input->variable->find(name); - if ( ivar < 0 ) return -1; + if (ivar < 0) return -1; if (lmp->input->variable->equalstyle(ivar)) return LMP_VAR_EQUAL; @@ -5186,7 +5190,7 @@ int lammps_find_pair_neighlist(void *handle, const char *style, int exact, int n // find neigh list for (int i = 0; i < lmp->neighbor->nlist; i++) { NeighList *list = lmp->neighbor->lists[i]; - if ( (list->requestor_type == NeighList::PAIR) + if ((list->requestor_type == NeighList::PAIR) && (pair == list->requestor) && (list->id == reqid) ) return i; } @@ -5216,7 +5220,7 @@ int lammps_find_fix_neighlist(void *handle, const char *id, int reqid) { // find neigh list for (int i = 0; i < lmp->neighbor->nlist; i++) { NeighList *list = lmp->neighbor->lists[i]; - if ( (list->requestor_type == NeighList::FIX) + if ((list->requestor_type == NeighList::FIX) && (fix == list->requestor) && (list->id == reqid) ) return i; } @@ -5245,7 +5249,7 @@ int lammps_find_compute_neighlist(void *handle, const char *id, int reqid) { // find neigh list for (int i = 0; i < lmp->neighbor->nlist; i++) { NeighList * list = lmp->neighbor->lists[i]; - if ( (list->requestor_type == NeighList::COMPUTE) + if ((list->requestor_type == NeighList::COMPUTE) && (compute == list->requestor) && (list->id == reqid) ) return i; } @@ -5696,7 +5700,7 @@ int lammps_style_name(void *handle, const char *category, int idx, Info info(lmp); auto styles = info.get_available_styles(category); - if ((idx >=0) && (idx < (int) styles.size())) { + if ((idx >= 0) && (idx < (int) styles.size())) { strncpy(buffer, styles[idx].c_str(), buf_size); return 1; } @@ -5831,23 +5835,23 @@ int lammps_id_name(void *handle, const char *category, int idx, char *buffer, in return 1; } } else if (strcmp(category,"group") == 0) { - if ((idx >=0) && (idx < lmp->group->ngroup)) { + if ((idx >= 0) && (idx < lmp->group->ngroup)) { strncpy(buffer, lmp->group->names[idx], buf_size); return 1; } } else if (strcmp(category,"molecule") == 0) { - if ((idx >=0) && (idx < lmp->atom->nmolecule)) { + if ((idx >= 0) && (idx < lmp->atom->nmolecule)) { strncpy(buffer, lmp->atom->molecules[idx]->id, buf_size); return 1; } } else if (strcmp(category,"region") == 0) { auto regions = lmp->domain->get_region_list(); - if ((idx >=0) && (idx < (int) regions.size())) { + if ((idx >= 0) && (idx < (int) regions.size())) { strncpy(buffer, regions[idx]->id, buf_size); return 1; } } else if (strcmp(category,"variable") == 0) { - if ((idx >=0) && (idx < lmp->input->variable->nvar)) { + if ((idx >= 0) && (idx < lmp->input->variable->nvar)) { strncpy(buffer, lmp->input->variable->names[idx], buf_size); return 1; } @@ -6475,15 +6479,37 @@ void lammps_force_timeout(void *handle) This function can be used to query if an error inside of LAMMPS has thrown a :ref:`C++ exception `. +.. note:: + + .. versionchanged: 2Aug2023 + + The *handle* pointer may be ``NULL`` for this function, as would be + the case when a call to create a LAMMPS instance has failed. Then + this function will not check the error status inside the LAMMPS + instance, but instead would check the global error buffer of the + library interface. + +.. note:: + + This function will always report "no error" when the LAMMPS library + has been compiled without ``-DLAMMPS_EXCEPTIONS``, which turns fatal + errors aborting LAMMPS into C++ exceptions. You can use the library + function :cpp:func:`lammps_config_has_exceptions` to check whether this is + the case. \endverbatim * - * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. + * \param handle pointer to a previously created LAMMPS instance cast to ``void *`` or NULL * \return 0 on no error, 1 on error. */ -int lammps_has_error(void *handle) { - LAMMPS *lmp = (LAMMPS *) handle; - Error *error = lmp->error; - return (error->get_last_error().empty()) ? 0 : 1; +int lammps_has_error(void *handle) +{ + if (handle) { + LAMMPS *lmp = (LAMMPS *) handle; + Error *error = lmp->error; + return (error->get_last_error().empty()) ? 0 : 1; + } else { + return lammps_last_global_errormessage.empty() ? 0 : 1; + } } /* ---------------------------------------------------------------------- */ @@ -6502,23 +6528,50 @@ a "2" indicates an abort that would happen only in a single MPI rank and thus may not be recoverable, as other MPI ranks may be waiting on the failing MPI ranks to send messages. +.. note:: + + .. versionchanged: 2Aug2023 + + The *handle* pointer may be ``NULL`` for this function, as would be + the case when a call to create a LAMMPS instance has failed. Then + this function will not check the error buffer inside the LAMMPS + instance, but instead would check the global error buffer of the + library interface. + +.. note:: + + This function will do nothing when the LAMMPS library has been + compiled without ``-DLAMMPS_EXCEPTIONS``, which turns errors aborting + LAMMPS into C++ exceptions. You can use the library function + :cpp:func:`lammps_config_has_exceptions` to check whether this is the case. \endverbatim * - * \param handle pointer to a previously created LAMMPS instance cast to ``void *``. + * \param handle pointer to a previously created LAMMPS instance cast to ``void *`` or NULL. * \param buffer string buffer to copy the error message to * \param buf_size size of the provided string buffer * \return 1 when all ranks had the error, 2 on a single rank error. */ -int lammps_get_last_error_message(void *handle, char *buffer, int buf_size) { - LAMMPS *lmp = (LAMMPS *) handle; - Error *error = lmp->error; - buffer[0] = buffer[buf_size-1] = '\0'; +int lammps_get_last_error_message(void *handle, char *buffer, int buf_size) +{ + if (handle) { + LAMMPS *lmp = (LAMMPS *) handle; + Error *error = lmp->error; + buffer[0] = buffer[buf_size-1] = '\0'; - if (!error->get_last_error().empty()) { - int error_type = error->get_last_error_type(); - strncpy(buffer, error->get_last_error().c_str(), buf_size-1); - error->set_last_error("", ERROR_NONE); - return error_type; + if (!error->get_last_error().empty()) { + int error_type = error->get_last_error_type(); + strncpy(buffer, error->get_last_error().c_str(), buf_size-1); + error->set_last_error("", ERROR_NONE); + return error_type; + } + } else { + buffer[0] = buffer[buf_size-1] = '\0'; + + if (!lammps_last_global_errormessage.empty()) { + strncpy(buffer, lammps_last_global_errormessage.c_str(), buf_size-1); + lammps_last_global_errormessage.clear(); + return 1; + } } return 0; } diff --git a/src/lmptype.h b/src/lmptype.h index 2089350f48..4e62a1a7eb 100644 --- a/src/lmptype.h +++ b/src/lmptype.h @@ -44,7 +44,6 @@ #include // IWYU pragma: export #include // IWYU pragma: export -#include // IWYU pragma: export #include // IWYU pragma: export // grrr - IBM Power6 does not provide this def in their system header files diff --git a/src/modify.cpp b/src/modify.cpp index d0656d3895..427c4e259b 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -191,11 +191,7 @@ void Modify::init() for (i = 0; i < ncompute; i++) { compute[i]->init(); - compute[i]->invoked_scalar = -1; - compute[i]->invoked_vector = -1; - compute[i]->invoked_array = -1; - compute[i]->invoked_peratom = -1; - compute[i]->invoked_local = -1; + compute[i]->init_flags(); } addstep_compute_all(update->ntimestep); diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 006101da64..df1547e5eb 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -837,10 +837,20 @@ int Neighbor::init_pair() // similar to what vanilla Nbin::coord2atom() does now in atom2bin if (style == Neighbor::BIN) { - for (i = 0; i < nrequest; i++) + for (i = 0; i < nrequest; ++i) if (requests[i]->occasional && requests[i]->ghost) - error->all(FLERR,"Cannot request an occasional binned neighbor list " - "with ghost info"); + error->all(FLERR, "Cannot request an occasional binned neighbor list with ghost info"); + } + + // check requests with a custom neighbor list cutoff to make sure the cutoff is within + // the communication cutoff. For perpetual lists, neighbor list skin is added later. + + const double comm_cutoff = comm->get_comm_cutoff(); + for (i = 0; i < nrequest; ++i) { + if (requests[i]->cut) { + if (comm_cutoff < (requests[i]->cutoff + (requests[i]->occasional ? 0.0 : skin))) + error->all(FLERR, "Custom neighbor list cutoff too large for communication cutoff"); + } } // morph requests in various ways @@ -2672,8 +2682,7 @@ void Neighbor::modify_params(int narg, char **arg) strcmp(arg[iarg+1],"molecule/intra") == 0) { if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "neigh_modify exclude molecule", error); if (atom->molecule_flag == 0) - error->all(FLERR,"Neigh_modify exclude molecule " - "requires atom attribute molecule"); + error->all(FLERR,"Neigh_modify exclude molecule requires atom attribute molecule"); if (nex_mol == maxex_mol) { maxex_mol += EXDELTA; memory->grow(ex_mol_group,maxex_mol,"neigh:ex_mol_group"); diff --git a/src/npair_half_respa_nsq_newton.cpp b/src/npair_half_respa_nsq_newton.cpp index 77d6af141f..d231cddb87 100644 --- a/src/npair_half_respa_nsq_newton.cpp +++ b/src/npair_half_respa_nsq_newton.cpp @@ -38,9 +38,9 @@ NPairHalfRespaNsqNewton::NPairHalfRespaNsqNewton(LAMMPS *lmp) : NPair(lmp) {} void NPairHalfRespaNsqNewton::build(NeighList *list) { - int i,j,n,itype,jtype,itag,jtag,n_inner,n_middle,bitmask; + int i,j,n,itype,jtype,n_inner,n_middle,bitmask; int imol,iatom,moltemplate; - tagint tagprev; + tagint itag,jtag,tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*neighptr_inner,*neighptr_middle; diff --git a/src/npair_half_size_nsq_newton.cpp b/src/npair_half_size_nsq_newton.cpp index 8b596e6968..93d65c7a45 100644 --- a/src/npair_half_size_nsq_newton.cpp +++ b/src/npair_half_size_nsq_newton.cpp @@ -39,8 +39,8 @@ NPairHalfSizeNsqNewton::NPairHalfSizeNsqNewton(LAMMPS *lmp) : NPair(lmp) {} void NPairHalfSizeNsqNewton::build(NeighList *list) { - int i,j,jh,n,itag,jtag,bitmask,which,imol,iatom,moltemplate; - tagint tagprev; + int i,j,jh,n,bitmask,which,imol,iatom,moltemplate; + tagint itag,jtag,tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radi,radsum,cutsq; int *neighptr; diff --git a/src/read_data.cpp b/src/read_data.cpp index 2fea75f7c0..e3087ae215 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -2021,9 +2021,7 @@ void ReadData::pairIJcoeffs() if (eof) error->all(FLERR, "Unexpected end of data file"); if (tlabelflag && !lmap->is_complete(Atom::ATOM)) - error->all(FLERR, - "Label map is incomplete: " - "all types must be assigned a unique type label"); + error->all(FLERR,"Label map is incomplete: all types must be assigned a unique type label"); char *original = buf; for (i = 0; i < ntypes; i++) @@ -2032,10 +2030,7 @@ void ReadData::pairIJcoeffs() *next = '\0'; parse_coeffs(buf, nullptr, 0, 2, toffset, tlabelflag, lmap->lmap2lmap.atom); if (ncoeffarg == 0) - error->all(FLERR, - "Unexpected empty line in PairIJCoeffs section. " - "Expected {} lines.", - (ntypes - 1) * ntypes); + error->all(FLERR, "Unexpected empty line in PairIJCoeffs section. Expected {} lines.", nsq); force->pair->coeff(ncoeffarg, coeffarg); buf = next + 1; } @@ -2055,9 +2050,7 @@ void ReadData::bondcoeffs() if (eof) error->all(FLERR, "Unexpected end of data file"); if (blabelflag && !lmap->is_complete(Atom::BOND)) - error->all(FLERR, - "Label map is incomplete: " - "all types must be assigned a unique type label"); + error->all(FLERR, "Label map is incomplete: all types must be assigned a unique type label"); char *original = buf; for (int i = 0; i < nbondtypes; i++) { @@ -2086,9 +2079,7 @@ void ReadData::anglecoeffs(int which) if (eof) error->all(FLERR, "Unexpected end of data file"); if (alabelflag && !lmap->is_complete(Atom::ANGLE)) - error->all(FLERR, - "Label map is incomplete: " - "all types must be assigned a unique type label"); + error->all(FLERR, "Label map is incomplete: all types must be assigned a unique type label"); char *original = buf; for (int i = 0; i < nangletypes; i++) { @@ -2122,9 +2113,7 @@ void ReadData::dihedralcoeffs(int which) if (eof) error->all(FLERR, "Unexpected end of data file"); if (dlabelflag && !lmap->is_complete(Atom::DIHEDRAL)) - error->all(FLERR, - "Label map is incomplete: " - "all types must be assigned a unique type label"); + error->all(FLERR, "Label map is incomplete: all types must be assigned a unique type label"); char *original = buf; for (int i = 0; i < ndihedraltypes; i++) { diff --git a/src/read_restart.cpp b/src/read_restart.cpp index aa9f5fe8ee..0de36ebe1e 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -768,7 +768,7 @@ void ReadRestart::header() for (int i = 0; i < nargcopy; i++) argcopy[i] = read_string(); atom->create_avec(style,nargcopy,argcopy,1); - if (comm->me ==0) + if (comm->me == 0) utils::logmesg(lmp," restoring atom style {} from restart\n",atom->atom_style); for (int i = 0; i < nargcopy; i++) delete[] argcopy[i]; delete[] argcopy; @@ -921,14 +921,14 @@ void ReadRestart::force_fields() style = read_string(); force->create_pair(style,1); delete[] style; - if (comm->me ==0) + if (comm->me == 0) utils::logmesg(lmp," restoring pair style {} from restart\n", force->pair_style); force->pair->read_restart(fp); } else if (flag == NO_PAIR) { style = read_string(); - if (comm->me ==0) + if (comm->me == 0) utils::logmesg(lmp," pair style {} stores no restart info\n", style); force->create_pair("none",0); force->pair_restart = style; @@ -937,7 +937,7 @@ void ReadRestart::force_fields() style = read_string(); force->create_bond(style,1); delete[] style; - if (comm->me ==0) + if (comm->me == 0) utils::logmesg(lmp," restoring bond style {} from restart\n", force->bond_style); force->bond->read_restart(fp); @@ -946,7 +946,7 @@ void ReadRestart::force_fields() style = read_string(); force->create_angle(style,1); delete[] style; - if (comm->me ==0) + if (comm->me == 0) utils::logmesg(lmp," restoring angle style {} from restart\n", force->angle_style); force->angle->read_restart(fp); @@ -955,7 +955,7 @@ void ReadRestart::force_fields() style = read_string(); force->create_dihedral(style,1); delete[] style; - if (comm->me ==0) + if (comm->me == 0) utils::logmesg(lmp," restoring dihedral style {} from restart\n", force->dihedral_style); force->dihedral->read_restart(fp); @@ -964,7 +964,7 @@ void ReadRestart::force_fields() style = read_string(); force->create_improper(style,1); delete[] style; - if (comm->me ==0) + if (comm->me == 0) utils::logmesg(lmp," restoring improper style {} from restart\n", force->improper_style); force->improper->read_restart(fp); diff --git a/src/reset_atoms_id.cpp b/src/reset_atoms_id.cpp index c0fce95326..9e8ba3630d 100644 --- a/src/reset_atoms_id.cpp +++ b/src/reset_atoms_id.cpp @@ -55,9 +55,9 @@ void ResetAtomsID::command(int narg, char **arg) error->all(FLERR, "Reset_atoms id command before simulation box is defined"); if (atom->tag_enable == 0) error->all(FLERR, "Cannot use reset_atoms id unless atoms have IDs"); - for (int i = 0; i < modify->nfix; i++) - if (modify->fix[i]->stores_ids) - error->all(FLERR, "Cannot use reset_atoms id when a fix exists that stores atom IDs"); + for (const auto &ifix : modify->get_fix_list()) + if (ifix->stores_ids) + error->all(FLERR, "Cannot use reset_atoms id with a fix {} storing atom IDs", ifix->style); if (comm->me == 0) utils::logmesg(lmp, "Resetting atom IDs ...\n"); diff --git a/src/reset_atoms_image.cpp b/src/reset_atoms_image.cpp index d39ea0fec1..84df5bf746 100644 --- a/src/reset_atoms_image.cpp +++ b/src/reset_atoms_image.cpp @@ -61,6 +61,22 @@ void ResetAtomsImage::command(int narg, char **arg) MPI_Barrier(world); double time1 = platform::walltime(); + // create computes and variables + // must come before lmp->init so the computes are properly initialized + + auto frags = modify->add_compute("frags_r_i_f all fragment/atom single yes"); + auto chunk = modify->add_compute("chunk_r_i_f all chunk/atom c_frags_r_i_f compress yes"); + auto flags = modify->add_compute("flags_r_i_f all property/atom ix iy iz"); + input->variable->set("ix_r_i_f atom c_flags_r_i_f[1]"); + input->variable->set("iy_r_i_f atom c_flags_r_i_f[2]"); + input->variable->set("iz_r_i_f atom c_flags_r_i_f[3]"); + auto ifmin = modify->add_compute("ifmin_r_i_f all reduce/chunk chunk_r_i_f min " + "v_ix_r_i_f v_iy_r_i_f v_iz_r_i_f"); + auto ifmax = modify->add_compute("ifmax_r_i_f all reduce/chunk chunk_r_i_f max " + "v_ix_r_i_f v_iy_r_i_f v_iz_r_i_f"); + auto cdist = modify->add_compute("cdist_r_i_f all chunk/spread/atom chunk_r_i_f " + "c_ifmax_r_i_f[*] c_ifmin_r_i_f[*]"); + // initialize system since comm->borders() will be invoked lmp->init(); @@ -77,30 +93,7 @@ void ResetAtomsImage::command(int narg, char **arg) comm->borders(); if (domain->triclinic) domain->lamda2x(atom->nlocal + atom->nghost); - // create computes and variables - - auto frags = modify->add_compute("frags_r_i_f all fragment/atom single yes"); - auto chunk = modify->add_compute("chunk_r_i_f all chunk/atom c_frags_r_i_f compress yes"); - auto flags = modify->add_compute("flags_r_i_f all property/atom ix iy iz"); - input->variable->set("ix_r_i_f atom c_flags_r_i_f[1]"); - input->variable->set("iy_r_i_f atom c_flags_r_i_f[2]"); - input->variable->set("iz_r_i_f atom c_flags_r_i_f[3]"); - auto ifmin = modify->add_compute("ifmin_r_i_f all reduce/chunk chunk_r_i_f min " - "v_ix_r_i_f v_iy_r_i_f v_iz_r_i_f"); - auto ifmax = modify->add_compute("ifmax_r_i_f all reduce/chunk chunk_r_i_f max " - "v_ix_r_i_f v_iy_r_i_f v_iz_r_i_f"); - auto cdist = modify->add_compute("cdist_r_i_f all chunk/spread/atom chunk_r_i_f " - "c_ifmax_r_i_f[*] c_ifmin_r_i_f[*]"); - // trigger computes - // need to ensure update->first_update = 1 - // to allow this input script command prior to first run/minimize - // this is b/c internal variables are evaulated which invoke computes - // that will trigger an error unless first_update = 1 - // reset update->first_update when done - - int first_update_saved = update->first_update; - update->first_update = 1; frags->compute_peratom(); chunk->compute_peratom(); @@ -109,8 +102,6 @@ void ResetAtomsImage::command(int narg, char **arg) ifmax->compute_array(); cdist->compute_peratom(); - update->first_update = first_update_saved; - // reset image flags for atoms in group const int *const mask = atom->mask; diff --git a/src/special.cpp b/src/special.cpp index a210b6a82a..7e15ec9e80 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -958,7 +958,7 @@ void Special::combine() void Special::angle_trim() { - int i,j,k,m;; + int i,j,k,m; int *num_angle = atom->num_angle; int *num_dihedral = atom->num_dihedral; diff --git a/src/thermo.cpp b/src/thermo.cpp index 6122edec83..88ceb27f87 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -1134,8 +1134,8 @@ void Thermo::check_temp(const std::string &keyword) if (!temperature) error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init temperature", keyword); - if (update->first_update == 0) - error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword); + if (!temperature->is_initialized()) + error->all(FLERR,"Thermo keyword {} cannot be invoked before initialization by a run",keyword); if (!(temperature->invoked_flag & Compute::INVOKED_SCALAR)) { temperature->compute_scalar(); temperature->invoked_flag |= Compute::INVOKED_SCALAR; @@ -1153,8 +1153,8 @@ void Thermo::check_pe(const std::string &keyword) if (!pe) error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init potential energy", keyword); - if (update->first_update == 0) - error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword); + if (!pe->is_initialized()) + error->all(FLERR,"Thermo keyword {} cannot be invoked before initialization by a run",keyword); if (!(pe->invoked_flag & Compute::INVOKED_SCALAR)) { pe->compute_scalar(); pe->invoked_flag |= Compute::INVOKED_SCALAR; @@ -1169,8 +1169,8 @@ void Thermo::check_press_scalar(const std::string &keyword) { if (!pressure) error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init press", keyword); - if (update->first_update == 0) - error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword); + if (!pressure->is_initialized()) + error->all(FLERR,"Thermo keyword {} cannot be invoked before initialization by a run",keyword); if (!(pressure->invoked_flag & Compute::INVOKED_SCALAR)) { pressure->compute_scalar(); pressure->invoked_flag |= Compute::INVOKED_SCALAR; @@ -1185,8 +1185,8 @@ void Thermo::check_press_vector(const std::string &keyword) { if (!pressure) error->all(FLERR, "Thermo keyword {} in variable requires thermo to use/init press", keyword); - if (update->first_update == 0) - error->all(FLERR,"Thermo keyword {} cannot be invoked before first run",keyword); + if (!pressure->is_initialized()) + error->all(FLERR,"Thermo keyword {} cannot be invoked before initialization by a run",keyword); if (!(pressure->invoked_flag & Compute::INVOKED_VECTOR)) { pressure->compute_vector(); pressure->invoked_flag |= Compute::INVOKED_VECTOR; @@ -1228,13 +1228,13 @@ int Thermo::evaluate_keyword(const std::string &word, double *answer) } else if (word == "elapsed") { if (update->whichflag == 0) - error->all(FLERR, "This variable thermo keyword cannot be used between runs"); + error->all(FLERR, "The variable thermo keyword elapsed cannot be used between runs"); compute_elapsed(); dvalue = bivalue; } else if (word == "elaplong") { if (update->whichflag == 0) - error->all(FLERR, "This variable thermo keyword cannot be used between runs"); + error->all(FLERR, "The variable thermo keyword elaplong cannot be used between runs"); compute_elapsed_long(); dvalue = bivalue; @@ -1246,22 +1246,22 @@ int Thermo::evaluate_keyword(const std::string &word, double *answer) } else if (word == "cpu") { if (update->whichflag == 0) - error->all(FLERR, "This variable thermo keyword cannot be used between runs"); + error->all(FLERR, "The variable thermo keyword cpu cannot be used between runs"); compute_cpu(); } else if (word == "tpcpu") { if (update->whichflag == 0) - error->all(FLERR, "This variable thermo keyword cannot be used between runs"); + error->all(FLERR, "The variable thermo keyword tpcpu cannot be used between runs"); compute_tpcpu(); } else if (word == "spcpu") { if (update->whichflag == 0) - error->all(FLERR, "This variable thermo keyword cannot be used between runs"); + error->all(FLERR, "The variable thermo keyword spcpu cannot be used between runs"); compute_spcpu(); } else if (word == "cpuremain") { if (update->whichflag == 0) - error->all(FLERR, "This variable thermo keyword cannot be used between runs"); + error->all(FLERR, "The variable thermo keyword cpuremain cannot be used between runs"); compute_cpuremain(); } else if (word == "part") { @@ -1350,7 +1350,7 @@ int Thermo::evaluate_keyword(const std::string &word, double *answer) } else if (word == "etail") { if (update->eflag_global != update->ntimestep) - error->all(FLERR, "Energy was not tallied on needed timestep"); + error->all(FLERR, "Energy was not tallied on needed timestep for thermo keyword etail"); compute_etail(); } else if (word == "enthalpy") { diff --git a/src/utils.cpp b/src/utils.cpp index bc4eee7385..dd18c4406d 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -272,6 +272,7 @@ int utils::read_lines_from_file(FILE *fp, int nlines, int nmax, char *buffer, in { char *ptr = buffer; *ptr = '\0'; + int mylines = 0; if (me == 0) { if (fp) { @@ -282,11 +283,14 @@ int utils::read_lines_from_file(FILE *fp, int nlines, int nmax, char *buffer, in ptr += strlen(ptr); // ensure buffer is null terminated. null char is start of next line. *ptr = '\0'; + // count line + ++mylines; } } } int n = strlen(buffer); + if (nlines != mylines) n = 0; MPI_Bcast(&n, 1, MPI_INT, 0, comm); if (n == 0) return 1; MPI_Bcast(buffer, n + 1, MPI_CHAR, 0, comm); @@ -879,8 +883,8 @@ char *utils::expand_type(const char *file, int line, const std::string &str, int caller decides what to do if arg is not a COMPUTE or FIX reference ------------------------------------------------------------------------- */ -int utils::check_grid_reference(char *errstr, char *ref, int nevery, - char *&id, int &igrid, int &idata, int &index, LAMMPS *lmp) +int utils::check_grid_reference(char *errstr, char *ref, int nevery, char *&id, int &igrid, + int &idata, int &index, LAMMPS *lmp) { ArgInfo argi(ref, ArgInfo::COMPUTE | ArgInfo::FIX); index = argi.get_index1(); @@ -889,80 +893,85 @@ int utils::check_grid_reference(char *errstr, char *ref, int nevery, switch (argi.get_type()) { case ArgInfo::UNKNOWN: { - lmp->error->all(FLERR,"%s grid reference %s is invalid",errstr,ref); + lmp->error->all(FLERR, "%s grid reference %s is invalid", errstr, ref); } break; - // compute value = c_ID + // compute value = c_ID case ArgInfo::COMPUTE: { // split name = idcompute:gname:dname into 3 strings - auto words = parse_grid_id(FLERR,name,lmp->error); + auto words = parse_grid_id(FLERR, name, lmp->error); const auto &idcompute = words[0]; const auto &gname = words[1]; const auto &dname = words[2]; auto icompute = lmp->modify->get_compute_by_id(idcompute); - if (!icompute) lmp->error->all(FLERR,"{} compute ID {} not found",errstr,idcompute); + if (!icompute) lmp->error->all(FLERR, "{} compute ID {} not found", errstr, idcompute); if (icompute->pergrid_flag == 0) - lmp->error->all(FLERR,"{} compute {} does not compute per-grid info",errstr,idcompute); + lmp->error->all(FLERR, "{} compute {} does not compute per-grid info", errstr, idcompute); int dim; - igrid = icompute->get_grid_by_name(gname,dim); + igrid = icompute->get_grid_by_name(gname, dim); if (igrid < 0) - lmp->error->all(FLERR,"{} compute {} does not recognize grid name {}",errstr,idcompute,gname); + lmp->error->all(FLERR, "{} compute {} does not recognize grid name {}", errstr, idcompute, + gname); int ncol; - idata = icompute->get_griddata_by_name(igrid,dname,ncol); + idata = icompute->get_griddata_by_name(igrid, dname, ncol); if (idata < 0) - lmp->error->all(FLERR,"{} compute {} does not recognize data name {}",errstr,idcompute,dname); + lmp->error->all(FLERR, "{} compute {} does not recognize data name {}", errstr, idcompute, + dname); if (argi.get_dim() == 0 && ncol) - lmp->error->all(FLERR,"{} compute {} data {} is not per-grid vector",errstr,idcompute,dname); + lmp->error->all(FLERR, "{} compute {} data {} is not per-grid vector", errstr, idcompute, + dname); if (argi.get_dim() && ncol == 0) - lmp->error->all(FLERR,"{} compute {} data {} is not per-grid array",errstr,idcompute,dname); + lmp->error->all(FLERR, "{} compute {} data {} is not per-grid array", errstr, idcompute, + dname); if (argi.get_dim() && argi.get_index1() > ncol) - lmp->error->all(FLERR,"{} compute {} array {} is accessed out-of-range",errstr,idcompute,dname); + lmp->error->all(FLERR, "{} compute {} array {} is accessed out-of-range", errstr, idcompute, + dname); id = utils::strdup(idcompute); return ArgInfo::COMPUTE; } break; - // fix value = f_ID + // fix value = f_ID case ArgInfo::FIX: { // split name = idfix:gname:dname into 3 strings - auto words = parse_grid_id(FLERR,name,lmp->error); + auto words = parse_grid_id(FLERR, name, lmp->error); const auto &idfix = words[0]; const auto &gname = words[1]; const auto &dname = words[2]; auto ifix = lmp->modify->get_fix_by_id(idfix); - if (!ifix) lmp->error->all(FLERR,"{} fix ID {} not found",errstr,idfix); + if (!ifix) lmp->error->all(FLERR, "{} fix ID {} not found", errstr, idfix); if (ifix->pergrid_flag == 0) - lmp->error->all(FLERR,"{} fix {} does not compute per-grid info",errstr,idfix); + lmp->error->all(FLERR, "{} fix {} does not compute per-grid info", errstr, idfix); if (nevery % ifix->pergrid_freq) - lmp->error->all(FLERR,"{} fix {} not computed at compatible time",errstr,idfix); + lmp->error->all(FLERR, "{} fix {} not computed at compatible time", errstr, idfix); int dim; - igrid = ifix->get_grid_by_name(gname,dim); + igrid = ifix->get_grid_by_name(gname, dim); if (igrid < 0) - lmp->error->all(FLERR,"{} fix {} does not recognize grid name {}",errstr,idfix,gname); + lmp->error->all(FLERR, "{} fix {} does not recognize grid name {}", errstr, idfix, gname); int ncol; - idata = ifix->get_griddata_by_name(igrid,dname,ncol); + idata = ifix->get_griddata_by_name(igrid, dname, ncol); if (idata < 0) - lmp->error->all(FLERR,"{} fix {} does not recognize data name {}",errstr,idfix,dname); + lmp->error->all(FLERR, "{} fix {} does not recognize data name {}", errstr, idfix, dname); if (argi.get_dim() == 0 && ncol) - lmp->error->all(FLERR,"{} fix {} data {} is not per-grid vector",errstr,idfix,dname); + lmp->error->all(FLERR, "{} fix {} data {} is not per-grid vector", errstr, idfix, dname); if (argi.get_dim() > 0 && ncol == 0) - lmp->error->all(FLERR,"{} fix {} data {} is not per-grid array",errstr,idfix,dname); + lmp->error->all(FLERR, "{} fix {} data {} is not per-grid array", errstr, idfix, dname); if (argi.get_dim() > 0 && argi.get_index1() > ncol) - lmp->error->all(FLERR,"{} fix {} array {} is accessed out-of-range",errstr,idfix,dname); + lmp->error->all(FLERR, "{} fix {} array {} is accessed out-of-range", errstr, idfix, dname); id = utils::strdup(idfix); return ArgInfo::FIX; @@ -1360,8 +1369,9 @@ bool utils::is_double(const std::string &str) { if (str.empty()) return false; - return strmatch(str, "^[+-]?\\d+\\.?\\d*$") || strmatch(str, "^[+-]?\\d+\\.?\\d*[eE][+-]?\\d+$") || - strmatch(str, "^[+-]?\\d*\\.?\\d+$") || strmatch(str, "^[+-]?\\d*\\.?\\d+[eE][+-]?\\d+$"); + return strmatch(str, "^[+-]?\\d+\\.?\\d*$") || + strmatch(str, "^[+-]?\\d+\\.?\\d*[eE][+-]?\\d+$") || strmatch(str, "^[+-]?\\d*\\.?\\d+$") || + strmatch(str, "^[+-]?\\d*\\.?\\d+[eE][+-]?\\d+$"); } /* ---------------------------------------------------------------------- diff --git a/src/variable.cpp b/src/variable.cpp index 456359de2f..cf2e5c3b6f 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -1505,8 +1505,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (nbracket == 0 && compute->scalar_flag && lowercase) { - if (update->first_update == 0) - print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar); + if (!compute->is_initialized()) + print_var_error(FLERR,"Variable formula compute cannot be invoked before " + "initialization by a run",ivar); if (!(compute->invoked_flag & Compute::INVOKED_SCALAR)) { compute->compute_scalar(); compute->invoked_flag |= Compute::INVOKED_SCALAR; @@ -1527,8 +1528,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (index1 > compute->size_vector && compute->size_vector_variable == 0) print_var_error(FLERR,"Variable formula compute vector is accessed out-of-range",ivar,0); - if (update->first_update == 0) - print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar); + if (!compute->is_initialized()) + print_var_error(FLERR,"Variable formula compute cannot be invoked before " + "initialization by a run",ivar); if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); compute->invoked_flag |= Compute::INVOKED_VECTOR; @@ -1553,8 +1555,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0); if (index2 > compute->size_array_cols) print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0); - if (update->first_update == 0) - print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar); + if (!compute->is_initialized()) + print_var_error(FLERR,"Variable formula compute cannot be invoked before " + "initialization by a run",ivar); if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); compute->invoked_flag |= Compute::INVOKED_ARRAY; @@ -1580,8 +1583,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) print_var_error(FLERR,"Compute global vector in atom-style variable formula",ivar); if (compute->size_vector == 0) print_var_error(FLERR,"Variable formula compute vector is zero length",ivar); - if (update->first_update == 0) - print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar); + if (!compute->is_initialized()) + print_var_error(FLERR,"Variable formula compute cannot be invoked before " + "initialization by a run",ivar); if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); compute->invoked_flag |= Compute::INVOKED_VECTOR; @@ -1604,8 +1608,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) print_var_error(FLERR,"Compute global vector in atom-style variable formula",ivar); if (compute->size_array_rows == 0) print_var_error(FLERR,"Variable formula compute array is zero length",ivar); - if (update->first_update == 0) - print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar); + if (!compute->is_initialized()) + print_var_error(FLERR,"Variable formula compute cannot be invoked before " + "initialization by a run",ivar); if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); compute->invoked_flag |= Compute::INVOKED_ARRAY; @@ -1623,8 +1628,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) } else if (nbracket == 1 && compute->peratom_flag && compute->size_peratom_cols == 0) { - if (update->first_update == 0) - print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar); + if (!compute->is_initialized()) + print_var_error(FLERR,"Variable formula compute cannot be invoked before " + "initialization by a run",ivar); if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); compute->invoked_flag |= Compute::INVOKED_PERATOM; @@ -1640,8 +1646,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) if (index2 > compute->size_peratom_cols) print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0); - if (update->first_update == 0) - print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar); + if (!compute->is_initialized()) + print_var_error(FLERR,"Variable formula compute cannot be invoked before " + "initialization by a run",ivar); if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); compute->invoked_flag |= Compute::INVOKED_PERATOM; @@ -1663,8 +1670,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) print_var_error(FLERR,"Per-atom compute in equal-style variable formula",ivar); if (treetype == VECTOR) print_var_error(FLERR,"Per-atom compute in vector-style variable formula",ivar); - if (update->first_update == 0) - print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar); + if (!compute->is_initialized()) + print_var_error(FLERR,"Variable formula compute cannot be invoked before " + "initialization by a run",ivar); if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); compute->invoked_flag |= Compute::INVOKED_PERATOM; @@ -1687,8 +1695,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) print_var_error(FLERR,"Per-atom compute in vector-style variable formula",ivar); if (index1 > compute->size_peratom_cols) print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0); - if (update->first_update == 0) - print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar); + if (!compute->is_initialized()) + print_var_error(FLERR,"Variable formula compute cannot be invoked before " + "initialization by a run",ivar); if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { compute->compute_peratom(); compute->invoked_flag |= Compute::INVOKED_PERATOM; @@ -2726,7 +2735,7 @@ double Variable::collapse_tree(Tree *tree) if (tree->first->type != VALUE || tree->second->type != VALUE || tree->extra[0]->type != VALUE) return 0.0; tree->type = VALUE; - if (ivalue1 <= 0 || ivalue2 <= 0 || ivalue3 <= 0 ) + if (ivalue1 <= 0 || ivalue2 <= 0 || ivalue3 <= 0) error->all(FLERR,"Invalid math function in variable formula"); if (update->ntimestep < ivalue1) tree->value = ivalue1; else { @@ -3097,7 +3106,7 @@ double Variable::eval_tree(Tree *tree, int i) auto ivalue1 = static_cast (eval_tree(tree->first,i)); auto ivalue2 = static_cast (eval_tree(tree->second,i)); auto ivalue3 = static_cast (eval_tree(tree->extra[0],i)); - if (ivalue1 <= 0 || ivalue2 <= 0 || ivalue3 <= 0 ) + if (ivalue1 <= 0 || ivalue2 <= 0 || ivalue3 <= 0) error->all(FLERR,"Invalid math function in variable formula"); if (update->ntimestep < ivalue1) arg = ivalue1; else { @@ -3628,7 +3637,7 @@ int Variable::math_function(char *word, char *contents, Tree **tree, Tree **tree auto ivalue1 = static_cast (value1); auto ivalue2 = static_cast (value2); auto ivalue3 = static_cast (values[0]); - if (ivalue1 <= 0 || ivalue2 <= 0 || ivalue3 <= 0 ) + if (ivalue1 <= 0 || ivalue2 <= 0 || ivalue3 <= 0) print_var_error(FLERR,"Invalid math function in variable formula",ivar); double value; if (update->ntimestep < ivalue1) value = ivalue1; @@ -3658,7 +3667,6 @@ int Variable::math_function(char *word, char *contents, Tree **tree, Tree **tree print_var_error(FLERR,"Invalid math function in variable formula",ivar); double value; if (update->ntimestep < ivalue1) value = ivalue1; - //else if (update->ntimestep <= ivalue3) { else { value = ivalue1; double logsp = ivalue1; @@ -4164,8 +4172,9 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree **t print_var_error(FLERR,mesg,ivar); } if (index == 0 && compute->vector_flag) { - if (update->first_update == 0) - print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar); + if (!compute->is_initialized()) + print_var_error(FLERR,"Variable formula compute cannot be invoked before " + "initialization by a run",ivar); if (!(compute->invoked_flag & Compute::INVOKED_VECTOR)) { compute->compute_vector(); compute->invoked_flag |= Compute::INVOKED_VECTOR; @@ -4175,8 +4184,9 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree **t } else if (index && compute->array_flag) { if (index > compute->size_array_cols) print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0); - if (update->first_update == 0) - print_var_error(FLERR,"Variable formula compute cannot be invoked before first run",ivar); + if (!compute->is_initialized()) + print_var_error(FLERR,"Variable formula compute cannot be invoked before " + "initialization by a run",ivar); if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) { compute->compute_array(); compute->invoked_flag |= Compute::INVOKED_ARRAY; diff --git a/src/version.h b/src/version.h index 2a1c8a9a37..15d6002fd4 100644 --- a/src/version.h +++ b/src/version.h @@ -1,2 +1 @@ -#define LAMMPS_VERSION "15 Jun 2023" -#define LAMMPS_UPDATE "Development" +#define LAMMPS_VERSION "2 Aug 2023" diff --git a/tools/coding_standard/permissions.py b/tools/coding_standard/permissions.py index f76cfc1883..377de2015b 100644 --- a/tools/coding_standard/permissions.py +++ b/tools/coding_standard/permissions.py @@ -26,6 +26,7 @@ include: - src/** - examples/** - tools/coding_standard + - tools/lammps-gui patterns: - "*.c" - "*.cmake" diff --git a/tools/coding_standard/whitespace.py b/tools/coding_standard/whitespace.py index 1c980717d6..7f602ca9b0 100644 --- a/tools/coding_standard/whitespace.py +++ b/tools/coding_standard/whitespace.py @@ -30,6 +30,7 @@ include: - lib/** - tools/coding_standard - tools/python + - tools/lammps-gui - unittest/** exclude: - lib/colvars/Install.py diff --git a/tools/lammps-gui/.clang-format b/tools/lammps-gui/.clang-format new file mode 100644 index 0000000000..cb352b37f5 --- /dev/null +++ b/tools/lammps-gui/.clang-format @@ -0,0 +1,23 @@ +--- +Language: Cpp +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignConsecutiveAssignments: true +AlignEscapedNewlines: Left +AllowShortFunctionsOnASingleLine: Inline +AllowShortLambdasOnASingleLine: None +AllowShortIfStatementsOnASingleLine: WithoutElse +BraceWrapping: + AfterFunction: true +BreakBeforeBraces: Custom +BreakInheritanceList: AfterColon +BreakConstructorInitializers: AfterColon +ColumnLimit: 100 +IndentCaseLabels: true +IndentWidth: 4 +ObjCBlockIndentWidth: 4 +PenaltyBreakAssignment: 4 +Standard: Cpp11 +TabWidth: 4 +UseTab: Never +... diff --git a/tools/lammps-gui/.gitignore b/tools/lammps-gui/.gitignore new file mode 100644 index 0000000000..fab7372d79 --- /dev/null +++ b/tools/lammps-gui/.gitignore @@ -0,0 +1,73 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/tools/lammps-gui/CMakeLists.txt b/tools/lammps-gui/CMakeLists.txt new file mode 100644 index 0000000000..b942b6c8b8 --- /dev/null +++ b/tools/lammps-gui/CMakeLists.txt @@ -0,0 +1,204 @@ +cmake_minimum_required(VERSION 3.16) + +project(lammps-gui VERSION 1.0.0 LANGUAGES CXX) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +option(LAMMPS_GUI_USE_PLUGIN "Load LAMMPS library dynamically at runtime" OFF) +mark_as_advanced(LAMMPS_GUI_USE_PLUGIN) + +# checks +if(NOT LAMMPS_EXCEPTIONS) + message(FATAL_ERROR "Must enable LAMMPS_EXCEPTIONS for building the LAMMPS GUI") +endif() +if(BUILD_MPI) + message(FATAL_ERROR "Must disable BUILD_MPI for building the LAMMPS GUI") +endif() + +# when this file is included as subdirectory in the LAMMPS build, many settings are directly imported +if(LAMMPS_DIR) + set(LAMMPS_HEADER_DIR ${LAMMPS_SOURCE_DIR}) + set(LAMMPS_LIBRARY lammps) +else() + # NOTE: the next line should be commented out when used outside of the LAMMPS package + get_filename_component(LAMMPS_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../../src ABSOLUTE) + set(LAMMPS_HEADER_DIR ${LAMMPS_SOURCE_DIR} CACHE PATH "Location of LAMMPS headers") + if(NOT LAMMPS_HEADER_DIR) + message(FATAL_ERROR "Must set LAMMPS_HEADER_DIR") + endif() + get_filename_component(LAMMPS_DIR ${LAMMPS_SOURCE_DIR}/.. ABSOLUTE) + # find LAMMPS library + find_library(LAMMPS_LIBRARY + NAMES lammps lammps_serial + HINTS ${LAMMPS_LIB_DIR} ${LAMMPS_HEADER_DIR}/../build ${LAMMPS_HEADER_DIR}/../build-clang ${LAMMPS_HEADER_DIR}/../build-test ${LAMMPS_HEADER_DIR} + REQUIRED + ) + # by default, install into $HOME/.local (not /usr/local), + # so that no root access (and sudo) is needed + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "Default install path" FORCE) + endif() + # ugly hacks for MSVC which by default always reports an old C++ standard in the __cplusplus macro + # and prints lots of pointless warnings about "unsafe" functions + if(MSVC) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_options(/Zc:__cplusplus) + add_compile_options(/wd4244) + add_compile_options(/wd4267) + if(LAMMPS_EXCEPTIONS) + add_compile_options(/EHsc) + endif() + endif() + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + endif() +endif() + +set(LAMMPS_PLUGINLIB_DIR ${LAMMPS_DIR}/examples/COUPLE/plugin) +if(LAMMPS_GUI_USE_PLUGIN) + enable_language(C) + set(PLUGIN_LOADER_SRC ${LAMMPS_PLUGINLIB_DIR}/liblammpsplugin.c) +endif() + +# we require Qt 5 and at least version 5.12 at that. +find_package(Qt5 5.12 REQUIRED COMPONENTS Widgets) + +set(PROJECT_SOURCES + main.cpp + codeeditor.cpp + codeeditor.h + highlighter.cpp + highlighter.h + imageviewer.cpp + imageviewer.h + lammpsgui.cpp + lammpsgui.h + lammpsgui.ui + lammpsrunner.h + lammpswrapper.cpp + lammpswrapper.h + linenumberarea.h + preferences.cpp + preferences.h + stdcapture.cpp + ${PLUGIN_LOADER_SRC} +) +qt5_add_resources(PROJECT_SOURCES lammpsgui.qrc) + +if(APPLE) + set(MACOSX_ICON_FILE ${LAMMPS_DIR}/cmake/packaging/lammps.icns) + set(MACOSX_README_FILE ${LAMMPS_DIR}/cmake/packaging/README.macos) + set(MACOSX_BACKGROUND_FILE ${LAMMPS_DIR}/cmake/packaging/LAMMPS_DMG_Background.png) +endif() + +add_executable(lammps-gui + ${MACOSX_ICON_FILE} + ${PROJECT_SOURCES} +) + +# compilation settings +if(LAMMPS_GUI_USE_PLUGIN) + target_compile_definitions(lammps-gui PRIVATE LAMMPS_GUI_USE_PLUGIN) + target_include_directories(lammps-gui PRIVATE ${LAMMPS_PLUGINLIB_DIR}) +else() + target_include_directories(lammps-gui PRIVATE ${LAMMPS_HEADER_DIR}) + target_link_libraries(lammps-gui PRIVATE ${LAMMPS_LIBRARY}) +endif() +target_include_directories(lammps-gui PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_definitions(lammps-gui PRIVATE LAMMPS_GUI_VERSION="${PROJECT_VERSION}") +target_link_libraries(lammps-gui PRIVATE Qt5::Widgets) +if(BUILD_OMP) + find_package(OpenMP COMPONENTS CXX REQUIRED) + target_link_libraries(lammps-gui PRIVATE OpenMP::OpenMP_CXX) +endif() + +# when compiling on macOS, create an "app bundle" +if(APPLE) + set_target_properties(lammps-gui PROPERTIES + MACOSX_BUNDLE_INFO_PLIST ${LAMMPS_DIR}/cmake/packaging/MacOSXBundleInfo.plist.in + MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} + MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} + MACOSX_BUNDLE_ICON_FILE lammps.icns + MACOSX_BUNDLE_COPYRIGHT "(c) 2003 - 2023, The LAMMPS Developers" + MACOSX_BUNDLE TRUE + ) + # additional targets to populate the bundle tree and create the .dmg image file + set(APP_CONTENTS ${CMAKE_BINARY_DIR}/lammps-gui.app/Contents) + add_custom_target(complete-bundle + ${CMAKE_COMMAND} -E make_directory ${APP_CONTENTS}/bin + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/lmp ${APP_CONTENTS}/bin/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/msi2lmp ${APP_CONTENTS}/bin/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/binary2txt ${APP_CONTENTS}/bin/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/stl_bin2txt ${APP_CONTENTS}/bin/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/phana ${APP_CONTENTS}/bin/ + COMMAND ${CMAKE_COMMAND} -E create_symlink ../MacOS/lammps-gui ${APP_CONTENTS}/bin/lammps-gui + COMMAND ${CMAKE_COMMAND} -E make_directory ${APP_CONTENTS}/Resources + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_DIR}/cmake/packaging/README.macos ${APP_CONTENTS}/Resources/README.txt + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_DIR}/cmake/packaging/lammps.icns ${APP_CONTENTS}/Resources + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_DIR}/cmake/packaging/LAMMPS_DMG_Background.png ${APP_CONTENTS}/Resources + COMMAND ${CMAKE_COMMAND} -E make_directory ${APP_CONTENTS}/share/lammps + COMMAND ${CMAKE_COMMAND} -E make_directory ${APP_CONTENTS}/share/lammps/man/man1 + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LAMMPS_DIR}/potentials ${APP_CONTENTS}/share/lammps/potentials + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LAMMPS_DIR}/bench ${APP_CONTENTS}/share/lammps/bench + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LAMMPS_DIR}/tools/msi2lmp/frc_files ${APP_CONTENTS}/share/lammps/frc_files + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_DIR}/doc/lammps.1 ${APP_CONTENTS}/share/lammps/man/man1/ + COMMAND ${CMAKE_COMMAND} -E create_symlink lammps.1 ${APP_CONTENTS}/share/lammps/man/man1/lmp.1 + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LAMMPS_DIR}/doc/msi2lmp.1 ${APP_CONTENTS}/share/lammps/man/man1 + DEPENDS lammps-gui lammps + COMMENT "Copying additional files into macOS app bundle tree" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + add_custom_target(dmg + COMMAND ${LAMMPS_DIR}/cmake/packaging/build_macos_dmg.sh + DEPENDS complete-bundle + COMMENT "Create Drag-n-Drop installer disk image from app bundle" + BYPRODUCT LAMMPS-macOS-multiarch.dmg + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + # settings or building on Windows with Visual Studio +elseif(MSVC) + install(TARGETS lammps-gui DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(FILES $ TYPE BIN) + install(FILES $ TYPE BIN) + install(FILES $ TYPE BIN) + # find path to VC++ init batch file + get_filename_component(VC_COMPILER_DIR "${CMAKE_CXX_COMPILER}" DIRECTORY) + get_filename_component(VC_BASE_DIR "${VC_COMPILER_DIR}/../../../../../.." ABSOLUTE) + set(VC_INIT "${VC_BASE_DIR}/Auxiliary/Build/vcvarsall.bat") + get_filename_component(QT5_BIN_DIR "${Qt5Core_DIR}/../../../bin" ABSOLUTE) + get_filename_component(INSTNAME ${CMAKE_INSTALL_PREFIX} NAME) + install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -D INSTNAME=${INSTNAME} -D VC_INIT=\"${VC_INIT}\" -D QT5_BIN_DIR=\"${QT5_BIN_DIR}\" -P \"${CMAKE_SOURCE_DIR}/packaging/build_windows_vs.cmake\" WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}/..\" COMMAND_ECHO STDOUT)") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + install(TARGETS lammps-gui DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(CODE [[ + file(GET_RUNTIME_DEPENDENCIES + LIBRARIES $ + EXECUTABLES $ $ + RESOLVED_DEPENDENCIES_VAR _r_deps + UNRESOLVED_DEPENDENCIES_VAR _u_deps + ) + foreach(_file ${_r_deps}) + file(INSTALL + DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" + TYPE SHARED_LIBRARY + FOLLOW_SYMLINK_CHAIN + FILES "${_file}" + ) + endforeach() + list(LENGTH _u_deps _u_length) + if("${_u_length}" GREATER 0) + message(WARNING "Unresolved dependencies detected: ${_u_deps}") + endif() ]] + ) + add_custom_target(tgz + COMMAND ${LAMMPS_DIR}/cmake/packaging/build_linux_tgz.sh + DEPENDS lammps-gui + COMMENT "Create compressed tar file of LAMMPS with dependent libraries and wrapper" + BYPRODUCT LAMMPS-Linux-amd64.tar.gz + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) +endif() diff --git a/tools/lammps-gui/CMakeLists.txt.user b/tools/lammps-gui/CMakeLists.txt.user new file mode 100644 index 0000000000..eaa7cf2ae6 --- /dev/null +++ b/tools/lammps-gui/CMakeLists.txt.user @@ -0,0 +1,322 @@ + + + + + + EnvironmentId + {ed0d4570-2589-4771-8b12-00999b3e43be} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + Builtin.BuildSystem + + true + true + Builtin.DefaultTidyAndClazy + 2 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Desktop + {287695d9-d112-4f65-92b5-675d1d6bc655} + 0 + 0 + 0 + + Debug + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_BUILD_TYPE:STRING=Debug +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} + /home/akohlmey/compile/lammps/tools/build-lammps-gui-Desktop-Debug + + + + all + + true + Build + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + clean + + true + Build + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + CMakeProjectManager.CMakeBuildConfiguration + + + Release + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_BUILD_TYPE:STRING=Release +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} + /home/akohlmey/compile/lammps/tools/build-lammps-gui-Desktop-Release + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + CMakeProjectManager.CMakeBuildConfiguration + + + RelWithDebInfo + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} + /home/akohlmey/compile/lammps/tools/build-lammps-gui-Desktop-RelWithDebInfo + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release with Debug Information + CMakeProjectManager.CMakeBuildConfiguration + + + MinSizeRel + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_BUILD_TYPE:STRING=MinSizeRel +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} + /home/akohlmey/compile/lammps/tools/build-lammps-gui-Desktop-MinSizeRel + + + + all + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + clean + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Minimum Size Release + CMakeProjectManager.CMakeBuildConfiguration + + 4 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + lammps-gui + CMakeProjectManager.CMakeRunConfiguration.lammps-gui + lammps-gui + false + true + true + false + true + /home/akohlmey/compile/lammps/tools/build-lammps-gui-Desktop-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/tools/lammps-gui/DejaVuSansMono.ttf b/tools/lammps-gui/DejaVuSansMono.ttf new file mode 100644 index 0000000000..d126ad605b Binary files /dev/null and b/tools/lammps-gui/DejaVuSansMono.ttf differ diff --git a/tools/lammps-gui/README.md b/tools/lammps-gui/README.md new file mode 100644 index 0000000000..2af9ee6faa --- /dev/null +++ b/tools/lammps-gui/README.md @@ -0,0 +1,104 @@ +LAMMPS GUI + +# Overview + +LAMMPS GUI is essentially a small graphical text editor that is linked +to the LAMMPS library and thus can run LAMMPS using the contents of the +text buffer as input. This is similar to what people usually would do +using a text editor to edit the input and then a command line terminal +window to run the input commands. The main benefit is that this +integrates very well with graphical desktop environments and that it is +easier to use for beginners in running computations and thus very +suitable for tutorials on LAMMPS. + +# Features + +The main window of the LAMMPS GUI is a text editor window with syntax +highlighting set up for LAMMPS input files. It can be used to edit any +kind of text file, but then trying to run those files will cause errors. +The output of a run is captured and displayed in a separate window +dialog. The log window is updated during the run and a progress bar for +each run command shown in the main window. Starting a new run will open +another log windows. After the simulation is finished, an image of the +simulated system can be created and shown in another window. Ongoing +runs can be stopped at the next iteration via triggering a timeout. + +When opening a file, the editor will determine the directory where the +file resides and switch its current working directory to that folder. +Many LAMMPS inputs contain commands that read other files, typically +from the folder with the input file. The GUI will show the current +working directory. The editor window can also receive (entire) files +via drag-n-drop from a file manager GUI or a desktop environment. + +Almost all commands are accessible via hotkeys. Which those hotkeys are, +is shown next to the entries in the menu. Log and image viewer windows +can be closed with CTRL-W (or Command-W on macOS). The "About LAMMPS" +dialog will show the LAMMPS version and the features included into the +LAMMPS library linked to the LAMMPS GUI. + +Due to its nature as a graphical application, it is not possible to use +the LAMMPS GUI in parallel with MPI, but OpenMP multi-threading is +available. + +# Prerequisites and portability + +LAMMPS GUI is programmed using the Qt cross-platform GUI toolkit, +currently using Qt version 5.15LTS for better compatibility with older +compilers. It has been successfully compiled and tested on: + +- Fedora Linux 38 x86\_64 using GCC 13 and Clang 16 +- Apple macOS 12 (Monterey) and macOS 13 (Ventura) with Xcode on arm64 and x86\_64 +- Windows 10 and 11 x86_64 with Visual Studio 2022 and Visual C++ 14.36 + +# Compilation + +The source for the LAMMPS GUI is included with the LAMMPS source code +distribution in the folder `tools/lammps-gui` and thus it can be can be +built as part of a regular LAMMPS compilation. Using CMake is required. +To enable its compilation the CMake variable `-D BUILD_LAMMPS_GUI=on` +must be set when creating the CMake configuration. All other settings +(compiler, flags, compile type) for LAMMPS GUI are then inherited from +the regular LAMMPS build. If the Qt library is packaged for Linux +distributions, then its location is typically auto-detected since the +required CMake configuration files are stored in a location where CMake +can find them without additional help. Otherwise, the location of the +Qt library installation must be indicated by setting `-D +Qt5_DIR=/path/to/qt5/lib/cmake/Qt5`, which is a path to a folder inside +the Qt installation that contains the file `Qt5Config.cmake`. + +It is also possible to build the LAMMPS GUI as a standalone executable +(e.g. when LAMMPS has been compiled with traditional make), then the +CMake configuration needs to be told where to find the LAMMPS headers +and the LAMMPS library, via `-D LAMMPS_SOURCE_DIR=/path/to/lammps/src`. +CMake will try to guess a build folder with the LAMMPS library from that +path, but it can also be set with `-D LAMMPS_LIB_DIR=/path/to/lammps/lib`. + +Rather than linking to the LAMMPS library during compilation, it is also +possible to compile the GUI with a plugin loader library that will load +the LAMMPS library at runtime during startup of the GUI from a shared +library; e.g. `liblammps.so` or `liblammps.dylib` or `liblammps.dll` +depending on the operating system. This has the advantage that the +LAMMPS library can be updated LAMMPS without having to recompile the +GUI. The ABI of the LAMMPS C-library interface is very stable and +generally backward compatible. This feature is enabled by setting +`-D LAMMPS_GUI_USE_PLUGIN=on` and then +`-D LAMMPS_PLUGINLIB_DIR=/path/to/lammps/plugin/loader`. Typically, this +would be the `examples/COUPLE/plugin` folder of the LAMMPS distribution. + +# Platform notes + +## macOS + +When building on macOS, the build procedure will try to manufacture a +drag-n-drop installer, LAMMPS-macOS-multiarch.dmg. To build multi-arch +executables that will run on both, arm64 and x86_64 architectures +natively, it is necessary to set the CMake variable +`-D CMAKE_OSX_ARCHITECTURES=arm64;x86_64`. To achieve wide compatibility +with different macOS versions, you can also set +`-D CMAKE_OSX_DEPLOYMENT_TARGET=11.0` which will set compatibility to macOS +11 (Big Sur) and later, even if you are compiling on a more recent macOS +version. + +-------- + +updated by Axel Kohlmeyer, 08/1023 diff --git a/tools/lammps-gui/TODO.md b/tools/lammps-gui/TODO.md new file mode 100644 index 0000000000..af53fb3cf9 --- /dev/null +++ b/tools/lammps-gui/TODO.md @@ -0,0 +1,19 @@ +LAMMPS-GUI TODO list: + +# Short term goals + +- add CTRL-q hotkey to log windows so you can exit the entire application (add do you really want to? dialog to this) +- add "syntax check" with enabled "-skiprun" flag +- add multi-tab settings dialog where certain properties can be set through customizing the LAMMPS command line + + select Font +- add list of 5(?) most recently opened/saved files to file dialog (and also write to settings state on exit) (note: must store full path!) + +# Long term ideas +- write a "wizard" dialog that can be used for beginners to create an input file template for a few typical use scenarios +- use the "lammps_get_last_thermo" function to get access to thermodynamic data during a run and add plot/graph dialog that can plot one or more of those graphs while the simulation is still running +- possibly also implement a callback interface, so that external programs can be called after thermo data is updated. +- support single stepping, i.e. process input line by line (need to detect continuation chars!) with highlighting active line(s) +- have command text input file in/above status bar where individual commands can be tested. have insert button to copy line into file at the current point +- support text completion as done with lammps-shell +- have context menu for known commands to offer retrieving help by dispatching URL to webbrowser (process index from sphinx for that purpose) +- add a "python" mode, where instead of launching LAMMPS, python is loaded that the LAMMPS python module is made available. diff --git a/tools/lammps-gui/codeeditor.cpp b/tools/lammps-gui/codeeditor.cpp new file mode 100644 index 0000000000..f0a375efc0 --- /dev/null +++ b/tools/lammps-gui/codeeditor.cpp @@ -0,0 +1,143 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "codeeditor.h" +#include "lammpsgui.h" +#include "linenumberarea.h" + +#include +#include +#include +#include +#include + +CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) +{ + lineNumberArea = new LineNumberArea(this); + + connect(this, &CodeEditor::blockCountChanged, this, &CodeEditor::updateLineNumberAreaWidth); + connect(this, &CodeEditor::updateRequest, this, &CodeEditor::updateLineNumberArea); + + updateLineNumberAreaWidth(0); +} + +int CodeEditor::lineNumberAreaWidth() +{ + int digits = 1; + int max = qMax(1, blockCount()); + while (max >= 10) { + max /= 10; + ++digits; + } + + int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits; + + return space; +} + +void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */) +{ + setViewportMargins(lineNumberAreaWidth(), 0, 0, 0); +} + +void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) +{ + if (dy) + lineNumberArea->scroll(0, dy); + else + lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height()); + + if (rect.contains(viewport()->rect())) updateLineNumberAreaWidth(0); +} + +void CodeEditor::dragEnterEvent(QDragEnterEvent *event) +{ + event->acceptProposedAction(); +} + +bool CodeEditor::canInsertFromMimeData(const QMimeData *source) const +{ + return source->hasUrls(); // || source->hasText(); +} + +void CodeEditor::dropEvent(QDropEvent *event) +{ + if (event->mimeData()->hasUrls()) { + event->accept(); + auto file = event->mimeData()->urls()[0].url().remove("file://"); + auto gui = dynamic_cast(parent()); + if (gui) { + moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor); + gui->open_file(file); + } + } else if (event->mimeData()->hasText()) { + event->accept(); + fprintf(stderr, "Drag - Drop for text block not yet implemented: text=%s\n", + event->mimeData()->text().toStdString().c_str()); + } else + event->ignore(); +} + +void CodeEditor::resizeEvent(QResizeEvent *e) +{ + QPlainTextEdit::resizeEvent(e); + + QRect cr = contentsRect(); + lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); +} + +void CodeEditor::highlightCurrentLine() +{ + QList extraSelections; + + if (!isReadOnly()) { + QTextEdit::ExtraSelection selection; + + QColor lineColor = QColor(Qt::yellow).lighter(160); + + selection.format.setBackground(lineColor); + selection.format.setProperty(QTextFormat::FullWidthSelection, true); + selection.cursor = textCursor(); + selection.cursor.clearSelection(); + extraSelections.append(selection); + } + + setExtraSelections(extraSelections); +} + +void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) +{ + QPainter painter(lineNumberArea); + painter.fillRect(event->rect(), Qt::lightGray); + QTextBlock block = firstVisibleBlock(); + int blockNumber = block.blockNumber(); + int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top()); + int bottom = top + qRound(blockBoundingRect(block).height()); + while (block.isValid() && top <= event->rect().bottom()) { + if (block.isVisible() && bottom >= event->rect().top()) { + QString number = QString::number(blockNumber + 1); + painter.setPen(Qt::black); + painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(), + Qt::AlignRight, number); + } + + block = block.next(); + top = bottom; + bottom = top + qRound(blockBoundingRect(block).height()); + ++blockNumber; + } +} + +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/codeeditor.h b/tools/lammps-gui/codeeditor.h new file mode 100644 index 0000000000..49abf81553 --- /dev/null +++ b/tools/lammps-gui/codeeditor.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. +------------------------------------------------------------------------- */ + +#ifndef CODEEDITOR_H +#define CODEEDITOR_H + +#include + +class CodeEditor : public QPlainTextEdit { + Q_OBJECT + +public: + CodeEditor(QWidget *parent = nullptr); + + void lineNumberAreaPaintEvent(QPaintEvent *event); + int lineNumberAreaWidth(); + +protected: + void resizeEvent(QResizeEvent *event) override; + void dragEnterEvent(QDragEnterEvent *event) override; + bool canInsertFromMimeData(const QMimeData *source) const override; + void dropEvent(QDropEvent *event) override; + +private slots: + void updateLineNumberAreaWidth(int newBlockCount); + void highlightCurrentLine(); + void updateLineNumberArea(const QRect &rect, int dy); + +private: + QWidget *lineNumberArea; +}; + +#endif +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/highlighter.cpp b/tools/lammps-gui/highlighter.cpp new file mode 100644 index 0000000000..3e75cb56d4 --- /dev/null +++ b/tools/lammps-gui/highlighter.cpp @@ -0,0 +1,215 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "highlighter.h" + +Highlighter::Highlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) +{ + HighlightingRule rule; + + outputFormat.setForeground(Qt::darkYellow); + readFormat.setForeground(Qt::magenta); + latticeFormat.setForeground(Qt::darkGreen); + particleFormat.setForeground(Qt::darkRed); + setupFormat.setForeground(Qt::darkCyan); + runFormat.setForeground(Qt::green); + runFormat.setFontWeight(QFont::Bold); + defineFormat.setForeground(Qt::darkMagenta); + defineFormat.setFontWeight(QFont::Bold); + + numberFormat.setForeground(Qt::blue); + commentFormat.setForeground(Qt::red); + stringFormat.setForeground(Qt::cyan); + stringFormat.setFontWeight(QFont::Normal); + + const QString output_keywords[] = { + QStringLiteral("^\\s*log\\W"), QStringLiteral("^\\s*write_data\\W"), + QStringLiteral("^\\s*write_dump\\W"), QStringLiteral("^\\s*write_coeff\\W"), + QStringLiteral("^\\s*info\\W"), QStringLiteral("^\\s*shell\\W"), + QStringLiteral("^\\s*write_restart\\W"), QStringLiteral("^\\s*restart\\W"), + QStringLiteral("^\\s*dump\\W"), QStringLiteral("^\\s*undump\\W"), + QStringLiteral("^\\s*thermo\\W"), QStringLiteral("^\\s*thermo_modify\\W"), + QStringLiteral("^\\s*thermo_style\\W"), QStringLiteral("^\\s*print\\W"), + QStringLiteral("^\\s*timer\\W")}; + for (const QString &pattern : output_keywords) { + rule.pattern = QRegularExpression(pattern); + rule.format = outputFormat; + highlightingRules.append(rule); + } + + const QString read_keywords[] = { + QStringLiteral("^\\s*include\\W"), QStringLiteral("^\\s*read_restart\\W"), + QStringLiteral("^\\s*read_data\\W"), QStringLiteral("^\\s*read_dump\\W"), + QStringLiteral("^\\s*molecule\\W")}; + for (const QString &pattern : read_keywords) { + rule.pattern = QRegularExpression(pattern); + rule.format = readFormat; + highlightingRules.append(rule); + } + + const QString lattice_keywords[] = { + QStringLiteral("^\\s*boundary\\W"), QStringLiteral("^\\s*units\\W"), + QStringLiteral("^\\s*atom_style\\W"), QStringLiteral("^\\s*lattice\\W"), + QStringLiteral("^\\s*region\\W"), QStringLiteral("^\\s*create_box\\W"), + QStringLiteral("^\\s*create_atoms\\W"), QStringLiteral("^\\s*dielectric\\W"), + QStringLiteral("^\\s*delete_atoms\\W"), QStringLiteral("^\\s*displace_atoms\\W"), + QStringLiteral("^\\s*change_box\\W"), QStringLiteral("^\\s*dimension\\W"), + QStringLiteral("^\\s*replicate\\W")}; + for (const QString &pattern : lattice_keywords) { + rule.pattern = QRegularExpression(pattern); + rule.format = latticeFormat; + highlightingRules.append(rule); + } + + const QString particle_keywords[] = { + QStringLiteral("^\\s*pair_coeff\\W"), QStringLiteral("^\\s*pair_style\\W"), + QStringLiteral("^\\s*pair_modify\\W"), QStringLiteral("^\\s*pair_write\\W"), + QStringLiteral("^\\s*mass\\W"), QStringLiteral("^\\s*velocity\\W"), + QStringLiteral("^\\s*angle_coeff\\W"), QStringLiteral("^\\s*angle_style\\W"), + QStringLiteral("^\\s*angle_write\\W"), QStringLiteral("^\\s*atom_modify\\W"), + QStringLiteral("^\\s*atom_style\\W"), QStringLiteral("^\\s*bond_coeff\\W"), + QStringLiteral("^\\s*bond_style\\W"), QStringLiteral("^\\s*bond_write\\W"), + QStringLiteral("^\\s*create_bonds\\W"), QStringLiteral("^\\s*delete_bonds\\W"), + QStringLiteral("^\\s*kspace_style\\W"), QStringLiteral("^\\s*kspace_modify\\W"), + QStringLiteral("^\\s*dihedral_style\\W"), QStringLiteral("^\\s*dihedral_coeff\\W"), + QStringLiteral("^\\s*dihedral_write\\W"), QStringLiteral("^\\s*improper_style\\W"), + QStringLiteral("^\\s*improper_coeff\\W"), QStringLiteral("^\\s*labelmap\\W")}; + for (const QString &pattern : particle_keywords) { + rule.pattern = QRegularExpression(pattern); + rule.format = particleFormat; + highlightingRules.append(rule); + } + + const QString setup_keywords[] = {QStringLiteral("^\\s*min_style\\W"), + QStringLiteral("^\\s*min_modify\\W"), + QStringLiteral("^\\s*run_style\\W"), + QStringLiteral("^\\s*timestep\\W"), + QStringLiteral("^\\s*neighbor\\W"), + QStringLiteral("^\\s*neigh_modify\\W"), + QStringLiteral("^\\s*suffix\\W"), + QStringLiteral("^\\s*special_bonds\\W"), + QStringLiteral("^\\s*balance\\W"), + QStringLiteral("^\\s*box\\W"), + QStringLiteral("^\\s*clear\\W"), + QStringLiteral("^\\s*comm_modify\\W"), + QStringLiteral("^\\s*comm_style\\W"), + QStringLiteral("^\\s*newton\\W"), + QStringLiteral("^\\s*package\\W"), + QStringLiteral("^\\s*processors\\W"), + QStringLiteral("^\\s*reset_atoms\\W"), + QStringLiteral("^\\s*dump_modify\\W"), + QStringLiteral("^\\s*reset_ids\\W"), + QStringLiteral("^\\s*reset_timestep\\W"), + QStringLiteral("^\\s*label\\W"), + QStringLiteral("^\\s*jump\\W"), + QStringLiteral("^\\s*next\\W"), + QStringLiteral("^\\s*loop\\W") + + }; + for (const QString &pattern : setup_keywords) { + rule.pattern = QRegularExpression(pattern); + rule.format = setupFormat; + highlightingRules.append(rule); + } + + const QString run_keywords[] = {QStringLiteral("^\\s*minimize\\W"), + QStringLiteral("^\\s*minimize/kk\\W"), + QStringLiteral("^\\s*run\\W"), + QStringLiteral("^\\s*rerun\\W"), + QStringLiteral("^\\s*tad\\W"), + QStringLiteral("^\\s*neb\\W"), + QStringLiteral("^\\s*neb/spin\\W"), + QStringLiteral("^\\s*prd\\W"), + QStringLiteral("^\\s*quit\\W"), + QStringLiteral("^\\s*server\\W"), + QStringLiteral("^\\s*temper/npt\\W"), + QStringLiteral("^\\s*temper/grem\\W"), + QStringLiteral("^\\s*temper\\W"), + QStringLiteral("^\\s*message\\W"), + QStringLiteral("^\\s*hyper\\W"), + QStringLiteral("^\\s*dynamical_matrix\\W"), + QStringLiteral("^\\s*dynamical_matrix/kk\\W"), + QStringLiteral("^\\s*third_order\\W"), + QStringLiteral("^\\s*third_order/kk\\W"), + QStringLiteral("^\\s*fitpod\\W"), + QStringLiteral("^\\s*if\\W"), + QStringLiteral("^\\s*then\\W"), + QStringLiteral("^\\s*elif\\W"), + QStringLiteral("^\\s*else\\W")}; + for (const QString &pattern : run_keywords) { + rule.pattern = QRegularExpression(pattern); + rule.format = runFormat; + highlightingRules.append(rule); + } + + const QString define_keywords[] = {QStringLiteral("^\\s*variable\\W"), + QStringLiteral("^\\s*group\\W"), + QStringLiteral("^\\s*compute\\W"), + QStringLiteral("^\\s*python\\W"), + QStringLiteral("^\\s*set\\W"), + QStringLiteral("^\\s*uncompute\\W"), + QStringLiteral("^\\s*kim_query\\W"), + QStringLiteral("^\\s*kim\\W"), + QStringLiteral("^\\s*group2ndx\\W"), + QStringLiteral("^\\s*ndx2group\\W"), + QStringLiteral("^\\s*compute_modify\\W"), + QStringLiteral("^\\s*fix_modify\\W"), + QStringLiteral("^\\s*fix\\W"), + QStringLiteral("^\\s*unfix\\W"), + QStringLiteral("^\\s*INF\\W"), + QStringLiteral("^\\s*EDGE\\W"), + QStringLiteral("^\\s*NULL\\W"), + QStringLiteral("^\\s*&\\s*$"), + QStringLiteral("^\\s*mdi\\W")}; + for (const QString &pattern : define_keywords) { + rule.pattern = QRegularExpression(pattern); + rule.format = defineFormat; + highlightingRules.append(rule); + } + + const QString number_keywords[] = { + QStringLiteral("(^|\\s+)[0-9]+"), // integer + QStringLiteral("(^|\\s+)[0-9]+\\.[0-9]*[edED]?[-+]?[0-9]*"), // floating point 1 + QStringLiteral("(^|\\s+)[0-9]*\\.[0-9]+[edED]?[-+]?[0-9]*"), // floating point 2 + QStringLiteral("(^|\\s+)[0-9]+([edED][-+]?[0-9]+)?") // floating point 3 + }; + for (const QString &pattern : number_keywords) { + rule.pattern = QRegularExpression(pattern); + rule.format = numberFormat; + highlightingRules.append(rule); + } + + // comments, must come before strings but after other keywords. + rule.pattern = QRegularExpression("#.*"); + rule.format = commentFormat; + highlightingRules.append(rule); + + // strings, must come last so it overwrites other formatting + rule.pattern = QRegularExpression("(\".*\"|'.*')"); + rule.format = stringFormat; + highlightingRules.append(rule); +} + +void Highlighter::highlightBlock(const QString &text) +{ + for (const HighlightingRule &rule : qAsConst(highlightingRules)) { + QRegularExpressionMatchIterator matchIterator = rule.pattern.globalMatch(text); + while (matchIterator.hasNext()) { + QRegularExpressionMatch match = matchIterator.next(); + setFormat(match.capturedStart(), match.capturedLength(), rule.format); + } + } +} +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/highlighter.h b/tools/lammps-gui/highlighter.h new file mode 100644 index 0000000000..234333924e --- /dev/null +++ b/tools/lammps-gui/highlighter.h @@ -0,0 +1,52 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +#ifndef HIGHLIGHTER_H +#define HIGHLIGHTER_H + +#include +#include +#include + +class Highlighter : public QSyntaxHighlighter { + Q_OBJECT + +public: + Highlighter(QTextDocument *parent = 0); + +protected: + void highlightBlock(const QString &text) override; + +private: + struct HighlightingRule { + QRegularExpression pattern; + QTextCharFormat format; + }; + QVector highlightingRules; + + QTextCharFormat outputFormat; + QTextCharFormat readFormat; + QTextCharFormat latticeFormat; + QTextCharFormat particleFormat; + QTextCharFormat setupFormat; + QTextCharFormat runFormat; + QTextCharFormat defineFormat; + + QTextCharFormat numberFormat; + QTextCharFormat stringFormat; + QTextCharFormat commentFormat; +}; +#endif +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/imageviewer.cpp b/tools/lammps-gui/imageviewer.cpp new file mode 100644 index 0000000000..ec2f6cfbc4 --- /dev/null +++ b/tools/lammps-gui/imageviewer.cpp @@ -0,0 +1,209 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "imageviewer.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +ImageViewer::ImageViewer(const QString &fileName, QWidget *parent) : + QDialog(parent), imageLabel(new QLabel), scrollArea(new QScrollArea), menuBar(new QMenuBar) +{ + imageLabel->setBackgroundRole(QPalette::Base); + imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + imageLabel->setScaledContents(true); + imageLabel->minimumSizeHint(); + + scrollArea->setBackgroundRole(QPalette::Dark); + scrollArea->setWidget(imageLabel); + scrollArea->setMouseTracking(true); + scrollArea->installEventFilter(this); + scrollArea->setVisible(false); + + buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); + + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(menuBar); + mainLayout->addWidget(scrollArea); + mainLayout->addWidget(buttonBox); + setWindowTitle(QString("Image Viewer: ") + QFileInfo(fileName).completeBaseName()); + + createActions(); + + QImageReader reader(fileName); + reader.setAutoTransform(true); + const QImage newImage = reader.read(); + if (newImage.isNull()) { + QMessageBox::warning(this, QGuiApplication::applicationDisplayName(), + tr("Cannot load %1: %2").arg(fileName, reader.errorString())); + return; + } + image = newImage; + imageLabel->setPixmap(QPixmap::fromImage(image)); + scaleFactor = 1.0; + resize(image.width() + 20, image.height() + 50); + + scrollArea->setVisible(true); + fitToWindowAct->setEnabled(true); + updateActions(); + if (!fitToWindowAct->isChecked()) imageLabel->adjustSize(); + setLayout(mainLayout); +} + +void ImageViewer::saveAs() +{ + QString fileName = QFileDialog::getSaveFileName(this, "Save Image File As", QString(), + "Image Files (*.jpg *.png *.bmp *.ppm)"); + saveFile(fileName); +} + +void ImageViewer::copy() {} + +void ImageViewer::zoomIn() +{ + scaleImage(1.1); +} + +void ImageViewer::zoomOut() +{ + scaleImage(0.9); +} + +void ImageViewer::normalSize() +{ + imageLabel->adjustSize(); + scaleFactor = 1.0; +} + +void ImageViewer::fitToWindow() +{ + bool fitToWindow = fitToWindowAct->isChecked(); + scrollArea->setWidgetResizable(fitToWindow); + if (!fitToWindow) normalSize(); + updateActions(); +} + +void ImageViewer::saveFile(const QString &fileName) +{ + if (!fileName.isEmpty()) image.save(fileName); +} + +void ImageViewer::createActions() +{ + QMenu *fileMenu = menuBar->addMenu(tr("&File")); + + saveAsAct = fileMenu->addAction(tr("&Save As..."), this, &ImageViewer::saveAs); + saveAsAct->setEnabled(false); + fileMenu->addSeparator(); + copyAct = fileMenu->addAction(tr("&Copy"), this, &ImageViewer::copy); + copyAct->setShortcut(QKeySequence::Copy); + copyAct->setEnabled(false); + fileMenu->addSeparator(); + QAction *exitAct = fileMenu->addAction(tr("&Close"), this, &QWidget::close); + exitAct->setShortcut(tr("Ctrl+W")); + + QMenu *viewMenu = menuBar->addMenu(tr("&View")); + + zoomInAct = viewMenu->addAction(tr("Zoom &In (10%)"), this, &ImageViewer::zoomIn); + zoomInAct->setShortcut(QKeySequence::ZoomIn); + zoomInAct->setEnabled(false); + + zoomOutAct = viewMenu->addAction(tr("Zoom &Out (10%)"), this, &ImageViewer::zoomOut); + zoomOutAct->setShortcut(QKeySequence::ZoomOut); + zoomOutAct->setEnabled(false); + + normalSizeAct = viewMenu->addAction(tr("&Normal Size"), this, &ImageViewer::normalSize); + normalSizeAct->setShortcut(tr("Ctrl+S")); + normalSizeAct->setEnabled(false); + + viewMenu->addSeparator(); + + fitToWindowAct = viewMenu->addAction(tr("&Fit to Window"), this, &ImageViewer::fitToWindow); + fitToWindowAct->setEnabled(false); + fitToWindowAct->setCheckable(true); + fitToWindowAct->setShortcut(tr("Ctrl+F")); +} + +void ImageViewer::updateActions() +{ + saveAsAct->setEnabled(!image.isNull()); + copyAct->setEnabled(!image.isNull()); + zoomInAct->setEnabled(!fitToWindowAct->isChecked()); + zoomOutAct->setEnabled(!fitToWindowAct->isChecked()); + normalSizeAct->setEnabled(!fitToWindowAct->isChecked()); +} + +void ImageViewer::scaleImage(double factor) +{ + scaleFactor *= factor; +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) + imageLabel->resize(scaleFactor * imageLabel->pixmap()->size()); +#else + imageLabel->resize(scaleFactor * imageLabel->pixmap(Qt::ReturnByValue).size()); +#endif + + adjustScrollBar(scrollArea->horizontalScrollBar(), factor); + adjustScrollBar(scrollArea->verticalScrollBar(), factor); + zoomInAct->setEnabled(scaleFactor < 3.0); + zoomOutAct->setEnabled(scaleFactor > 0.333); +} + +void ImageViewer::adjustScrollBar(QScrollBar *scrollBar, double factor) +{ + scrollBar->setValue( + int(factor * scrollBar->value() + ((factor - 1) * scrollBar->pageStep() / 2))); +} + +bool ImageViewer::eventFilter(QObject *, QEvent *event) +{ + if (event->type() == QEvent::Wheel) { + wheelEvent((QWheelEvent *)event); + return true; + } + return false; +} + +void ImageViewer::wheelEvent(QWheelEvent *event) +{ + QPoint num = event->angleDelta(); + if (!num.isNull()) { + if (num.y() > 0) + zoomIn(); + else + zoomOut(); + } + event->accept(); +} + +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/imageviewer.h b/tools/lammps-gui/imageviewer.h new file mode 100644 index 0000000000..edd66c9e73 --- /dev/null +++ b/tools/lammps-gui/imageviewer.h @@ -0,0 +1,72 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +#ifndef IMAGEVIEWER_H +#define IMAGEVIEWER_H + +#include +#include + +class QAction; +class QMenuBar; +class QDialogButtonBox; +class QLabel; +class QObject; +class QScrollArea; +class QScrollBar; +class QStatusBar; +class QWheelEvent; + +class ImageViewer : public QDialog { + Q_OBJECT + +public: + explicit ImageViewer(const QString &fileName, QWidget *parent = nullptr); + +private slots: + void saveAs(); + void copy(); + void zoomIn(); + void zoomOut(); + void normalSize(); + void fitToWindow(); + +private: + void createActions(); + void updateActions(); + void saveFile(const QString &fileName); + void scaleImage(double factor); + void adjustScrollBar(QScrollBar *scrollBar, double factor); + bool eventFilter(QObject *object, QEvent *event); + void wheelEvent(QWheelEvent *event); + +private: + QImage image; + QMenuBar *menuBar; + QLabel *imageLabel; + QScrollArea *scrollArea; + QDialogButtonBox *buttonBox; + double scaleFactor = 1.0; + + QAction *saveAsAct; + QAction *copyAct; + QAction *zoomInAct; + QAction *zoomOutAct; + QAction *normalSizeAct; + QAction *fitToWindowAct; +}; +#endif + +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/lammps-icon-128x128.png b/tools/lammps-gui/lammps-icon-128x128.png new file mode 100644 index 0000000000..0c39f1ca25 Binary files /dev/null and b/tools/lammps-gui/lammps-icon-128x128.png differ diff --git a/tools/lammps-gui/lammpsgui.cpp b/tools/lammps-gui/lammpsgui.cpp new file mode 100644 index 0000000000..3902e89abb --- /dev/null +++ b/tools/lammps-gui/lammpsgui.cpp @@ -0,0 +1,710 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "lammpsgui.h" + +#include "highlighter.h" +#include "imageviewer.h" +#include "lammpsrunner.h" +#include "preferences.h" +#include "stdcapture.h" +#include "ui_lammpsgui.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#if defined(_OPENMP) +#include +#include +#endif + +#if defined(_WIN32) +#include +#else +#include +#endif + +static const QString blank(" "); + +// duplicate string +static char *mystrdup(const std::string &text) +{ + auto tmp = new char[text.size() + 1]; + memcpy(tmp, text.c_str(), text.size() + 1); + return tmp; +} + +LammpsGui::LammpsGui(QWidget *parent, const char *filename) : + QMainWindow(parent), ui(new Ui::LammpsGui), highlighter(nullptr), capturer(nullptr), + status(nullptr), logwindow(nullptr), imagewindow(nullptr), logupdater(nullptr), + dirstatus(nullptr), progress(nullptr), prefdialog(nullptr) +{ + ui->setupUi(this); + this->setCentralWidget(ui->textEdit); + highlighter = new Highlighter(ui->textEdit->document()); + capturer = new StdCapture; + current_file.clear(); + current_dir = QDir(".").absolutePath(); + recent_files.clear(); + + QCoreApplication::setOrganizationName("The LAMMPS Developers"); + QCoreApplication::setOrganizationDomain("lammps.org"); + QCoreApplication::setApplicationName("LAMMPS GUI"); + + // restorge and initialize settings + QSettings settings; + + // check and initialize nthreads setting. Default is to use max, + // but not override OMP_NUM_THREADS and preferences setting. +#if defined(_OPENMP) + // use maximum number of available threads unless OMP_NUM_THREADS was set + int nthreads = settings.value("nthreads", omp_get_max_threads()).toInt(); +#if _WIN32 + if (!getenv("OMP_NUM_THREADS")) { + _putenv_s("OMP_NUM_THREADS", std::to_string(nthreads).c_str()); + } +#else + setenv("OMP_NUM_THREADS", std::to_string(nthreads).c_str(), 0); +#endif +#else + int nthreads = settings.value("nthreads", 1).toInt(); +#endif + settings.setValue("nthreads", QString::number(nthreads)); + + const char *tmpdir = getenv("TMPDIR"); + if (!tmpdir) tmpdir = getenv("TMP"); + if (!tmpdir) tmpdir = getenv("TEMPDIR"); + if (!tmpdir) tmpdir = getenv("TEMP"); +#if _WIN32 + if (!tmpdir) tmpdir = "C:\\Windows\\Temp"; +#else + if (!tmpdir) tmpdir = "/tmp"; +#endif + settings.setValue("tempdir", QString(tmpdir)); + + lammps_args.clear(); + lammps_args.push_back(mystrdup("LAMMPS-GUI")); + lammps_args.push_back(mystrdup("-log")); + lammps_args.push_back(mystrdup("none")); + + setWindowIcon(QIcon(":/lammps-icon-128x128.png")); +#if (__APPLE__) + QFont text_font("Menlo"); +#else + QFont text_font(":/Monospace.ttf"); +#endif + text_font.setStyleHint(QFont::TypeWriter); + ui->textEdit->document()->setDefaultFont(text_font); + ui->textEdit->setMinimumSize(600, 400); + + connect(ui->actionNew, &QAction::triggered, this, &LammpsGui::new_document); + connect(ui->actionOpen, &QAction::triggered, this, &LammpsGui::open); + connect(ui->actionSave, &QAction::triggered, this, &LammpsGui::save); + connect(ui->actionSave_As, &QAction::triggered, this, &LammpsGui::save_as); + connect(ui->actionQuit, &QAction::triggered, this, &LammpsGui::quit); + connect(ui->actionCopy, &QAction::triggered, this, &LammpsGui::copy); + connect(ui->actionCut, &QAction::triggered, this, &LammpsGui::cut); + connect(ui->actionPaste, &QAction::triggered, this, &LammpsGui::paste); + connect(ui->actionUndo, &QAction::triggered, this, &LammpsGui::undo); + connect(ui->actionRedo, &QAction::triggered, this, &LammpsGui::redo); + connect(ui->actionRun_Buffer, &QAction::triggered, this, &LammpsGui::run_buffer); + connect(ui->actionStop_LAMMPS, &QAction::triggered, this, &LammpsGui::stop_run); + connect(ui->actionImage, &QAction::triggered, this, &LammpsGui::view_image); + connect(ui->actionAbout_LAMMPS_GUI, &QAction::triggered, this, &LammpsGui::about); + connect(ui->action_Help, &QAction::triggered, this, &LammpsGui::help); + connect(ui->actionLAMMPS_Manual, &QAction::triggered, this, &LammpsGui::manual); + connect(ui->actionPreferences, &QAction::triggered, this, &LammpsGui::preferences); + connect(ui->actionDefaults, &QAction::triggered, this, &LammpsGui::defaults); + connect(ui->textEdit->document(), &QTextDocument::modificationChanged, this, + &LammpsGui::modified); + +#if !QT_CONFIG(clipboard) + ui->actionCut->setEnabled(false); + ui->actionCopy->setEnabled(false); + ui->actionPaste->setEnabled(false); +#endif + + status = new QLabel("Ready."); + status->setFixedWidth(300); + ui->statusbar->addWidget(status); + dirstatus = new QLabel(QString(" Directory: ") + current_dir); + dirstatus->setMinimumWidth(500); + ui->statusbar->addWidget(dirstatus); + progress = new QProgressBar(); + progress->setRange(0, 1000); + progress->setMinimumWidth(500); + progress->hide(); + dirstatus->show(); + ui->statusbar->addWidget(progress); + +#if defined(LAMMPS_GUI_USE_PLUGIN) + plugin_path.clear(); + std::string deffile = settings.value("plugin_path", "liblammps.so").toString().toStdString(); + for (const char *libfile : {deffile.c_str(), "./liblammps.so", "liblammps.dylib", + "./liblammps.dylib", "liblammps.dll"}) { + if (lammps.load_lib(libfile)) { + auto canonical = QFileInfo(libfile).canonicalFilePath(); + plugin_path = canonical.toStdString(); + settings.setValue("plugin_path", canonical); + break; + } + } + + if (plugin_path.empty()) { + // none of the plugin paths could load, remove key + settings.remove("plugin_path"); + QMessageBox::critical(this, "Error", "Cannot open LAMMPS shared library file"); + // QCoreApplication::quit(); + exit(1); + } +#endif + + if (filename) { + open_file(filename); + } else { + setWindowTitle(QString("LAMMPS-GUI - *unknown*")); + } +} + +LammpsGui::~LammpsGui() +{ + delete ui; + delete highlighter; + delete capturer; + delete status; + delete logwindow; + delete imagewindow; + delete dirstatus; +} + +void LammpsGui::new_document() +{ + current_file.clear(); + ui->textEdit->document()->setPlainText(QString()); + + lammps.close(); + setWindowTitle(QString("LAMMPS-GUI - *unknown*")); +} + +void LammpsGui::open() +{ + QString fileName = QFileDialog::getOpenFileName(this, "Open the file"); + open_file(fileName); +} + +// open file and switch CWD to path of file +void LammpsGui::open_file(const QString &fileName) +{ + if (ui->textEdit->document()->isModified()) { + QMessageBox msg; + msg.setWindowTitle("Unsaved Changes"); + msg.setWindowIcon(windowIcon()); + msg.setText(QString("The buffer ") + current_file + " has changes"); + msg.setInformativeText("Do you want to save the file before opening a new file?"); + msg.setIcon(QMessageBox::Question); + msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); + int rv = msg.exec(); + switch (rv) { + case QMessageBox::Yes: + save(); + break; + case QMessageBox::Cancel: + return; + break; + case QMessageBox::No: // fallthrough + default: + // do nothing + break; + } + } + + QFileInfo path(fileName); + current_file = path.fileName(); + current_dir = path.absolutePath(); + QFile file(path.absoluteFilePath()); + + QDir::setCurrent(current_dir); + if (!file.open(QIODevice::ReadOnly | QFile::Text)) { + QMessageBox::warning(this, "Warning", + "Cannot open file " + path.absoluteFilePath() + ": " + + file.errorString()); + return; + } + setWindowTitle(QString("LAMMPS-GUI - " + current_file)); + QTextStream in(&file); + QString text = in.readAll(); + ui->textEdit->document()->setPlainText(text); + ui->textEdit->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor); + ui->textEdit->document()->setModified(false); + file.close(); + dirstatus->setText(QString(" Directory: ") + current_dir); +} + +void LammpsGui::write_file(const QString &fileName) +{ + QFile file(fileName); + QFileInfo path(file); + current_file = path.fileName(); + current_dir = path.absolutePath(); + + if (!file.open(QIODevice::WriteOnly | QFile::Text)) { + QMessageBox::warning(this, "Warning", "Cannot save file: " + file.errorString()); + return; + } + setWindowTitle(QString("LAMMPS-GUI - " + current_file)); + QTextStream out(&file); + QString text = ui->textEdit->toPlainText(); + out << text; + if (text.back().toLatin1() != '\n') out << "\n"; // add final newline if missing + file.close(); + dirstatus->setText(QString(" Directory: ") + current_dir); + ui->textEdit->document()->setModified(false); +} + +void LammpsGui::save() +{ + QString fileName = current_file; + // If we don't have a filename from before, get one. + if (fileName.isEmpty()) fileName = QFileDialog::getSaveFileName(this, "Save"); + + write_file(fileName); +} + +void LammpsGui::save_as() +{ + QString fileName = QFileDialog::getSaveFileName(this, "Save as"); + write_file(fileName); +} + +void LammpsGui::quit() +{ + lammps.close(); + lammps.finalize(); + + if (ui->textEdit->document()->isModified()) { + QMessageBox msg; + msg.setWindowTitle("Unsaved Changes"); + msg.setWindowIcon(windowIcon()); + msg.setText(QString("The buffer ") + current_file + " has changes"); + msg.setInformativeText("Do you want to save the file before exiting?"); + msg.setIcon(QMessageBox::Question); + msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); + int rv = msg.exec(); + switch (rv) { + case QMessageBox::Yes: + save(); + break; + case QMessageBox::Cancel: + return; + break; + case QMessageBox::No: // fallthrough + default: + // do nothing + break; + } + } + QCoreApplication::quit(); +} + +void LammpsGui::copy() +{ +#if QT_CONFIG(clipboard) + ui->textEdit->copy(); +#endif +} + +void LammpsGui::cut() +{ +#if QT_CONFIG(clipboard) + ui->textEdit->cut(); +#endif +} + +void LammpsGui::paste() +{ +#if QT_CONFIG(clipboard) + ui->textEdit->paste(); +#endif +} + +void LammpsGui::undo() +{ + ui->textEdit->undo(); +} + +void LammpsGui::redo() +{ + ui->textEdit->redo(); +} + +void LammpsGui::stop_run() +{ + lammps.force_timeout(); +} + +void LammpsGui::logupdate() +{ + double t_elapsed, t_remain, t_total; + int completed = 1000; + + if (lammps.is_running()) { + t_elapsed = lammps.get_thermo("cpu"); + t_remain = lammps.get_thermo("cpuremain"); + t_total = t_elapsed + t_remain + 1.0e-10; + completed = t_elapsed / t_total * 1000.0; + } + + progress->setValue(completed); + if (logwindow) { + const auto text = capturer->GetChunk(); + if (text.size() > 0) { + logwindow->insertPlainText(text.c_str()); + logwindow->moveCursor(QTextCursor::End); + logwindow->textCursor().deleteChar(); + } + } +} + +void LammpsGui::modified() +{ + const QString modflag(" - *modified*"); + auto title = windowTitle().remove(modflag); + if (ui->textEdit->document()->isModified()) + setWindowTitle(title + modflag); + else + setWindowTitle(title); +} + +void LammpsGui::run_done() +{ + logupdater->stop(); + delete logupdater; + logupdater = nullptr; + progress->setValue(1000); + + capturer->EndCapture(); + auto log = capturer->GetCapture(); + logwindow->insertPlainText(log.c_str()); + logwindow->moveCursor(QTextCursor::End); + + bool success = true; + constexpr int BUFLEN = 1024; + char errorbuf[BUFLEN]; + + if (lammps.has_error()) { + lammps.get_last_error_message(errorbuf, BUFLEN); + success = false; + } + + if (success) { + status->setText("Ready."); + } else { + status->setText("Failed."); + QMessageBox::critical(this, "LAMMPS-GUI Error", + QString("Error running LAMMPS:\n\n") + errorbuf); + } + progress->hide(); + dirstatus->show(); +} + +void LammpsGui::run_buffer() +{ + QSettings settings; + progress->setValue(0); + dirstatus->hide(); + progress->show(); + int nthreads = settings.value("nthreads", 1).toInt(); + status->setText(QString("Running LAMMPS with %1 thread(s)...").arg(nthreads)); + status->repaint(); + start_lammps(); + if (!lammps.is_open()) return; + clear(); + capturer->BeginCapture(); + + // always add final newline since the text edit widget does not + char *input = mystrdup(ui->textEdit->toPlainText().toStdString() + "\n"); + is_running = true; + + LammpsRunner *runner = new LammpsRunner(this); + runner->setup_run(&lammps, input); + connect(runner, &LammpsRunner::resultReady, this, &LammpsGui::run_done); + connect(runner, &LammpsRunner::finished, runner, &QObject::deleteLater); + runner->start(); + + logwindow = new QPlainTextEdit(); + logwindow->setReadOnly(true); + logwindow->setCenterOnScroll(true); + logwindow->moveCursor(QTextCursor::End); + logwindow->setWindowTitle("LAMMPS-GUI - Output from running LAMMPS on buffer - " + + current_file); + logwindow->setWindowIcon(QIcon(":/lammps-icon-128x128.png")); +#if (__APPLE__) + QFont text_font("Menlo"); +#else + QFont text_font(":/Monospace.ttf"); +#endif + text_font.setStyleHint(QFont::TypeWriter); + logwindow->document()->setDefaultFont(text_font); + logwindow->setLineWrapMode(QPlainTextEdit::NoWrap); + logwindow->setMinimumSize(600, 400); + QShortcut *shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), logwindow); + QObject::connect(shortcut, &QShortcut::activated, logwindow, &QPlainTextEdit::close); + shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Slash), logwindow); + QObject::connect(shortcut, &QShortcut::activated, this, &LammpsGui::stop_run); + logwindow->show(); + + logupdater = new QTimer(this); + connect(logupdater, &QTimer::timeout, this, &LammpsGui::logupdate); + logupdater->start(1000); +} + +void LammpsGui::view_image() +{ + // LAMMPS is not re-entrant, so we can only query LAMMPS when it is not running + if (!lammps.is_running()) { + start_lammps(); + if (!lammps.extract_setting("box_exists")) { + QMessageBox::warning(this, "ImageViewer Error", + "Cannot create snapshot image without a system box"); + return; + } + + QSettings settings; + QString dumpcmd = "write_dump all image "; + QString dumpfile = settings.value("tempdir").toString(); +#if defined(_WIN32) + dumpfile += '\\'; +#else + dumpfile += '/'; +#endif + dumpfile += current_file + ".ppm"; + dumpcmd += dumpfile; + + settings.beginGroup("snapshot"); + dumpcmd += blank + settings.value("color", "type").toString(); + dumpcmd += blank + settings.value("diameter", "type").toString(); + dumpcmd += QString(" size ") + settings.value("xsize", "800").toString(); + dumpcmd += blank + settings.value("ysize", "600").toString(); + dumpcmd += QString(" zoom ") + settings.value("zoom", "1.0").toString(); + settings.endGroup(); + + lammps.command(dumpcmd.toLocal8Bit()); + imagewindow = new ImageViewer(dumpfile); +#if defined(_WIN32) + _unlink(dumpfile.toLocal8Bit()); +#else + unlink(dumpfile.toLocal8Bit()); +#endif + } else { + QMessageBox::warning(this, "ImageViewer Error", + "Cannot create snapshot image while LAMMPS is running"); + return; + } + imagewindow->show(); +} + +void LammpsGui::clear() +{ + ui->textEdit->moveCursor(QTextCursor::Start, QTextCursor::MoveAnchor); +} + +void LammpsGui::about() +{ + std::string version = "This is LAMMPS-GUI version " LAMMPS_GUI_VERSION; + if (lammps.has_plugin()) { + version += " - LAMMPS linked dynamically"; + if (!plugin_path.empty()) { + version += " from file "; + version += plugin_path; + } + } else { + version += " - LAMMPS linked statically"; + } + std::string info = "LAMMPS is currently running. LAMMPS config info not available."; + + // LAMMPS is not re-entrant, so we can only query LAMMPS when it is not running + if (!lammps.is_running()) { + start_lammps(); + capturer->BeginCapture(); + lammps.command("info config"); + capturer->EndCapture(); + info = capturer->GetCapture(); + auto start = info.find("LAMMPS version:"); + auto end = info.find("Info-Info-Info", start); + info = std::string(info, start, end - start); + } + + QMessageBox msg; + msg.setWindowTitle("About LAMMPS-GUI"); + msg.setText(version.c_str()); + msg.setInformativeText(info.c_str()); + msg.setIconPixmap(QPixmap(":/lammps-icon-128x128.png").scaled(64, 64)); + msg.setStandardButtons(QMessageBox::Ok); + QFont font; + font.setFixedPitch(true); + font.setStyleHint(QFont::TypeWriter); + font.setFamily("Arial"); + font.setPointSize(8); + msg.setFont(font); + msg.exec(); +} + +void LammpsGui::help() +{ + QMessageBox msg; + msg.setWindowTitle("LAMMPS-GUI Quick Help"); + msg.setText("
This is LAMMPS-GUI version " LAMMPS_GUI_VERSION "
"); + msg.setInformativeText("Overview" + "
LAMMPS GUI is a graphical text editor that is " + "linked to the LAMMPS library and thus can run LAMMPS directly using " + "the contents of the text buffer as input through the LAMMPS C-library " + "interface. This makes it convenient to use for beginners and during " + "tutorials


" + "Features" + "
The main window of the LAMMPS GUI is a text " + "editor window with syntax highlighting. The output of a LAMMPS run is " + "captured and displayed in a log window. The log window is updated " + "regularly during the run, as is a progress bar in the main window. " + "After the simulation is finished, an image of the simulated system " + "can be created and shown (and saved) in image viewer window. Ongoing " + "runs can be stopped at the next run iteration.

" + "
When opening a file, the editor will determine " + "the directory where the input file resides and switch its current " + "working directory to that same folder. Many LAMMPS inputs contain " + "commands that read other files, typically from the folder as the " + "input file. The GUI will show its current working directory. " + "In addition to using the menu, the editor window also receive files " + "as the first command line argument or via drag-n-drop from a " + "graphical file manager GUI or a desktop environment.

" + "
Almost all commands are accessible via hotkeys. " + "Which those hotkeys are, is shown next to the entries in the menus. " + "Log and image viewer windows can be closed with CTRL-W (or Command-W " + "on macOS).

" + "
The 'About LAMMPS' dialog will show the " + "LAMMPS version and the features included into the LAMMPS library " + "linked to the LAMMPS GUI.

" + "Due to its nature as a graphical application, it is not " + "possible to use the LAMMPS GUI in parallel with MPI, but OpenMP " + "multi-threading is available.
"); + msg.setIconPixmap(QPixmap(":/lammps-icon-128x128.png").scaled(64, 64)); + msg.setStandardButtons(QMessageBox::Close); + msg.exec(); +} + +void LammpsGui::manual() +{ + QDesktopServices::openUrl(QUrl("https://docs.lammps.org/")); +} + +void LammpsGui::defaults() +{ + QSettings settings; + settings.clear(); + settings.sync(); +} + +void LammpsGui::preferences() +{ + Preferences prefs(&lammps); + if (prefs.exec() == QDialog::Accepted) { + // must delete LAMMPS instance after setting may be changed so we can apply different + // suffixes + lammps.close(); + } +} + +void LammpsGui::start_lammps() +{ + // temporary extend lammps_args with additional arguments + int initial_narg = lammps_args.size(); + QSettings settings; + int nthreads = settings.value("nthreads", 1).toInt(); + int accel = settings.value("accelerator", AcceleratorTab::None).toInt(); + if (accel == AcceleratorTab::Opt) { + lammps_args.push_back(mystrdup("-suffix")); + lammps_args.push_back(mystrdup("opt")); + } else if (accel == AcceleratorTab::OpenMP) { + lammps_args.push_back(mystrdup("-suffix")); + lammps_args.push_back(mystrdup("omp")); + lammps_args.push_back(mystrdup("-pk")); + lammps_args.push_back(mystrdup("omp")); + lammps_args.push_back(mystrdup(std::to_string(nthreads))); + } else if (accel == AcceleratorTab::Intel) { + lammps_args.push_back(mystrdup("-suffix")); + lammps_args.push_back(mystrdup("intel")); + lammps_args.push_back(mystrdup("-pk")); + lammps_args.push_back(mystrdup("intel")); + lammps_args.push_back(mystrdup(std::to_string(nthreads))); + } else if (accel == AcceleratorTab::Gpu) { + lammps_args.push_back(mystrdup("-suffix")); + lammps_args.push_back(mystrdup("gpu")); + lammps_args.push_back(mystrdup("-pk")); + lammps_args.push_back(mystrdup("gpu")); + lammps_args.push_back(mystrdup("0")); + } else if (accel == AcceleratorTab::Kokkos) { + lammps_args.push_back(mystrdup("-kokkos")); + lammps_args.push_back(mystrdup("on")); + lammps_args.push_back(mystrdup("t")); + lammps_args.push_back(mystrdup(std::to_string(nthreads))); + lammps_args.push_back(mystrdup("-suffix")); + lammps_args.push_back(mystrdup("kk")); + } + if (settings.value("echo", "0").toInt()) { + lammps_args.push_back(mystrdup("-echo")); + lammps_args.push_back(mystrdup("screen")); + } + if (settings.value("cite", "0").toInt()) { + lammps_args.push_back(mystrdup("-cite")); + lammps_args.push_back(mystrdup("screen")); + } + + char **args = lammps_args.data(); + int narg = lammps_args.size(); + lammps.open(narg, args); + + // delete additional arguments again (3 were there initially + while (lammps_args.size() > initial_narg) { + delete lammps_args.back(); + lammps_args.pop_back(); + } + + if (lammps.has_error()) { + constexpr int BUFLEN = 1024; + char errorbuf[BUFLEN]; + lammps.get_last_error_message(errorbuf, BUFLEN); + + QMessageBox::critical(this, "LAMMPS-GUI Error", + QString("Error launching LAMMPS:\n\n") + errorbuf); + } +} + +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/lammpsgui.h b/tools/lammps-gui/lammpsgui.h new file mode 100644 index 0000000000..78e518609e --- /dev/null +++ b/tools/lammps-gui/lammpsgui.h @@ -0,0 +1,105 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +#ifndef LAMMPSGUI_H +#define LAMMPSGUI_H + +#include + +#include +#include +#include + +#include "lammpswrapper.h" + +// forward declarations + +QT_BEGIN_NAMESPACE +namespace Ui { +class LammpsGui; +} +QT_END_NAMESPACE + +class QLabel; +class QPlainTextEdit; +class QProgressBar; +class QTimer; + +class Highlighter; +class StdCapture; +class Preferences; +class ImageViewer; + +class LammpsGui : public QMainWindow { + Q_OBJECT + + friend class CodeEditor; + +public: + LammpsGui(QWidget *parent = nullptr, const char *filename = nullptr); + ~LammpsGui() override; + +protected: + void open_file(const QString &filename); + void write_file(const QString &filename); + void start_lammps(); + void run_done(); + +private slots: + void new_document(); + void open(); + void save(); + void save_as(); + void quit(); + void copy(); + void cut(); + void paste(); + void undo(); + void redo(); + void clear(); + void run_buffer(); + void stop_run(); + void view_image(); + void about(); + void help(); + void manual(); + void logupdate(); + void modified(); + void preferences(); + void defaults(); + +private: + Ui::LammpsGui *ui; + Highlighter *highlighter; + StdCapture *capturer; + QLabel *status; + QPlainTextEdit *logwindow; + ImageViewer *imagewindow; + QTimer *logupdater; + QLabel *dirstatus; + QProgressBar *progress; + Preferences *prefdialog; + + QString current_file; + QString current_dir; + LammpsWrapper lammps; + std::string plugin_path; + bool is_running; + QList recent_files; + std::vector lammps_args; +}; +#endif // LAMMPSGUI_H + +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/lammpsgui.qrc b/tools/lammps-gui/lammpsgui.qrc new file mode 100644 index 0000000000..391ebcc5d1 --- /dev/null +++ b/tools/lammps-gui/lammpsgui.qrc @@ -0,0 +1,6 @@ + + + DejaVuSansMono.ttf + lammps-icon-128x128.png + + diff --git a/tools/lammps-gui/lammpsgui.ui b/tools/lammps-gui/lammpsgui.ui new file mode 100644 index 0000000000..cc8f6fad50 --- /dev/null +++ b/tools/lammps-gui/lammpsgui.ui @@ -0,0 +1,364 @@ + + + LammpsGui + + + + 0 + 0 + 600 + 400 + + + + LammpsGui + + + + + + + true + + + true + + + + + + + + + 0 + 0 + 600 + 23 + + + + + &File + + + + + + + + + + + + &Edit + + + + + + + + + + + + + + &Run + + + + + + + + + &About + + + + + + + + + + + + + + + .. + + + &New + + + Start a New Input File + + + Start a New Input File + + + Ctrl+N + + + + + + .. + + + &Open + + + Open an Input File + + + Open an Input File + + + Ctrl+O + + + + + + .. + + + &Save + + + Save Input File + + + Save Input File + + + Ctrl+S + + + + + + .. + + + Save &As + + + Save Input File As... + + + Save Input File As... + + + Ctrl+Shift+S + + + + + + .. + + + &Quit + + + Quit LAMMPS-GUI + + + Quit LAMMPS-GUI + + + Ctrl+Q + + + + + + .. + + + Cu&t + + + Cut Selected Text to Clipboard + + + Ctrl+X + + + + + + .. + + + &Copy + + + Copy Selected Text to Clipboard + + + Ctrl+C + + + + + + .. + + + &Paste + + + Paste Text from Clipboard + + + Ctrl+V + + + + + + .. + + + &Undo + + + Undo Edit + + + Ctrl+Z + + + + + + .. + + + &Redo + + + Redo Edit + + + Ctrl+Shift+Z + + + + + + .. + + + &Run LAMMPS + + + Run LAMMPS with Input + + + Ctrl+Return + + + + + + .. + + + &Stop LAMMPS + + + Stop LAMMPS Process + + + Ctrl+/ + + + + + + .. + + + &View Snapshot + + + View Snapshot of current LAMMPS state + + + Ctrl+I + + + + + + .. + + + &About LAMMPS-GUI + + + About LAMMPS-GUI + + + + + + .. + + + Quick &Help + + + Quick Help + + + Ctrl+Shift+/ + + + + + + .. + + + Pre&ferences... + + + Ctrl+P + + + + + + .. + + + LAMMPS &Manual + + + + + + + + Reset to &Defaults + + + + + + CodeEditor + QPlainTextEdit +
codeeditor.h
+
+
+ + +
diff --git a/tools/lammps-gui/lammpsrunner.h b/tools/lammps-gui/lammpsrunner.h new file mode 100644 index 0000000000..a8cd6a1502 --- /dev/null +++ b/tools/lammps-gui/lammpsrunner.h @@ -0,0 +1,54 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +#ifndef LAMMPSRUNNER_H +#define LAMMPSRUNNER_H + +#include + +class LammpsRunner : public QThread { + Q_OBJECT + +public: + LammpsRunner(QObject *parent = nullptr) : QThread(parent), lammps(nullptr), input(nullptr) {} + ~LammpsRunner() = default; + +public: + // execute LAMMPS in runner thread + void run() override + { + lammps->command("clear"); + lammps->commands_string(input); + delete[] input; + emit resultReady(); + } + + // transfer info to worker thread + void setup_run(LammpsWrapper *_lammps, const char *_input) + { + lammps = _lammps; + input = _input; + } + +signals: + void resultReady(); + +private: + LammpsWrapper *lammps; + const char *input; +}; + +#endif +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/lammpswrapper.cpp b/tools/lammps-gui/lammpswrapper.cpp new file mode 100644 index 0000000000..3292217d77 --- /dev/null +++ b/tools/lammps-gui/lammpswrapper.cpp @@ -0,0 +1,215 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "lammpswrapper.h" + +#if defined(LAMMPS_GUI_USE_PLUGIN) +#include "liblammpsplugin.h" +#else +#include "library.h" +#endif + +LammpsWrapper::LammpsWrapper() : lammps_handle(nullptr), plugin_handle(nullptr) {} + +void LammpsWrapper::open(int narg, char **args) +{ + if (!lammps_handle) { +#if defined(LAMMPS_GUI_USE_PLUGIN) + lammps_handle = ((liblammpsplugin_t *)plugin_handle)->open_no_mpi(narg, args, nullptr); +#else + lammps_handle = lammps_open_no_mpi(narg, args, nullptr); +#endif + } +} + +int LammpsWrapper::extract_setting(const char *keyword) +{ + int val = 0; + if (lammps_handle) { +#if defined(LAMMPS_GUI_USE_PLUGIN) + val = ((liblammpsplugin_t *)plugin_handle)->extract_setting(lammps_handle, keyword); +#else + val = lammps_extract_setting(lammps_handle, keyword); +#endif + } + return val; +} + +double LammpsWrapper::get_thermo(const char *keyword) +{ + double val = 0.0; + if (lammps_handle) { +#if defined(LAMMPS_GUI_USE_PLUGIN) + val = ((liblammpsplugin_t *)plugin_handle)->get_thermo(lammps_handle, keyword); +#else + val = lammps_get_thermo(lammps_handle, keyword); +#endif + } + return val; +} + +bool LammpsWrapper::is_running() +{ + int val = 0; + if (lammps_handle) { +#if defined(LAMMPS_GUI_USE_PLUGIN) + val = ((liblammpsplugin_t *)plugin_handle)->is_running(lammps_handle); +#else + val = lammps_is_running(lammps_handle); +#endif + } + return val != 0; +} + +void LammpsWrapper::command(const char *input) +{ + if (lammps_handle) { +#if defined(LAMMPS_GUI_USE_PLUGIN) + ((liblammpsplugin_t *)plugin_handle)->command(lammps_handle, input); +#else + lammps_command(lammps_handle, input); +#endif + } +} + +void LammpsWrapper::commands_string(const char *input) +{ + if (lammps_handle) { +#if defined(LAMMPS_GUI_USE_PLUGIN) + ((liblammpsplugin_t *)plugin_handle)->commands_string(lammps_handle, input); +#else + lammps_commands_string(lammps_handle, input); +#endif + } +} + +// may be called with null handle. returns global error then. +bool LammpsWrapper::has_error() const +{ +#if defined(LAMMPS_GUI_USE_PLUGIN) + return ((liblammpsplugin_t *)plugin_handle)->has_error(lammps_handle) != 0; +#else + return lammps_has_error(lammps_handle) != 0; +#endif +} + +int LammpsWrapper::get_last_error_message(char *buf, int buflen) +{ +#if defined(LAMMPS_GUI_USE_PLUGIN) + return ((liblammpsplugin_t *)plugin_handle)->get_last_error_message(lammps_handle, buf, buflen); +#else + return lammps_get_last_error_message(lammps_handle, buf, buflen); +#endif +} + +void LammpsWrapper::force_timeout() +{ +#if defined(LAMMPS_GUI_USE_PLUGIN) + ((liblammpsplugin_t *)plugin_handle)->force_timeout(lammps_handle); +#else + lammps_force_timeout(lammps_handle); +#endif +} + +void LammpsWrapper::close() +{ +#if defined(LAMMPS_GUI_USE_PLUGIN) + if (lammps_handle) ((liblammpsplugin_t *)plugin_handle)->close(lammps_handle); +#else + if (lammps_handle) lammps_close(lammps_handle); +#endif + lammps_handle = nullptr; +} + +void LammpsWrapper::finalize() +{ +#if defined(LAMMPS_GUI_USE_PLUGIN) + if (lammps_handle) { + liblammpsplugin_t *lammps = (liblammpsplugin_t *)plugin_handle; + lammps->close(lammps_handle); + lammps->mpi_finalize(); + lammps->kokkos_finalize(); + lammps->python_finalize(); + } +#else + if (lammps_handle) { + lammps_close(lammps_handle); + lammps_mpi_finalize(); + lammps_kokkos_finalize(); + lammps_python_finalize(); + } +#endif +} + +bool LammpsWrapper::config_has_package(const char *package) const +{ +#if defined(LAMMPS_GUI_USE_PLUGIN) + return ((liblammpsplugin_t *)plugin_handle)->config_has_package(package) != 0; +#else + return lammps_config_has_package(package) != 0; +#endif +} + +bool LammpsWrapper::config_accelerator(const char *package, const char *category, + const char *setting) const +{ +#if defined(LAMMPS_GUI_USE_PLUGIN) + return ((liblammpsplugin_t *)plugin_handle)->config_accelerator(package, category, setting) != + 0; +#else + return lammps_config_accelerator(package, category, setting) != 0; +#endif +} + +bool LammpsWrapper::has_gpu_device() const +{ +#if defined(LAMMPS_GUI_USE_PLUGIN) + return ((liblammpsplugin_t *)plugin_handle)->has_gpu_device() != 0; +#else + return lammps_has_gpu_device() != 0; +#endif +} + +#if defined(LAMMPS_GUI_USE_PLUGIN) +bool LammpsWrapper::has_plugin() const +{ + return true; +} + +bool LammpsWrapper::load_lib(const char *libfile) +{ + if (plugin_handle) liblammpsplugin_release((liblammpsplugin_t *)plugin_handle); + plugin_handle = liblammpsplugin_load(libfile); + if (!plugin_handle) return false; + if (((liblammpsplugin_t *)plugin_handle)->abiversion != LAMMPSPLUGIN_ABI_VERSION) { + liblammpsplugin_release((liblammpsplugin_t *)plugin_handle); + plugin_handle = nullptr; + return false; + } + return true; +} +#else +bool LammpsWrapper::has_plugin() const +{ + return false; +} + +bool LammpsWrapper::load_lib(const char *) +{ + return true; +} +#endif + +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/lammpswrapper.h b/tools/lammps-gui/lammpswrapper.h new file mode 100644 index 0000000000..db8a0ba3d6 --- /dev/null +++ b/tools/lammps-gui/lammpswrapper.h @@ -0,0 +1,52 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +#ifndef LAMMPSWRAPPER_H +#define LAMMPSWRAPPER_H + +class LammpsWrapper { +public: + LammpsWrapper(); + +public: + void open(int nargs, char **args); + void close(); + void finalize(); + + void command(const char *); + void commands_string(const char *); + + void force_timeout(); + + int extract_setting(const char *keyword); + double get_thermo(const char *keyword); + bool is_open() const { return lammps_handle != nullptr; } + bool is_running(); + bool has_error() const; + int get_last_error_message(char *errorbuf, int buflen); + bool config_accelerator(const char *package, const char *category, const char *setting) const; + bool config_has_package(const char *pkg) const; + bool has_gpu_device() const; + + bool load_lib(const char *lammpslib); + bool has_plugin() const; + +private: + void *lammps_handle; + void *plugin_handle; +}; +#endif + +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/linenumberarea.h b/tools/lammps-gui/linenumberarea.h new file mode 100644 index 0000000000..2b8bb3bc55 --- /dev/null +++ b/tools/lammps-gui/linenumberarea.h @@ -0,0 +1,35 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +#ifndef LINENUMBERAREA_H +#define LINENUMBERAREA_H + +#include "codeeditor.h" +#include + +class LineNumberArea : public QWidget { +public: + LineNumberArea(CodeEditor *editor) : QWidget(editor), codeEditor(editor) {} + + QSize sizeHint() const override { return QSize(codeEditor->lineNumberAreaWidth(), 0); } + +protected: + void paintEvent(QPaintEvent *event) override { codeEditor->lineNumberAreaPaintEvent(event); } + +private: + CodeEditor *codeEditor; +}; +#endif +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/main.cpp b/tools/lammps-gui/main.cpp new file mode 100644 index 0000000000..bdd3885492 --- /dev/null +++ b/tools/lammps-gui/main.cpp @@ -0,0 +1,32 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "lammpsgui.h" + +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + + const char *infile = nullptr; + if (argc > 1) infile = argv[1]; + + LammpsGui w(nullptr, infile); + w.show(); + return a.exec(); +} + +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/preferences.cpp b/tools/lammps-gui/preferences.cpp new file mode 100644 index 0000000000..628a50a11a --- /dev/null +++ b/tools/lammps-gui/preferences.cpp @@ -0,0 +1,319 @@ +/* ---------------------------------------------------------------------- + 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. +------------------------------------------------------------------------- */ + +#include "preferences.h" + +#include "lammpswrapper.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(_OPENMP) +#include +#endif + +Preferences::Preferences(LammpsWrapper *_lammps, QWidget *parent) : + QDialog(parent), tabWidget(new QTabWidget), + buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel)), + settings(new QSettings), lammps(_lammps) +{ + tabWidget->addTab(new GeneralTab(settings, lammps), "&General Settings"); + tabWidget->addTab(new AcceleratorTab(settings, lammps), "&Accelerators"); + tabWidget->addTab(new SnapshotTab(settings), "&Snapshot Image"); + + connect(buttonBox, &QDialogButtonBox::accepted, this, &Preferences::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + auto *layout = new QVBoxLayout; + layout->addWidget(tabWidget); + layout->addWidget(buttonBox); + setLayout(layout); + setWindowTitle("LAMMPS-GUI - Preferences"); + resize(500, 400); +} + +Preferences::~Preferences() +{ + delete buttonBox; + delete tabWidget; + delete settings; +} + +void Preferences::accept() +{ + // store all data in settings class + // and then confirm accepting + + // store selected accelerator + QList allButtons = tabWidget->findChildren(); + for (int i = 0; i < allButtons.size(); ++i) { + if (allButtons[i]->isChecked()) { + if (allButtons[i]->objectName() == "none") + settings->setValue("accelerator", QString::number(AcceleratorTab::None)); + if (allButtons[i]->objectName() == "opt") + settings->setValue("accelerator", QString::number(AcceleratorTab::Opt)); + if (allButtons[i]->objectName() == "openmp") + settings->setValue("accelerator", QString::number(AcceleratorTab::OpenMP)); + if (allButtons[i]->objectName() == "intel") + settings->setValue("accelerator", QString::number(AcceleratorTab::Intel)); + if (allButtons[i]->objectName() == "kokkos") + settings->setValue("accelerator", QString::number(AcceleratorTab::Kokkos)); + if (allButtons[i]->objectName() == "gpu") + settings->setValue("accelerator", QString::number(AcceleratorTab::Gpu)); + } + } + + // store number of threads + QLineEdit *field = tabWidget->findChild("nthreads"); + if (field) + if (field->hasAcceptableInput()) settings->setValue("nthreads", field->text()); + + // store image width, height, and zoom + + settings->beginGroup("snapshot"); + field = tabWidget->findChild("xsize"); + if (field) + if (field->hasAcceptableInput()) settings->setValue("xsize", field->text()); + field = tabWidget->findChild("ysize"); + if (field) + if (field->hasAcceptableInput()) settings->setValue("ysize", field->text()); + field = tabWidget->findChild("zoom"); + if (field) + if (field->hasAcceptableInput()) settings->setValue("zoom", field->text()); + settings->endGroup(); + + // general settings + QCheckBox *box = tabWidget->findChild("echo"); + if (box) settings->setValue("echo", box->isChecked() ? "1" : "0"); + box = tabWidget->findChild("cite"); + if (box) settings->setValue("cite", box->isChecked() ? "1" : "0"); + + QDialog::accept(); +} + +GeneralTab::GeneralTab(QSettings *_settings, LammpsWrapper *_lammps, QWidget *parent) : + QWidget(parent), settings(_settings), lammps(_lammps) +{ + auto *layout = new QVBoxLayout; + + auto *echo = new QCheckBox("Echo input to log"); + echo->setCheckState(settings->value("echo", "0").toInt() ? Qt::Checked : Qt::Unchecked); + echo->setObjectName("echo"); + auto *cite = new QCheckBox("Include Citations"); + cite->setCheckState(settings->value("cite", "0").toInt() ? Qt::Checked : Qt::Unchecked); + cite->setObjectName("cite"); +#if !defined(__APPLE__) + auto *tmplabel = new QLabel("Scratch Folder:"); + auto *tmpedit = new QLineEdit(settings->value("tempdir", ".").toString()); + auto *tmpbrowse = new QPushButton("Browse..."); + auto *tmplayout = new QHBoxLayout; + tmpedit->setObjectName("tmpedit"); + tmplayout->addWidget(tmplabel); + tmplayout->addWidget(tmpedit); + tmplayout->addWidget(tmpbrowse); +#endif + +#if defined(LAMMPS_GUI_USE_PLUGIN) + auto *pluginlabel = new QLabel("Path to LAMMPS Shared Library File:"); + auto *pluginedit = + new QLineEdit(settings->value("plugin_path", "liblammpsplugin.so").toString()); + auto *pluginbrowse = new QPushButton("Browse..."); + auto *pluginlayout = new QHBoxLayout; + pluginedit->setObjectName("pluginedit"); + pluginlayout->addWidget(pluginedit); + pluginlayout->addWidget(pluginbrowse); + + connect(pluginbrowse, &QPushButton::released, this, &GeneralTab::pluginpath); +#endif + layout->addWidget(echo); + layout->addWidget(cite); +#if !defined(__APPLE__) + layout->addLayout(tmplayout); +#endif +#if defined(LAMMPS_GUI_USE_PLUGIN) + layout->addWidget(pluginlabel); + layout->addLayout(pluginlayout); +#endif + layout->addStretch(1); + setLayout(layout); +} + +void GeneralTab::newtmpfolder() +{ + QLineEdit *field = findChild("tmpedit"); + QString tmpdir = + QFileDialog::getExistingDirectory(this, "Find Folder for Temporary Files", field->text()); + if (!tmpdir.isEmpty()) field->setText(tmpdir); +} + +void GeneralTab::pluginpath() +{ + QLineEdit *field = findChild("pluginedit"); + QString pluginfile = + QFileDialog::getOpenFileName(this, "Select Shared LAMMPS Library to Load", field->text(), + "Shared Objects (*.so *.dll *.dylib)"); + if (!pluginfile.isEmpty() && pluginfile.contains("liblammps", Qt::CaseSensitive)) { + if (lammps->load_lib(pluginfile.toStdString().c_str())) { + auto canonical = QFileInfo(pluginfile).canonicalFilePath(); + field->setText(pluginfile); + settings->setValue("plugin_path", canonical); + } else { + // plugin did not load cannot continue + settings->remove("plugin_path"); + QMessageBox::critical(this, "Error", "Cannot open LAMMPS shared library file"); + QCoreApplication::quit(); + } + } +} + +AcceleratorTab::AcceleratorTab(QSettings *_settings, LammpsWrapper *_lammps, QWidget *parent) : + QWidget(parent), settings(_settings), lammps(_lammps) +{ + auto *mainLayout = new QHBoxLayout; + auto *accelerator = new QGroupBox("Choose Accelerator:"); + auto *none = new QRadioButton("&None"); + auto *opt = new QRadioButton("O&pt"); + auto *openmp = new QRadioButton("&OpenMP"); + auto *intel = new QRadioButton("&Intel"); + auto *kokkos = new QRadioButton("&Kokkos"); + auto *gpu = new QRadioButton("&GPU"); + + auto *buttonLayout = new QVBoxLayout; + buttonLayout->addWidget(none); + buttonLayout->addWidget(opt); + buttonLayout->addWidget(openmp); + buttonLayout->addWidget(intel); + buttonLayout->addWidget(kokkos); + buttonLayout->addWidget(gpu); + buttonLayout->addStretch(1); + accelerator->setLayout(buttonLayout); + mainLayout->addWidget(accelerator); + + none->setEnabled(true); + none->setObjectName("none"); + opt->setEnabled(lammps->config_has_package("OPT")); + opt->setObjectName("opt"); + openmp->setEnabled(lammps->config_has_package("OPENMP")); + openmp->setObjectName("openmp"); + intel->setEnabled(lammps->config_has_package("INTEL")); + intel->setObjectName("intel"); + // Kokkos support only works with OpenMP for now. + kokkos->setEnabled(false); + if (lammps->config_has_package("KOKKOS")) { + if (lammps->config_accelerator("KOKKOS", "api", "openmp") && + !(lammps->config_accelerator("KOKKOS", "api", "cuda") || + lammps->config_accelerator("KOKKOS", "api", "hip") || + lammps->config_accelerator("KOKKOS", "api", "sycl"))) + kokkos->setEnabled(true); + } + kokkos->setObjectName("kokkos"); + gpu->setEnabled(lammps->config_has_package("GPU") && lammps->has_gpu_device()); + gpu->setObjectName("gpu"); + + int choice = settings->value("accelerator", AcceleratorTab::None).toInt(); + switch (choice) { + case AcceleratorTab::Opt: + if (opt->isEnabled()) opt->setChecked(true); + break; + case AcceleratorTab::OpenMP: + if (openmp->isEnabled()) openmp->setChecked(true); + break; + case AcceleratorTab::Intel: + if (intel->isEnabled()) intel->setChecked(true); + break; + case AcceleratorTab::Kokkos: + if (kokkos->isEnabled()) kokkos->setChecked(true); + break; + case AcceleratorTab::Gpu: + if (gpu->isEnabled()) gpu->setChecked(true); + break; + case AcceleratorTab::None: // fallthrough + default: + none->setChecked(true); + break; + } + + int maxthreads = 1; +#if defined(_OPENMP) + maxthreads = omp_get_max_threads(); +#endif + auto *choices = new QFrame; + auto *choiceLayout = new QVBoxLayout; + auto *ntlabel = new QLabel("Number of threads:"); + auto *ntchoice = new QLineEdit(settings->value("nthreads", maxthreads).toString()); + auto *intval = new QIntValidator(1, maxthreads, this); + ntchoice->setValidator(intval); + ntchoice->setObjectName("nthreads"); + + choiceLayout->addWidget(ntlabel); + choiceLayout->addWidget(ntchoice); + choices->setLayout(choiceLayout); + choiceLayout->addStretch(1); + + mainLayout->addWidget(choices); + setLayout(mainLayout); +} + +SnapshotTab::SnapshotTab(QSettings *_settings, QWidget *parent) : + QWidget(parent), settings(_settings) +{ + auto *grid = new QGridLayout; + + auto *xsize = new QLabel("Image width:"); + auto *ysize = new QLabel("Image height:"); + auto *zoom = new QLabel("Zoom factor:"); + settings->beginGroup("snapshot"); + auto *xval = new QLineEdit(settings->value("xsize", "800").toString()); + auto *yval = new QLineEdit(settings->value("ysize", "600").toString()); + auto *zval = new QLineEdit(settings->value("zoom", "1.0").toString()); + settings->endGroup(); + + auto *intval = new QIntValidator(100, 100000, this); + xval->setValidator(intval); + xval->setObjectName("xsize"); + yval->setValidator(intval); + yval->setObjectName("ysize"); + zval->setValidator(new QDoubleValidator(0.01, 100.0, 100, this)); + zval->setObjectName("zoom"); + + grid->addWidget(xsize, 0, 0, Qt::AlignTop); + grid->addWidget(ysize, 1, 0, Qt::AlignTop); + grid->addWidget(zoom, 2, 0, Qt::AlignTop); + grid->addWidget(xval, 0, 1, Qt::AlignTop); + grid->addWidget(yval, 1, 1, Qt::AlignTop); + grid->addWidget(zval, 2, 1, Qt::AlignTop); + grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), 3, 0); + grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Minimum, QSizePolicy::Expanding), 3, 1); + grid->addItem(new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding), 3, 2); + setLayout(grid); +} + +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/preferences.h b/tools/lammps-gui/preferences.h new file mode 100644 index 0000000000..46a512772a --- /dev/null +++ b/tools/lammps-gui/preferences.h @@ -0,0 +1,84 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +#ifndef PREFERENCES_H +#define PREFERENCES_H + +#include + +class QDialogButtonBox; +class QSettings; +class QTabWidget; +class LammpsWrapper; + +class Preferences : public QDialog { + Q_OBJECT + +public: + explicit Preferences(LammpsWrapper *lammps, QWidget *parent = nullptr); + ~Preferences() override; + +private slots: + void accept() override; + +private: + QTabWidget *tabWidget; + QDialogButtonBox *buttonBox; + QSettings *settings; + LammpsWrapper *lammps; +}; + +// individual tabs + +class GeneralTab : public QWidget { + Q_OBJECT + +public: + explicit GeneralTab(QSettings *settings, LammpsWrapper *lammps, QWidget *parent = nullptr); + +private slots: + void pluginpath(); + void newtmpfolder(); + +private: + QSettings *settings; + LammpsWrapper *lammps; +}; + +class AcceleratorTab : public QWidget { + Q_OBJECT + +public: + explicit AcceleratorTab(QSettings *settings, LammpsWrapper *lammps, QWidget *parent = nullptr); + enum { None, Opt, OpenMP, Intel, Kokkos, Gpu }; + +private: + QSettings *settings; + LammpsWrapper *lammps; +}; + +class SnapshotTab : public QWidget { + Q_OBJECT + +public: + explicit SnapshotTab(QSettings *settings, QWidget *parent = nullptr); + +private: + QSettings *settings; +}; + +#endif + +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/stdcapture.cpp b/tools/lammps-gui/stdcapture.cpp new file mode 100644 index 0000000000..428277cc10 --- /dev/null +++ b/tools/lammps-gui/stdcapture.cpp @@ -0,0 +1,136 @@ +/* ---------------------------------------------------------------------- + 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. + ------------------------------------------------------------------------- */ + +// adapted from: https://stackoverflow.com/questions/5419356/redirect-stdout-stderr-to-a-string + +#include "stdcapture.h" + +#ifdef _WIN32 +#include +#define popen _popen +#define pclose _pclose +#define stat _stat +#define dup _dup +#define dup2 _dup2 +#define fileno _fileno +#define close _close +#define read _read +#define eof _eof +#else +#include +#endif + +#include +#include +#include +#include + +StdCapture::StdCapture() : m_oldStdOut(0), m_capturing(false) +{ + // make stdout unbuffered so that we don't need to flush the stream + setvbuf(stdout, NULL, _IONBF, 0); + + m_pipe[READ] = 0; + m_pipe[WRITE] = 0; +#if _WIN32 + if (_pipe(m_pipe, 65536, O_BINARY) == -1) return; +#else + if (pipe(m_pipe) == -1) return; + fcntl(m_pipe[READ], F_SETFL, fcntl(m_pipe[READ], F_GETFL) | O_NONBLOCK); +#endif + m_oldStdOut = dup(fileno(stdout)); + if (m_oldStdOut == -1) return; +} + +StdCapture::~StdCapture() +{ + if (m_capturing) { + EndCapture(); + } + if (m_oldStdOut > 0) close(m_oldStdOut); + if (m_pipe[READ] > 0) close(m_pipe[READ]); + if (m_pipe[WRITE] > 0) close(m_pipe[WRITE]); +} + +void StdCapture::BeginCapture() +{ + if (m_capturing) EndCapture(); + dup2(m_pipe[WRITE], fileno(stdout)); + m_capturing = true; +} + +bool StdCapture::EndCapture() +{ + if (!m_capturing) return false; + dup2(m_oldStdOut, fileno(stdout)); + m_captured.clear(); + + int bytesRead; + bool fd_blocked; + + do { + bytesRead = 0; + fd_blocked = false; + +#ifdef _WIN32 + if (!eof(m_pipe[READ])) { + bytesRead = read(m_pipe[READ], buf, bufSize - 1); + } +#else + bytesRead = read(m_pipe[READ], buf, bufSize - 1); +#endif + if (bytesRead > 0) { + buf[bytesRead] = 0; + m_captured += buf; + } else if (bytesRead < 0) { + fd_blocked = ((errno == EAGAIN) || (errno == EWOULDBLOCK) || (errno == EINTR)); + + if (fd_blocked) std::this_thread::sleep_for(std::chrono::milliseconds(10)); + } + } while (fd_blocked || (bytesRead == (bufSize - 1))); + m_capturing = false; + return true; +} + +std::string StdCapture::GetChunk() +{ + if (!m_capturing) return std::string(); + int bytesRead = 0; + buf[0] = '\0'; + +#ifdef _WIN32 + if (!eof(m_pipe[READ])) { + bytesRead = read(m_pipe[READ], buf, bufSize - 1); + } +#else + bytesRead = read(m_pipe[READ], buf, bufSize - 1); +#endif + if (bytesRead > 0) { + buf[bytesRead] = '\0'; + } + return std::string(buf); +} + +std::string StdCapture::GetCapture() +{ + std::string::size_type idx = m_captured.find_last_not_of("\r\n"); + if (idx == std::string::npos) { + return m_captured; + } else { + return m_captured.substr(0, idx + 1); + } +} + +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/lammps-gui/stdcapture.h b/tools/lammps-gui/stdcapture.h new file mode 100644 index 0000000000..ee8bb44dd3 --- /dev/null +++ b/tools/lammps-gui/stdcapture.h @@ -0,0 +1,44 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +#ifndef STDCAPTURE_H +#define STDCAPTURE_H + +#include + +class StdCapture { +public: + StdCapture(); + virtual ~StdCapture(); + + void BeginCapture(); + bool EndCapture(); + std::string GetCapture(); + std::string GetChunk(); + +private: + enum PIPES { READ, WRITE }; + int m_pipe[2]; + int m_oldStdOut; + bool m_capturing; + bool m_init; + std::string m_captured; + + static constexpr int bufSize = 1025; + char buf[bufSize]; +}; + +#endif +// Local Variables: +// c-basic-offset: 4 +// End: diff --git a/tools/phonon/CMakeLists.txt b/tools/phonon/CMakeLists.txt index 60da1cc79f..f3c3b8386c 100644 --- a/tools/phonon/CMakeLists.txt +++ b/tools/phonon/CMakeLists.txt @@ -85,6 +85,7 @@ if(USE_SPGLIB) include(LAMMPSUtils) GetFallbackURL(SPGLIB_URL SPGLIB_FALLBACK) + string(REPLACE ";" "$" CMAKE_OSX_ARCHITECTURES_ "${CMAKE_OSX_ARCHITECTURES}") include(ExternalProject) ExternalProject_Add(spglib_build URL ${SPGLIB_URL} ${SPGLIB_FALLBACK} @@ -96,6 +97,8 @@ if(USE_SPGLIB) -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES_} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} UPDATE_COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.spglib ${CMAKE_CURRENT_BINARY_DIR}/spglib_build_ext/src/spglib_build/CMakeLists.txt INSTALL_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/spglib_build_ext/src/spglib_build-build --target install BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/spglib_build_ext/lib/${CMAKE_STATIC_LIBRARY_PREFIX}symspg${CMAKE_STATIC_LIBRARY_SUFFIX}" diff --git a/tools/vim/lammps.vim b/tools/vim/lammps.vim index 008ae1ee3f..25c18f4a9c 100644 --- a/tools/vim/lammps.vim +++ b/tools/vim/lammps.vim @@ -1,31 +1,35 @@ " Vim syntax file -" Language: Lammps Simulation Script File +" Language: Lammps Simulation Script File " Maintainer: Gerolf Ziegenhain " Updates: Axel Kohlmeyer , Sam Bateman , Daniel Möller Montull , Eryk Skalinski -" Latest Revision: 2022-08-17 +" Latest Revision: 2023-07-15 syn clear -syn keyword lammpsOutput log write_data write_dump info shell write_restart restart dump undump thermo thermo_modify thermo_style print timer +" Add '/' to list of valid keyword characters +set iskeyword+=/ + +syn keyword lammpsOutput log write_data write_dump write_coeff info shell write_restart restart dump undump thermo thermo_modify +syn keyword lammpsOutput thermo_style print timer syn keyword lammpsRead include read_restart read_data read_dump molecule syn keyword lammpsLattice boundary units atom_style lattice region create_box create_atoms dielectric syn keyword lammpsLattice delete_atoms displace_atoms change_box dimension replicate -syn keyword lammpsParticle pair_coeff pair_style pair_modify pair_write mass velocity angle_coeff angle_style +syn keyword lammpsParticle pair_coeff pair_style pair_modify pair_write mass velocity angle_coeff angle_style angle_write syn keyword lammpsParticle atom_modify atom_style bond_coeff bond_style bond_write create_bonds delete_bonds kspace_style -syn keyword lammpsParticle kspace_modify dihedral_style dihedral_coeff improper_style improper_coeff -syn keyword lammpsSetup min_style fix_modify run_style timestep neighbor neigh_modify fix unfix suffix special_bonds -syn keyword lammpsSetup balance box clear comm_modify comm_style newton package processors reset_ids reset_timestep -syn keyword lammpsRun minimize run rerun tad neb prd quit server temper temper/grem temper/npt -syn keyword lammpsRun min/spin message hyper dynamical_matrix -syn keyword lammpsDefine variable group compute python set uncompute kim_query +syn keyword lammpsParticle kspace_modify dihedral_style dihedral_coeff dihedral_write improper_style improper_coeff labelmap +syn keyword lammpsSetup min_style min_modify fix_modify run_style timestep neighbor neigh_modify fix unfix suffix special_bonds dump_modify +syn keyword lammpsSetup balance box clear comm_modify comm_style newton package processors reset_atoms reset_ids reset_timestep +syn keyword lammpsRun minimize minimize/kk run rerun tad neb neb/spin prd quit server temper/npt temper/grem temper +syn keyword lammpsRun message hyper dynamical_matrix dynamical_matrix/kk third_order third_order/kk fitpod +syn keyword lammpsDefine variable group compute python set uncompute kim_query kim group2ndx ndx2group mdi -syn keyword lammpsRepeat jump next loop +syn keyword lammpsRepeat jump next loop label syn keyword lammpsOperator equal add sub mult div syn keyword lammpsConditional if then elif else -syn keyword lammpsSpecial EDGE NULL & +syn keyword lammpsSpecial EDGE NULL INF & syn region lammpsString start=+'+ end=+'+ oneline syn region lammpsString start=+"+ end=+"+ oneline diff --git a/unittest/force-styles/CMakeLists.txt b/unittest/force-styles/CMakeLists.txt index dfffdfea0c..ac5cd7dfd7 100644 --- a/unittest/force-styles/CMakeLists.txt +++ b/unittest/force-styles/CMakeLists.txt @@ -199,6 +199,9 @@ add_executable(test_fix_timestep test_fix_timestep.cpp) if(NOT BUILD_SHARED_LIBS) target_compile_definitions(test_fix_timestep PRIVATE USING_STATIC_LIBS=1) endif() +if(FFT_SINGLE) + target_compile_definitions(test_fix_timestep PRIVATE -DFFT_SINGLE) +endif() target_link_libraries(test_fix_timestep PRIVATE lammps style_tests) # tests for timestep related fixes (time integration, thermostat, force manipulation, constraints/restraints) diff --git a/unittest/force-styles/test_fix_timestep.cpp b/unittest/force-styles/test_fix_timestep.cpp index d2e35b463f..b65eab2049 100644 --- a/unittest/force-styles/test_fix_timestep.cpp +++ b/unittest/force-styles/test_fix_timestep.cpp @@ -279,6 +279,10 @@ TEST(FixTimestep, plain) ASSERT_EQ(lmp->atom->natoms, nlocal); double epsilon = test_config.epsilon; + // relax test precision when using pppm and single precision FFTs +#if defined(FFT_SINGLE) + if (lmp->force->kspace && utils::strmatch(lmp->force->kspace_style, "^pppm")) epsilon *= 2.0e8; +#endif ErrorStats stats; @@ -411,7 +415,6 @@ TEST(FixTimestep, plain) ifix = lmp->modify->find_fix("test"); if (!utils::strmatch(lmp->modify->fix[ifix]->style, "^rigid") && !utils::strmatch(lmp->modify->fix[ifix]->style, "^nve/limit")) { - if (!verbose) ::testing::internal::CaptureStdout(); cleanup_lammps(lmp, test_config); if (!verbose) ::testing::internal::GetCapturedStdout(); @@ -579,6 +582,10 @@ TEST(FixTimestep, omp) ASSERT_EQ(lmp->atom->natoms, nlocal); double epsilon = test_config.epsilon; + // relax test precision when using pppm and single precision FFTs +#if defined(FFT_SINGLE) + if (lmp->force->kspace && utils::strmatch(lmp->force->kspace_style, "^pppm")) epsilon *= 2.0e8; +#endif ErrorStats stats;