Compare commits

...

111 Commits

Author SHA1 Message Date
1651a21f92 Merge pull request #1198 from akohlmey/next-patch-release
Patch release 9 November 2018
2018-11-08 20:49:49 -05:00
cbae3b5afa Merge pull request #1184 from DiscreteLogarithm/sdpd
add USER-SDPD package for Smoothed Dissipative Particle Dynamics
2018-11-08 17:21:21 -05:00
f2a29880e2 patch 9Nov2018 2018-11-08 16:48:43 -05:00
e0955f6434 Merge branch 'master' into sdpd to resolve merge conflicts
# Conflicts:
#	cmake/CMakeLists.txt
#	src/Makefile
2018-11-08 16:32:02 -05:00
3681bc853d Merge pull request #1195 from jrgissing/bond/react-custom_edges
Bond/react: charge update for custom edges
2018-11-08 16:19:23 -05:00
a6e9b99295 Merge pull request #1180 from gtribello/master
Add natively supported PLUMED interface to LAMMPS
2018-11-08 16:16:50 -05:00
893a51ce14 Merge pull request #1191 from akohlmey/msi2lmp-avoid-bad-topology
Dihedral generation bugfix for msi2lmp
2018-11-08 16:10:31 -05:00
80ee08482c Merge pull request #1182 from junghans/pkgconfig_doc
liblammps.pc: add some more documentation
2018-11-08 16:10:15 -05:00
bbb371134d include USER-SDPD package in list of user packages in conventional make 2018-11-06 22:38:02 -05:00
a1e8992eac replace non-ASCII characters 2018-11-06 22:21:19 -05:00
baa7b705b8 improve logic and grammar of error messages 2018-11-06 22:13:38 -05:00
2d12260ade remove bogus single function and set single_enable = 0 2018-11-06 22:13:05 -05:00
31277349c6 remove dead code and avoid compiler warnings 2018-11-06 22:10:27 -05:00
df232c1cf6 use c++ style include files for c-library functions 2018-11-06 22:09:05 -05:00
bdf73f7adb ignore USER-SDPD files when installed 2018-11-06 22:07:35 -05:00
84fcf01bed bond/react: allow custom update of charges near template edges
also, fixes a bug introduced in PR #1189, when not using stabilization
2018-11-06 19:59:22 -07:00
cc0d685e8e Merge pull request #32 from lammps/master
rebase
2018-11-06 19:52:08 -07:00
5196fa37e0 Merge pull request #1194 from ohenrich/user-cgdna
Update reference for USER-CGDNA
2018-11-06 15:52:22 -05:00
4e6253254c Merge branch 'master' into user-cgdna 2018-11-06 19:48:06 +00:00
562296bdb7 Updated link to preprint article 2018-11-06 19:44:35 +00:00
91c4ef6f64 Merge pull request #1189 from jrgissing/bond/react-custom_group
Bond/react custom group support
2018-11-06 10:32:06 -05:00
f46d6a4312 Merge pull request #1192 from julient31/master
update reference for SPIN package
2018-11-06 10:26:27 -05:00
cb828e9579 update reference 2018-11-06 07:48:47 +01:00
ed77701e56 Merge pull request #31 from lammps/master
rebase
2018-11-05 20:25:38 -07:00
7ed6cab040 do not generate illegal dihedrals, e.g. from 3-membered rings 2018-11-05 20:35:43 -05:00
ce7f76de1d cmake: switch plumed to full static mode 2018-11-05 07:39:23 -07:00
58d2f0cc57 cmake: fix linking again plumed 2018-11-05 05:55:31 -07:00
ab7aa9dfda correction to fix group property doc 2018-11-05 00:49:33 -07:00
6d1ea2d0b1 broke smooth restarts at some point. fixed 2018-11-05 00:46:53 -07:00
a3ca177d20 various small changes and reformatting
- add memory usage estimator
- test against varying number of atoms
- test against non-consecutive atom tags
- test for 32-bit overflow in number of atoms
- test for 32-bit overflow in timestep
- reduce tail correction error to warning
- more LAMMPS style formatting of the source code
- remove trailing whitespace
- avoid leaking memory from allocated arrays for masses/charges/tags
2018-11-04 19:52:10 -05:00
a3c0fe7726 Added check on fix modify for PLUMED to ensures that virial is calculated for group all 2018-11-04 11:43:07 +00:00
a051d61e1f Added functionality to support fix modify for fix plumed 2018-11-04 11:24:01 +00:00
8cb665f013 Added functionality to throw error when time step changes and PLUMED is being used 2018-11-04 10:21:28 +00:00
cb8c51e353 Got rid of some of the hard-coded units in the plumed interface 2018-11-03 18:13:28 +00:00
a37d718ed1 update bond/react examples 2018-11-03 12:01:00 -06:00
f7aa01d74a bond/react: convert group-ID to group-ID-prefix
enables consistent syntax when using custom groups
2018-11-03 11:57:46 -06:00
badfdd7433 download only the plumed-src package and include further tweaks to be compatible with plumed 2.5b 2018-11-03 00:21:10 -04:00
ac11d66d5a provide reference logfiles and move generated files to reference folder 2018-11-02 23:28:09 -04:00
18216de084 correctly check for fixes that maintain their own pressure compute 2018-11-02 23:21:09 -04:00
3cb2291a5a need to include comm.h now 2018-11-02 22:52:51 -04:00
54c52c3bdf adjust compilation settings to link in plumed library statically and all its dependencies 2018-11-02 22:52:36 -04:00
df3390e224 update formatting to closer match LAMMPS' programming style 2018-11-02 21:33:30 -04:00
d185b34b19 reformat to closer match LAMMPS programming style 2018-11-02 21:19:53 -04:00
30518a993b add LAMMPS header 2018-11-02 21:14:36 -04:00
b7e507a258 fix typo and reformat 2018-11-02 21:08:45 -04:00
ea9746f26d insert fix plumed docs into manual generation 2018-11-02 21:08:32 -04:00
2635f7d160 Merge pull request #1190 from giacomofiorin/colvars-update
Update Colvars library to version 2018-10-16
2018-11-02 20:11:28 -04:00
85a5cab663 Update Colvars library to version 2018-10-16 2018-11-02 17:45:20 -04:00
b1c50e3bbe Added plumed documentation in a txt file 2018-11-02 19:50:49 +00:00
0c7c344e19 additional molecule templates sanity-check
thanks to Sagar Patil for report
2018-11-01 01:26:12 -06:00
b67e54dd7d reciprocal 'related commands' 2018-11-01 01:09:52 -06:00
5821a5ecc8 bond/react: custom group with stabilization option 2018-11-01 01:04:45 -06:00
20b9c7fd79 Merge pull request #30 from lammps/master
rebase
2018-10-31 20:15:45 -06:00
a66d4c7451 Merge pull request #1186 from akohlmey/various-small-fixes
Various small fixes
2018-10-31 12:13:38 -04:00
7514838700 put LAMMPS sources folder first in list of include directories 2018-10-31 04:18:08 -04:00
1fccb391a6 Merge pull request #1185 from jrgissing/bond/react-update_edges-option
Bond/react: update edges option
2018-10-31 00:43:07 -04:00
688945a0ef silence compiler warnings about initialization order and unused args 2018-10-31 00:34:58 -04:00
50b99c8450 silence compiler warnings about unused arguments 2018-10-31 00:19:06 -04:00
446b05ebc1 silence warning about initialization order 2018-10-31 00:17:17 -04:00
2a5cd1d31e remove debug output 2018-10-31 00:16:44 -04:00
3faecc4d28 add option to update all atoms' atomic charges
option to update all atomic charges, even when edge atoms are defined
2018-10-30 22:11:52 -06:00
e992bf935b Merge pull request #29 from lammps/master
rebase
2018-10-30 20:35:47 -06:00
42068944aa Merge branch 'master' of github.com:gtribello/lammps into fix-plumed 2018-10-30 20:43:49 -04:00
e3b89b60dc add checksum support for downloaded tar archives. upgrade to v2.4.3 2018-10-30 20:43:20 -04:00
e70a9b0f26 updated CMakeLists to handle the optional dependency of USER-SDPD 2018-10-30 19:35:22 +03:30
113539b053 Merge pull request #1183 from akohlmey/voro-clean-namespace
Reduce namespace pollution for VORONOI package
2018-10-30 11:53:56 -04:00
ba6f6f73f1 first commit: added SDPD 2018-10-30 17:40:00 +03:30
c838a9fd48 use forward declarations for better namespace hygiene 2018-10-30 00:33:51 -04:00
fb4df86d3d Merge pull request #1170 from akohlmey/fix-merge-sort
Bug fix for merge sort by Jeffrey Frey
2018-10-29 18:47:50 -04:00
1bae30c295 liblammps.pc: add some more documentation 2018-10-29 06:57:46 -06:00
044507640f include Plumed.h with full path 2018-10-29 06:52:19 -06:00
bcc7a4c32f cmake: add PLUMED include dir 2018-10-29 06:36:47 -06:00
283096d1d5 update .gitignore 2018-10-29 03:50:55 -04:00
079134255d make sure class member "list" is initialized to NULL in constructor 2018-10-29 03:49:25 -04:00
25b425dbb0 no need to import the PLMD namespace globally 2018-10-28 22:21:35 -04:00
bee2cb96fa remove references to Plumed.cpp and Plumed.h 2018-10-28 22:18:27 -04:00
360aca581c remove last reference to voro++ 2018-10-28 21:56:49 -04:00
21661f84db Merge pull request #1181 from akohlmey/fixup-github-folder
Updates to contributing guidelines
2018-10-28 21:55:02 -04:00
a662afe970 fully integrate USER-PLUMED package into conventional build 2018-10-28 21:37:33 -04:00
3a082e227e remove obsolete and redundant files 2018-10-28 21:33:51 -04:00
54d728c0c7 reduce need for include files by adding forward declaration 2018-10-28 21:33:06 -04:00
ae499b980d make Plumed.cpp obsolete in USER-PLUMED code by inserting it into fix_plumed.cpp 2018-10-28 21:32:47 -04:00
925d6d37b9 adjust header inclusion to current LAMMPS conventions 2018-10-28 21:32:01 -04:00
bdf3764905 update user-plumed Install.sh file to fit better into LAMMPS, adjust to changes in lib folder 2018-10-28 21:31:40 -04:00
bfbf5695fd adjust path for includelink to find the Plumed.h wrapper properly 2018-10-28 21:30:37 -04:00
e788ffe210 Merge branch 'master' of github.com:gtribello/lammps into fix-plumed 2018-10-28 21:29:53 -04:00
3cc9384488 cmake: add support USER-PLUMED 2018-10-28 16:23:29 -06:00
a60b6d1ab8 add feature to python lib install script to support existing installation and use links 2018-10-28 18:12:32 -04:00
174b180a41 remove file that is not present 2018-10-28 18:12:02 -04:00
7bbd8644c8 rework some of the pull request instructions to be realigned with the recent changes in the workflow. 2018-10-28 08:50:37 -04:00
f36b7e38a8 correct link to github tutorial in CONTRIBUTING doc 2018-10-28 08:42:28 -04:00
f70af61b35 Added new version of Plumed wrapper 2018-10-28 09:27:22 +00:00
4fa78a78de Added instructions on PLUMED to build extras and Package details pages of manual 2018-10-26 22:12:17 +01:00
ff9f836be4 Merge remote-tracking branch 'upstream/master' 2018-10-26 22:01:05 +01:00
2e79d9f340 Merged Pablo's fixes into the plumed interface for lammps 2018-10-25 21:45:35 +01:00
2428c1c1f3 Merge pull request #1177 from lammps/modify-reorder
reorder operations in init() to fix a bug with compute chunk/atom del…
2018-10-25 10:55:14 -04:00
0e213b80e9 reorder operations in init() to fix a bug with compute chunk/atom deleting a fix 2018-10-25 08:23:10 -06:00
da38ae0370 apply fix for merge sort from issue #1163 by @jtfrey and re-enable it 2018-10-23 08:57:33 -04:00
c442166ded Tidied up example directory for PLUMED 2018-07-12 16:22:40 +01:00
6d9face1ec Added documentation describing PLUMED package installation 2018-07-12 12:26:09 +01:00
4734bc09dc Added descriptions of static linking of PLUMED to README files 2018-07-11 21:56:08 +01:00
492e945b5a Added options to link plumed statically 2018-07-11 16:39:52 +01:00
4d5635a3c4 Fixed virial contribution from PLUMED 2018-07-10 16:01:45 +01:00
c84ae38e34 Fixed installation scripts for PLUMED 2018-07-09 17:27:41 +01:00
43cdca80f2 Fixed passing of charges 2018-07-09 15:06:10 +01:00
7f5a83cb1d Added first go at checks on PLUMED interface to LAMMPS 2018-07-02 17:04:19 +01:00
b299bfa821 Started adding tests on PLUMED interface 2018-07-02 13:58:38 +01:00
2c5f2a6683 Added running example of PLUMED + LAMMPS
Not sure if this has been done correctly.  I add both the input and the output
2018-07-02 10:22:23 +01:00
9b44529591 Added an example 2018-06-29 17:46:51 +01:00
f5642ac292 Removed reference to local version of PLUMED from interface 2018-06-29 16:28:53 +01:00
ef0f9c0451 First attempt at permanent PLUMED interface 2018-06-29 12:26:19 +01:00
120 changed files with 13808 additions and 610 deletions

View File

@ -6,7 +6,7 @@ The following is a set of guidelines as well as explanations of policies and wor
Thus please also have a look at:
* [The Section on submitting new features for inclusion in LAMMPS of the Manual](http://lammps.sandia.gov/doc/Section_modify.html#mod-15)
* [The LAMMPS GitHub Tutorial in the Manual](http://lammps.sandia.gov/doc/tutorial_github.html)
* [The LAMMPS GitHub Tutorial in the Manual](http://lammps.sandia.gov/doc/Howto_github.html)
## Table of Contents
@ -62,7 +62,7 @@ To be able to submit an issue on GitHub, you have to register for an account (fo
We encourage users to submit new features or modifications for LAMMPS to the core developers so they can be added to the LAMMPS distribution. The preferred way to manage and coordinate this is by submitting a pull request at the LAMMPS project on GitHub. For any larger modifications or programming project, you are encouraged to contact the LAMMPS developers ahead of time, in order to discuss implementation strategies and coding guidelines, that will make it easier to integrate your contribution and result in less work for everybody involved. You are also encouraged to search through the list of open issues on GitHub and submit a new issue for a planned feature, so you would not duplicate the work of others (and possibly get scooped by them) or have your work duplicated by others.
How quickly your contribution will be integrated depends largely on how much effort it will cause to integrate and test it, how much it requires changes to the core code base, and of how much interest it is to the larger LAMMPS community. Please see below for a checklist of typical requirements. Once you have prepared everything, see [this tutorial](http://lammps.sandia.gov/doc/tutorial_github.html)
How quickly your contribution will be integrated depends largely on how much effort it will cause to integrate and test it, how much it requires changes to the core code base, and of how much interest it is to the larger LAMMPS community. Please see below for a checklist of typical requirements. Once you have prepared everything, see [this tutorial](http://lammps.sandia.gov/doc/Howto_github.html)
for instructions on how to submit your changes or new files through a GitHub pull request
Here is a checklist of steps you need to follow to submit a single file or user package for our consideration. Following these steps will save both you and us time. See existing files in packages in the source directory for examples. If you are uncertain, please ask on the lammps-users mailing list.
@ -102,11 +102,11 @@ For bug reports, the next step is that one of the core LAMMPS developers will se
### Pull Requests
For submitting pull requests, there is a [detailed tutorial](http://lammps.sandia.gov/doc/tutorial_github.html) in the LAMMPS manual. Thus only a brief breakdown of the steps is presented here.
For submitting pull requests, there is a [detailed tutorial](http://lammps.sandia.gov/doc/Howto_github.html) in the LAMMPS manual. Thus only a brief breakdown of the steps is presented here. Please note, that the LAMMPS developers are still reviewing and trying to improve the process. If you are unsure about something, do not hesitate to post a question on the lammps-users mailing list or contact one fo the core LAMMPS developers.
Immediately after the submission, the LAMMPS continuing integration server at ci.lammps.org will download your submitted branch and perform a simple compilation test, i.e. will test whether your submitted code can be compiled under various conditions. It will also do a check on whether your included documentation translates cleanly. Whether these tests are successful or fail will be recorded. If a test fails, please inspect the corresponding output on the CI server and take the necessary steps, if needed, so that the code can compile cleanly again. The test will be re-run each the pull request is updated with a push to the remote branch on GitHub.
Next a LAMMPS core developer will self-assign and do an overall technical assessment of the submission. If you are not yet registered as a LAMMPS collaborator, you will receive an invitation for that.
You may also receive comments and suggestions on the overall submission or specific details. If permitted, additional changes may be pushed into your pull request branch or a pull request may be filed in your LAMMPS fork on GitHub to include those changes.
The LAMMPS developer may then decide to assign the pull request to another developer (e.g. when that developer is more knowledgeable about the submitted feature or enhancement or has written the modified code). It may also happen, that additional developers are requested to provide a review and approve the changes. For submissions, that may change the general behavior of LAMMPS, or where a possibility of unwanted side effects exists, additional tests may be requested by the assigned developer.
If the assigned developer is satisfied and considers the submission ready for inclusion into LAMMPS, the pull request will be assigned to the LAMMPS lead developer, Steve Plimpton (@sjplimp), who will then have the final decision on whether the submission will be included, additional changes are required or it will be ultimately rejected. After the pull request is merged, you may delete the pull request branch in your personal LAMMPS fork.
Since the learning curve for git is quite steep for efficiently managing remote repositories, local and remote branches, pull requests and more, do not hesitate to ask questions, if you are not sure about how to do certain steps that are asked of you. Even if the changes asked of you do not make sense to you, they may be important for the LAMMPS developers. Please also note, that these all are guidelines and not set in stone.
If the assigned developer is satisfied and considers the submission ready for inclusion into LAMMPS, the pull request will receive approvals and be merged into the master branch by one of the core LAMMPS developers. After the pull request is merged, you may delete the feature branch used for the pull request in your personal LAMMPS fork.
Since the learning curve for git is quite steep for efficiently managing remote repositories, local and remote branches, pull requests and more, do not hesitate to ask questions, if you are not sure about how to do certain steps that are asked of you. Even if the changes asked of you do not make sense to you, they may be important for the LAMMPS developers. Please also note, that these all are guidelines and nothing set in stone. So depending on the nature of the contribution, the workflow may be adjusted.

View File

@ -171,8 +171,9 @@ set(DEFAULT_PACKAGES ASPHERE BODY CLASS2 COLLOID COMPRESS DIPOLE GRANULAR
USER-BOCS USER-CGDNA USER-MESO USER-CGSDK USER-COLVARS USER-DIFFRACTION
USER-DPD USER-DRUDE USER-EFF USER-FEP USER-H5MD USER-LB USER-MANIFOLD
USER-MEAMC USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE USER-NETCDF
USER-PHONON USER-PTM USER-QTB USER-REAXC USER-SCAFACOS USER-SMD USER-SMTBQ
USER-SPH USER-TALLY USER-UEF USER-VTK USER-QUIP USER-QMMM)
USER-PHONON USER-PLUMED USER-PTM USER-QTB USER-REAXC USER-SCAFACOS
USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY USER-UEF USER-VTK
USER-QUIP USER-QMMM)
set(ACCEL_PACKAGES USER-OMP KOKKOS OPT USER-INTEL GPU)
set(OTHER_PACKAGES CORESHELL QEQ)
foreach(PKG ${DEFAULT_PACKAGES})
@ -193,6 +194,8 @@ if(PKG_MEAM OR PKG_USER-H5MD OR PKG_USER-QMMM OR PKG_USER-SCAFACOS)
enable_language(C)
endif()
include_directories(${LAMMPS_SOURCE_DIR})
# do MPI detection after language activation, if MPI for these language is required
find_package(MPI QUIET)
option(BUILD_MPI "Build MPI version" ${MPI_FOUND})
@ -526,6 +529,32 @@ if(PKG_USER-SCAFACOS)
include_directories(${SCAFACOS_INCLUDE_DIRS})
endif()
if(PKG_USER-PLUMED)
find_package(GSL REQUIRED)
option(DOWNLOAD_PLUMED "Download Plumed (instead of using the system's one)" OFF)
if(DOWNLOAD_PLUMED)
include(ExternalProject)
ExternalProject_Add(plumed_build
URL https://github.com/plumed/plumed2/releases/download/v2.4.3/plumed-src-2.4.3.tgz
URL_MD5 b1be7c48971627febc11c61b70767fc5
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
$<$<BOOL:${BUILD_SHARED_LIBS}>:--with-pic> )
ExternalProject_get_property(plumed_build INSTALL_DIR)
set(PLUMED_INSTALL_DIR ${INSTALL_DIR})
list(APPEND LAMMPS_DEPS plumed_build)
list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/plumed/obj/kernel.o
${PLUMED_INSTALL_DIR}/lib/plumed/obj/PlumedStatic.o ${GSL_LIBRARIES} ${CMAKE_DL_LIBS})
set(PLUMED_INCLUDE_DIRS "${PLUMED_INSTALL_DIR}/include")
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(PLUMED plumed REQUIRED)
include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.static)
list(APPEND LAMMPS_LINK_LIBS ${PLUMED_LOAD})
endif()
include_directories(${PLUMED_INCLUDE_DIRS})
endif()
if(PKG_USER-MOLFILE)
add_library(molfile INTERFACE)
target_include_directories(molfile INTERFACE ${LAMMPS_LIB_SOURCE_DIR}/molfile)
@ -876,6 +905,20 @@ if(PKG_USER-OMP)
include_directories(${USER-OMP_SOURCES_DIR})
endif()
# Fix rigid/meso requires RIGID to be installed
if(PKG_USER-SDPD)
set(USER-SDPD_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/USER-SDPD)
get_property(hlist GLOBAL PROPERTY FIX)
if(NOT PKG_RIGID)
list(REMOVE_ITEM hlist ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.h)
list(REMOVE_ITEM LIB_SOURCES ${USER-SDPD_SOURCES_DIR}/fix_rigid_meso.cpp)
endif()
set_property(GLOBAL PROPERTY FIX "${hlist}")
include_directories(${USER-SDPD_SOURCES_DIR})
endif()
if(PKG_KOKKOS)
set(LAMMPS_LIB_KOKKOS_SRC_DIR ${LAMMPS_LIB_SOURCE_DIR}/kokkos)
set(LAMMPS_LIB_KOKKOS_BIN_DIR ${LAMMPS_LIB_BINARY_DIR}/kokkos)
@ -1166,7 +1209,6 @@ set(LAMMPS_STYLE_HEADERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/styles)
GenerateStyleHeaders(${LAMMPS_STYLE_HEADERS_DIR})
include_directories(${LAMMPS_SOURCE_DIR})
include_directories(${LAMMPS_STYLE_HEADERS_DIR})
######################################

View File

@ -1,9 +1,29 @@
# pkg-config file for lammps
# https://people.freedesktop.org/~dbn/pkg-config-guide.html
# Usage: cc `pkg-config --cflags --libs liblammps` -o myapp myapp.c
# after you added @CMAKE_INSTALL_FULL_LIBDIR@/pkg-config to PKG_CONFIG_PATH,
# Add the directory where lammps.pc got installed to your PKG_CONFIG_PATH
# e.g. export PKG_CONFIG_PATH=@CMAKE_INSTALL_FULL_LIBDIR@/pkgconfig
# Use this on commandline with:
# c++ `pkg-config --cflags --libs lammps` -o myapp myapp.cpp
# Use this in a Makefile:
# myapp: myapp.cpp
# $(CC) `pkg-config --cflags --libs lammps` -o $@ $<
# Use this in autotools:
# configure.ac:
# PKG_CHECK_MODULES([LAMMPS], [lammps])
# Makefile.am:
# myapp_CFLAGS = $(LAMMPS_CFLAGS)
# myapp_LDADD = $(LAMMPS_LIBS)
# Use this in CMake:
# CMakeLists.txt:
# find_package(PkgConfig)
# pkg_check_modules(LAMMPS IMPORTED_TARGET lammps)
# target_link_libraries(<lib> PkgConfig::LAMMPS)
prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@

View File

@ -8,7 +8,7 @@ set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVA
USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO
USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE
USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB
USER-QUIP USER-REAXC USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-UEF USER-VTK)
set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI

View File

@ -8,7 +8,7 @@ set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVA
USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO
USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE
USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB
USER-QUIP USER-REAXC USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-UEF USER-VTK)
set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI

View File

@ -61,6 +61,7 @@ set(PKG_USER-QMMM OFF CACHE BOOL "" FORCE)
set(PKG_USER-QTB OFF CACHE BOOL "" FORCE)
set(PKG_USER-QUIP OFF CACHE BOOL "" FORCE)
set(PKG_USER-REAXC OFF CACHE BOOL "" FORCE)
set(PKG_USER-SDPD OFF CACHE BOOL "" FORCE)
set(PKG_USER-SMD OFF CACHE BOOL "" FORCE)
set(PKG_USER-SMTBQ OFF CACHE BOOL "" FORCE)
set(PKG_USER-SPH OFF CACHE BOOL "" FORCE)

View File

@ -8,7 +8,7 @@ set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVA
USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO
USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE
USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB
USER-QUIP USER-REAXC USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-UEF USER-VTK)
set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI

View File

@ -8,7 +8,7 @@ set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVA
USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO
USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE
USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB
USER-QUIP USER-REAXC USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-UEF USER-VTK)
set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI

View File

@ -8,7 +8,7 @@ set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVA
USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO
USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE
USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB
USER-QUIP USER-REAXC USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-UEF USER-VTK)
set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI

View File

@ -8,7 +8,7 @@ set(USER_PACKAGES USER-ATC USER-AWPMD USER-BOCS USER-CGDNA USER-CGSDK USER-COLVA
USER-INTEL USER-LB USER-MANIFOLD USER-MEAMC USER-MESO
USER-MGPT USER-MISC USER-MOFFF USER-MOLFILE
USER-NETCDF USER-OMP USER-PHONON USER-QMMM USER-QTB
USER-QUIP USER-REAXC USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-QUIP USER-REAXC USER-SDPD USER-SMD USER-SMTBQ USER-SPH USER-TALLY
USER-UEF USER-VTK)
set(PACKAGES_WITH_LIB COMPRESS GPU KIM KOKKOS LATTE MEAM MPIIO MSCG POEMS PYTHON REAX VORONOI

View File

@ -41,6 +41,7 @@ This is the list of packages that may require additional steps.
"USER-ATC"_#user-atc,
"USER-AWPMD"_#user-awpmd,
"USER-COLVARS"_#user-colvars,
"USER-PLUMED" _#user-plumed,
"USER-H5MD"_#user-h5md,
"USER-INTEL"_#user-intel,
"USER-MOLFILE"_#user-molfile,
@ -712,6 +713,62 @@ a corresponding Makefile.lammps.machine file.
:line
USER-PLUMED package :h4,link(user-plumed)
[CMake build]:
[Traditional make]:
Before building LAMMPS with this package, you must first build
PLUMED. We recommending building PLUMED separately to LAMMPS using
the instructions that can be found at http://plumed.github.io/doc-master/user-doc/html/_installation.html.
Before compiling LAMMPS you can then install the fix plumed command
and compile LAMMPS in the usual manner:
make yes-user-plumed
make machine :pre
Once this compilation completes you should be able to run LAMMPS in the usual
way. When running LAMMPS with an input script that contains a fix
plumed command LAMMPS will try to call the PLUMED runtime library. PLUMED
must therefore be available in your path if LAMMPS is compiled in this way.
On some machines it is not possible to call runtime libraries in the way described
above. When compiling on these machines it is thus better to statically link
PLUMED when compiling LAMMPS. To do this you must either download a PLUMED
tarball from http://www.plumed.org/get-it or clone it using
git clone https://github.com/plumed/plumed2.git. If you download the tarball
unpack it in the /lib/plumed directory. Similarly if you clone
it clone it to the /lib/plumed directory as if there is a version of PLUMED within
this directory LAMMPS will always try to statically link the version of PLUMED
that this directory contains instead of dynamically linking the library.
Once you have downloaded PLUMED into /lib/plumed you must again build the code
here by following the instructions that can be found at
http://plumed.github.io/doc-master/user-doc/html/_installation.html.
You can statically link PLUMED manually and if you want to access the full
range of PLUMED functionalities this is what you should do. If you only want the
basic range of functionalities, however, (i.e. no user contributed modules) then
you can download and compile PLUMED in one step from the lammps/src dir, using a
command like like those below:
make lib-plumed # print help message
make lib-plumed args="-b" # download and build the latest stable version of PLUMED
These commands will simply invoke the lib/plumed/Install.py script with
args specified. Furthermore, once the script has completed you should
have a compiled version of PLUMED. With this built you can install/un-install
PLUMED and build LAMMPS in the usual manner:
make yes-user-plumed
make machine :pre
make no-user-plumed
make machine :pre
:line
USER-H5MD package :h4,link(user-h5md)
To build with this package you must have the HDF5 software package

View File

@ -94,6 +94,7 @@ OPT.
"lineforce"_fix_lineforce.html,
"manifoldforce"_fix_manifoldforce.html,
"meso"_fix_meso.html,
"meso/move"_fix_meso_move.html,
"meso/stationary"_fix_meso_stationary.html,
"momentum (k)"_fix_momentum.html,
"move"_fix_move.html,
@ -172,6 +173,7 @@ OPT.
"restrain"_fix_restrain.html,
"rhok"_fix_rhok.html,
"rigid (o)"_fix_rigid.html,
"rigid/meso"_fix_rigid_meso.html,
"rigid/nph (o)"_fix_rigid.html,
"rigid/nph/small"_fix_rigid.html,
"rigid/npt (o)"_fix_rigid.html,

View File

@ -198,6 +198,7 @@ OPT.
"reax/c (ko)"_pair_reaxc.html,
"rebo (io)"_pair_airebo.html,
"resquared (go)"_pair_resquared.html,
"sdpd/taitwater/isothermal"_pair_sdpd_taitwater_isothermal.html,
"smd/hertz"_pair_smd_hertz.html,
"smd/tlsph"_pair_smd_tlsph.html,
"smd/tri_surface"_pair_smd_triangulated_surface.html,

View File

@ -1,7 +1,7 @@
<!-- HTML_ONLY -->
<HEAD>
<TITLE>LAMMPS Users Manual</TITLE>
<META NAME="docnumber" CONTENT="24 Oct 2018 version">
<META NAME="docnumber" CONTENT="9 Nov 2018 version">
<META NAME="author" CONTENT="http://lammps.sandia.gov - Sandia National Laboratories">
<META NAME="copyright" CONTENT="Copyright (2003) Sandia Corporation. This software and manual is distributed under the GNU General Public License.">
</HEAD>
@ -21,7 +21,7 @@
:line
LAMMPS Documentation :c,h1
24 Oct 2018 version :c,h2
9 Nov 2018 version :c,h2
"What is a LAMMPS version?"_Manual_version.html

View File

@ -95,6 +95,7 @@ as contained in the file name.
"USER-QUIP"_#PKG-USER-QUIP,
"USER-REAXC"_#PKG-USER-REAXC,
"USER-SCAFACOS"_#PKG-USER-SCAFACOS,
"USER-SDPD"_#PKG-USER-SDPD,
"USER-SMD"_#PKG-USER-SMD,
"USER-SMTBQ"_#PKG-USER-SMTBQ,
"USER-SPH"_#PKG-USER-SPH,
@ -1200,6 +1201,34 @@ examples/USER/colvars :ul
:line
USER-PLUMED package :link(USER-PLUMED),h4
[Contents:]
The fix plumed command allows you to use the plugin for molecular
dynamics PLUMED to analyse and bias your LAMMPS trajectory on the fly.
In practise PLUMED is called from within the lammps input script by using
the "fix plumed _fix_plumed.html command.
[Authors:] The PLUMED library is written and maintained by
Massimilliano Bonomi, Giovanni Bussi, Carlo Camiloni and
Gareth Tribello.
[Install:]
This package has "specific installation
instructions"_Build_extras.html#gpu on the "Build
extras"_Build_extras.html doc page.
[Supporting info:]
src/USER-PLUMED/README
lib/plumed/README
"fix plumed "_fix_plumed.html
examples/USER/plumed :ul
:line
USER-DIFFRACTION package :link(PKG-USER-DIFFRACTION),h4
[Contents:]
@ -1916,6 +1945,31 @@ examples/USER/scafacos :ul
:line
USER-SDPD package :link(PKG-USER-SDPD),h4
[Contents:]
A pair style for smoothed dissipative particle dynamics (SDPD), which
is an extension of smoothed particle hydrodynamics (SPH) to mesoscale
where thermal fluctuations are important (see the
"USER-SPH package"_#PKG-USER-SPH).
Also two fixes for moving and rigid body integration of SPH/SDPD particles
(particles of atom_style meso).
[Author:] Morteza Jalalvand (Institute for Advanced Studies in Basic
Sciences, Iran).
[Supporting info:]
src/USER-SDPD: filenames -> commands
src/USER-SDPD/README
"pair_style sdpd/taitwater/isothermal"_pair_sdpd_taitwater_isothermal.html
"fix meso/move"_fix_meso_move.html
"fix rigid/meso"_fix_rigid_meso.html
examples/USER/sdpd :ul
:line
USER-SMD package :link(PKG-USER-SMD),h4
[Contents:]

View File

@ -68,6 +68,7 @@ Package, Description, Doc page, Example, Library
"USER-QUIP"_Packages_details.html#PKG-USER-QUIP, QUIP/libatoms interface,"pair_style quip"_pair_quip.html, USER/quip, ext
"USER-REAXC"_Packages_details.html#PKG-USER-REAXC, ReaxFF potential (C/C++) ,"pair_style reaxc"_pair_reaxc.html, reax, no
"USER-SCAFACOS"_Packages_details.html#PKG-USER-SCAFACOS, wrapper on ScaFaCoS solver,"kspace_style scafacos"_kspace_style.html, USER/scafacos, ext
"USER-SDPD"_Packages_details.html#PKG-USER-SDPD, smoothed dissipative particle dynamics,"pair_style sdpd/taitwater/isothermal"_pair_sdpd_taitwater_isothermal, USER/sdpd, no
"USER-SMD"_Packages_details.html#PKG-USER-SMD, smoothed Mach dynamics,"SMD User Guide"_PDF/SMD_LAMMPS_userguide.pdf, USER/smd, ext
"USER-SMTBQ"_Packages_details.html#PKG-USER-SMTBQ, second moment tight binding QEq potential,"pair_style smtbq"_pair_smtbq.html, USER/smtbq, no
"USER-SPH"_Packages_details.html#PKG-USER-SPH, smoothed particle hydrodynamics,"SPH User Guide"_PDF/SPH_LAMMPS_userguide.pdf, USER/sph, no

View File

@ -237,6 +237,7 @@ accelerated styles exist.
"lineforce"_fix_lineforce.html - constrain atoms to move in a line
"manifoldforce"_fix_manifoldforce.html -
"meso"_fix_meso.html -
"meso"_fix_meso_move.html - move mesoscopic SPH/SDPD particles in a prescribed fashion
"meso/stationary"_fix_meso_stationary.html -
"momentum"_fix_momentum.html - zero the linear and/or angular momentum of a group of atoms
"move"_fix_move.html - move atoms in a prescribed fashion
@ -331,6 +332,7 @@ accelerated styles exist.
"rigid/small/npt"_fix_rigid.html - constrain many small clusters of atoms to move as a rigid body with NPT integration
"rigid/small/nve"_fix_rigid.html - constrain many small clusters of atoms to move as a rigid body with alternate NVE integration
"rigid/small/nvt"_fix_rigid.html - constrain many small clusters of atoms to move as a rigid body with NVT integration
"rigid/meso"_fix_rigid_meso.html - constrain clusters of mesoscopic SPH/SDPD particles to move as a rigid body
"rx"_fix_rx.html -
"saed/vtk"_fix_saed_vtk.html -
"setforce"_fix_setforce.html - set the force on each atom

View File

@ -137,8 +137,8 @@ doc page for more info.
[Related commands:]
"fix bond/create"_fix_bond_create.html, "fix
bond/swap"_fix_bond_swap.html, "dump local"_dump.html,
"special_bonds"_special_bonds.html
bond/react"_fix_bond_react.html, "fix bond/swap"_fix_bond_swap.html,
"dump local"_dump.html, "special_bonds"_special_bonds.html
[Default:]

View File

@ -232,8 +232,8 @@ doc page for more info.
[Related commands:]
"fix bond/break"_fix_bond_break.html, "fix
bond/swap"_fix_bond_swap.html, "dump local"_dump.html,
"special_bonds"_special_bonds.html
bond/react"_fix_bond_react.html, "fix bond/swap"_fix_bond_swap.html,
"dump local"_dump.html, "special_bonds"_special_bonds.html
[Default:]

View File

@ -24,11 +24,11 @@ common_keyword = {stabilization} :l
{stabilization} values = {no} or {yes} {group-ID} {xmax}
{no} = no reaction site stabilization
{yes} = perform reaction site stabilization
{group-ID} = user-assigned ID for all non-reacting atoms (group created internally)
{group-ID} = user-assigned prefix for the dynamic group of non-reacting atoms
{xmax} = xmax value that is used by an internally created "nve/limit"_fix_nve_limit.html integrator :pre
react = mandatory argument indicating new reaction specification :l
react-ID = user-assigned name for the reaction :l
react-group-ID = only atoms in this group are available for the reaction :l
react-group-ID = only atoms in this group are considered for the reaction :l
Nevery = attempt reaction every this many steps :l
Rmin = bonding pair atoms must be separated by more than Rmin to initiate reaction (distance units) :l
Rmax = bonding pair atoms must be separated by less than Rmax to initiate reaction (distance units) :l
@ -41,14 +41,18 @@ react = mandatory argument indicating new reaction specification :l
fraction = initiate reaction with this probability if otherwise eligible
seed = random number seed (positive integer)
{stabilize_steps} value = timesteps
timesteps = number of timesteps to apply internally created nve/limit.html :pre
timesteps = number of timesteps to apply internally created nve/limit.html
{update_edges} value = {none} or {charges} :l
none = do not update topology near the edges of reaction templates
charges = update atomic charges of all atoms in reaction templates
custom = force the update of user-specified atomic charges :pre
:ule
[Examples:]
molecule mol1 pre_reacted_topology.txt
molecule mol2 post_reacted_topology.txt
fix 5 all bond/react stabilization no react myrxn1 all 1 0 3.25 mol1 mol2 map_file.txt :pre
fix 5 all bond/react react myrxn1 all 1 0 3.25 mol1 mol2 map_file.txt :pre
molecule mol1 pre_reacted_rxn1.txt
molecule mol2 post_reacted_rxn1.txt
@ -57,7 +61,7 @@ molecule mol4 post_reacted_rxn2.txt
fix 5 all bond/react stabilization yes nvt_grp .03 &
react myrxn1 all 1 0 3.25 mol1 mol2 map_file_rxn1.txt prob 0.50 12345 &
react myrxn2 all 1 0 2.75 mol3 mol4 map_file_rxn2.txt prob 0.25 12345
fix 6 nvt_grp nvt temp 300 300 100 # set thermostat after bond/react :pre
fix 6 nvt_grp_REACT nvt temp 300 300 100 # set thermostat after bond/react :pre
[Description:]
@ -99,19 +103,29 @@ involved in any new reactions. The {xmax} value keyword should
typically be set to the maximum distance that non-reacting atoms move
during the simulation.
The group-ID set using the {stabilization} keyword should be a
previously unused group-ID. It cannot be specified as 'all'. The fix
bond/react command creates a "dynamic group"_group.html of this name
that includes all non-reacting atoms. This dynamic group-ID should
then be used by a subsequent system-wide time integrator such as nvt,
npt, or nve, as shown in the second example above. It is currently
necessary to place the time integration command after the fix
bond/react command due to the internal dynamic grouping performed by
fix bond/react.
The group-ID set using the {stabilization} keyword can be an existing
static group or a previously-unused group-ID. It cannot be specified
as 'all'. If the group-ID is previously unused, the fix bond/react
command creates a "dynamic group"_group.html that is initialized to
include all atoms. If the group-ID is that of an existing static
group, the group is used as the parent group of new,
internally-created dynamic group. In both cases, this new dynamic
group is named by appending '_REACT' to the group-ID, e.g.
nvt_grp_REACT. By specifying an existing group, you may thermostat
constant-topology parts of your system separately. The dynamic group
contains only non-reacting atoms at a given timestep, and therefore
should be used by a subsequent system-wide time integrator such as
nvt, npt, or nve, as shown in the second example above. The time
integration command should be placed after the fix bond/react command
due to the internal dynamic grouping performed by fix bond/react.
NOTE: The internally created group currently applies to all atoms in
the system, i.e. you should generally not have a separate thermostat
which acts on the 'all' group.
NOTE: If the group-ID is an existing static group, react-group-IDs
should also be specified as this static group, or a subset.
NOTE: If the group-ID is previously unused, the internally created
group applies to all atoms in the system, i.e. you should generally
not have a separate thermostat which acts on the 'all' group, or any
other group.
The following comments pertain to each {react} argument:
@ -155,7 +169,17 @@ Some atoms in the pre-reacted template that are not reacting may have
missing topology with respect to the simulation. For example, the
pre-reacted template may contain an atom that would connect to the
rest of a long polymer chain. These are referred to as edge atoms, and
are also specified in the map file.
are also specified in the map file. When the pre-reaction template
contains edge atoms, not all atoms, bonds, charges, etc. specified in
the reaction templates will be updated. Specifically, topology that
involves only atoms that are 'too near' to template edges will not be
updated. The definition of 'too near the edge' depends on which
interactions are defined in the simulation. If the simulation has
defined dihedrals, atoms within two bonds of edge atoms are considered
'too near the edge.' If the simulation defines angles, but not
dihedrals, atoms within one bond of edge atoms are considered 'too
near the edge.' If just bonds are defined, only edge atoms are
considered 'too near the edge.'
Note that some care must be taken when a building a molecule template
for a given simulation. All atom types in the pre-reacted template
@ -178,23 +202,30 @@ A discussion of correctly handling this is also provided on the
The map file is a text document with the following format:
A map file has a header and a body. The header of map file the
contains one mandatory keyword and one optional keyword. The mandatory
keyword is 'equivalences' and the optional keyword is 'edgeIDs':
contains one mandatory keyword and two optional keywords. The mandatory
keyword is 'equivalences' and the optional keywords are 'edgeIDs' and
'customIDs':
N {equivalences} = # of atoms N in the reaction molecule templates
N {edgeIDs} = # of edge atoms N in the pre-reacted molecule template :pre
N {edgeIDs} = # of edge atoms N in the pre-reacted molecule template
N {customIDs} = # of atoms N that are specified for a custom update :pre
The body of the map file contains two mandatory sections and one
optional section. The first mandatory section begins with the keyword
The body of the map file contains two mandatory sections and two
optional sections. The first mandatory section begins with the keyword
'BondingIDs' and lists the atom IDs of the bonding atom pair in the
pre-reacted molecule template. The second mandatory section begins
with the keyword 'Equivalences' and lists a one-to-one correspondence
between atom IDs of the pre- and post-reacted templates. The first
column is an atom ID of the pre-reacted molecule template, and the
second column is the corresponding atom ID of the post-reacted
molecule template. The optional section begins with the keyword
molecule template. The first optional section begins with the keyword
'EdgeIDs' and lists the atom IDs of edge atoms in the pre-reacted
molecule template.
molecule template. The second optional section begins with the keyword
'Custom Edges' and allows for forcing the update of a specific atom's
atomic charge. The first column is the ID of an atom near the edge of
the pre-reacted molecule template, and the value of the second column
is either 'none' or 'charges.' Further details are provided in the
discussion of the 'update_edges' keyword.
A sample map file is given below:
@ -255,6 +286,18 @@ The {stabilize_steps} keyword allows for the specification of how many
timesteps a reaction site is stabilized before being returned to the
overall system thermostat.
The {update_edges} keyword can increase the number of atoms whose
atomic charges are updated, when the pre-reaction template contains
edge atoms. When the value is set to 'charges,' all atoms' atomic
charges are updated to those specified by the post-reaction template,
including atoms near the edge of reaction templates. When the value is
set to 'custom,' an additional section must be included in the map
file that specifies whether to update charges, on a per-atom basis.
The format of this section is detailed above. Listing a pre-reaction
atom ID with a value of 'charges' will force the update of the atom's
charge, even if it is near a template edge. Atoms not near a template
edge are unaffected by this setting.
In order to produce the most physical behavior, this 'reaction site
equilibration time' should be tuned to be as small as possible while
retaining stability for a given system or reaction step. After a
@ -323,7 +366,7 @@ bond/break"_fix_bond_break.html, "fix bond/swap"_fix_bond_swap.html,
[Default:]
The option defaults are stabilization = no, prob = 1.0, stabilize_steps = 60
The option defaults are stabilization = no, prob = 1.0, stabilize_steps = 60, update_edges = none
:line

233
doc/src/fix_meso_move.txt Normal file
View File

@ -0,0 +1,233 @@
"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c
:link(lws,http://lammps.sandia.gov)
:link(ld,Manual.html)
:link(lc,Commands_all.html)
:line
fix meso/move command :h3
[Syntax:]
fix ID group-ID meso/move style args keyword values ... :pre
ID, group-ID are documented in "fix"_fix.html command :ulb,l
meso/move = style name of this fix command :l
style = {linear} or {wiggle} or {rotate} or {variable} :l
{linear} args = Vx Vy Vz
Vx,Vy,Vz = components of velocity vector (velocity units), any component can be specified as NULL
{wiggle} args = Ax Ay Az period
Ax,Ay,Az = components of amplitude vector (distance units), any component can be specified as NULL
period = period of oscillation (time units)
{rotate} args = Px Py Pz Rx Ry Rz period
Px,Py,Pz = origin point of axis of rotation (distance units)
Rx,Ry,Rz = axis of rotation vector
period = period of rotation (time units)
{variable} args = v_dx v_dy v_dz v_vx v_vy v_vz
v_dx,v_dy,v_dz = 3 variable names that calculate x,y,z displacement as function of time, any component can be specified as NULL
v_vx,v_vy,v_vz = 3 variable names that calculate x,y,z velocity as function of time, any component can be specified as NULL :pre
zero or more keyword/value pairs may be appended :l
keyword = {units} :l
{units} value = {box} or {lattice} :pre
:ule
[Examples:]
fix 1 boundary meso/move wiggle 3.0 0.0 0.0 1.0 units box
fix 2 boundary meso/move rotate 0.0 0.0 0.0 0.0 0.0 1.0 5.0
fix 2 boundary meso/move variable v_myx v_myy NULL v_VX v_VY NULL :pre
[Description:]
Perform updates of position, velocity, internal energy and local
density for mesoscopic particles in the group each timestep using the
specified settings or formulas, without regard to forces on the
particles. This can be useful for boundary, solid bodies or other
particles, whose movement can influence nearby particles.
The operation of this fix is exactly like that described by the
"fix move"_fix_move.html command, except that particles' density,
internal energy and extrapolated velocity are also updated.
NOTE: The particles affected by this fix should not be time integrated
by other fixes (e.g. "fix meso"_fix_meso.html, "fix
meso/stationary"_fix_meso_stationary.html), since that will change their
positions and velocities twice.
NOTE: As particles move due to this fix, they will pass thru periodic
boundaries and be remapped to the other side of the simulation box,
just as they would during normal time integration (e.g. via the "fix
meso"_fix_meso.html command). It is up to you to decide whether periodic
boundaries are appropriate with the kind of particle motion you are
prescribing with this fix.
NOTE: As dicsussed below, particles are moved relative to their initial
position at the time the fix is specified. These initial coordinates
are stored by the fix in "unwrapped" form, by using the image flags
associated with each particle. See the "dump custom"_dump.html command
for a discussion of "unwrapped" coordinates. See the Atoms section of
the "read_data"_read_data.html command for a discussion of image flags
and how they are set for each particle. You can reset the image flags
(e.g. to 0) before invoking this fix by using the "set image"_set.html
command.
:line
The {linear} style moves particles at a constant velocity, so that their
position {X} = (x,y,z) as a function of time is given in vector
notation as
X(t) = X0 + V * delta :pre
where {X0} = (x0,y0,z0) is their position at the time the fix is
specified, {V} is the specified velocity vector with components
(Vx,Vy,Vz), and {delta} is the time elapsed since the fix was
specified. This style also sets the velocity of each particle to V =
(Vx,Vy,Vz). If any of the velocity components is specified as NULL,
then the position and velocity of that component is time integrated
the same as the "fix meso"_fix_meso.html command would perform, using
the corresponding force component on the particle.
Note that the {linear} style is identical to using the {variable}
style with an "equal-style variable"_variable.html that uses the
vdisplace() function. E.g.
variable V equal 10.0
variable x equal vdisplace(0.0,$V)
fix 1 boundary move variable v_x NULL NULL v_V NULL NULL :pre
The {wiggle} style moves particles in an oscillatory fashion, so that
their position {X} = (x,y,z) as a function of time is given in vector
notation as
X(t) = X0 + A sin(omega*delta) :pre
where {X0} = (x0,y0,z0) is their position at the time the fix is
specified, {A} is the specified amplitude vector with components
(Ax,Ay,Az), {omega} is 2 PI / {period}, and {delta} is the time
elapsed since the fix was specified. This style also sets the
velocity of each particle to the time derivative of this expression.
If any of the amplitude components is specified as NULL, then the
position and velocity of that component is time integrated the same as
the "fix meso"_fix_meso.html command would perform, using the
corresponding force component on the particle.
Note that the {wiggle} style is identical to using the {variable}
style with "equal-style variables"_variable.html that use the
swiggle() and cwiggle() functions. E.g.
variable A equal 10.0
variable T equal 5.0
variable omega equal 2.0*PI/$T
variable x equal swiggle(0.0,$A,$T)
variable v equal v_omega*($A-cwiggle(0.0,$A,$T))
fix 1 boundary move variable v_x NULL NULL v_v NULL NULL :pre
The {rotate} style rotates particles around a rotation axis {R} =
(Rx,Ry,Rz) that goes thru a point {P} = (Px,Py,Pz). The {period} of
the rotation is also specified. The direction of rotation for the
particles around the rotation axis is consistent with the right-hand
rule: if your right-hand thumb points along {R}, then your fingers wrap
around the axis in the direction of rotation.
This style also sets the velocity of each particle to (omega cross
Rperp) where omega is its angular velocity around the rotation axis and
Rperp is a perpendicular vector from the rotation axis to the particle.
The {variable} style allows the position and velocity components of
each particle to be set by formulas specified via the
"variable"_variable.html command. Each of the 6 variables is
specified as an argument to the fix as v_name, where name is the
variable name that is defined elsewhere in the input script.
Each variable must be of either the {equal} or {atom} style.
{Equal}-style variables compute a single numeric quantity, that can be
a function of the timestep as well as of other simulation values.
{Atom}-style variables compute a numeric quantity for each particle, that
can be a function per-atom quantities, such as the particle's position, as
well as of the timestep and other simulation values. Note that this
fix stores the original coordinates of each particle (see note below) so
that per-atom quantity can be used in an atom-style variable formula.
See the "variable"_variable.html command for details.
The first 3 variables (v_dx,v_dy,v_dz) specified for the {variable}
style are used to calculate a displacement from the particle's original
position at the time the fix was specified. The second 3 variables
(v_vx,v_vy,v_vz) specified are used to compute a velocity for each
particle.
Any of the 6 variables can be specified as NULL. If both the
displacement and velocity variables for a particular x,y,z component
are specified as NULL, then the position and velocity of that
component is time integrated the same as the "fix meso"_fix_meso.html
command would perform, using the corresponding force component on the
particle. If only the velocity variable for a component is specified as
NULL, then the displacement variable will be used to set the position
of the particle, and its velocity component will not be changed. If only
the displacement variable for a component is specified as NULL, then
the velocity variable will be used to set the velocity of the particle,
and the position of the particle will be time integrated using that
velocity.
The {units} keyword determines the meaning of the distance units used
to define the {linear} velocity and {wiggle} amplitude and {rotate}
origin. This setting is ignored for the {variable} style. A {box}
value selects standard units as defined by the "units"_units.html
command, e.g. velocity in Angstroms/fmsec and amplitude and position
in Angstroms for units = real. A {lattice} value means the velocity
units are in lattice spacings per time and the amplitude and position
are in lattice spacings. The "lattice"_lattice.html command must have
been previously used to define the lattice spacing. Each of these 3
quantities may be dependent on the x,y,z dimension, since the lattice
spacings can be different in x,y,z.
:line
[Restart, fix_modify, output, run start/stop, minimize info:]
This fix writes the original coordinates of moving particles to "binary
restart files"_restart.html, as well as the initial timestep, so that
the motion can be continuous in a restarted simulation. See the
"read_restart"_read_restart.html command for info on how to re-specify
a fix in an input script that reads a restart file, so that the
operation of the fix continues in an uninterrupted fashion.
NOTE: Because the move positions are a function of the current
timestep and the initial timestep, you cannot reset the timestep to a
different value after reading a restart file, if you expect a fix move
command to work in an uninterrupted fashion.
None of the "fix_modify"_fix_modify.html options are relevant to this
fix.
This fix produces a per-atom array which can be accessed by various
"output commands"_Howto_output.html. The number of columns for each
atom is 3, and the columns store the original unwrapped x,y,z coords
of each particle. The per-atom values can be accessed on any timestep.
No parameter of this fix can be used with the {start/stop} keywords of
the "run"_run.html command.
This fix is not invoked during "energy minimization"_minimize.html.
[Restrictions:]
This fix is part of the USER-SDPD package. It is only enabled if
LAMMPS was built with that package. See the "Build
package"_Build_package.html doc page for more info.
This fix requires that atoms store density and internal energy as
defined by the "atom_style meso"_atom_style.html command.
All particles in the group must be mesoscopic SPH/SDPD particles.
[Related commands:]
"fix move"_fix_move.html, "fix meso"_fix_meso.html,
"displace_atoms"_displace_atoms.html
[Default:]
The option default is units = lattice.

View File

@ -36,8 +36,8 @@ The command is equivalent to the "fix nve"_fix_nve.html.
The particles are always considered to have a finite size.
An example input file can be found in /examples/USER/cgdna/examples/duplex1/.
A technical report with more information on this integrator can be found
"here"_PDF/USER-CGDNA-overview.pdf.
Further details of the implementation and stability of the integrator are contained in "(Henrich)"_#Henrich3.
The preprint version of the article can be found "here"_PDF/USER-CGDNA.pdf.
:line
@ -59,3 +59,5 @@ See the "Build package"_Build_package.html doc page for more info.
[(Davidchack)] R.L Davidchack, T.E. Ouldridge, and M.V. Tretyakov. J. Chem. Phys. 142, 144114 (2015).
:link(Miller1)
[(Miller)] T. F. Miller III, M. Eleftheriou, P. Pattnaik, A. Ndirango, G. J. Martyna, J. Chem. Phys., 116, 8649-8659 (2002).
:link(Henrich3)
[(Henrich)] O. Henrich, Y. A. Gutierrez-Fosado, T. Curk, T. E. Ouldridge, Eur. Phys. J. E 41, 57 (2018).

View File

@ -114,8 +114,8 @@ The scale factor after the {angmom} keyword gives the ratio of the rotational to
the translational friction coefficient.
An example input file can be found in /examples/USER/cgdna/examples/duplex2/.
A technical report with more information on this integrator can be found
"here"_PDF/USER-CGDNA-overview.pdf.
Further details of the implementation and stability of the integrators are contained in "(Henrich)"_#Henrich4.
The preprint version of the article can be found "here"_PDF/USER-CGDNA.pdf.
:line
@ -139,3 +139,5 @@ See the "Build package"_Build_package.html doc page for more info.
[(Miller)] T. F. Miller III, M. Eleftheriou, P. Pattnaik, A. Ndirango, G. J. Martyna, J. Chem. Phys., 116, 8649-8659 (2002).
:link(Dunweg3)
[(Dunweg)] B. Dunweg, W. Paul, Int. J. Mod. Phys. C, 2, 817-27 (1991).
:link(Henrich4)
[(Henrich)] O. Henrich, Y. A. Gutierrez-Fosado, T. Curk, T. E. Ouldridge, Eur. Phys. J. E 41, 57 (2018).

117
doc/src/fix_plumed.txt Normal file
View File

@ -0,0 +1,117 @@
"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c
:link(lws,http://lammps.sandia.gov)
:link(ld,Manual.html)
:link(lc,Commands_all.html)
:line
fix plumed command :h3
[Syntax:]
fix ID group-ID plumed keyword value ... :pre
ID, group-ID are documented in "fix"_fix.html command :ulb,l
plumed = style name of this fix command :l
keyword = {plumedfile} or {outfile} :l
{plumedfile} arg = name of PLUMED input file to use (default: NULL)
{outfile} arg = name of file on which to write the PLUMED log (default: NULL) :pre
:ule
[Examples:]
fix pl all plumed all plumed plumedfile plumed.dat outfile p.log
[Description:]
This fix instructs LAMMPS to call the PLUMED library, which allows one
to perform various forms of trajectory analysis on the fly and to also
use methods such as umbrella sampling and metadynamics to enhance the
sampling of phase space.
The documentation included here only describes the fix plumed command.
This command is LAMMPS specific whereas most of the functionality
implemented in PLUMED will work with a range of MD codes and also when
PLUMED is used as a stand alone code. The full documentation for PLUMED
is available at "this website"_http://www.plumed.org/documentation
The PLUMED library is developed at
"https://github.com/plumed/plumed2"_https://github.com/plumed/plumed2 A
detailed discussion of the code can be found in "(PLUMED)"_#PLUMED.
There are some example scripts for using this package with LAMMPS in the
examples/USER/plumed directory.
:line
The command to call PLUMED above is reasonably self explanatory. Within
the input file for lammps the user is required to specify the input file
for PLUMED and a file on which to output the PLUMED log. The user must
specify both of these arguments every time PLUMED is to be used.
Furthermore, the fix plumed command should appear in the LAMMPS input
file after the relevant input paramters (e.g. the timestep) have been
set.
The {group-ID} entry is ignored. LAMMPS will always pass all the atoms
to PLUMED and there can only be one instance of the plumed fix at a
time. The plumed fix communicates the minimum amount of information
required and the PLUMED supports multiple, completely independent
collective variables, multiple independent biases and multiple
independent forms of analysis. There is thus really no restriction in
functionality by only allowing only one plumed fix in the LAMMPS input.
The {plumedfile} keyword allows the user to specify the name of the
PLUMED input file. Instructions as to what should be included in a
plumed input file can be found in the "documentation for
PLUMED"_http://www.plumed.org/documentation.
The {outfile} keyword allows the user to specify the name of a file on
which to output the PLUMED log. This log file normally just parots the
information that is contained in the input file. The names of the files
on which the results from the various analyses that have been performed
using PLUMED will be specified by the user in the PLUMED input file.
[Restart, fix_modify, output, run start/stop, minimize info:]
When performing a restart of a calculation that involves PLUMED you must
include a RESTART command in the PLUMED input file as detailed in the
"PLUMED documentation"_http://www.plumed.org/documentation. When the
restart command is found in the PLUMED input PLUMED will append to the
files that were generated in the run that was performed previously.
Furthermore, any history dependent bias potentials that were accumulated
in previous calculations will be read in when the restart command is
included in the PLUMED input.
The "fix_modify"_fix_modify.html {energy} option is not supported by
this fix.
Nothing is computed by this fix that can be accessed by any of the
"output commands"_Howto_output.html within LAMMPS. All the quantities
of interest can be output by commands that are native to PLUMED,
however.
[Restrictions:]
This fix is part of the USER-PLUMED package. It is only enabled if
LAMMPS was built with that package. See the "Build
package"_Build_package.html doc page for more info.
There can only be one plumed fix active at a time. Since the interface
communicates only the minimum amount of information and since the PLUMED
module itself can handle an arbitrary number of analysis and biasing
methods, this is not a limitation of functionality.
[Related commands:]
"fix smd"_fix_smd.html
"fix colvars"_fix_colvars.html
[Default:]
The default options are plumedfile = NULL and outfile = NULL
:line
:link(PLUMED)
[(PLUMED)] G.A. Tribello, M. Bonomi, D. Branduardi, C. Camilloni and G. Bussi, Comp. Phys. Comm 185, 604 (2014)

349
doc/src/fix_rigid_meso.txt Normal file
View File

@ -0,0 +1,349 @@
"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c
:link(lws,http://lammps.sandia.gov)
:link(ld,Manual.html)
:link(lc,Commands_all.html)
:line
fix rigid/meso command :h3
[Syntax:]
fix ID group-ID rigid/meso bodystyle args keyword values ... :pre
ID, group-ID are documented in "fix"_fix.html command :ulb,l
rigid/meso = style name of this fix command :l
bodystyle = {single} or {molecule} or {group} :l
{single} args = none
{molecule} args = none
{custom} args = {i_propname} or {v_varname}
i_propname = an integer property defined via fix property/atom
v_varname = an atom-style or atomfile-style variable
{group} args = N groupID1 groupID2 ...
N = # of groups
groupID1, groupID2, ... = list of N group IDs :pre
zero or more keyword/value pairs may be appended :l
keyword = {reinit} or {force} or {torque} or {infile} :l
{reinit} = {yes} or {no}
{force} values = M xflag yflag zflag
M = which rigid body from 1-Nbody (see asterisk form below)
xflag,yflag,zflag = off/on if component of center-of-mass force is active
{torque} values = M xflag yflag zflag
M = which rigid body from 1-Nbody (see asterisk form below)
xflag,yflag,zflag = off/on if component of center-of-mass torque is active
{infile} filename
filename = file with per-body values of mass, center-of-mass, moments of inertia :pre
:ule
[Examples:]
fix 1 ellipsoid rigid/meso single
fix 1 rods rigid/meso molecule
fix 1 spheres rigid/meso single force 1 off off on
fix 1 particles rigid/meso molecule force 1*5 off off off force 6*10 off off on
fix 2 spheres rigid/meso group 3 sphere1 sphere2 sphere3 torque * off off off :pre
[Description:]
Treat one or more sets of mesoscopic SPH/SDPD particles as independent
rigid bodies. This means that each timestep the total force and torque
on each rigid body is computed as the sum of the forces and torques on
its constituent particles. The coordinates and velocities of the
particles in each body are then updated so that the body moves and
rotates as a single entity using the methods described in the paper by
"(Miller)"_#Miller. Density and internal energy of the particles will
also be updated. This is implemented by creating internal data structures
for each rigid body and performing time integration on these data
structures. Positions and velocities of the constituent particles are
regenerated from the rigid body data structures in every time step. This
restricts which operations and fixes can be applied to rigid bodies. See
below for a detailed discussion.
The operation of this fix is exactly like that described by the
"fix rigid/nve"_fix_rigid.html command, except that particles' density,
internal energy and extrapolated velocity are also updated.
NOTE: You should not update the particles in rigid bodies via other
time-integration fixes (e.g. "fix meso"_fix_meso.html,
"fix meso/stationary"_fix_meso_stationary.html), or you will have conflicting
updates to positions and velocities resulting in unphysical behavior in most
cases. When performing a hybrid simulation with some atoms in rigid bodies,
and some not, a separate time integration fix like "fix meso"_fix_meso.html
should be used for the non-rigid particles.
NOTE: These fixes are overkill if you simply want to hold a collection
of particles stationary or have them move with a constant velocity. To
hold particles stationary use "fix
meso/stationary"_fix_meso_stationary.html instead. If you would like to
move particles with a constant velocity use "fix
meso/move"_fix_meso_move.html.
IMPORTANT NOTE: The aggregate properties of each rigid body are
calculated at the start of a simulation run and are maintained in
internal data structures. The properties include the position and
velocity of the center-of-mass of the body, its moments of inertia, and
its angular momentum. This is done using the properties of the
constituent particles of the body at that point in time (or see the {infile}
keyword option). Thereafter, changing these properties of individual
particles in the body will have no effect on a rigid body's dynamics, unless
they effect any computation of per-particle forces or torques. If the
keyword {reinit} is set to {yes} (the default), the rigid body data
structures will be recreated at the beginning of each {run} command;
if the keyword {reinit} is set to {no}, the rigid body data structures
will be built only at the very first {run} command and maintained for
as long as the rigid fix is defined. For example, you might think you
could displace the particles in a body or add a large velocity to each particle
in a body to make it move in a desired direction before a 2nd run is
performed, using the "set"_set.html or
"displace_atoms"_displace_atoms.html or "velocity"_velocity.html
commands. But these commands will not affect the internal attributes
of the body unless {reinit} is set to {yes}. With {reinit} set to {no}
(or using the {infile} option, which implies {reinit} {no}) the position
and velocity of individual particles in the body will be reset when time
integration starts again.
:line
Each rigid body must have two or more particles. A particle can belong
to at most one rigid body. Which particles are in which bodies can be
defined via several options.
For bodystyle {single} the entire fix group of particles is treated as
one rigid body.
For bodystyle {molecule}, particles are grouped into rigid bodies by their
respective molecule IDs: each set of particles in the fix group with the
same molecule ID is treated as a different rigid body. Note that particles
with a molecule ID = 0 will be treated as a single rigid body. For a
system with solvent (typically this is particles with molecule ID = 0)
surrounding rigid bodies, this may not be what you want. Thus you
should be careful to use a fix group that only includes particles you
want to be part of rigid bodies.
Bodystyle {custom} is similar to bodystyle {molecule} except that it
is more flexible in using other per-atom properties to define the sets
of particles that form rigid bodies. An integer vector defined by the
"fix property/atom"_fix_property_atom.html command can be used. Or an
"atom-style or atomfile-style variable"_variable.html can be used; the
floating-point value produced by the variable is rounded to an
integer. As with bondstyle {molecule}, each set of particles in the fix
groups with the same integer value is treated as a different rigid
body. Since fix property/atom vectors and atom-style variables
produce values for all particles, you should be careful to use a fix group
that only includes particles you want to be part of rigid bodies.
For bodystyle {group}, each of the listed groups is treated as a
separate rigid body. Only particles that are also in the fix group are
included in each rigid body.
NOTE: To compute the initial center-of-mass position and other
properties of each rigid body, the image flags for each particle in the
body are used to "unwrap" the particle coordinates. Thus you must
insure that these image flags are consistent so that the unwrapping
creates a valid rigid body (one where the particles are close together)
, particularly if the particles in a single rigid body straddle a
periodic boundary. This means the input data file or restart file must
define the image flags for each particle consistently or that you have
used the "set"_set.html command to specify them correctly. If a
dimension is non-periodic then the image flag of each particle must be
0 in that dimension, else an error is generated.
By default, each rigid body is acted on by other particles which induce
an external force and torque on its center of mass, causing it to
translate and rotate. Components of the external center-of-mass force
and torque can be turned off by the {force} and {torque} keywords.
This may be useful if you wish a body to rotate but not translate, or
vice versa, or if you wish it to rotate or translate continuously
unaffected by interactions with other particles. Note that if you
expect a rigid body not to move or rotate by using these keywords, you
must insure its initial center-of-mass translational or angular
velocity is 0.0. Otherwise the initial translational or angular
momentum the body has will persist.
An xflag, yflag, or zflag set to {off} means turn off the component of
force or torque in that dimension. A setting of {on} means turn on
the component, which is the default. Which rigid body(s) the settings
apply to is determined by the first argument of the {force} and
{torque} keywords. It can be an integer M from 1 to Nbody, where
Nbody is the number of rigid bodies defined. A wild-card asterisk can
be used in place of, or in conjunction with, the M argument to set the
flags for multiple rigid bodies. This takes the form "*" or "*n" or
"n*" or "m*n". If N = the number of rigid bodies, then an asterisk
with no numeric values means all bodies from 1 to N. A leading
asterisk means all bodies from 1 to n (inclusive). A trailing
asterisk means all bodies from n to N (inclusive). A middle asterisk
means all bodies from m to n (inclusive). Note that you can use the
{force} or {torque} keywords as many times as you like. If a
particular rigid body has its component flags set multiple times, the
settings from the final keyword are used.
For computational efficiency, you should typically define one fix
rigid/meso command which includes all the desired rigid bodies. LAMMPS
will allow multiple rigid/meso fixes to be defined, but it is more
expensive.
:line
The keyword/value option pairs are used in the following ways.
The {reinit} keyword determines, whether the rigid body properties
are re-initialized between run commands. With the option {yes} (the
default) this is done, with the option {no} this is not done. Turning
off the re-initialization can be helpful to protect rigid bodies against
unphysical manipulations between runs or when properties cannot be
easily re-computed (e.g. when read from a file). When using the {infile}
keyword, the {reinit} option is automatically set to {no}.
:line
The {infile} keyword allows a file of rigid body attributes to be read
in from a file, rather then having LAMMPS compute them. There are 5
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
overlap. To avoid this issue, the values can be pre-computed
(e.g. using Monte Carlo integration).
The format of the file is as follows. Note that the file does not
have to list attributes for every rigid body integrated by fix rigid.
Only bodies which the file specifies will have their computed
attributes overridden. The file can contain initial blank lines or
comment lines starting with "#" which are ignored. The first
non-blank, non-comment line should list N = the number of lines to
follow. The N successive lines contain the following information:
ID1 masstotal xcm ycm zcm ixx iyy izz ixy ixz iyz vxcm vycm vzcm lx ly lz ixcm iycm izcm
ID2 masstotal xcm ycm zcm ixx iyy izz ixy ixz iyz vxcm vycm vzcm lx ly lz ixcm iycm izcm
...
IDN masstotal xcm ycm zcm ixx iyy izz ixy ixz iyz vxcm vycm vzcm lx ly lz ixcm iycm izcm :pre
The rigid body IDs are all positive integers. For the {single}
bodystyle, only an ID of 1 can be used. For the {group} bodystyle,
IDs from 1 to Ng can be used where Ng is the number of specified
groups. For the {molecule} bodystyle, use the molecule ID for the
atoms in a specific rigid body as the rigid body ID.
The masstotal and center-of-mass coordinates (xcm,ycm,zcm) are
self-explanatory. The center-of-mass should be consistent with what
is calculated for the position of the rigid body with all its atoms
unwrapped by their respective image flags. If this produces a
center-of-mass that is outside the simulation box, LAMMPS wraps it
back into the box.
The 6 moments of inertia (ixx,iyy,izz,ixy,ixz,iyz) should be the
values consistent with the current orientation of the rigid body
around its center of mass. The values are with respect to the
simulation box XYZ axes, not with respect to the principal axes of the
rigid body itself. LAMMPS performs the latter calculation internally.
The (vxcm,vycm,vzcm) values are the velocity of the center of mass.
The (lx,ly,lz) values are the angular momentum of the body. The
(vxcm,vycm,vzcm) and (lx,ly,lz) values can simply be set to 0 if you
wish the body to have no initial motion.
The (ixcm,iycm,izcm) values are the image flags of the center of mass
of the body. For periodic dimensions, they specify which image of the
simulation box the body is considered to be in. An image of 0 means
it is inside the box as defined. A value of 2 means add 2 box lengths
to get the true value. A value of -1 means subtract 1 box length to
get the true value. LAMMPS updates these flags as the rigid bodies
cross periodic boundaries during the simulation.
NOTE: If you use the {infile} keyword and write restart
files during a simulation, then each time a restart file is written,
the fix also write an auxiliary restart file with the name
rfile.rigid, where "rfile" is the name of the restart file,
e.g. tmp.restart.10000 and tmp.restart.10000.rigid. This auxiliary
file is in the same format described above. Thus it can be used in a
new input script that restarts the run and re-specifies a rigid fix
using an {infile} keyword and the appropriate filename. Note that the
auxiliary file will contain one line for every rigid body, even if the
original file only listed a subset of the rigid bodies.
:line
[Restart, fix_modify, output, run start/stop, minimize info:]
No information is written to "binary restart files"_restart.html.
If the {infile} keyword is used, an auxiliary file is written out
with rigid body information each time a restart file is written, as
explained above for the {infile} keyword.
None of the "fix_modify"_fix_modify.html options are relevant to this
fix.
This fix computes a global array of values which can be accessed by
various "output commands"_Howto_output.html.
The number of rows in the array is equal to the number of rigid
bodies. The number of columns is 28. Thus for each rigid body, 28
values are stored: the xyz coords of the center of mass (COM), the xyz
components of the COM velocity, the xyz components of the force acting
on the COM, the components of the 4-vector quaternion representing the
orientation of the rigid body, the xyz components of the angular momentum
of the body around its COM, the xyz components of the torque acting on the
COM, the 3 principal components of the moment of inertia and the xyz image
flags of the COM.
The center of mass (COM) for each body is similar to unwrapped
coordinates written to a dump file. It will always be inside (or
slightly outside) the simulation box. The image flags have the same
meaning as image flags for particle positions (see the "dump" command).
This means you can calculate the unwrapped COM by applying the image
flags to the COM, the same as when unwrapped coordinates are written
to a dump file.
The force and torque values in the array are not affected by the
{force} and {torque} keywords in the fix rigid command; they reflect
values before any changes are made by those keywords.
The ordering of the rigid bodies (by row in the array) is as follows.
For the {single} keyword there is just one rigid body. For the
{molecule} keyword, the bodies are ordered by ascending molecule ID.
For the {group} keyword, the list of group IDs determines the ordering
of bodies.
The array values calculated by this fix are "intensive", meaning they
are independent of the number of particles in the simulation.
No parameter of this fix can be used with the {start/stop} keywords of
the "run"_run.html command.
This fix is not invoked during "energy minimization"_minimize.html.
:line
[Restrictions:]
This fix is part of the USER-SDPD package and also depends on the RIGID
package. It is only enabled if LAMMPS was built with both packages. See
the "Build package"_Build_package.html doc page for more info.
This fix requires that atoms store density and internal energy as
defined by the "atom_style meso"_atom_style.html command.
All particles in the group must be mesoscopic SPH/SDPD particles.
[Related commands:]
"fix meso/move"_fix_meso_move.html, "fix rigid"_fix_rigid.html,
"neigh_modify exclude"_neigh_modify.html
[Default:]
The option defaults are force * on on on and torque * on on on,
meaning all rigid bodies are acted on by center-of-mass force and
torque. Also reinit = yes.
:line
:link(Miller)
[(Miller)] Miller, Eleftheriou, Pattnaik, Ndirango, and Newns,
J Chem Phys, 116, 8649 (2002).

View File

@ -73,6 +73,7 @@ Fixes :h1
fix_lineforce
fix_manifoldforce
fix_meso
fix_meso_move
fix_meso_stationary
fix_momentum
fix_move
@ -117,6 +118,7 @@ Fixes :h1
fix_phonon
fix_pimd
fix_planeforce
fix_plumed
fix_poems
fix_pour
fix_precession_spin
@ -137,6 +139,7 @@ Fixes :h1
fix_restrain
fix_rhok
fix_rigid
fix_rigid_meso
fix_rx
fix_saed_vtk
fix_setforce

View File

@ -225,8 +225,7 @@ atomfile-style variable. The variable is evaluated and atoms whose
per-atom values are 0.0, are removed from the dynamic group. If the {property}
keyword is used, the per-atom property name must be a previously defined
per-atom property. The per-atom property is evaluated and atoms whose
values are 0.0 are removed from the dynamic group, otherwise they
are added to the group.
values are 0.0 are removed from the dynamic group.
The assignment of atoms to a dynamic group is done at the beginning of
each run and on every timestep that is a multiple of {N}, which is the

View File

@ -293,6 +293,7 @@ fix_lb_viscous.html
fix_lineforce.html
fix_manifoldforce.html
fix_meso.html
fix_meso_move.html
fix_meso_stationary.html
fix_momentum.html
fix_move.html
@ -337,6 +338,7 @@ fix_orient.html
fix_phonon.html
fix_pimd.html
fix_planeforce.html
fix_plumed.html
fix_poems.html
fix_pour.html
fix_precession_spin.html
@ -356,6 +358,7 @@ fix_reaxc_species.html
fix_recenter.html
fix_restrain.html
fix_rigid.html
fix_rigid_meso.html
fix_rhok.html
fix_rx.html
fix_saed_vtk.html
@ -615,6 +618,7 @@ pair_reax.html
pair_reaxc.html
pair_resquared.html
pair_sdk.html
pair_sdpd_taitwater_isothermal.html
pair_smd_hertz.html
pair_smd_tlsph.html
pair_smd_triangulated_surface.html

View File

@ -0,0 +1,108 @@
"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c
:link(lws,http://lammps.sandia.gov)
:link(ld,Manual.html)
:link(lc,Commands_all.html)
:line
pair_style sdpd/taitwater/isothermal command :h3
[Syntax:]
pair_style sdpd/taitwater/isothermal temperature viscosity seed
:pre
temperature = temperature of the fluid (temperature units)
viscosity = dynamic viscosity of the fluid (mass*distance/time units)
seed = random number generator seed (positive integer, optional) :ul
[Examples:]
pair_style sdpd/taitwater/isothermal 300. 1. 28681
pair_coeff * * 1000.0 1430.0 2.4 :pre
[Description:]
The sdpd/taitwater/isothermal style computes forces between mesoscopic
particles according to the Smoothed Dissipative Particle Dynamics model
described in this paper by "(Espanol and Revenga)"_#Espanol_Revenga under
the following assumptions:
:olb
The temperature is constant and uniform. :l
The shear viscosity is constant and uniform. :l
The volume viscosity is negligible before the shear viscosity. :l
The Boltzmann constant is negligible before the heat capacity of a
single mesoscopic particle of fluid. :ole,l
The third assumption is true for water in nearly incompressible flows.
The fourth holds true for water for any reasonable size one can
imagine for a mesoscopic particle.
The pressure forces between particles will be computed according to
Tait's equation of state:
:c,image(Eqs/pair_sph_tait.jpg)
where gamma = 7 and B = c_0^2 rho_0 / gamma, with rho_0 being the
reference density and c_0 the reference speed of sound.
The laminar viscosity and the random forces will be computed according
to formulas described in "(Espanol and Revenga)"_#Espanol_Revenga.
IMPORTANT NOTE: Similar to "brownian"_pair_brownian.html and
"dpd"_pair_dpd.html styles, the "newton"_newton.html setting for
pairwise interactions needs to be on when running LAMMPS in parallel
if you want to ensure linear momentum conservation. Otherwise random
forces generated for pairs straddling processor boundary will not be
equal and opposite.
NOTE: The actual random seed used will be a mix of what you specify
and other parameters like the MPI ranks. This is to ensure that
different MPI tasks have distinct seeds.
The following coefficients must be defined for each pair of atoms
types via the "pair_coeff"_pair_coeff.html command as in the examples
above.
rho0 reference density (mass/volume units)
c0 reference soundspeed (distance/time units)
h kernel function cutoff (distance units) :ul
:line
[Mixing, shift, table, tail correction, restart, rRESPA info]:
This style does not support mixing. Thus, coefficients for all
I,J pairs must be specified explicitly.
This style does not support the "pair_modify"_pair_modify.html
shift, table, and tail options.
This style does not write information to "binary restart
files"_restart.html. Thus, you need to re-specify the pair_style and
pair_coeff commands in an input script that reads a restart file.
This style can only be used via the {pair} keyword of the "run_style
respa"_run_style.html command. It does not support the {inner},
{middle}, {outer} keywords.
[Restrictions:]
This pair style is part of the USER-SDPD package. It is only enabled
if LAMMPS was built with that package. See the "Build
package"_Build_package.html doc page for more info.
[Related commands:]
"pair coeff"_pair_coeff.html, "pair sph/rhosum"_pair_sph_rhosum.html
[Default:]
The default seed is 0 (before mixing).
:line
:link(Espanol_Revenga)
[(Espanol and Revenga)] Espanol, Revenga, Physical Review E, 67, 026705 (2003).

View File

@ -268,6 +268,7 @@ pair"_Commands_pair.html doc page are followed by one or more of
"reax/c"_pair_reaxc.html - ReaxFF potential in C
"rebo"_pair_airebo.html - 2nd generation REBO potential of Brenner
"resquared"_pair_resquared.html - Everaers RE-Squared ellipsoidal potential
"sdpd/taitwater/isothermal"_pair_sdpd_taitwater_isothermal.html - smoothed dissipative particle dynamics for water at isothermal conditions
"smd/hertz"_pair_smd_hertz.html -
"smd/tlsph"_pair_smd_tlsph.html -
"smd/tri_surface"_pair_smd_triangulated_surface.html -

View File

@ -86,6 +86,7 @@ Pair Styles :h1
pair_reaxc
pair_resquared
pair_sdk
pair_sdpd_taitwater_isothermal
pair_smd_hertz
pair_smd_tlsph
pair_smd_triangulated_surface

View File

@ -36,7 +36,7 @@ fix myrxns all bond/react stabilization yes statted_grp .03 &
react rxn2 all 1 0.0 5.0 mol3 mol4 rxn1_stp2_map
# stable at 800K
fix 1 statted_grp nvt temp 800 800 100
fix 1 statted_grp_REACT nvt temp 800 800 100
# in order to customize behavior of reacting atoms,
# you can use the internally created 'bond_react_MASTER_group', like so:

View File

@ -36,7 +36,7 @@ fix myrxns all bond/react stabilization yes statted_grp .03 &
react rxn1 all 1 0.0 2.9 mol1 mol2 rxn1_stp1_map &
react rxn2 all 1 0.0 5.0 mol3 mol4 rxn1_stp2_map
fix 1 statted_grp nvt temp 300 300 100
fix 1 statted_grp_REACT nvt temp 300 300 100
fix 4 bond_react_MASTER_group temp/rescale 1 300 300 10 1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
# Solvated 5-mer peptide
units real
atom_style full
pair_style lj/charmm/coul/long 8.0 10.0 10.0
bond_style harmonic
angle_style charmm
dihedral_style charmm
improper_style harmonic
kspace_style pppm 0.0001
read_data data.peptide
neighbor 2.0 bin
neigh_modify delay 5
timestep 2.0
group peptide type <= 12
group one id 2 4 5 6
group two id 80 82 83 84
group ref id 37
group colvar union one two ref
fix 1 all nvt temp 275.0 275.0 100.0 tchain 1
fix 2 all plumed plumedfile plumed.dat outfile p.log
fix 2a ref setforce 0.0 0.0 0.0
fix 4 all shake 0.0001 10 100 b 4 6 8 10 12 14 18 a 31
#dump 1 colvar custom 1 dump.colvar.lammpstrj id xu yu zu fx fy fz
#dump_modify 1 sort id
thermo_style custom step temp etotal pe ke epair ebond f_2
thermo 10
variable step equal step
variable pe equal pe
run 101

View File

@ -0,0 +1,162 @@
LAMMPS (24 Oct 2018)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (../comm.cpp:87)
using 1 OpenMP thread(s) per MPI task
# Solvated 5-mer peptide
units real
atom_style full
pair_style lj/charmm/coul/long 8.0 10.0 10.0
bond_style harmonic
angle_style charmm
dihedral_style charmm
improper_style harmonic
kspace_style pppm 0.0001
read_data data.peptide
orthogonal box = (36.8402 41.0137 29.7681) to (64.2116 68.3851 57.1395)
1 by 1 by 1 MPI processor grid
reading atoms ...
2004 atoms
reading velocities ...
2004 velocities
scanning bonds ...
3 = max bonds/atom
scanning angles ...
6 = max angles/atom
scanning dihedrals ...
14 = max dihedrals/atom
scanning impropers ...
1 = max impropers/atom
reading bonds ...
1365 bonds
reading angles ...
786 angles
reading dihedrals ...
207 dihedrals
reading impropers ...
12 impropers
4 = max # of 1-2 neighbors
7 = max # of 1-3 neighbors
14 = max # of 1-4 neighbors
18 = max # of special neighbors
neighbor 2.0 bin
neigh_modify delay 5
timestep 2.0
group peptide type <= 12
84 atoms in group peptide
group one id 2 4 5 6
4 atoms in group one
group two id 80 82 83 84
4 atoms in group two
group ref id 37
1 atoms in group ref
group colvar union one two ref
9 atoms in group colvar
fix 1 all nvt temp 275.0 275.0 100.0 tchain 1
fix 2 all plumed plumedfile plumed.dat outfile p.log
fix 2a ref setforce 0.0 0.0 0.0
fix 4 all shake 0.0001 10 100 b 4 6 8 10 12 14 18 a 31
19 = # of size 2 clusters
6 = # of size 3 clusters
3 = # of size 4 clusters
640 = # of frozen angles
#dump 1 colvar custom 1 dump.colvar.lammpstrj id xu yu zu fx fy fz
#dump_modify 1 sort id
thermo_style custom step temp etotal pe ke epair ebond f_2
thermo 10
variable step equal step
variable pe equal pe
run 101
PPPM initialization ...
using 12-bit tables for long-range coulomb (../kspace.cpp:321)
G vector (1/distance) = 0.268725
grid = 15 15 15
stencil order = 5
estimated absolute RMS force accuracy = 0.0228209
estimated relative force accuracy = 6.87243e-05
using double precision FFTs
3d grid and FFT values/proc = 10648 3375
Neighbor list info ...
update every 1 steps, delay 5 steps, check yes
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 12
ghost atom cutoff = 12
binsize = 6, bins = 5 5 5
1 neighbor lists, perpetual/occasional/extra = 1 0 0
(1) pair lj/charmm/coul/long, perpetual
attributes: half, newton on
pair build: half/bin/newton
stencil: half/bin/3d/newton
bin: standard
SHAKE stats (type/ave/delta) on step 0
4 1.111 1.44264e-05
6 0.996998 7.26967e-06
8 1.08 1.32536e-05
10 1.111 1.22749e-05
12 1.08 1.11767e-05
14 0.96 0
18 0.957206 4.37979e-05
31 104.519 0.00396029
Per MPI rank memory allocation (min/avg/max) = 18.7 | 18.7 | 18.7 Mbytes
Step Temp TotEng PotEng KinEng E_pair E_bond f_2
0 282.10052 -5237.458 -6372.3766 1134.9186 -6442.768 16.557152 0
10 276.9783 -5234.3057 -6348.6171 1114.3114 -6421.6171 17.024361 0.47785504
20 279.08532 -5226.4036 -6349.1917 1122.7881 -6441.0169 20.764378 0.52605302
30 282.32141 -5222.3866 -6358.1939 1135.8073 -6448.9785 22.945165 0.65106011
40 276.34173 -5218.7623 -6330.5128 1111.7504 -6423.7566 15.655345 0.23795099
50 286.12741 -5215.9248 -6367.0439 1151.1192 -6449.2655 17.420975 0.42646205
60 273.01449 -5217.7381 -6316.1026 1098.3646 -6406.4709 21.800931 0.92327815
70 274.67549 -5221.0246 -6326.0716 1105.047 -6409.7721 19.41235 0.0016975896
80 273.74824 -5224.7613 -6326.0778 1101.3165 -6418.5055 19.206793 0.48550348
90 284.32594 -5229.195 -6373.0667 1143.8717 -6461.3467 21.124789 0.5468014
SHAKE stats (type/ave/delta) on step 100
4 1.111 2.06868e-06
6 0.996999 2.09521e-06
8 1.08 1.10835e-06
10 1.111 2.46599e-06
12 1.08 8.86314e-07
14 0.959999 0
18 0.9572 9.14098e-06
31 104.52 0.000760401
100 270.40648 -5234.9604 -6322.8327 1087.8723 -6417.73 19.666404 0.0094784372
101 270.99811 -5235.8295 -6326.082 1090.2525 -6418.8974 17.285816 0.086681332
Loop time of 2.12948 on 1 procs for 101 steps with 2004 atoms
Performance: 8.196 ns/day, 2.928 hours/ns, 47.429 timesteps/s
99.8% CPU use with 1 MPI tasks x 1 OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 1.757 | 1.757 | 1.757 | 0.0 | 82.51
Bond | 0.0052233 | 0.0052233 | 0.0052233 | 0.0 | 0.25
Kspace | 0.14772 | 0.14772 | 0.14772 | 0.0 | 6.94
Neigh | 0.16455 | 0.16455 | 0.16455 | 0.0 | 7.73
Comm | 0.0083704 | 0.0083704 | 0.0083704 | 0.0 | 0.39
Output | 0.00031424 | 0.00031424 | 0.00031424 | 0.0 | 0.01
Modify | 0.044411 | 0.044411 | 0.044411 | 0.0 | 2.09
Other | | 0.001851 | | | 0.09
Nlocal: 2004 ave 2004 max 2004 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 11134 ave 11134 max 11134 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 707961 ave 707961 max 707961 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Total # of neighbors = 707961
Ave neighs/atom = 353.274
Ave special neighs/atom = 2.34032
Neighbor list builds = 8
Dangerous builds = 0
Total wall time: 0:00:02

View File

@ -0,0 +1,162 @@
LAMMPS (24 Oct 2018)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (../comm.cpp:87)
using 1 OpenMP thread(s) per MPI task
# Solvated 5-mer peptide
units real
atom_style full
pair_style lj/charmm/coul/long 8.0 10.0 10.0
bond_style harmonic
angle_style charmm
dihedral_style charmm
improper_style harmonic
kspace_style pppm 0.0001
read_data data.peptide
orthogonal box = (36.8402 41.0137 29.7681) to (64.2116 68.3851 57.1395)
1 by 2 by 2 MPI processor grid
reading atoms ...
2004 atoms
reading velocities ...
2004 velocities
scanning bonds ...
3 = max bonds/atom
scanning angles ...
6 = max angles/atom
scanning dihedrals ...
14 = max dihedrals/atom
scanning impropers ...
1 = max impropers/atom
reading bonds ...
1365 bonds
reading angles ...
786 angles
reading dihedrals ...
207 dihedrals
reading impropers ...
12 impropers
4 = max # of 1-2 neighbors
7 = max # of 1-3 neighbors
14 = max # of 1-4 neighbors
18 = max # of special neighbors
neighbor 2.0 bin
neigh_modify delay 5
timestep 2.0
group peptide type <= 12
84 atoms in group peptide
group one id 2 4 5 6
4 atoms in group one
group two id 80 82 83 84
4 atoms in group two
group ref id 37
1 atoms in group ref
group colvar union one two ref
9 atoms in group colvar
fix 1 all nvt temp 275.0 275.0 100.0 tchain 1
fix 2 all plumed plumedfile plumed.dat outfile p.log
fix 2a ref setforce 0.0 0.0 0.0
fix 4 all shake 0.0001 10 100 b 4 6 8 10 12 14 18 a 31
19 = # of size 2 clusters
6 = # of size 3 clusters
3 = # of size 4 clusters
640 = # of frozen angles
#dump 1 colvar custom 1 dump.colvar.lammpstrj id xu yu zu fx fy fz
#dump_modify 1 sort id
thermo_style custom step temp etotal pe ke epair ebond f_2
thermo 10
variable step equal step
variable pe equal pe
run 101
PPPM initialization ...
using 12-bit tables for long-range coulomb (../kspace.cpp:321)
G vector (1/distance) = 0.268725
grid = 15 15 15
stencil order = 5
estimated absolute RMS force accuracy = 0.0228209
estimated relative force accuracy = 6.87243e-05
using double precision FFTs
3d grid and FFT values/proc = 4312 960
Neighbor list info ...
update every 1 steps, delay 5 steps, check yes
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 12
ghost atom cutoff = 12
binsize = 6, bins = 5 5 5
1 neighbor lists, perpetual/occasional/extra = 1 0 0
(1) pair lj/charmm/coul/long, perpetual
attributes: half, newton on
pair build: half/bin/newton
stencil: half/bin/3d/newton
bin: standard
SHAKE stats (type/ave/delta) on step 0
4 1.111 1.44264e-05
6 0.996998 7.26967e-06
8 1.08 1.32536e-05
10 1.111 1.22749e-05
12 1.08 1.11767e-05
14 0.96 0
18 0.957206 4.37979e-05
31 104.519 0.00396029
Per MPI rank memory allocation (min/avg/max) = 15.65 | 15.86 | 16.05 Mbytes
Step Temp TotEng PotEng KinEng E_pair E_bond f_2
0 282.10052 -5237.458 -6372.3766 1134.9186 -6442.768 16.557152 0
10 276.9783 -5234.3057 -6348.6171 1114.3114 -6421.6171 17.024361 0.47785504
20 279.08532 -5226.4036 -6349.1917 1122.7881 -6441.0169 20.764378 0.52605302
30 282.32141 -5222.3866 -6358.1939 1135.8073 -6448.9785 22.945165 0.65106011
40 276.34173 -5218.7623 -6330.5128 1111.7504 -6423.7566 15.655345 0.23795099
50 286.12741 -5215.9248 -6367.0439 1151.1192 -6449.2655 17.420975 0.42646205
60 273.01449 -5217.7381 -6316.1026 1098.3646 -6406.4709 21.800931 0.92327815
70 274.67549 -5221.0246 -6326.0716 1105.047 -6409.7721 19.41235 0.0016975896
80 273.74824 -5224.7613 -6326.0778 1101.3165 -6418.5055 19.206793 0.48550348
90 284.32594 -5229.195 -6373.0667 1143.8717 -6461.3466 21.124789 0.5468014
SHAKE stats (type/ave/delta) on step 100
4 1.111 2.06868e-06
6 0.996999 2.09521e-06
8 1.08 1.10835e-06
10 1.111 2.46599e-06
12 1.08 8.86314e-07
14 0.959999 0
18 0.9572 9.14098e-06
31 104.52 0.000760401
100 270.40648 -5234.9604 -6322.8327 1087.8723 -6417.73 19.666404 0.009478437
101 270.99811 -5235.8295 -6326.082 1090.2525 -6418.8974 17.285816 0.086681332
Loop time of 1.16767 on 4 procs for 101 steps with 2004 atoms
Performance: 14.947 ns/day, 1.606 hours/ns, 86.497 timesteps/s
97.8% CPU use with 4 MPI tasks x 1 OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 0.84633 | 0.86651 | 0.88617 | 1.6 | 74.21
Bond | 0.0010614 | 0.0027132 | 0.004288 | 3.0 | 0.23
Kspace | 0.095008 | 0.1162 | 0.13491 | 4.3 | 9.95
Neigh | 0.07834 | 0.078424 | 0.078516 | 0.0 | 6.72
Comm | 0.03314 | 0.033299 | 0.033426 | 0.1 | 2.85
Output | 0.00036979 | 0.00076199 | 0.0019338 | 0.0 | 0.07
Modify | 0.063471 | 0.064011 | 0.065312 | 0.3 | 5.48
Other | | 0.005751 | | | 0.49
Nlocal: 501 ave 512 max 492 min
Histogram: 1 0 0 1 0 1 0 0 0 1
Nghost: 6570.25 ave 6604 max 6529 min
Histogram: 1 0 0 1 0 0 0 0 1 1
Neighs: 176990 ave 181122 max 173551 min
Histogram: 1 1 0 0 0 0 1 0 0 1
Total # of neighbors = 707961
Ave neighs/atom = 353.274
Ave special neighs/atom = 2.34032
Neighbor list builds = 8
Dangerous builds = 0
Total wall time: 0:00:01

View File

@ -0,0 +1,4 @@
UNITS LENGTH=A ENERGY=kcal/mol
dd: DISTANCE ATOMS=45,48
RESTRAINT ARG=dd KAPPA=2000 AT=6.0
PRINT ARG=dd FILE=colvar

View File

@ -0,0 +1,103 @@
#! FIELDS time dd
0.000000 5.985554
0.002000 6.002880
0.004000 6.022015
0.006000 6.029922
0.008000 6.020103
0.010000 5.996906
0.012000 5.972734
0.014000 5.960079
0.016000 5.963714
0.018000 5.978140
0.020000 5.991813
0.022000 5.995155
0.024000 5.987021
0.026000 5.975340
0.028000 5.971456
0.030000 5.981945
0.032000 6.003550
0.034000 6.024743
0.036000 6.032990
0.038000 6.022936
0.040000 6.000131
0.042000 5.977800
0.044000 5.968692
0.046000 5.977224
0.048000 5.996934
0.050000 6.014800
0.052000 6.019586
0.054000 6.008803
0.056000 5.989809
0.058000 5.974484
0.060000 5.971140
0.062000 5.979074
0.064000 5.989379
0.066000 5.991356
0.068000 5.980176
0.070000 5.960625
0.072000 5.944401
0.074000 5.942614
0.076000 5.958402
0.078000 5.984574
0.080000 6.007964
0.082000 6.017667
0.084000 6.011795
0.086000 5.998304
0.088000 5.989405
0.090000 5.993275
0.092000 6.008545
0.094000 6.025183
0.096000 6.031186
0.098000 6.020651
0.100000 5.997952
0.102000 5.975230
0.104000 5.964757
0.106000 5.971150
0.108000 5.988568
0.110000 6.004676
0.112000 6.008731
0.114000 5.998481
0.116000 5.981406
0.118000 5.969615
0.120000 5.971827
0.122000 5.987658
0.124000 6.007888
0.126000 6.020477
0.128000 6.018377
0.130000 6.004046
0.132000 5.987682
0.134000 5.980338
0.136000 5.986534
0.138000 6.001303
0.140000 6.013589
0.142000 6.013717
0.144000 6.000028
0.146000 5.980283
0.148000 5.966836
0.150000 5.968670
0.152000 5.985459
0.154000 6.007612
0.156000 6.022374
0.158000 6.022034
0.160000 6.008851
0.162000 5.993355
0.164000 5.987212
0.166000 5.995452
0.168000 6.013111
0.170000 6.028386
0.172000 6.030387
0.174000 6.016468
0.176000 5.994191
0.178000 5.976616
0.180000 5.973983
0.182000 5.987185
0.184000 6.007275
0.186000 6.021338
0.188000 6.020837
0.190000 6.006955
0.192000 5.989433
0.194000 5.979796
0.196000 5.983601
0.198000 5.996921
0.200000 6.009310
0.202000 6.011114

View File

@ -0,0 +1,57 @@
PLUMED: PLUMED is starting
PLUMED: Version: 2.4.2 (git: Unknown) compiled on Jul 11 2018 at 19:09:03
PLUMED: Please cite this paper when using PLUMED [1]
PLUMED: For further information see the PLUMED web page at http://www.plumed.org
PLUMED: Root: /Users/gareth/MD_code/lammps-permanent/lammps/lib/plumed/plumed2-2.4.2/
PLUMED: For installed feature, see /Users/gareth/MD_code/lammps-permanent/lammps/lib/plumed/plumed2-2.4.2//src/config/config.txt
PLUMED: Molecular dynamics engine: LAMMPS
PLUMED: Precision of reals: 8
PLUMED: Running over 1 node
PLUMED: Number of threads: 1
PLUMED: Cache line size: 512
PLUMED: Number of atoms: 2004
PLUMED: File suffix:
PLUMED: FILE: plumed.dat
PLUMED: Action UNITS
PLUMED: with label @0
PLUMED: length: A
PLUMED: energy: kcal/mol
PLUMED: time: ps
PLUMED: charge: e
PLUMED: mass: amu
PLUMED: using physical units
PLUMED: inside PLUMED, Boltzmann constant is 0.001987
PLUMED: Action DISTANCE
PLUMED: with label dd
PLUMED: between atoms 45 48
PLUMED: using periodic boundary conditions
PLUMED: Action RESTRAINT
PLUMED: with label @2
PLUMED: with arguments dd
PLUMED: added component to this action: @2.bias
PLUMED: at 6.000000
PLUMED: with harmonic force constant 2000.000000
PLUMED: and linear force constant 0.000000
PLUMED: added component to this action: @2.force2
PLUMED: Action PRINT
PLUMED: with label @3
PLUMED: with stride 1
PLUMED: with arguments dd
PLUMED: on file colvar
PLUMED: with format %f
PLUMED: END FILE: plumed.dat
PLUMED: Timestep: 0.002000
PLUMED: KbT has not been set by the MD engine
PLUMED: It should be set by hand where needed
PLUMED: Relevant bibliography:
PLUMED: [1] Tribello, Bonomi, Branduardi, Camilloni, and Bussi, Comput. Phys. Commun. 185, 604 (2014)
PLUMED: Please read and cite where appropriate!
PLUMED: Finished setup
PLUMED: Cycles Total Average Minumum Maximum
PLUMED: 1 0.020354 0.020354 0.020354 0.020354
PLUMED: 1 Prepare dependencies 102 0.000256 0.000003 0.000001 0.000006
PLUMED: 2 Sharing data 102 0.010002 0.000098 0.000078 0.000546
PLUMED: 3 Waiting for data 102 0.001398 0.000014 0.000011 0.000072
PLUMED: 4 Calculating (forward loop) 102 0.001797 0.000018 0.000013 0.000058
PLUMED: 5 Applying (backward loop) 102 0.002666 0.000026 0.000022 0.000062
PLUMED: 6 Update 102 0.001126 0.000011 0.000007 0.000055

View File

@ -0,0 +1,61 @@
dimension 2
units micro
atom_style meso
variable R equal 0.5 # radius of sphere micrometers
variable a equal $R/5 # lattice spacing micrometers
variable Lf equal $R*3
variable Lb equal $R*4
variable wall_velocity equal 0.01 # micrometers/microsecond
variable T equal 300.
variable rho_0 equal 1. # density picograms/micrometer^3
variable c_0 equal 100. # speed of sound micrometers/microsecond
variable mu equal 1. # dynamic viscosity picogram/(micrometer-microsecond)
variable h equal $a*4.5 # kernel function cutoff micrometers
variable mass equal $a*$a*$a*${rho_0}
variable dt equal 1e-3 # timestep microseconds
variable skin equal 0.2*$h
region box block -${Lb} ${Lb} -${Lb} ${Lb} 0 ${a} units box
create_box 4 box
lattice sq $a
create_atoms 1 box
region sphere sphere 0 0 0 $R units box
set region sphere type 2
region upper_wall block INF INF +${Lf} INF INF INF units box
set region upper_wall type 3
region lower_wall block INF INF INF -${Lf} INF INF units box
set region lower_wall type 4
group fluid type 1
group sphere type 2
group upper_wall type 3
group lower_wall type 4
mass * ${mass}
set group all meso/rho ${rho_0}
pair_style sdpd/taitwater/isothermal $T ${mu} 76787 # temperature viscosity random_seed
pair_coeff * * ${rho_0} ${c_0} ${h}
fix 1 fluid meso
fix 2 sphere rigid/meso single
fix 3 upper_wall meso/move linear +${wall_velocity} 0 0 units box
fix 4 lower_wall meso/move linear -${wall_velocity} 0 0 units box
fix 2d all enforce2d
neighbor ${skin} bin
neigh_modify delay 0 every 1 check yes
timestep ${dt}
dump dump_id all atom 100 dump.lammpstrj
thermo 100
thermo_style custom step time nbuild ndanger
run 10000

View File

@ -0,0 +1,247 @@
LAMMPS (24 Oct 2018)
dimension 2
units micro
atom_style meso
variable R equal 0.5 # radius of sphere micrometers
variable a equal $R/5 # lattice spacing micrometers
variable a equal 0.5/5
variable Lf equal $R*3
variable Lf equal 0.5*3
variable Lb equal $R*4
variable Lb equal 0.5*4
variable wall_velocity equal 0.01 # micrometers/microsecond
variable T equal 300.
variable rho_0 equal 1. # density picograms/micrometer^3
variable c_0 equal 100. # speed of sound micrometers/microsecond
variable mu equal 1. # dynamic viscosity picogram/(micrometer-microsecond)
variable h equal $a*4.5 # kernel function cutoff micrometers
variable h equal 0.1*4.5
variable mass equal $a*$a*$a*${rho_0}
variable mass equal 0.1*$a*$a*${rho_0}
variable mass equal 0.1*0.1*$a*${rho_0}
variable mass equal 0.1*0.1*0.1*${rho_0}
variable mass equal 0.1*0.1*0.1*1
variable dt equal 1e-3 # timestep microseconds
variable skin equal 0.2*$h
variable skin equal 0.2*0.45
region box block -${Lb} ${Lb} -${Lb} ${Lb} 0 ${a} units box
region box block -2 ${Lb} -${Lb} ${Lb} 0 ${a} units box
region box block -2 2 -${Lb} ${Lb} 0 ${a} units box
region box block -2 2 -2 ${Lb} 0 ${a} units box
region box block -2 2 -2 2 0 ${a} units box
region box block -2 2 -2 2 0 0.1 units box
create_box 4 box
Created orthogonal box = (-2 -2 0) to (2 2 0.1)
1 by 1 by 1 MPI processor grid
lattice sq $a
lattice sq 0.1
Lattice spacing in x,y,z = 0.1 0.1 0.1
create_atoms 1 box
Created 1600 atoms
Time spent = 0.00169706 secs
region sphere sphere 0 0 0 $R units box
region sphere sphere 0 0 0 0.5 units box
set region sphere type 2
81 settings made for type
region upper_wall block INF INF +${Lf} INF INF INF units box
region upper_wall block INF INF +1.5 INF INF INF units box
set region upper_wall type 3
200 settings made for type
region lower_wall block INF INF INF -${Lf} INF INF units box
region lower_wall block INF INF INF -1.5 INF INF units box
set region lower_wall type 4
240 settings made for type
group fluid type 1
1079 atoms in group fluid
group sphere type 2
81 atoms in group sphere
group upper_wall type 3
200 atoms in group upper_wall
group lower_wall type 4
240 atoms in group lower_wall
mass * ${mass}
mass * 0.001
set group all meso/rho ${rho_0}
set group all meso/rho 1
1600 settings made for meso/rho
pair_style sdpd/taitwater/isothermal $T ${mu} 76787 # temperature viscosity random_seed
pair_style sdpd/taitwater/isothermal 300 ${mu} 76787
pair_style sdpd/taitwater/isothermal 300 1 76787
pair_coeff * * ${rho_0} ${c_0} ${h}
pair_coeff * * 1 ${c_0} ${h}
pair_coeff * * 1 100 ${h}
pair_coeff * * 1 100 0.45
fix 1 fluid meso
fix 2 sphere rigid/meso single
1 rigid bodies with 81 atoms
fix 3 upper_wall meso/move linear +${wall_velocity} 0 0 units box
fix 3 upper_wall meso/move linear +0.01 0 0 units box
fix 4 lower_wall meso/move linear -${wall_velocity} 0 0 units box
fix 4 lower_wall meso/move linear -0.01 0 0 units box
fix 2d all enforce2d
neighbor ${skin} bin
neighbor 0.09 bin
neigh_modify delay 0 every 1 check yes
timestep ${dt}
timestep 0.001
dump dump_id all atom 100 dump.lammpstrj
thermo 100
thermo_style custom step time nbuild ndanger
run 10000
Neighbor list info ...
update every 1 steps, delay 0 steps, check yes
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 0.54
ghost atom cutoff = 0.54
binsize = 0.27, bins = 15 15 1
1 neighbor lists, perpetual/occasional/extra = 1 0 0
(1) pair sdpd/taitwater/isothermal, perpetual
attributes: half, newton on
pair build: half/bin/atomonly/newton
stencil: half/bin/2d/newton
bin: standard
Per MPI rank memory allocation (min/avg/max) = 6.937 | 6.937 | 6.937 Mbytes
Step Time Nbuild Ndanger
0 0 0 0
100 0.1 0 0
200 0.2 0 0
300 0.3 0 0
400 0.4 0 0
500 0.5 1 0
600 0.6 1 0
700 0.7 2 0
800 0.8 2 0
900 0.9 2 0
1000 1 3 0
1100 1.1 3 0
1200 1.2 3 0
1300 1.3 4 0
1400 1.4 4 0
1500 1.5 4 0
1600 1.6 5 0
1700 1.7 5 0
1800 1.8 5 0
1900 1.9 6 0
2000 2 6 0
2100 2.1 6 0
2200 2.2 7 0
2300 2.3 7 0
2400 2.4 7 0
2500 2.5 8 0
2600 2.6 8 0
2700 2.7 8 0
2800 2.8 9 0
2900 2.9 9 0
3000 3 9 0
3100 3.1 10 0
3200 3.2 10 0
3300 3.3 10 0
3400 3.4 11 0
3500 3.5 11 0
3600 3.6 11 0
3700 3.7 12 0
3800 3.8 12 0
3900 3.9 12 0
4000 4 13 0
4100 4.1 13 0
4200 4.2 14 0
4300 4.3 14 0
4400 4.4 14 0
4500 4.5 15 0
4600 4.6 15 0
4700 4.7 15 0
4800 4.8 16 0
4900 4.9 16 0
5000 5 16 0
5100 5.1 17 0
5200 5.2 17 0
5300 5.3 17 0
5400 5.4 17 0
5500 5.5 18 0
5600 5.6 18 0
5700 5.7 19 0
5800 5.8 19 0
5900 5.9 19 0
6000 6 20 0
6100 6.1 20 0
6200 6.2 21 0
6300 6.3 21 0
6400 6.4 21 0
6500 6.5 22 0
6600 6.6 22 0
6700 6.7 22 0
6800 6.8 23 0
6900 6.9 23 0
7000 7 23 0
7100 7.1 24 0
7200 7.2 24 0
7300 7.3 25 0
7400 7.4 25 0
7500 7.5 25 0
7600 7.6 26 0
7700 7.7 26 0
7800 7.8 26 0
7900 7.9 27 0
8000 8 27 0
8100 8.1 27 0
8200 8.2 28 0
8300 8.3 28 0
8400 8.4 28 0
8500 8.5 29 0
8600 8.6 29 0
8700 8.7 30 0
8800 8.8 30 0
8900 8.9 30 0
9000 9 31 0
9100 9.1 31 0
9200 9.2 31 0
9300 9.3 32 0
9400 9.4 32 0
9500 9.5 32 0
9600 9.6 33 0
9700 9.7 33 0
9800 9.8 33 0
9900 9.9 34 0
10000 10 34 0
Loop time of 144.208 on 1 procs for 10000 steps with 1600 atoms
Performance: 5991348.580 ns/day, 0.000 hours/ns, 69.344 timesteps/s
99.7% CPU use with 1 MPI tasks x no OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 143.08 | 143.08 | 143.08 | 0.0 | 99.22
Neigh | 0.033195 | 0.033195 | 0.033195 | 0.0 | 0.02
Comm | 0.24139 | 0.24139 | 0.24139 | 0.0 | 0.17
Output | 0.11687 | 0.11687 | 0.11687 | 0.0 | 0.08
Modify | 0.61566 | 0.61566 | 0.61566 | 0.0 | 0.43
Other | | 0.117 | | | 0.08
Nlocal: 1600 ave 1600 max 1600 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 993 ave 993 max 993 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 73236 ave 73236 max 73236 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Total # of neighbors = 73236
Ave neighs/atom = 45.7725
Neighbor list builds = 34
Dangerous builds = 0
Total wall time: 0:02:24

View File

@ -0,0 +1,247 @@
LAMMPS (24 Oct 2018)
dimension 2
units micro
atom_style meso
variable R equal 0.5 # radius of sphere micrometers
variable a equal $R/5 # lattice spacing micrometers
variable a equal 0.5/5
variable Lf equal $R*3
variable Lf equal 0.5*3
variable Lb equal $R*4
variable Lb equal 0.5*4
variable wall_velocity equal 0.01 # micrometers/microsecond
variable T equal 300.
variable rho_0 equal 1. # density picograms/micrometer^3
variable c_0 equal 100. # speed of sound micrometers/microsecond
variable mu equal 1. # dynamic viscosity picogram/(micrometer-microsecond)
variable h equal $a*4.5 # kernel function cutoff micrometers
variable h equal 0.1*4.5
variable mass equal $a*$a*$a*${rho_0}
variable mass equal 0.1*$a*$a*${rho_0}
variable mass equal 0.1*0.1*$a*${rho_0}
variable mass equal 0.1*0.1*0.1*${rho_0}
variable mass equal 0.1*0.1*0.1*1
variable dt equal 1e-3 # timestep microseconds
variable skin equal 0.2*$h
variable skin equal 0.2*0.45
region box block -${Lb} ${Lb} -${Lb} ${Lb} 0 ${a} units box
region box block -2 ${Lb} -${Lb} ${Lb} 0 ${a} units box
region box block -2 2 -${Lb} ${Lb} 0 ${a} units box
region box block -2 2 -2 ${Lb} 0 ${a} units box
region box block -2 2 -2 2 0 ${a} units box
region box block -2 2 -2 2 0 0.1 units box
create_box 4 box
Created orthogonal box = (-2 -2 0) to (2 2 0.1)
2 by 2 by 1 MPI processor grid
lattice sq $a
lattice sq 0.1
Lattice spacing in x,y,z = 0.1 0.1 0.1
create_atoms 1 box
Created 1600 atoms
Time spent = 0.000589566 secs
region sphere sphere 0 0 0 $R units box
region sphere sphere 0 0 0 0.5 units box
set region sphere type 2
81 settings made for type
region upper_wall block INF INF +${Lf} INF INF INF units box
region upper_wall block INF INF +1.5 INF INF INF units box
set region upper_wall type 3
200 settings made for type
region lower_wall block INF INF INF -${Lf} INF INF units box
region lower_wall block INF INF INF -1.5 INF INF units box
set region lower_wall type 4
240 settings made for type
group fluid type 1
1079 atoms in group fluid
group sphere type 2
81 atoms in group sphere
group upper_wall type 3
200 atoms in group upper_wall
group lower_wall type 4
240 atoms in group lower_wall
mass * ${mass}
mass * 0.001
set group all meso/rho ${rho_0}
set group all meso/rho 1
1600 settings made for meso/rho
pair_style sdpd/taitwater/isothermal $T ${mu} 76787 # temperature viscosity random_seed
pair_style sdpd/taitwater/isothermal 300 ${mu} 76787
pair_style sdpd/taitwater/isothermal 300 1 76787
pair_coeff * * ${rho_0} ${c_0} ${h}
pair_coeff * * 1 ${c_0} ${h}
pair_coeff * * 1 100 ${h}
pair_coeff * * 1 100 0.45
fix 1 fluid meso
fix 2 sphere rigid/meso single
1 rigid bodies with 81 atoms
fix 3 upper_wall meso/move linear +${wall_velocity} 0 0 units box
fix 3 upper_wall meso/move linear +0.01 0 0 units box
fix 4 lower_wall meso/move linear -${wall_velocity} 0 0 units box
fix 4 lower_wall meso/move linear -0.01 0 0 units box
fix 2d all enforce2d
neighbor ${skin} bin
neighbor 0.09 bin
neigh_modify delay 0 every 1 check yes
timestep ${dt}
timestep 0.001
dump dump_id all atom 100 dump.lammpstrj
thermo 100
thermo_style custom step time nbuild ndanger
run 10000
Neighbor list info ...
update every 1 steps, delay 0 steps, check yes
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 0.54
ghost atom cutoff = 0.54
binsize = 0.27, bins = 15 15 1
1 neighbor lists, perpetual/occasional/extra = 1 0 0
(1) pair sdpd/taitwater/isothermal, perpetual
attributes: half, newton on
pair build: half/bin/atomonly/newton
stencil: half/bin/2d/newton
bin: standard
Per MPI rank memory allocation (min/avg/max) = 6.854 | 6.854 | 6.854 Mbytes
Step Time Nbuild Ndanger
0 0 0 0
100 0.1 0 0
200 0.2 0 0
300 0.3 0 0
400 0.4 1 0
500 0.5 1 0
600 0.6 1 0
700 0.7 2 0
800 0.8 2 0
900 0.9 2 0
1000 1 3 0
1100 1.1 3 0
1200 1.2 4 0
1300 1.3 4 0
1400 1.4 4 0
1500 1.5 4 0
1600 1.6 5 0
1700 1.7 5 0
1800 1.8 5 0
1900 1.9 6 0
2000 2 6 0
2100 2.1 6 0
2200 2.2 6 0
2300 2.3 7 0
2400 2.4 7 0
2500 2.5 7 0
2600 2.6 8 0
2700 2.7 8 0
2800 2.8 8 0
2900 2.9 9 0
3000 3 9 0
3100 3.1 9 0
3200 3.2 10 0
3300 3.3 10 0
3400 3.4 10 0
3500 3.5 11 0
3600 3.6 11 0
3700 3.7 11 0
3800 3.8 12 0
3900 3.9 12 0
4000 4 12 0
4100 4.1 13 0
4200 4.2 13 0
4300 4.3 13 0
4400 4.4 14 0
4500 4.5 14 0
4600 4.6 15 0
4700 4.7 15 0
4800 4.8 15 0
4900 4.9 16 0
5000 5 16 0
5100 5.1 17 0
5200 5.2 17 0
5300 5.3 17 0
5400 5.4 17 0
5500 5.5 18 0
5600 5.6 18 0
5700 5.7 18 0
5800 5.8 19 0
5900 5.9 19 0
6000 6 20 0
6100 6.1 20 0
6200 6.2 20 0
6300 6.3 21 0
6400 6.4 21 0
6500 6.5 21 0
6600 6.6 22 0
6700 6.7 22 0
6800 6.8 22 0
6900 6.9 23 0
7000 7 23 0
7100 7.1 23 0
7200 7.2 24 0
7300 7.3 24 0
7400 7.4 25 0
7500 7.5 25 0
7600 7.6 25 0
7700 7.7 25 0
7800 7.8 26 0
7900 7.9 26 0
8000 8 26 0
8100 8.1 27 0
8200 8.2 27 0
8300 8.3 27 0
8400 8.4 28 0
8500 8.5 28 0
8600 8.6 28 0
8700 8.7 29 0
8800 8.8 29 0
8900 8.9 29 0
9000 9 30 0
9100 9.1 30 0
9200 9.2 31 0
9300 9.3 31 0
9400 9.4 31 0
9500 9.5 32 0
9600 9.6 32 0
9700 9.7 32 0
9800 9.8 32 0
9900 9.9 33 0
10000 10 33 0
Loop time of 63.2372 on 4 procs for 10000 steps with 1600 atoms
Performance: 13662841.706 ns/day, 0.000 hours/ns, 158.135 timesteps/s
94.3% CPU use with 4 MPI tasks x no OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 51.576 | 53.662 | 55.484 | 23.9 | 84.86
Neigh | 0.011519 | 0.012395 | 0.013405 | 0.7 | 0.02
Comm | 6.8389 | 8.5423 | 10.517 | 56.1 | 13.51
Output | 0.12342 | 0.12513 | 0.1302 | 0.8 | 0.20
Modify | 0.58708 | 0.69128 | 0.78806 | 11.3 | 1.09
Other | | 0.2038 | | | 0.32
Nlocal: 400 ave 411 max 388 min
Histogram: 1 1 0 0 0 0 0 0 0 2
Nghost: 552.25 ave 567 max 539 min
Histogram: 2 0 0 0 0 0 0 0 1 1
Neighs: 18298.8 ave 18781 max 17829 min
Histogram: 2 0 0 0 0 0 0 0 0 2
Total # of neighbors = 73195
Ave neighs/atom = 45.7469
Neighbor list builds = 33
Dangerous builds = 0
Total wall time: 0:01:03

View File

@ -0,0 +1,49 @@
dimension 2
units micro
atom_style meso
variable R equal 0.5 # radius of sphere micrometers
variable a equal $R/5 # lattice spacing micrometers
variable L equal $R*3
variable T equal 300.
variable rho_0 equal 1. # density picograms/micrometer^3
variable c_0 equal 100. # speed of sound micrometers/microsecond
variable mu equal 1. # dynamic viscosity picogram/(micrometer-microsecond)
variable h equal $a*4.5 # kernel function cutoff micrometers
variable mass equal $a*$a*$a*${rho_0}
variable dt equal 1e-3 # timestep microseconds
variable skin equal 0.2*$h
region box block -$L $L -$L $L 0 $a units box
create_box 2 box
lattice sq $a
create_atoms 1 box
region sphere sphere 0 0 0 $R units box
set region sphere type 2
group fluid type 1
group sphere type 2
mass * ${mass}
set group all meso/rho ${rho_0}
pair_style sdpd/taitwater/isothermal $T ${mu} 76787 # temperature viscosity random_seed
pair_coeff * * ${rho_0} ${c_0} ${h}
fix 1 fluid meso
fix 2 sphere rigid/meso single
fix 2d all enforce2d
neighbor ${skin} bin
neigh_modify delay 0 every 1 check yes
timestep ${dt}
dump dump_id all atom 100 dump.lammpstrj
thermo 100
thermo_style custom step time nbuild ndanger
run 10000

View File

@ -0,0 +1,226 @@
LAMMPS (24 Oct 2018)
dimension 2
units micro
atom_style meso
variable R equal 0.5 # radius of sphere micrometers
variable a equal $R/5 # lattice spacing micrometers
variable a equal 0.5/5
variable L equal $R*3
variable L equal 0.5*3
variable T equal 300.
variable rho_0 equal 1. # density picograms/micrometer^3
variable c_0 equal 100. # speed of sound micrometers/microsecond
variable mu equal 1. # dynamic viscosity picogram/(micrometer-microsecond)
variable h equal $a*4.5 # kernel function cutoff micrometers
variable h equal 0.1*4.5
variable mass equal $a*$a*$a*${rho_0}
variable mass equal 0.1*$a*$a*${rho_0}
variable mass equal 0.1*0.1*$a*${rho_0}
variable mass equal 0.1*0.1*0.1*${rho_0}
variable mass equal 0.1*0.1*0.1*1
variable dt equal 1e-3 # timestep microseconds
variable skin equal 0.2*$h
variable skin equal 0.2*0.45
region box block -$L $L -$L $L 0 $a units box
region box block -1.5 $L -$L $L 0 $a units box
region box block -1.5 1.5 -$L $L 0 $a units box
region box block -1.5 1.5 -1.5 $L 0 $a units box
region box block -1.5 1.5 -1.5 1.5 0 $a units box
region box block -1.5 1.5 -1.5 1.5 0 0.1 units box
create_box 2 box
Created orthogonal box = (-1.5 -1.5 0) to (1.5 1.5 0.1)
1 by 1 by 1 MPI processor grid
lattice sq $a
lattice sq 0.1
Lattice spacing in x,y,z = 0.1 0.1 0.1
create_atoms 1 box
Created 900 atoms
Time spent = 0.0015769 secs
region sphere sphere 0 0 0 $R units box
region sphere sphere 0 0 0 0.5 units box
set region sphere type 2
81 settings made for type
group fluid type 1
819 atoms in group fluid
group sphere type 2
81 atoms in group sphere
mass * ${mass}
mass * 0.001
set group all meso/rho ${rho_0}
set group all meso/rho 1
900 settings made for meso/rho
pair_style sdpd/taitwater/isothermal $T ${mu} 76787 # temperature viscosity random_seed
pair_style sdpd/taitwater/isothermal 300 ${mu} 76787
pair_style sdpd/taitwater/isothermal 300 1 76787
pair_coeff * * ${rho_0} ${c_0} ${h}
pair_coeff * * 1 ${c_0} ${h}
pair_coeff * * 1 100 ${h}
pair_coeff * * 1 100 0.45
fix 1 fluid meso
fix 2 sphere rigid/meso single
1 rigid bodies with 81 atoms
fix 2d all enforce2d
neighbor ${skin} bin
neighbor 0.09 bin
neigh_modify delay 0 every 1 check yes
timestep ${dt}
timestep 0.001
dump dump_id all atom 100 dump.lammpstrj
thermo 100
thermo_style custom step time nbuild ndanger
run 10000
Neighbor list info ...
update every 1 steps, delay 0 steps, check yes
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 0.54
ghost atom cutoff = 0.54
binsize = 0.27, bins = 12 12 1
1 neighbor lists, perpetual/occasional/extra = 1 0 0
(1) pair sdpd/taitwater/isothermal, perpetual
attributes: half, newton on
pair build: half/bin/atomonly/newton
stencil: half/bin/2d/newton
bin: standard
Per MPI rank memory allocation (min/avg/max) = 6.137 | 6.137 | 6.137 Mbytes
Step Time Nbuild Ndanger
0 0 0 0
100 0.1 0 0
200 0.2 0 0
300 0.3 0 0
400 0.4 1 0
500 0.5 1 0
600 0.6 1 0
700 0.7 2 0
800 0.8 2 0
900 0.9 2 0
1000 1 3 0
1100 1.1 3 0
1200 1.2 3 0
1300 1.3 4 0
1400 1.4 4 0
1500 1.5 4 0
1600 1.6 5 0
1700 1.7 5 0
1800 1.8 6 0
1900 1.9 6 0
2000 2 6 0
2100 2.1 7 0
2200 2.2 7 0
2300 2.3 7 0
2400 2.4 7 0
2500 2.5 8 0
2600 2.6 8 0
2700 2.7 8 0
2800 2.8 9 0
2900 2.9 9 0
3000 3 10 0
3100 3.1 10 0
3200 3.2 10 0
3300 3.3 11 0
3400 3.4 11 0
3500 3.5 11 0
3600 3.6 12 0
3700 3.7 12 0
3800 3.8 12 0
3900 3.9 13 0
4000 4 13 0
4100 4.1 13 0
4200 4.2 14 0
4300 4.3 14 0
4400 4.4 14 0
4500 4.5 15 0
4600 4.6 15 0
4700 4.7 15 0
4800 4.8 16 0
4900 4.9 16 0
5000 5 17 0
5100 5.1 17 0
5200 5.2 17 0
5300 5.3 17 0
5400 5.4 18 0
5500 5.5 18 0
5600 5.6 18 0
5700 5.7 19 0
5800 5.8 19 0
5900 5.9 19 0
6000 6 19 0
6100 6.1 20 0
6200 6.2 20 0
6300 6.3 20 0
6400 6.4 21 0
6500 6.5 21 0
6600 6.6 21 0
6700 6.7 21 0
6800 6.8 22 0
6900 6.9 22 0
7000 7 22 0
7100 7.1 23 0
7200 7.2 23 0
7300 7.3 23 0
7400 7.4 24 0
7500 7.5 24 0
7600 7.6 24 0
7700 7.7 25 0
7800 7.8 25 0
7900 7.9 26 0
8000 8 26 0
8100 8.1 26 0
8200 8.2 26 0
8300 8.3 27 0
8400 8.4 27 0
8500 8.5 27 0
8600 8.6 28 0
8700 8.7 28 0
8800 8.8 28 0
8900 8.9 29 0
9000 9 29 0
9100 9.1 29 0
9200 9.2 30 0
9300 9.3 30 0
9400 9.4 30 0
9500 9.5 30 0
9600 9.6 31 0
9700 9.7 31 0
9800 9.8 32 0
9900 9.9 32 0
10000 10 32 0
Loop time of 80.9456 on 1 procs for 10000 steps with 900 atoms
Performance: 10673829.855 ns/day, 0.000 hours/ns, 123.540 timesteps/s
99.8% CPU use with 1 MPI tasks x no OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 80.306 | 80.306 | 80.306 | 0.0 | 99.21
Neigh | 0.017418 | 0.017418 | 0.017418 | 0.0 | 0.02
Comm | 0.16939 | 0.16939 | 0.16939 | 0.0 | 0.21
Output | 0.070281 | 0.070281 | 0.070281 | 0.0 | 0.09
Modify | 0.3154 | 0.3154 | 0.3154 | 0.0 | 0.39
Other | | 0.067 | | | 0.08
Nlocal: 900 ave 900 max 900 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 762 ave 762 max 762 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 40697 ave 40697 max 40697 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Total # of neighbors = 40697
Ave neighs/atom = 45.2189
Neighbor list builds = 32
Dangerous builds = 0
Total wall time: 0:01:20

View File

@ -0,0 +1,226 @@
LAMMPS (24 Oct 2018)
dimension 2
units micro
atom_style meso
variable R equal 0.5 # radius of sphere micrometers
variable a equal $R/5 # lattice spacing micrometers
variable a equal 0.5/5
variable L equal $R*3
variable L equal 0.5*3
variable T equal 300.
variable rho_0 equal 1. # density picograms/micrometer^3
variable c_0 equal 100. # speed of sound micrometers/microsecond
variable mu equal 1. # dynamic viscosity picogram/(micrometer-microsecond)
variable h equal $a*4.5 # kernel function cutoff micrometers
variable h equal 0.1*4.5
variable mass equal $a*$a*$a*${rho_0}
variable mass equal 0.1*$a*$a*${rho_0}
variable mass equal 0.1*0.1*$a*${rho_0}
variable mass equal 0.1*0.1*0.1*${rho_0}
variable mass equal 0.1*0.1*0.1*1
variable dt equal 1e-3 # timestep microseconds
variable skin equal 0.2*$h
variable skin equal 0.2*0.45
region box block -$L $L -$L $L 0 $a units box
region box block -1.5 $L -$L $L 0 $a units box
region box block -1.5 1.5 -$L $L 0 $a units box
region box block -1.5 1.5 -1.5 $L 0 $a units box
region box block -1.5 1.5 -1.5 1.5 0 $a units box
region box block -1.5 1.5 -1.5 1.5 0 0.1 units box
create_box 2 box
Created orthogonal box = (-1.5 -1.5 0) to (1.5 1.5 0.1)
2 by 2 by 1 MPI processor grid
lattice sq $a
lattice sq 0.1
Lattice spacing in x,y,z = 0.1 0.1 0.1
create_atoms 1 box
Created 900 atoms
Time spent = 0.0010246 secs
region sphere sphere 0 0 0 $R units box
region sphere sphere 0 0 0 0.5 units box
set region sphere type 2
81 settings made for type
group fluid type 1
819 atoms in group fluid
group sphere type 2
81 atoms in group sphere
mass * ${mass}
mass * 0.001
set group all meso/rho ${rho_0}
set group all meso/rho 1
900 settings made for meso/rho
pair_style sdpd/taitwater/isothermal $T ${mu} 76787 # temperature viscosity random_seed
pair_style sdpd/taitwater/isothermal 300 ${mu} 76787
pair_style sdpd/taitwater/isothermal 300 1 76787
pair_coeff * * ${rho_0} ${c_0} ${h}
pair_coeff * * 1 ${c_0} ${h}
pair_coeff * * 1 100 ${h}
pair_coeff * * 1 100 0.45
fix 1 fluid meso
fix 2 sphere rigid/meso single
1 rigid bodies with 81 atoms
fix 2d all enforce2d
neighbor ${skin} bin
neighbor 0.09 bin
neigh_modify delay 0 every 1 check yes
timestep ${dt}
timestep 0.001
dump dump_id all atom 100 dump.lammpstrj
thermo 100
thermo_style custom step time nbuild ndanger
run 10000
Neighbor list info ...
update every 1 steps, delay 0 steps, check yes
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 0.54
ghost atom cutoff = 0.54
binsize = 0.27, bins = 12 12 1
1 neighbor lists, perpetual/occasional/extra = 1 0 0
(1) pair sdpd/taitwater/isothermal, perpetual
attributes: half, newton on
pair build: half/bin/atomonly/newton
stencil: half/bin/2d/newton
bin: standard
Per MPI rank memory allocation (min/avg/max) = 6.087 | 6.087 | 6.087 Mbytes
Step Time Nbuild Ndanger
0 0 0 0
100 0.1 0 0
200 0.2 0 0
300 0.3 0 0
400 0.4 1 0
500 0.5 1 0
600 0.6 1 0
700 0.7 2 0
800 0.8 2 0
900 0.9 2 0
1000 1 3 0
1100 1.1 3 0
1200 1.2 3 0
1300 1.3 4 0
1400 1.4 4 0
1500 1.5 5 0
1600 1.6 5 0
1700 1.7 5 0
1800 1.8 6 0
1900 1.9 6 0
2000 2 6 0
2100 2.1 7 0
2200 2.2 7 0
2300 2.3 7 0
2400 2.4 8 0
2500 2.5 8 0
2600 2.6 8 0
2700 2.7 9 0
2800 2.8 9 0
2900 2.9 9 0
3000 3 9 0
3100 3.1 10 0
3200 3.2 10 0
3300 3.3 10 0
3400 3.4 11 0
3500 3.5 11 0
3600 3.6 11 0
3700 3.7 12 0
3800 3.8 12 0
3900 3.9 12 0
4000 4 13 0
4100 4.1 13 0
4200 4.2 13 0
4300 4.3 14 0
4400 4.4 14 0
4500 4.5 15 0
4600 4.6 15 0
4700 4.7 15 0
4800 4.8 16 0
4900 4.9 16 0
5000 5 16 0
5100 5.1 16 0
5200 5.2 17 0
5300 5.3 17 0
5400 5.4 18 0
5500 5.5 18 0
5600 5.6 19 0
5700 5.7 19 0
5800 5.8 19 0
5900 5.9 20 0
6000 6 20 0
6100 6.1 20 0
6200 6.2 21 0
6300 6.3 21 0
6400 6.4 21 0
6500 6.5 22 0
6600 6.6 22 0
6700 6.7 22 0
6800 6.8 23 0
6900 6.9 23 0
7000 7 23 0
7100 7.1 24 0
7200 7.2 24 0
7300 7.3 24 0
7400 7.4 25 0
7500 7.5 25 0
7600 7.6 25 0
7700 7.7 26 0
7800 7.8 26 0
7900 7.9 26 0
8000 8 27 0
8100 8.1 27 0
8200 8.2 27 0
8300 8.3 28 0
8400 8.4 28 0
8500 8.5 28 0
8600 8.6 28 0
8700 8.7 29 0
8800 8.8 29 0
8900 8.9 29 0
9000 9 30 0
9100 9.1 30 0
9200 9.2 31 0
9300 9.3 31 0
9400 9.4 31 0
9500 9.5 31 0
9600 9.6 32 0
9700 9.7 32 0
9800 9.8 32 0
9900 9.9 33 0
10000 10 33 0
Loop time of 69.01 on 4 procs for 10000 steps with 900 atoms
Performance: 12519931.275 ns/day, 0.000 hours/ns, 144.907 timesteps/s
48.7% CPU use with 4 MPI tasks x no OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 56.528 | 57.936 | 58.729 | 11.0 | 83.95
Neigh | 0.013157 | 0.013382 | 0.013551 | 0.1 | 0.02
Comm | 8.9594 | 9.7555 | 11.113 | 26.7 | 14.14
Output | 0.14644 | 0.15009 | 0.15809 | 1.2 | 0.22
Modify | 0.72913 | 0.91574 | 1.0524 | 12.4 | 1.33
Other | | 0.2389 | | | 0.35
Nlocal: 225 ave 229 max 223 min
Histogram: 1 2 0 0 0 0 0 0 0 1
Nghost: 442 ave 444 max 439 min
Histogram: 1 0 0 0 1 0 0 0 0 2
Neighs: 10188.8 ave 10437 max 9932 min
Histogram: 1 0 0 1 0 0 0 1 0 1
Total # of neighbors = 40755
Ave neighs/atom = 45.2833
Neighbor list builds = 33
Dangerous builds = 0
Total wall time: 0:01:09

24
examples/USER/sdpd/README Normal file
View File

@ -0,0 +1,24 @@
Smoothed Dissipative Particle Dynamics examples
equipartition-verification:
This example verifies the equipartition theorem.
It simulates a periodic box of water with no solid bodies.
If equipartition theorem holds true, the average of each component of
translational kinetic energy should be equal to k_B T, and therefore
vx_sq_check, vy_sq_check, and vz_sq_check should fluctuate near 1.
2d-diffusion:
This example demonstrates the free diffusion of a disk in 2D.
The 3D simulation is similar but takes much longer to complete.
As with other statistical experiments you need an ensemble to
extract meaningful average quantities.
For a more realistic simulation you should increase the resolution
of the disk/sphere which also necessitates reduction of timestep.
2d-diffusion-in-shear-flow:
This example demonstrates the diffusion of a disk in shear flow in 2D.
The 3D simulation is similar but takes much longer to complete.
As with other statistical experiments you need an ensemble to
extract meaningful average quantities.
For a more realistic simulation you should increase the resolution
of the disk/sphere which also necessitates reduction of timestep.

View File

@ -0,0 +1,45 @@
dimension 3
units micro
atom_style meso
variable a equal 0.1 # lattice spacing micrometers
variable L equal $a*10
variable T equal 300.
variable kB equal 1.3806504e-8 # picogram-micrometer^2/(microsecond^2-Kelvin)
variable rho_0 equal 1. # density picograms/micrometer^3
variable c_0 equal 10. # speed of sound micrometers/microsecond
variable mu equal 1. # dynamic viscosity picogram/(micrometer-microsecond)
variable h equal $a*4.0 # kernel function cutoff micrometers
variable mass equal $a*$a*$a*${rho_0}
variable dt equal 5e-4 # timestep microseconds
variable skin equal 0.1*$h
region box block -$L $L -$L $L -$L $L units box
create_box 1 box
lattice sc $a
create_atoms 1 box
mass * ${mass}
set group all meso/rho ${rho_0}
pair_style sdpd/taitwater/isothermal $T ${mu} 76787 # temperature viscosity random_seed
pair_coeff * * ${rho_0} ${c_0} ${h}
variable vx_sq atom vx*vx
variable vy_sq atom vy*vy
variable vz_sq atom vz*vz
compute v_sq all reduce ave v_vx_sq v_vy_sq v_vz_sq
variable vx_sq_check equal c_v_sq[1]*${mass}/${kB}/$T
variable vy_sq_check equal c_v_sq[2]*${mass}/${kB}/$T
variable vz_sq_check equal c_v_sq[3]*${mass}/${kB}/$T
fix 1 all meso
neighbor ${skin} bin
timestep ${dt}
thermo 10
thermo_style custom step time v_vx_sq_check v_vy_sq_check v_vz_sq_check
run 200

View File

@ -0,0 +1,146 @@
LAMMPS (24 Oct 2018)
dimension 3
units micro
atom_style meso
variable a equal 0.1 # lattice spacing micrometers
variable L equal $a*10
variable L equal 0.1*10
variable T equal 300.
variable kB equal 1.3806504e-8 # picogram-micrometer^2/(microsecond^2-Kelvin)
variable rho_0 equal 1. # density picograms/micrometer^3
variable c_0 equal 10. # speed of sound micrometers/microsecond
variable mu equal 1. # dynamic viscosity picogram/(micrometer-microsecond)
variable h equal $a*4.0 # kernel function cutoff micrometers
variable h equal 0.1*4.0
variable mass equal $a*$a*$a*${rho_0}
variable mass equal 0.1*$a*$a*${rho_0}
variable mass equal 0.1*0.1*$a*${rho_0}
variable mass equal 0.1*0.1*0.1*${rho_0}
variable mass equal 0.1*0.1*0.1*1
variable dt equal 5e-4 # timestep microseconds
variable skin equal 0.1*$h
variable skin equal 0.1*0.4
region box block -$L $L -$L $L -$L $L units box
region box block -1 $L -$L $L -$L $L units box
region box block -1 1 -$L $L -$L $L units box
region box block -1 1 -1 $L -$L $L units box
region box block -1 1 -1 1 -$L $L units box
region box block -1 1 -1 1 -1 $L units box
region box block -1 1 -1 1 -1 1 units box
create_box 1 box
Created orthogonal box = (-1 -1 -1) to (1 1 1)
1 by 1 by 1 MPI processor grid
lattice sc $a
lattice sc 0.1
Lattice spacing in x,y,z = 0.1 0.1 0.1
create_atoms 1 box
Created 8000 atoms
Time spent = 0.00285411 secs
mass * ${mass}
mass * 0.001
set group all meso/rho ${rho_0}
set group all meso/rho 1
8000 settings made for meso/rho
pair_style sdpd/taitwater/isothermal $T ${mu} 76787 # temperature viscosity random_seed
pair_style sdpd/taitwater/isothermal 300 ${mu} 76787
pair_style sdpd/taitwater/isothermal 300 1 76787
pair_coeff * * ${rho_0} ${c_0} ${h}
pair_coeff * * 1 ${c_0} ${h}
pair_coeff * * 1 10 ${h}
pair_coeff * * 1 10 0.4
variable vx_sq atom vx*vx
variable vy_sq atom vy*vy
variable vz_sq atom vz*vz
compute v_sq all reduce ave v_vx_sq v_vy_sq v_vz_sq
variable vx_sq_check equal c_v_sq[1]*${mass}/${kB}/$T
variable vx_sq_check equal c_v_sq[1]*0.001/${kB}/$T
variable vx_sq_check equal c_v_sq[1]*0.001/1.3806504e-08/$T
variable vx_sq_check equal c_v_sq[1]*0.001/1.3806504e-08/300
variable vy_sq_check equal c_v_sq[2]*${mass}/${kB}/$T
variable vy_sq_check equal c_v_sq[2]*0.001/${kB}/$T
variable vy_sq_check equal c_v_sq[2]*0.001/1.3806504e-08/$T
variable vy_sq_check equal c_v_sq[2]*0.001/1.3806504e-08/300
variable vz_sq_check equal c_v_sq[3]*${mass}/${kB}/$T
variable vz_sq_check equal c_v_sq[3]*0.001/${kB}/$T
variable vz_sq_check equal c_v_sq[3]*0.001/1.3806504e-08/$T
variable vz_sq_check equal c_v_sq[3]*0.001/1.3806504e-08/300
fix 1 all meso
neighbor ${skin} bin
neighbor 0.04 bin
timestep ${dt}
timestep 0.0005
thermo 10
thermo_style custom step time v_vx_sq_check v_vy_sq_check v_vz_sq_check
run 200
Neighbor list info ...
update every 1 steps, delay 10 steps, check yes
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 0.44
ghost atom cutoff = 0.44
binsize = 0.22, bins = 10 10 10
1 neighbor lists, perpetual/occasional/extra = 1 0 0
(1) pair sdpd/taitwater/isothermal, perpetual
attributes: half, newton on
pair build: half/bin/atomonly/newton
stencil: half/bin/3d/newton
bin: standard
Per MPI rank memory allocation (min/avg/max) = 13.54 | 13.54 | 13.54 Mbytes
Step Time v_vx_sq_check v_vy_sq_check v_vz_sq_check
0 0 0 0 0
10 0.005 0.70973271 0.71495693 0.71910087
20 0.01 0.90418096 0.88845437 0.89659567
30 0.015 0.9590736 0.97880338 0.9619016
40 0.02 0.98533774 0.96057682 0.95600448
50 0.025 0.96433662 0.96650071 0.95509683
60 0.03 0.96598029 0.96373656 0.96734888
70 0.035 0.95433045 0.98004764 0.96255924
80 0.04 0.97872906 0.95987289 0.96623598
90 0.045 0.99913888 0.99255731 0.95616142
100 0.05 0.98872675 0.97141018 0.95338841
110 0.055 0.97794592 0.97389258 0.98473719
120 0.06 0.98389266 0.96716284 0.95504862
130 0.065 0.98572886 0.96680923 0.95599065
140 0.07 0.97602684 0.97580081 0.9886878
150 0.075 0.99172003 0.95027467 0.96028033
160 0.08 0.96793247 0.94590928 0.95644301
170 0.085 0.94167619 0.98048861 0.93439426
180 0.09 0.97277934 0.97383622 0.96900866
190 0.095 0.96647288 1.0027643 0.96230782
200 0.1 0.94864291 0.95902585 0.96398175
Loop time of 60.1095 on 1 procs for 200 steps with 8000 atoms
Performance: 143737.595 ns/day, 0.000 hours/ns, 3.327 timesteps/s
99.7% CPU use with 1 MPI tasks x no OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 59.92 | 59.92 | 59.92 | 0.0 | 99.68
Neigh | 0 | 0 | 0 | 0.0 | 0.00
Comm | 0.11154 | 0.11154 | 0.11154 | 0.0 | 0.19
Output | 0.0063498 | 0.0063498 | 0.0063498 | 0.0 | 0.01
Modify | 0.043546 | 0.043546 | 0.043546 | 0.0 | 0.07
Other | | 0.02811 | | | 0.05
Nlocal: 8000 ave 8000 max 8000 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 16389 ave 16389 max 16389 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 1.456e+06 ave 1.456e+06 max 1.456e+06 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Total # of neighbors = 1456000
Ave neighs/atom = 182
Neighbor list builds = 0
Dangerous builds = 0
Total wall time: 0:01:00

View File

@ -0,0 +1,146 @@
LAMMPS (24 Oct 2018)
dimension 3
units micro
atom_style meso
variable a equal 0.1 # lattice spacing micrometers
variable L equal $a*10
variable L equal 0.1*10
variable T equal 300.
variable kB equal 1.3806504e-8 # picogram-micrometer^2/(microsecond^2-Kelvin)
variable rho_0 equal 1. # density picograms/micrometer^3
variable c_0 equal 10. # speed of sound micrometers/microsecond
variable mu equal 1. # dynamic viscosity picogram/(micrometer-microsecond)
variable h equal $a*4.0 # kernel function cutoff micrometers
variable h equal 0.1*4.0
variable mass equal $a*$a*$a*${rho_0}
variable mass equal 0.1*$a*$a*${rho_0}
variable mass equal 0.1*0.1*$a*${rho_0}
variable mass equal 0.1*0.1*0.1*${rho_0}
variable mass equal 0.1*0.1*0.1*1
variable dt equal 5e-4 # timestep microseconds
variable skin equal 0.1*$h
variable skin equal 0.1*0.4
region box block -$L $L -$L $L -$L $L units box
region box block -1 $L -$L $L -$L $L units box
region box block -1 1 -$L $L -$L $L units box
region box block -1 1 -1 $L -$L $L units box
region box block -1 1 -1 1 -$L $L units box
region box block -1 1 -1 1 -1 $L units box
region box block -1 1 -1 1 -1 1 units box
create_box 1 box
Created orthogonal box = (-1 -1 -1) to (1 1 1)
1 by 2 by 2 MPI processor grid
lattice sc $a
lattice sc 0.1
Lattice spacing in x,y,z = 0.1 0.1 0.1
create_atoms 1 box
Created 8000 atoms
Time spent = 0.00252754 secs
mass * ${mass}
mass * 0.001
set group all meso/rho ${rho_0}
set group all meso/rho 1
8000 settings made for meso/rho
pair_style sdpd/taitwater/isothermal $T ${mu} 76787 # temperature viscosity random_seed
pair_style sdpd/taitwater/isothermal 300 ${mu} 76787
pair_style sdpd/taitwater/isothermal 300 1 76787
pair_coeff * * ${rho_0} ${c_0} ${h}
pair_coeff * * 1 ${c_0} ${h}
pair_coeff * * 1 10 ${h}
pair_coeff * * 1 10 0.4
variable vx_sq atom vx*vx
variable vy_sq atom vy*vy
variable vz_sq atom vz*vz
compute v_sq all reduce ave v_vx_sq v_vy_sq v_vz_sq
variable vx_sq_check equal c_v_sq[1]*${mass}/${kB}/$T
variable vx_sq_check equal c_v_sq[1]*0.001/${kB}/$T
variable vx_sq_check equal c_v_sq[1]*0.001/1.3806504e-08/$T
variable vx_sq_check equal c_v_sq[1]*0.001/1.3806504e-08/300
variable vy_sq_check equal c_v_sq[2]*${mass}/${kB}/$T
variable vy_sq_check equal c_v_sq[2]*0.001/${kB}/$T
variable vy_sq_check equal c_v_sq[2]*0.001/1.3806504e-08/$T
variable vy_sq_check equal c_v_sq[2]*0.001/1.3806504e-08/300
variable vz_sq_check equal c_v_sq[3]*${mass}/${kB}/$T
variable vz_sq_check equal c_v_sq[3]*0.001/${kB}/$T
variable vz_sq_check equal c_v_sq[3]*0.001/1.3806504e-08/$T
variable vz_sq_check equal c_v_sq[3]*0.001/1.3806504e-08/300
fix 1 all meso
neighbor ${skin} bin
neighbor 0.04 bin
timestep ${dt}
timestep 0.0005
thermo 10
thermo_style custom step time v_vx_sq_check v_vy_sq_check v_vz_sq_check
run 200
Neighbor list info ...
update every 1 steps, delay 10 steps, check yes
max neighbors/atom: 2000, page size: 100000
master list distance cutoff = 0.44
ghost atom cutoff = 0.44
binsize = 0.22, bins = 10 10 10
1 neighbor lists, perpetual/occasional/extra = 1 0 0
(1) pair sdpd/taitwater/isothermal, perpetual
attributes: half, newton on
pair build: half/bin/atomonly/newton
stencil: half/bin/3d/newton
bin: standard
Per MPI rank memory allocation (min/avg/max) = 5.795 | 5.795 | 5.795 Mbytes
Step Time v_vx_sq_check v_vy_sq_check v_vz_sq_check
0 0 0 0 0
10 0.005 0.71224819 0.71470372 0.7008956
20 0.01 0.90627589 0.90683966 0.90116506
30 0.015 0.938505 0.95884272 0.93337542
40 0.02 0.94394649 0.93668038 0.96468004
50 0.025 0.97152309 0.97546161 0.95107762
60 0.03 0.94710871 0.95678322 0.97285504
70 0.035 0.96253148 0.95838642 0.95450883
80 0.04 0.97581495 0.95278681 0.95099478
90 0.045 0.96251614 0.9740684 0.96081505
100 0.05 0.94191275 0.97137523 0.94084858
110 0.055 0.953406 0.95739684 0.98574522
120 0.06 0.99001614 0.99608287 0.9839996
130 0.065 0.96575225 0.94309655 0.92847798
140 0.07 0.97642687 0.97458638 0.94696406
150 0.075 0.99316381 0.96876814 0.95440106
160 0.08 0.94589744 0.95264791 0.95495169
170 0.085 0.97599092 0.95336014 0.97687718
180 0.09 0.97214242 0.9726305 0.9726035
190 0.095 0.97577583 0.96523645 0.9756968
200 0.1 0.96386053 0.97268854 0.94582436
Loop time of 32.5247 on 4 procs for 200 steps with 8000 atoms
Performance: 265644.515 ns/day, 0.000 hours/ns, 6.149 timesteps/s
73.9% CPU use with 4 MPI tasks x no OpenMP threads
MPI task timing breakdown:
Section | min time | avg time | max time |%varavg| %total
---------------------------------------------------------------
Pair | 27.385 | 28.409 | 28.761 | 11.1 | 87.34
Neigh | 0 | 0 | 0 | 0.0 | 0.00
Comm | 3.582 | 3.9343 | 4.9531 | 29.7 | 12.10
Output | 0.022267 | 0.026073 | 0.033141 | 2.7 | 0.08
Modify | 0.031714 | 0.033134 | 0.034367 | 0.6 | 0.10
Other | | 0.1226 | | | 0.38
Nlocal: 2000 ave 2000 max 2000 min
Histogram: 4 0 0 0 0 0 0 0 0 0
Nghost: 8469 ave 8469 max 8469 min
Histogram: 4 0 0 0 0 0 0 0 0 0
Neighs: 364000 ave 376628 max 351184 min
Histogram: 1 0 1 0 0 0 0 1 0 1
Total # of neighbors = 1456000
Ave neighs/atom = 182
Neighbor list builds = 0
Dangerous builds = 0
Total wall time: 0:00:32

View File

@ -426,8 +426,8 @@ int colvar::init_custom_function(std::string const &conf)
if (x.size() != value_evaluators.size()) {
cvm::error("Error: based on custom function type, expected "
+ cvm::to_str(x.size()) + " scalar expressions, but "
+ cvm::to_str(value_evaluators.size() + " were found.\n"));
+ cvm::to_str(x.size()) + " scalar expressions, but "
+ cvm::to_str(value_evaluators.size()) + " were found.\n");
return INPUT_ERROR;
}
@ -455,36 +455,42 @@ int colvar::init_grid_parameters(std::string const &conf)
}
lower_boundary.type(value());
upper_boundary.type(value());
upper_wall.type(value());
if (is_enabled(f_cv_scalar)) {
if (get_keyval(conf, "lowerBoundary", lower_boundary, lower_boundary)) {
enable(f_cv_lower_boundary);
}
std::string lw_conf, uw_conf;
if (get_keyval(conf, "lowerWallConstant", lower_wall_k, 0.0, parse_silent)) {
cvm::log("Warning: lowerWallConstant and lowerWall are deprecated, "
"please define a harmonicWalls bias instead.\n");
lower_wall.type(value());
get_keyval(conf, "lowerWall", lower_wall, lower_boundary);
lw_conf = std::string("\n\
lowerWallConstant "+cvm::to_str(lower_wall_k*width*width)+"\n\
lowerWalls "+cvm::to_str(lower_wall)+"\n");
}
if (get_keyval(conf, "upperBoundary", upper_boundary, upper_boundary)) {
enable(f_cv_upper_boundary);
}
if (get_keyval(conf, "upperWallConstant", upper_wall_k, 0.0, parse_silent)) {
cvm::log("Warning: upperWallConstant and upperWall are deprecated, "
"please define a harmonicWalls bias instead.\n");
std::string lw_conf, uw_conf;
if (get_keyval(conf, "lowerWallConstant", lower_wall_k, 0.0,
parse_silent)) {
cvm::log("Reading legacy options lowerWall and lowerWallConstant: "
"consider using a harmonicWalls restraint.\n");
lower_wall.type(value());
if (!get_keyval(conf, "lowerWall", lower_wall, lower_boundary)) {
cvm::log("Warning: lowerWall will need to be "
"defined explicitly in the next release.\n");
}
lw_conf = std::string("\n\
lowerWallConstant "+cvm::to_str(lower_wall_k*width*width)+"\n\
lowerWalls "+cvm::to_str(lower_wall)+"\n");
}
if (get_keyval(conf, "upperWallConstant", upper_wall_k, 0.0,
parse_silent)) {
cvm::log("Reading legacy options upperWall and upperWallConstant: "
"consider using a harmonicWalls restraint.\n");
upper_wall.type(value());
get_keyval(conf, "upperWall", upper_wall, upper_boundary);
if (!get_keyval(conf, "upperWall", upper_wall, upper_boundary)) {
cvm::log("Warning: upperWall will need to be "
"defined explicitly in the next release.\n");
}
uw_conf = std::string("\n\
upperWallConstant "+cvm::to_str(upper_wall_k*width*width)+"\n\
upperWalls "+cvm::to_str(upper_wall)+"\n");
@ -677,6 +683,7 @@ template<typename def_class_name> int colvar::init_components_type(std::string c
if (cvcp != NULL) {
cvcs.push_back(cvcp);
cvcp->check_keywords(def_conf, def_config_key);
cvcp->config_key = def_config_key;
if (cvm::get_error()) {
cvm::error("Error: in setting up component \""+
std::string(def_config_key)+"\".\n", INPUT_ERROR);
@ -1022,13 +1029,13 @@ int colvar::calc()
int colvar::calc_cvcs(int first_cvc, size_t num_cvcs)
{
colvarproxy *proxy = cvm::main()->proxy;
int error_code = COLVARS_OK;
if (cvm::debug())
cvm::log("Calculating colvar \""+this->name+"\", components "+
cvm::to_str(first_cvc)+" through "+cvm::to_str(first_cvc+num_cvcs)+".\n");
colvarproxy *proxy = cvm::main()->proxy;
int error_code = COLVARS_OK;
error_code |= check_cvc_range(first_cvc, num_cvcs);
if (error_code != COLVARS_OK) {
return error_code;
@ -1059,9 +1066,10 @@ int colvar::collect_cvc_data()
if (cvm::debug())
cvm::log("Calculating colvar \""+this->name+"\"'s properties.\n");
colvarproxy *proxy = cvm::main()->proxy;
int error_code = COLVARS_OK;
if (cvm::step_relative() > 0) {
if ((cvm::step_relative() > 0) && (!proxy->total_forces_same_step())){
// Total force depends on Jacobian derivative from previous timestep
// collect_cvc_total_forces() uses the previous value of jd
error_code |= collect_cvc_total_forces();
@ -1069,6 +1077,10 @@ int colvar::collect_cvc_data()
error_code |= collect_cvc_values();
error_code |= collect_cvc_gradients();
error_code |= collect_cvc_Jacobians();
if (proxy->total_forces_same_step()){
// Use Jacobian derivative from this timestep
error_code |= collect_cvc_total_forces();
}
error_code |= calc_colvar_properties();
if (cvm::debug())
@ -1394,6 +1406,13 @@ int colvar::calc_colvar_properties()
vr.reset(); // (already 0; added for clarity)
}
// Special case of a repeated timestep (eg. multiple NAMD "run" statements)
// revert values of the extended coordinate and velocity prior to latest integration
if (cvm::step_relative() == prev_timestep) {
xr = prev_xr;
vr = prev_vr;
}
// report the restraint center as "value"
x_reported = xr;
v_reported = vr;
@ -1450,7 +1469,6 @@ cvm::real colvar::update_forces_energy()
// extended variable if there is one
if (is_enabled(f_cv_extended_Lagrangian)) {
if (cvm::debug()) {
cvm::log("Updating extended-Lagrangian degree of freedom.\n");
}
@ -1502,6 +1520,11 @@ cvm::real colvar::update_forces_energy()
ft_reported = f_ext;
}
// backup in case we need to revert this integration timestep
// if the same MD timestep is re-run
prev_xr = xr;
prev_vr = vr;
// leapfrog: starting from x_i, f_i, v_(i-1/2)
vr += (0.5 * dt) * f_ext / ext_mass;
// Because of leapfrog, kinetic energy at time i is approximate
@ -1638,18 +1661,26 @@ int colvar::set_cvc_flags(std::vector<bool> const &flags)
}
void colvar::update_active_cvc_square_norm()
{
active_cvc_square_norm = 0.0;
for (size_t i = 0; i < cvcs.size(); i++) {
if (cvcs[i]->is_enabled()) {
active_cvc_square_norm += cvcs[i]->sup_coeff * cvcs[i]->sup_coeff;
}
}
}
int colvar::update_cvc_flags()
{
// Update the enabled/disabled status of cvcs if necessary
if (cvc_flags.size()) {
n_active_cvcs = 0;
active_cvc_square_norm = 0.;
for (size_t i = 0; i < cvcs.size(); i++) {
cvcs[i]->set_enabled(f_cvc_active, cvc_flags[i]);
if (cvcs[i]->is_enabled()) {
n_active_cvcs++;
active_cvc_square_norm += cvcs[i]->sup_coeff * cvcs[i]->sup_coeff;
}
}
if (!n_active_cvcs) {
@ -1657,12 +1688,49 @@ int colvar::update_cvc_flags()
return COLVARS_ERROR;
}
cvc_flags.clear();
update_active_cvc_square_norm();
}
return COLVARS_OK;
}
int colvar::update_cvc_config(std::vector<std::string> const &confs)
{
cvm::log("Updating configuration for colvar \""+name+"\"");
if (confs.size() != cvcs.size()) {
return cvm::error("Error: Wrong number of CVC config strings. "
"For those CVCs that are not being changed, try passing "
"an empty string.", INPUT_ERROR);
}
int error_code = COLVARS_OK;
int num_changes = 0;
for (size_t i = 0; i < cvcs.size(); i++) {
if (confs[i].size()) {
std::string conf(confs[i]);
cvm::increase_depth();
error_code |= cvcs[i]->colvar::cvc::init(conf);
error_code |= cvcs[i]->check_keywords(conf,
cvcs[i]->config_key.c_str());
cvm::decrease_depth();
num_changes++;
}
}
if (num_changes == 0) {
cvm::log("Warning: no changes were applied through modifycvcs; "
"please check that its argument is a list of strings.\n");
}
update_active_cvc_square_norm();
return error_code;
}
// ******************** METRIC FUNCTIONS ********************
// Use the metrics defined by \link cvc \endlink objects

View File

@ -171,8 +171,12 @@ protected:
// Options for extended_lagrangian
/// Restraint center
colvarvalue xr;
/// Previous value of the restraint center;
colvarvalue prev_xr;
/// Velocity of the restraint center
colvarvalue vr;
/// Previous velocity of the restraint center
colvarvalue prev_vr;
/// Mass of the restraint center
cvm::real ext_mass;
/// Restraint force constant
@ -352,6 +356,9 @@ public:
/// \brief Updates the flags in the CVC objects, and their number
int update_cvc_flags();
/// \brief Modify the configuration of CVCs (currently, only base class data)
int update_cvc_config(std::vector<std::string> const &confs);
protected:
/// \brief Number of CVC objects with an active flag
size_t n_active_cvcs;
@ -359,10 +366,17 @@ protected:
/// Sum of square coefficients for active cvcs
cvm::real active_cvc_square_norm;
/// Update the sum of square coefficients for active cvcs
void update_active_cvc_square_norm();
/// \brief Absolute timestep number when this colvar was last updated
int prev_timestep;
public:
/// \brief Return the number of CVC objects defined
inline size_t num_cvcs() const { return cvcs.size(); }
/// \brief Return the number of CVC objects with an active flag (as set by update_cvc_flags)
inline size_t num_active_cvcs() const { return n_active_cvcs; }
@ -371,21 +385,21 @@ public:
///
/// Handles correctly symmetries and periodic boundary conditions
cvm::real dist2(colvarvalue const &x1,
colvarvalue const &x2) const;
colvarvalue const &x2) const;
/// \brief Use the internal metrics (as from \link cvc
/// \endlink objects) to calculate square distances and gradients
///
/// Handles correctly symmetries and periodic boundary conditions
colvarvalue dist2_lgrad(colvarvalue const &x1,
colvarvalue const &x2) const;
colvarvalue const &x2) const;
/// \brief Use the internal metrics (as from \link cvc
/// \endlink objects) to calculate square distances and gradients
///
/// Handles correctly symmetries and periodic boundary conditions
colvarvalue dist2_rgrad(colvarvalue const &x1,
colvarvalue const &x2) const;
colvarvalue const &x2) const;
/// \brief Use the internal metrics (as from \link cvc
/// \endlink objects) to wrap a value into a standard interval

View File

@ -21,6 +21,8 @@ cvm::atom::atom()
{
index = -1;
id = -1;
mass = 1.0;
charge = 1.0;
reset_data();
}
@ -395,7 +397,7 @@ int cvm::atom_group::parse(std::string const &group_conf)
}
// NOTE: calls to add_atom() and/or add_atom_id() are in the proxy-implemented function
cvm::load_atoms(atoms_file_name.c_str(), *this, atoms_col, atoms_col_value);
parse_error |= cvm::load_atoms(atoms_file_name.c_str(), *this, atoms_col, atoms_col_value);
}
}

View File

@ -90,7 +90,7 @@ public:
/// Destructor
~atom();
/// Set mutable data (everything except id and mass) to zero; update mass
/// Set mutable data (everything except id and mass) to zero
inline void reset_data()
{
pos = cvm::atom_pos(0.0);

View File

@ -564,6 +564,8 @@ int colvarbias_abf::replica_share() {
return COLVARS_OK;
}
void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool append)
{
std::string samples_out_name = prefix + ".count";
@ -572,10 +574,7 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool app
std::ostream *samples_os =
cvm::proxy->output_stream(samples_out_name, mode);
if (!samples_os) {
cvm::error("Error opening ABF samples file " + samples_out_name + " for writing");
return;
}
if (!samples_os) return;
samples->write_multicol(*samples_os);
cvm::proxy->close_output_stream(samples_out_name);
@ -583,10 +582,7 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool app
if (num_variables() > 2) {
std::string samples_dx_out_name = prefix + ".count.dx";
std::ostream *samples_dx_os = cvm::proxy->output_stream(samples_dx_out_name, mode);
if (!samples_os) {
cvm::error("Error opening samples file " + samples_dx_out_name + " for writing");
return;
}
if (!samples_os) return;
samples->write_opendx(*samples_dx_os);
*samples_dx_os << std::endl;
cvm::proxy->close_output_stream(samples_dx_out_name);
@ -594,10 +590,7 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool app
std::ostream *gradients_os =
cvm::proxy->output_stream(gradients_out_name, mode);
if (!gradients_os) {
cvm::error("Error opening ABF gradient file " + gradients_out_name + " for writing");
return;
}
if (!gradients_os) return;
gradients->write_multicol(*gradients_os);
cvm::proxy->close_output_stream(gradients_out_name);
@ -609,20 +602,14 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool app
std::string pmf_out_name = prefix + ".pmf";
std::ostream *pmf_os = cvm::proxy->output_stream(pmf_out_name, mode);
if (!pmf_os) {
cvm::error("Error opening pmf file " + pmf_out_name + " for writing");
return;
}
if (!pmf_os) return;
pmf->write_multicol(*pmf_os);
// In dimension higher than 2, dx is easier to handle and visualize
if (num_variables() > 2) {
std::string pmf_dx_out_name = prefix + ".pmf.dx";
std::ostream *pmf_dx_os = cvm::proxy->output_stream(pmf_dx_out_name, mode);
if (!pmf_dx_os) {
cvm::error("Error opening pmf file " + pmf_dx_out_name + " for writing");
return;
}
if (!pmf_dx_os) return;
pmf->write_opendx(*pmf_dx_os);
*pmf_dx_os << std::endl;
cvm::proxy->close_output_stream(pmf_dx_out_name);
@ -639,10 +626,7 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool app
std::ostream *z_samples_os =
cvm::proxy->output_stream(z_samples_out_name, mode);
if (!z_samples_os) {
cvm::error("Error opening eABF z-histogram file " + z_samples_out_name + " for writing");
return;
}
if (!z_samples_os) return;
z_samples->write_multicol(*z_samples_os);
cvm::proxy->close_output_stream(z_samples_out_name);
@ -651,10 +635,7 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool app
std::ostream *z_gradients_os =
cvm::proxy->output_stream(z_gradients_out_name, mode);
if (!z_gradients_os) {
cvm::error("Error opening eABF z-gradient file " + z_gradients_out_name + " for writing");
return;
}
if (!z_gradients_os) return;
z_gradients->write_multicol(*z_gradients_os);
cvm::proxy->close_output_stream(z_gradients_out_name);
}
@ -672,10 +653,7 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool app
std::ostream *czar_gradients_os =
cvm::proxy->output_stream(czar_gradients_out_name, mode);
if (!czar_gradients_os) {
cvm::error("Error opening CZAR gradient file " + czar_gradients_out_name + " for writing");
return;
}
if (!czar_gradients_os) return;
czar_gradients->write_multicol(*czar_gradients_os);
cvm::proxy->close_output_stream(czar_gradients_out_name);
@ -688,20 +666,14 @@ void colvarbias_abf::write_gradients_samples(const std::string &prefix, bool app
std::string czar_pmf_out_name = prefix + ".czar.pmf";
std::ostream *czar_pmf_os = cvm::proxy->output_stream(czar_pmf_out_name, mode);
if (!czar_pmf_os) {
cvm::error("Error opening CZAR pmf file " + czar_pmf_out_name + " for writing");
return;
}
if (!czar_pmf_os) return;
czar_pmf->write_multicol(*czar_pmf_os);
// In dimension higher than 2, dx is easier to handle and visualize
if (num_variables() > 2) {
std::string czar_pmf_dx_out_name = prefix + ".czar.pmf.dx";
std::ostream *czar_pmf_dx_os = cvm::proxy->output_stream(czar_pmf_dx_out_name, mode);
if (!czar_pmf_dx_os) {
cvm::error("Error opening CZAR pmf file " + czar_pmf_dx_out_name + " for writing");
return;
}
if (!czar_pmf_dx_os) return;
czar_pmf->write_opendx(*czar_pmf_dx_os);
*czar_pmf_dx_os << std::endl;
cvm::proxy->close_output_stream(czar_pmf_dx_out_name);
@ -854,3 +826,9 @@ std::istream & colvarbias_abf::read_state_data(std::istream& is)
return is;
}
int colvarbias_abf::write_output_files()
{
write_gradients_samples(output_prefix);
return COLVARS_OK;
}

View File

@ -136,13 +136,13 @@ private:
/// Write human-readable FE gradients and sample count, and DX file in dim > 2
void write_gradients_samples(const std::string &prefix, bool append = false);
void write_last_gradients_samples(const std::string &prefix, bool append = false);
/// Read human-readable FE gradients and sample count (if not using restart)
void read_gradients_samples();
std::istream& read_state_data(std::istream&);
std::ostream& write_state_data(std::ostream&);
virtual std::istream& read_state_data(std::istream&);
virtual std::ostream& write_state_data(std::ostream&);
virtual int write_output_files();
};
#endif

View File

@ -996,11 +996,16 @@ int colvarbias_restraint_harmonic_walls::init(std::string const &conf)
if ((lower_walls.size() > 0) && (upper_walls.size() > 0)) {
for (i = 0; i < num_variables(); i++) {
if (lower_walls[i] >= upper_walls[i]) {
cvm::error("Error: one upper wall, "+
cvm::to_str(upper_walls[i])+
", is not higher than the lower wall, "+
cvm::to_str(lower_walls[i])+".\n",
INPUT_ERROR);
return cvm::error("Error: one upper wall, "+
cvm::to_str(upper_walls[i])+
", is not higher than the lower wall, "+
cvm::to_str(lower_walls[i])+".\n",
INPUT_ERROR);
}
if (variables(i)->dist2(lower_walls[i], upper_walls[i]) < 1.0e-12) {
return cvm::error("Error: lower wall and upper wall are equal "
"in the domain of the variable \""+
variables(i)->name+"\".\n", INPUT_ERROR);
}
}
if (lower_wall_k * upper_wall_k == 0.0) {
@ -1279,13 +1284,16 @@ cvm::real colvarbias_restraint_linear::energy_difference(std::string const &conf
cvm::real colvarbias_restraint_linear::restraint_potential(size_t i) const
{
return force_k / variables(i)->width * (variables(i)->value() - colvar_centers[i]);
return force_k / variables(i)->width * (variables(i)->value() -
colvar_centers[i]).sum();
}
colvarvalue const colvarbias_restraint_linear::restraint_force(size_t i) const
{
return -1.0 * force_k / variables(i)->width;
colvarvalue dummy(variables(i)->value());
dummy.set_ones();
return -1.0 * force_k / variables(i)->width * dummy;
}

View File

@ -43,16 +43,27 @@ colvar::cvc::cvc(std::string const &conf)
int colvar::cvc::init(std::string const &conf)
{
int error_code = COLVARS_OK;
if (cvm::debug())
cvm::log("Initializing cvc base object.\n");
get_keyval(conf, "name", this->name, this->name);
std::string const old_name(name);
if (name.size() > 0) {
// Temporary description until child object is initialized
description = "cvc " + name;
} else {
description = "uninitialized cvc";
cvm::log("Updating configuration for component \""+name+"\"");
}
if (get_keyval(conf, "name", name, name)) {
if (name.size() > 0) {
description = "cvc \"" + name + "\" of type " + function_type;
} else {
description = "unnamed cvc";
}
if ((name != old_name) && (old_name.size() > 0)) {
cvm::error("Error: cannot rename component \""+old_name+
"\" after initialization (new name = \""+name+"\")",
INPUT_ERROR);
name = old_name;
}
}
get_keyval(conf, "componentCoeff", sup_coeff, sup_coeff);
@ -78,7 +89,7 @@ int colvar::cvc::init(std::string const &conf)
if (cvm::debug())
cvm::log("Done initializing cvc base object.\n");
return error_code;
return cvm::get_error();
}

View File

@ -82,6 +82,9 @@ public:
/// this variable definition should be set within the constructor.
std::string function_type;
/// Keyword used in the input to denote this CVC
std::string config_key;
/// \brief Coefficient in the polynomial combination (default: 1.0)
cvm::real sup_coeff;
/// \brief Exponent in the polynomial combination (default: 1)
@ -834,49 +837,70 @@ protected:
cvm::real r0;
/// \brief "Cutoff vector" for anisotropic calculation
cvm::rvector r0_vec;
/// \brief Wheter dist/r0 or \vec{dist}*\vec{1/r0_vec} should ne be
/// used
/// \brief Whether r/r0 or \vec{r}*\vec{1/r0_vec} should be used
bool b_anisotropic;
/// Integer exponent of the function numerator
int en;
/// Integer exponent of the function denominator
int ed;
/// \brief If true, group2 will be treated as a single atom
/// (default: loop over all pairs of atoms in group1 and group2)
bool b_group2_center_only;
/// \brief If true, group2 will be treated as a single atom, stored in this
/// accessory group
cvm::atom_group *group2_center;
/// Tolerance for the pair list
cvm::real tolerance;
/// Frequency of update of the pair list
int pairlist_freq;
/// Pair list
bool *pairlist;
public:
/// Constructor
coordnum(std::string const &conf);
coordnum();
virtual ~coordnum() {}
~coordnum();
virtual void calc_value();
virtual void calc_gradients();
virtual void apply_force(colvarvalue const &force);
template<bool b_gradients>
/// \brief Calculate a coordination number through the function
/// (1-x**n)/(1-x**m), x = |A1-A2|/r0 \param r0 "cutoff" for the
/// coordination number \param exp_num \i n exponent \param exp_den
/// \i m exponent \param A1 atom \param A2 atom
static cvm::real switching_function(cvm::real const &r0,
int const &exp_num, int const &exp_den,
cvm::atom &A1, cvm::atom &A2);
template<bool b_gradients>
/// \brief Calculate a coordination number through the function
/// (1-x**n)/(1-x**m), x = |(A1-A2)*(r0_vec)^-|1 \param r0_vec
/// vector of different cutoffs in the three directions \param
/// exp_num \i n exponent \param exp_den \i m exponent \param A1
/// atom \param A2 atom
static cvm::real switching_function(cvm::rvector const &r0_vec,
int const &exp_num, int const &exp_den,
cvm::atom &A1, cvm::atom &A2);
virtual cvm::real dist2(colvarvalue const &x1,
colvarvalue const &x2) const;
virtual colvarvalue dist2_lgrad(colvarvalue const &x1,
colvarvalue const &x2) const;
virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
colvarvalue const &x2) const;
enum {
ef_null = 0,
ef_gradients = 1,
ef_anisotropic = (1<<8),
ef_use_pairlist = (1<<9),
ef_rebuild_pairlist = (1<<10)
};
/// \brief Calculate a coordination number through the function
/// (1-x**n)/(1-x**m), where x = |A1-A2|/r0 \param r0, r0_vec "cutoff" for
/// the coordination number (scalar or vector depending on user choice)
/// \param en Numerator exponent \param ed Denominator exponent \param First
/// atom \param Second atom \param pairlist_elem pointer to pair flag for
/// this pair \param tolerance A pair is defined as having a larger
/// coordination than this number
template<int flags>
static cvm::real switching_function(cvm::real const &r0,
cvm::rvector const &r0_vec,
int en,
int ed,
cvm::atom &A1,
cvm::atom &A2,
bool **pairlist_elem,
cvm::real tolerance);
/// Main workhorse function
template<int flags> int compute_coordnum();
};
@ -887,7 +911,8 @@ class colvar::selfcoordnum
: public colvar::cvc
{
protected:
/// First atom group
/// Selected atoms
cvm::atom_group *group1;
/// \brief "Cutoff" for isotropic calculation (default)
cvm::real r0;
@ -895,22 +920,18 @@ protected:
int en;
/// Integer exponent of the function denominator
int ed;
cvm::real tolerance;
int pairlist_freq;
bool *pairlist;
public:
/// Constructor
selfcoordnum(std::string const &conf);
selfcoordnum();
virtual ~selfcoordnum() {}
~selfcoordnum();
virtual void calc_value();
virtual void calc_gradients();
virtual void apply_force(colvarvalue const &force);
template<bool b_gradients>
/// \brief Calculate a coordination number through the function
/// (1-x**n)/(1-x**m), x = |A1-A2|/r0 \param r0 "cutoff" for the
/// coordination number \param exp_num \i n exponent \param exp_den
/// \i m exponent \param A1 atom \param A2 atom
static cvm::real switching_function(cvm::real const &r0,
int const &exp_num, int const &exp_den,
cvm::atom &A1, cvm::atom &A2);
virtual cvm::real dist2(colvarvalue const &x1,
colvarvalue const &x2) const;
@ -918,6 +939,9 @@ public:
colvarvalue const &x2) const;
virtual colvarvalue dist2_rgrad(colvarvalue const &x1,
colvarvalue const &x2) const;
/// Main workhorse function
template<int flags> int compute_selfcoordnum();
};
@ -947,26 +971,6 @@ public:
virtual void calc_value();
virtual void calc_gradients();
virtual void apply_force(colvarvalue const &force);
template<bool b_gradients>
/// \brief Calculate a coordination number through the function
/// (1-x**n)/(1-x**m), x = |A1-A2|/r0 \param r0 "cutoff" for the
/// coordination number \param exp_num \i n exponent \param exp_den
/// \i m exponent \param A1 atom \param A2 atom
static cvm::real switching_function(cvm::real const &r0,
int const &exp_num, int const &exp_den,
cvm::atom &A1, cvm::atom &A2);
/*
template<bool b_gradients>
/// \brief Calculate a coordination number through the function
/// (1-x**n)/(1-x**m), x = |(A1-A2)*(r0_vec)^-|1 \param r0_vec
/// vector of different cutoffs in the three directions \param
/// exp_num \i n exponent \param exp_den \i m exponent \param A1
/// atom \param A2 atom
static cvm::real switching_function(cvm::rvector const &r0_vec,
int const &exp_num, int const &exp_den,
cvm::atom &A1, cvm::atom &A2);
*/
virtual cvm::real dist2(colvarvalue const &x1,
colvarvalue const &x2) const;

View File

@ -18,45 +18,36 @@
template<bool calculate_gradients>
template<int flags>
cvm::real colvar::coordnum::switching_function(cvm::real const &r0,
int const &en,
int const &ed,
cvm::rvector const &r0_vec,
int en,
int ed,
cvm::atom &A1,
cvm::atom &A2)
cvm::atom &A2,
bool **pairlist_elem,
cvm::real pairlist_tol)
{
cvm::rvector const diff = cvm::position_distance(A1.pos, A2.pos);
cvm::real const l2 = diff.norm2()/(r0*r0);
// Assume en and ed are even integers, and avoid sqrt in the following
int const en2 = en/2;
int const ed2 = ed/2;
cvm::real const xn = cvm::integer_power(l2, en2);
cvm::real const xd = cvm::integer_power(l2, ed2);
cvm::real const func = (1.0-xn)/(1.0-xd);
if (calculate_gradients) {
cvm::real const dFdl2 = (1.0/(1.0-xd))*(en2*(xn/l2) - func*ed2*(xd/l2))*(-1.0);
cvm::rvector const dl2dx = (2.0/(r0*r0))*diff;
A1.grad += (-1.0)*dFdl2*dl2dx;
A2.grad += dFdl2*dl2dx;
if ((flags & ef_use_pairlist) && !(flags & ef_rebuild_pairlist)) {
bool const within = **pairlist_elem;
(*pairlist_elem)++;
if (!within) {
return 0.0;
}
}
return func;
}
cvm::rvector const r0sq_vec(r0_vec.x*r0_vec.x,
r0_vec.y*r0_vec.y,
r0_vec.z*r0_vec.z);
template<bool calculate_gradients>
cvm::real colvar::coordnum::switching_function(cvm::rvector const &r0_vec,
int const &en,
int const &ed,
cvm::atom &A1,
cvm::atom &A2)
{
cvm::rvector const diff = cvm::position_distance(A1.pos, A2.pos);
cvm::rvector const scal_diff(diff.x/r0_vec.x, diff.y/r0_vec.y, diff.z/r0_vec.z);
cvm::rvector const scal_diff(diff.x/((flags & ef_anisotropic) ?
r0_vec.x : r0),
diff.y/((flags & ef_anisotropic) ?
r0_vec.y : r0),
diff.z/((flags & ef_anisotropic) ?
r0_vec.z : r0));
cvm::real const l2 = scal_diff.norm2();
// Assume en and ed are even integers, and avoid sqrt in the following
@ -65,22 +56,45 @@ cvm::real colvar::coordnum::switching_function(cvm::rvector const &r0_vec,
cvm::real const xn = cvm::integer_power(l2, en2);
cvm::real const xd = cvm::integer_power(l2, ed2);
cvm::real const func = (1.0-xn)/(1.0-xd);
//The subtraction and division stretches the function back to the range of [0,1] from [pairlist_tol,1]
cvm::real const func = (((1.0-xn)/(1.0-xd)) - pairlist_tol) / (1.0-pairlist_tol);
if (calculate_gradients) {
cvm::real const dFdl2 = (1.0/(1.0-xd))*(en2*(xn/l2) - func*ed2*(xd/l2))*(-1.0);
cvm::rvector const dl2dx((2.0/(r0_vec.x*r0_vec.x))*diff.x,
(2.0/(r0_vec.y*r0_vec.y))*diff.y,
(2.0/(r0_vec.z*r0_vec.z))*diff.z);
if (flags & ef_rebuild_pairlist) {
//Particles just outside of the cutoff also are considered if they come near.
**pairlist_elem = (func > (-pairlist_tol * 0.5)) ? true : false;
(*pairlist_elem)++;
}
//If the value is too small, we need to exclude it, rather than let it contribute to the sum or the gradients.
if (func < 0)
return 0;
if (flags & ef_gradients) {
//This is the old, completely correct expression for dFdl2:
//cvm::real const dFdl2 = (1.0/(1.0-xd))*(en2*(xn/l2) -
// func*ed2*(xd/l2))*(-1.0);
//This can become:
//cvm::real const dFdl2 = (1.0/(1.0-xd))*(en2*(xn/l2)*(1.0-xn)/(1.0-xn) -
// func*ed2*(xd/l2))*(-1.0);
//Recognizing that func = (1.0-xn)/(1.0-xd), we can group together the "func" and get a version of dFdl2 that is 0
//when func=0, which lets us skip this gradient calculation when func=0.
cvm::real const dFdl2 = func * ((ed2*xd/((1.0-xd)*l2)) - (en2*xn/((1.0-xn)*l2)));
cvm::rvector const dl2dx((2.0/((flags & ef_anisotropic) ? r0sq_vec.x :
r0*r0)) * diff.x,
(2.0/((flags & ef_anisotropic) ? r0sq_vec.y :
r0*r0)) * diff.y,
(2.0/((flags & ef_anisotropic) ? r0sq_vec.z :
r0*r0)) * diff.z);
A1.grad += (-1.0)*dFdl2*dl2dx;
A2.grad += dFdl2*dl2dx;
}
return func;
}
colvar::coordnum::coordnum(std::string const &conf)
: cvc(conf), b_anisotropic(false), b_group2_center_only(false)
: cvc(conf), b_anisotropic(false), group2_center(NULL), pairlist(NULL)
{
function_type = "coordnum";
x.type(colvarvalue::type_scalar);
@ -90,23 +104,26 @@ colvar::coordnum::coordnum(std::string const &conf)
if (int atom_number = cvm::atom_group::overlap(*group1, *group2)) {
cvm::error("Error: group1 and group2 share a common atom (number: " +
cvm::to_str(atom_number) + ")\n");
cvm::to_str(atom_number) + ")\n", INPUT_ERROR);
return;
}
if (group1->b_dummy) {
cvm::error("Error: only group2 is allowed to be a dummy atom\n");
cvm::error("Error: only group2 is allowed to be a dummy atom\n",
INPUT_ERROR);
return;
}
bool const b_isotropic = get_keyval(conf, "cutoff", r0,
cvm::real(4.0 * cvm::unit_angstrom()));
if (get_keyval(conf, "cutoff3", r0_vec, cvm::rvector(4.0 * cvm::unit_angstrom(),
4.0 * cvm::unit_angstrom(),
4.0 * cvm::unit_angstrom()))) {
if (get_keyval(conf, "cutoff3", r0_vec,
cvm::rvector(4.0 * cvm::unit_angstrom(),
4.0 * cvm::unit_angstrom(),
4.0 * cvm::unit_angstrom()))) {
if (b_isotropic) {
cvm::error("Error: cannot specify \"cutoff\" and \"cutoff3\" at the same time.\n",
cvm::error("Error: cannot specify \"cutoff\" and \"cutoff3\" "
"at the same time.\n",
INPUT_ERROR);
return;
}
@ -135,86 +152,178 @@ colvar::coordnum::coordnum(std::string const &conf)
cvm::log("Warning: only minimum-image distances are used by this variable.\n");
}
bool b_group2_center_only = false;
get_keyval(conf, "group2CenterOnly", b_group2_center_only, group2->b_dummy);
if (b_group2_center_only) {
if (!group2_center) {
group2_center = new cvm::atom_group();
group2_center->add_atom(cvm::atom());
}
}
get_keyval(conf, "tolerance", tolerance, 0.0);
if (tolerance > 0) {
get_keyval(conf, "pairListFrequency", pairlist_freq, 100);
if ( ! (pairlist_freq > 0) ) {
cvm::error("Error: non-positive pairlistfrequency provided.\n",
INPUT_ERROR);
return; // and do not allocate the pairlists below
}
if (b_group2_center_only) {
pairlist = new bool[group1->size()];
}
else {
pairlist = new bool[group1->size() * group2->size()];
}
}
}
colvar::coordnum::coordnum()
: b_anisotropic(false), b_group2_center_only(false)
: b_anisotropic(false), group2_center(NULL), pairlist(NULL)
{
function_type = "coordnum";
x.type(colvarvalue::type_scalar);
}
void colvar::coordnum::calc_value()
colvar::coordnum::~coordnum()
{
x.real_value = 0.0;
if (pairlist != NULL) {
delete [] pairlist;
}
if (group2_center != NULL) {
delete group2_center;
}
}
if (b_group2_center_only) {
// create a fake atom to hold the group2 com coordinates
cvm::atom group2_com_atom;
group2_com_atom.pos = group2->center_of_mass();
template<int compute_flags> int colvar::coordnum::compute_coordnum()
{
if (group2_center) {
(*group2_center)[0].pos = group2->center_of_mass();
group2_center->calc_required_properties();
}
cvm::atom_group *group2p = group2_center ? group2_center : group2;
if (b_anisotropic) {
for (cvm::atom_iter ai1 = group1->begin(); ai1 != group1->end(); ai1++)
x.real_value += switching_function<false>(r0_vec, en, ed, *ai1, group2_com_atom);
} else {
for (cvm::atom_iter ai1 = group1->begin(); ai1 != group1->end(); ai1++)
x.real_value += switching_function<false>(r0, en, ed, *ai1, group2_com_atom);
bool const use_pairlist = (pairlist != NULL);
bool const rebuild_pairlist = (pairlist != NULL) &&
(cvm::step_relative() % pairlist_freq == 0);
bool *pairlist_elem = use_pairlist ? pairlist : NULL;
cvm::atom_iter ai1 = group1->begin(), ai2 = group2p->begin();
cvm::atom_iter const ai1_end = group1->end();
cvm::atom_iter const ai2_end = group2p->end();
if (b_anisotropic) {
if (use_pairlist) {
if (rebuild_pairlist) {
int const flags = compute_flags | ef_anisotropic | ef_use_pairlist |
ef_rebuild_pairlist;
for (ai1 = group1->begin(); ai1 != ai1_end; ai1++) {
for (ai2 = group2->begin(); ai2 != ai2_end; ai2++) {
x.real_value += switching_function<flags>(r0, r0_vec, en, ed,
*ai1, *ai2,
&pairlist_elem,
tolerance);
}
}
} else {
int const flags = compute_flags | ef_anisotropic | ef_use_pairlist;
for (ai1 = group1->begin(); ai1 != ai1_end; ai1++) {
for (ai2 = group2->begin(); ai2 != ai2_end; ai2++) {
x.real_value += switching_function<flags>(r0, r0_vec, en, ed,
*ai1, *ai2,
&pairlist_elem,
tolerance);
}
}
}
} else { // if (use_pairlist) {
int const flags = compute_flags | ef_anisotropic;
for (ai1 = group1->begin(); ai1 != ai1_end; ai1++) {
for (ai2 = group2->begin(); ai2 != ai2_end; ai2++) {
x.real_value += switching_function<flags>(r0, r0_vec, en, ed,
*ai1, *ai2,
NULL, 0.0);
}
}
}
} else {
if (b_anisotropic) {
for (cvm::atom_iter ai1 = group1->begin(); ai1 != group1->end(); ai1++)
for (cvm::atom_iter ai2 = group2->begin(); ai2 != group2->end(); ai2++) {
x.real_value += switching_function<false>(r0_vec, en, ed, *ai1, *ai2);
if (use_pairlist) {
if (rebuild_pairlist) {
int const flags = compute_flags | ef_use_pairlist | ef_rebuild_pairlist;
for (ai1 = group1->begin(); ai1 != ai1_end; ai1++) {
for (ai2 = group2->begin(); ai2 != ai2_end; ai2++) {
x.real_value += switching_function<flags>(r0, r0_vec, en, ed,
*ai1, *ai2,
&pairlist_elem,
tolerance);
}
}
} else {
for (cvm::atom_iter ai1 = group1->begin(); ai1 != group1->end(); ai1++)
for (cvm::atom_iter ai2 = group2->begin(); ai2 != group2->end(); ai2++) {
x.real_value += switching_function<false>(r0, en, ed, *ai1, *ai2);
} else {
int const flags = compute_flags | ef_use_pairlist;
for (ai1 = group1->begin(); ai1 != ai1_end; ai1++) {
for (ai2 = group2->begin(); ai2 != ai2_end; ai2++) {
x.real_value += switching_function<flags>(r0, r0_vec, en, ed,
*ai1, *ai2,
&pairlist_elem,
tolerance);
}
}
}
} else { // if (use_pairlist) {
int const flags = compute_flags;
for (ai1 = group1->begin(); ai1 != ai1_end; ai1++) {
for (ai2 = group2->begin(); ai2 != ai2_end; ai2++) {
x.real_value += switching_function<flags>(r0, r0_vec, en, ed,
*ai1, *ai2,
NULL, 0.0);
}
}
}
}
if (compute_flags & ef_gradients) {
if (group2_center) {
group2->set_weighted_gradient((*group2_center)[0].grad);
}
}
return COLVARS_OK;
}
void colvar::coordnum::calc_value()
{
x.real_value = 0.0;
if (is_enabled(f_cvc_gradient)) {
compute_coordnum<ef_gradients>();
} else {
compute_coordnum<ef_null>();
}
}
void colvar::coordnum::calc_gradients()
{
if (b_group2_center_only) {
// create a fake atom to hold the group2 com coordinates
cvm::atom group2_com_atom;
group2_com_atom.pos = group2->center_of_mass();
if (b_anisotropic) {
for (cvm::atom_iter ai1 = group1->begin(); ai1 != group1->end(); ai1++)
switching_function<true>(r0_vec, en, ed, *ai1, group2_com_atom);
} else {
for (cvm::atom_iter ai1 = group1->begin(); ai1 != group1->end(); ai1++)
switching_function<true>(r0, en, ed, *ai1, group2_com_atom);
}
group2->set_weighted_gradient(group2_com_atom.grad);
} else {
if (b_anisotropic) {
for (cvm::atom_iter ai1 = group1->begin(); ai1 != group1->end(); ai1++)
for (cvm::atom_iter ai2 = group2->begin(); ai2 != group2->end(); ai2++) {
switching_function<true>(r0_vec, en, ed, *ai1, *ai2);
}
} else {
for (cvm::atom_iter ai1 = group1->begin(); ai1 != group1->end(); ai1++)
for (cvm::atom_iter ai2 = group2->begin(); ai2 != group2->end(); ai2++) {
switching_function<true>(r0, en, ed, *ai1, *ai2);
}
}
}
// Gradients are computed by calc_value() if f_cvc_gradients is enabled
}
@ -235,7 +344,7 @@ simple_scalar_dist_functions(coordnum)
// h_bond member functions
colvar::h_bond::h_bond(std::string const &conf)
: cvc(conf)
: cvc(conf)
{
if (cvm::debug())
cvm::log("Initializing h_bond object.\n");
@ -307,13 +416,24 @@ colvar::h_bond::~h_bond()
void colvar::h_bond::calc_value()
{
x.real_value = colvar::coordnum::switching_function<false>(r0, en, ed, (*atom_groups[0])[0], (*atom_groups[0])[1]);
int const flags = coordnum::ef_null;
cvm::rvector const r0_vec(0.0); // TODO enable the flag?
x.real_value =
coordnum::switching_function<flags>(r0, r0_vec, en, ed,
(*atom_groups[0])[0],
(*atom_groups[0])[1],
NULL, 0.0);
}
void colvar::h_bond::calc_gradients()
{
colvar::coordnum::switching_function<true>(r0, en, ed, (*atom_groups[0])[0], (*atom_groups[0])[1]);
int const flags = coordnum::ef_gradients;
cvm::rvector const r0_vec(0.0); // TODO enable the flag?
coordnum::switching_function<flags>(r0, r0_vec, en, ed,
(*atom_groups[0])[0],
(*atom_groups[0])[1],
NULL, 0.0);
}
@ -328,7 +448,7 @@ simple_scalar_dist_functions(h_bond)
colvar::selfcoordnum::selfcoordnum(std::string const &conf)
: cvc(conf)
: cvc(conf), pairlist(NULL)
{
function_type = "selfcoordnum";
x.type(colvarvalue::type_scalar);
@ -353,36 +473,115 @@ colvar::selfcoordnum::selfcoordnum(std::string const &conf)
if (!is_enabled(f_cvc_pbc_minimum_image)) {
cvm::log("Warning: only minimum-image distances are used by this variable.\n");
}
get_keyval(conf, "tolerance", tolerance, 0.0);
if (tolerance > 0) {
get_keyval(conf, "pairListFrequency", pairlist_freq, 100);
if ( ! (pairlist_freq > 0) ) {
cvm::error("Error: non-positive pairlistfrequency provided.\n",
INPUT_ERROR);
return;
}
pairlist = new bool[(group1->size()-1) * (group1->size()-1)];
}
}
colvar::selfcoordnum::selfcoordnum()
: pairlist(NULL)
{
function_type = "selfcoordnum";
x.type(colvarvalue::type_scalar);
}
colvar::selfcoordnum::~selfcoordnum()
{
if (pairlist != NULL) {
delete [] pairlist;
}
}
template<int compute_flags> int colvar::selfcoordnum::compute_selfcoordnum()
{
cvm::rvector const r0_vec(0.0); // TODO enable the flag?
bool const use_pairlist = (pairlist != NULL);
bool const rebuild_pairlist = (pairlist != NULL) &&
(cvm::step_relative() % pairlist_freq == 0);
bool *pairlist_elem = use_pairlist ? pairlist : NULL;
size_t i = 0, j = 0;
size_t const n = group1->size();
// Always isotropic (TODO: enable the ellipsoid?)
if (use_pairlist) {
if (rebuild_pairlist) {
int const flags = compute_flags | coordnum::ef_use_pairlist |
coordnum::ef_rebuild_pairlist;
for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; j++) {
x.real_value +=
coordnum::switching_function<flags>(r0, r0_vec, en, ed,
(*group1)[i],
(*group1)[j],
&pairlist_elem,
tolerance);
}
}
} else {
int const flags = compute_flags | coordnum::ef_use_pairlist;
for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; j++) {
x.real_value +=
coordnum::switching_function<flags>(r0, r0_vec, en, ed,
(*group1)[i],
(*group1)[j],
&pairlist_elem,
tolerance);
}
}
}
} else { // if (use_pairlist) {
int const flags = compute_flags | coordnum::ef_null;
for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; j++) {
x.real_value +=
coordnum::switching_function<flags>(r0, r0_vec, en, ed,
(*group1)[i],
(*group1)[j],
&pairlist_elem,
tolerance);
}
}
}
return COLVARS_OK;
}
void colvar::selfcoordnum::calc_value()
{
x.real_value = 0.0;
for (size_t i = 0; i < group1->size() - 1; i++) {
for (size_t j = i + 1; j < group1->size(); j++) {
x.real_value += colvar::coordnum::switching_function<false>(r0, en, ed, (*group1)[i], (*group1)[j]);
}
if (is_enabled(f_cvc_gradient)) {
compute_selfcoordnum<coordnum::ef_gradients>();
} else {
compute_selfcoordnum<coordnum::ef_null>();
}
}
void colvar::selfcoordnum::calc_gradients()
{
for (size_t i = 0; i < group1->size() - 1; i++) {
for (size_t j = i + 1; j < group1->size(); j++) {
colvar::coordnum::switching_function<true>(r0, en, ed, (*group1)[i], (*group1)[j]);
}
}
// Gradients are computed by calc_value() if f_cvc_gradients is enabled
}
void colvar::selfcoordnum::apply_force(colvarvalue const &force)
{
if (!group1->noforce) {
@ -394,6 +593,7 @@ void colvar::selfcoordnum::apply_force(colvarvalue const &force)
simple_scalar_dist_functions(selfcoordnum)
// groupcoordnum member functions
colvar::groupcoordnum::groupcoordnum(std::string const &conf)
: distance(conf), b_anisotropic(false)
@ -415,7 +615,7 @@ colvar::groupcoordnum::groupcoordnum(std::string const &conf)
if (b_scale) {
cvm::error("Error: cannot specify \"scale\" and "
"\"scale3\" at the same time.\n");
"\"scale3\" at the same time.\n");
return;
}
b_anisotropic = true;
@ -453,95 +653,56 @@ colvar::groupcoordnum::groupcoordnum()
}
template<bool calculate_gradients>
cvm::real colvar::groupcoordnum::switching_function(cvm::real const &r0,
int const &en,
int const &ed,
cvm::atom &A1,
cvm::atom &A2)
{
cvm::rvector const diff = cvm::position_distance(A1.pos, A2.pos);
cvm::real const l2 = diff.norm2()/(r0*r0);
// Assume en and ed are even integers, and avoid sqrt in the following
int const en2 = en/2;
int const ed2 = ed/2;
cvm::real const xn = cvm::integer_power(l2, en2);
cvm::real const xd = cvm::integer_power(l2, ed2);
cvm::real const func = (1.0-xn)/(1.0-xd);
if (calculate_gradients) {
cvm::real const dFdl2 = (1.0/(1.0-xd))*(en2*(xn/l2) - func*ed2*(xd/l2))*(-1.0);
cvm::rvector const dl2dx = (2.0/(r0*r0))*diff;
A1.grad += (-1.0)*dFdl2*dl2dx;
A2.grad += dFdl2*dl2dx;
}
return func;
}
#if 0 // AMG: I don't think there's any reason to support anisotropic,
// and I don't have those flags below in calc_value, but
// if I need them, I'll also need to uncomment this method
template<bool calculate_gradients>
cvm::real colvar::groupcoordnum::switching_function(cvm::rvector const &r0_vec,
int const &en,
int const &ed,
cvm::atom &A1,
cvm::atom &A2)
{
cvm::rvector const diff = cvm::position_distance(A1.pos, A2.pos);
cvm::rvector const scal_diff(diff.x/r0_vec.x, diff.y/r0_vec.y, diff.z/r0_vec.z);
cvm::real const l2 = scal_diff.norm2();
// Assume en and ed are even integers, and avoid sqrt in the following
int const en2 = en/2;
int const ed2 = ed/2;
cvm::real const xn = cvm::integer_power(l2, en2);
cvm::real const xd = cvm::integer_power(l2, ed2);
cvm::real const func = (1.0-xn)/(1.0-xd);
if (calculate_gradients) {
cvm::real const dFdl2 = (1.0/(1.0-xd))*(en2*(xn/l2) - func*ed2*(xd/l2))*(-1.0);
cvm::rvector const dl2dx((2.0/(r0_vec.x*r0_vec.x))*diff.x,
(2.0/(r0_vec.y*r0_vec.y))*diff.y,
(2.0/(r0_vec.z*r0_vec.z))*diff.z);
A1.grad += (-1.0)*dFdl2*dl2dx;
A2.grad += dFdl2*dl2dx;
}
return func;
}
#endif
void colvar::groupcoordnum::calc_value()
{
cvm::rvector const r0_vec(0.0); // TODO enable the flag?
// create fake atoms to hold the com coordinates
cvm::atom group1_com_atom;
cvm::atom group2_com_atom;
group1_com_atom.pos = group1->center_of_mass();
group2_com_atom.pos = group2->center_of_mass();
x.real_value = coordnum::switching_function<false>(r0, en, ed,
group1_com_atom, group2_com_atom);
if (b_anisotropic) {
int const flags = coordnum::ef_anisotropic;
x.real_value = coordnum::switching_function<flags>(r0, r0_vec, en, ed,
group1_com_atom,
group2_com_atom,
NULL, 0.0);
} else {
int const flags = coordnum::ef_null;
x.real_value = coordnum::switching_function<flags>(r0, r0_vec, en, ed,
group1_com_atom,
group2_com_atom,
NULL, 0.0);
}
}
void colvar::groupcoordnum::calc_gradients()
{
cvm::rvector const r0_vec(0.0); // TODO enable the flag?
cvm::atom group1_com_atom;
cvm::atom group2_com_atom;
group1_com_atom.pos = group1->center_of_mass();
group2_com_atom.pos = group2->center_of_mass();
coordnum::switching_function<true>(r0, en, ed, group1_com_atom, group2_com_atom);
if (b_anisotropic) {
int const flags = coordnum::ef_gradients | coordnum::ef_anisotropic;
coordnum::switching_function<flags>(r0, r0_vec, en, ed,
group1_com_atom,
group2_com_atom,
NULL, 0.0);
} else {
int const flags = coordnum::ef_gradients;
coordnum::switching_function<flags>(r0, r0_vec, en, ed,
group1_com_atom,
group2_com_atom,
NULL, 0.0);
}
group1->set_weighted_gradient(group1_com_atom.grad);
group2->set_weighted_gradient(group2_com_atom.grad);
}

View File

@ -939,7 +939,7 @@ colvar::rmsd::rmsd(std::string const &conf)
bool b_Jacobian_derivative = true;
if (atoms->fitting_group != NULL && b_Jacobian_derivative) {
cvm::log("The option \"refPositionsGroup\" (alternative group for fitting) was enabled: "
cvm::log("The option \"fittingGroup\" (alternative group for fitting) was enabled: "
"Jacobian derivatives of the RMSD will not be calculated.\n");
b_Jacobian_derivative = false;
}

View File

@ -139,7 +139,7 @@ int colvarmodule::read_config_file(char const *config_filename)
// read the config file into a string
std::string conf = "";
std::string line;
while (colvarparse::getline_nocomments(config_s, line)) {
while (parse->read_config_line(config_s, line)) {
// Delete lines that contain only white space after removing comments
if (line.find_first_not_of(colvarparse::white_space) != std::string::npos)
conf.append(line+"\n");
@ -159,11 +159,12 @@ int colvarmodule::read_config_string(std::string const &config_str)
// strip the comments away
std::string conf = "";
std::string line;
while (colvarparse::getline_nocomments(config_s, line)) {
while (parse->read_config_line(config_s, line)) {
// Delete lines that contain only white space after removing comments
if (line.find_first_not_of(colvarparse::white_space) != std::string::npos)
conf.append(line+"\n");
}
return parse_config(conf);
}
@ -191,6 +192,12 @@ int colvarmodule::parse_config(std::string &conf)
{
extra_conf.clear();
// Check that the input has matching braces
if (colvarparse::check_braces(conf, 0) != COLVARS_OK) {
return cvm::error("Error: unmatched curly braces in configuration.\n",
INPUT_ERROR);
}
// Parse global options
if (catch_input_errors(parse_global_params(conf))) {
return get_error();
@ -235,6 +242,12 @@ int colvarmodule::parse_config(std::string &conf)
}
std::string const & colvarmodule::get_config() const
{
return parse->get_config();
}
int colvarmodule::append_new_config(std::string const &new_conf)
{
extra_conf += new_conf;
@ -246,9 +259,13 @@ int colvarmodule::parse_global_params(std::string const &conf)
{
colvarmodule *cvm = cvm::main();
std::string index_file_name;
if (parse->get_keyval(conf, "indexFile", index_file_name)) {
cvm->read_index_file(index_file_name.c_str());
{
std::string index_file_name;
size_t pos = 0;
while (parse->key_lookup(conf, "indexFile", &index_file_name, &pos)) {
cvm->read_index_file(index_file_name.c_str());
index_file_name.clear();
}
}
if (parse->get_keyval(conf, "smp", proxy->b_smp_active, proxy->b_smp_active)) {
@ -1073,10 +1090,10 @@ colvarmodule::~colvarmodule()
int colvarmodule::reset()
{
parse->init();
cvm::log("Resetting the Collective Variables module.\n");
parse->init();
// Iterate backwards because we are deleting the elements as we go
for (std::vector<colvarbias *>::reverse_iterator bi = biases.rbegin();
bi != biases.rend();

View File

@ -131,7 +131,7 @@ public:
/// Module-wide error state
/// see constants at the top of this file
protected:
private:
static int errorCode;
@ -274,6 +274,9 @@ public:
/// \brief Parse a "clean" config string (no comments)
int parse_config(std::string &conf);
/// Get the configuration string read so far (includes comments)
std::string const & get_config() const;
// Parse functions (setup internal data based on a string)
/// Allow reading from Windows text files using using std::getline
@ -296,6 +299,9 @@ public:
private:
/// Configuration string read so far by the module (includes comments)
std::string config_string;
/// Auto-generated configuration during parsing (e.g. to implement
/// back-compatibility)
std::string extra_conf;

View File

@ -43,9 +43,10 @@ template<typename TYPE> bool colvarparse::_get_keyval_scalar_(std::string const
}
} while (b_found);
if (found_count > 1)
cvm::log("Warning: found more than one instance of \""+
std::string(key)+"\".\n");
if (found_count > 1) {
cvm::error("Error: found more than one instance of \""+
std::string(key)+"\".\n", INPUT_ERROR);
}
if (data.size()) {
std::istringstream is(data);
@ -98,9 +99,10 @@ bool colvarparse::_get_keyval_scalar_string_(std::string const &conf,
}
} while (b_found);
if (found_count > 1)
cvm::log("Warning: found more than one instance of \""+
std::string(key)+"\".\n");
if (found_count > 1) {
cvm::error("Error: found more than one instance of \""+
std::string(key)+"\".\n", INPUT_ERROR);
}
if (data.size()) {
std::istringstream is(data);
@ -162,9 +164,10 @@ template<typename TYPE> bool colvarparse::_get_keyval_vector_(std::string const
}
} while (b_found);
if (found_count > 1)
cvm::log("Warning: found more than one instance of \""+
std::string(key)+"\".\n");
if (found_count > 1) {
cvm::error("Error: found more than one instance of \""+
std::string(key)+"\".\n", INPUT_ERROR);
}
if (data.size()) {
std::istringstream is(data);
@ -319,9 +322,10 @@ bool colvarparse::get_keyval(std::string const &conf,
}
} while (b_found);
if (found_count > 1)
cvm::log("Warning: found more than one instance of \""+
std::string(key)+"\".\n");
if (found_count > 1) {
cvm::error("Error: found more than one instance of \""+
std::string(key)+"\".\n", INPUT_ERROR);
}
if (data.size()) {
if ( (data == std::string("on")) ||
@ -535,6 +539,19 @@ int colvarparse::check_keywords(std::string &conf, char const *key)
}
std::istream & colvarparse::read_config_line(std::istream &is,
std::string &line)
{
cvm::getline(is, line);
config_string += line+'\n';
size_t const comment = line.find('#');
if (comment != std::string::npos) {
line.erase(comment);
}
return is;
}
std::istream & colvarparse::getline_nocomments(std::istream &is,
std::string &line)
{
@ -607,7 +624,7 @@ bool colvarparse::key_lookup(std::string const &conf,
}
// check that there are matching braces between here and the end of conf
bool const b_not_within_block = brace_check(conf, pos);
bool const b_not_within_block = (check_braces(conf, pos) == COLVARS_OK);
bool const b_isolated = (b_isolated_left && b_isolated_right &&
b_not_within_block);
@ -781,19 +798,15 @@ std::istream & operator>> (std::istream &is, colvarparse::read_block const &rb)
}
bool colvarparse::brace_check(std::string const &conf,
int colvarparse::check_braces(std::string const &conf,
size_t const start_pos)
{
size_t brace_count = 0;
int brace_count = 0;
size_t brace = start_pos;
while ( (brace = conf.find_first_of("{}", brace)) != std::string::npos) {
while ((brace = conf.find_first_of("{}", brace)) != std::string::npos) {
if (conf[brace] == '{') brace_count++;
if (conf[brace] == '}') brace_count--;
brace++;
}
if (brace_count != 0)
return false;
else
return true;
return (brace_count != 0) ? INPUT_ERROR : COLVARS_OK;
}

View File

@ -24,7 +24,7 @@
/// need to parse input inherit from this
class colvarparse {
private:
protected:
/// \brief List of legal keywords for this object: this is updated
/// by each call to colvarparse::get_keyval() or
@ -47,7 +47,7 @@ private:
/// \brief Remove all the values from the config string
void strip_values(std::string &conf);
/// \brief Configuration string of the object
/// \brief Configuration string of the object (includes comments)
std::string config_string;
public:
@ -72,7 +72,7 @@ public:
}
/// Set a new config string for this object
inline void init(const std::string& conf)
inline void init(std::string const &conf)
{
if (! config_string.size()) {
init();
@ -80,7 +80,8 @@ public:
}
}
inline const std::string& get_config()
/// Get the configuration string (includes comments)
inline std::string const & get_config() const
{
return config_string;
}
@ -284,14 +285,19 @@ public:
std::string *data = NULL,
size_t *save_pos = NULL);
/// \brief Reads a configuration line, adds it to config_string, and returns
/// the stream \param is Input stream \param s String that will hold the
/// configuration line, with comments stripped
std::istream & read_config_line(std::istream &is, std::string &line);
/// \brief Works as std::getline() but also removes everything
/// between a comment character and the following newline
static std::istream & getline_nocomments(std::istream &is,
std::string &s);
static std::istream & getline_nocomments(std::istream &is, std::string &s);
/// Check if the content of the file has matching braces
bool brace_check(std::string const &conf,
size_t const start_pos = 0);
/// \brief Check if the content of a config string has matching braces
/// \param conf The configuration string \param start_pos Start the count
/// from this position
static int check_braces(std::string const &conf, size_t const start_pos);
};

View File

@ -289,13 +289,23 @@ colvarproxy_smp::colvarproxy_smp()
omp_lock_state = NULL;
#if defined(_OPENMP)
if (smp_thread_id() == 0) {
omp_lock_state = reinterpret_cast<void *>(new omp_lock_t);
omp_init_lock(reinterpret_cast<omp_lock_t *>(omp_lock_state));
}
#endif
}
colvarproxy_smp::~colvarproxy_smp() {}
colvarproxy_smp::~colvarproxy_smp()
{
#if defined(_OPENMP)
if (smp_thread_id() == 0) {
if (omp_lock_state) {
delete reinterpret_cast<omp_lock_t *>(omp_lock_state);
}
}
#endif
}
int colvarproxy_smp::smp_enabled()
@ -499,6 +509,14 @@ char const *colvarproxy_script::script_obj_to_str(unsigned char *obj)
}
std::vector<std::string> colvarproxy_script::script_obj_to_str_vector(unsigned char *obj)
{
cvm::error("Error: trying to print a script object without a scripting "
"language interface.\n", BUG_ERROR);
return std::vector<std::string>();
}
int colvarproxy_script::run_force_callback()
{
return COLVARS_NOT_IMPLEMENTED;

View File

@ -461,6 +461,9 @@ public:
/// Convert a script object (Tcl or Python call argument) to a C string
virtual char const *script_obj_to_str(unsigned char *obj);
/// Convert a script object (Tcl or Python call argument) to a vector of strings
virtual std::vector<std::string> script_obj_to_str_vector(unsigned char *obj);
/// Pointer to the scripting interface object
/// (does not need to be allocated in a new interface)
colvarscript *script;

View File

@ -1,5 +1,5 @@
#ifndef COLVARS_VERSION
#define COLVARS_VERSION "2018-04-29"
#define COLVARS_VERSION "2018-10-16"
// This file is part of the Collective Variables module (Colvars).
// The original version of Colvars and its updates are located at:
// https://github.com/colvars/colvars

View File

@ -82,6 +82,14 @@ int colvarscript::run(int objc, unsigned char *const objv[])
int error_code = COLVARS_OK;
// If command is found in map, execute it
std::string const cmd_key("cv_"+cmd);
if (comm_str_map.count(cmd_key) > 0) {
error_code |= (*(comm_fns[comm_str_map[cmd_key]]))(
reinterpret_cast<void *>(this), objc, objv);
return error_code;
}
if (cmd == "colvar") {
if (objc < 3) {
result = "Missing parameters\n" + help_string();
@ -295,11 +303,12 @@ int colvarscript::proc_colvar(colvar *cv, int objc, unsigned char *const objv[])
}
if (subcmd == "delete") {
size_t i;
for (i = 0; i < cv->biases.size(); i++) {
while (cv->biases.size() > 0) {
size_t i = cv->biases.size()-1;
cvm::log("Warning: before deleting colvar " + cv->name
+ ", deleting parent bias " + cv->biases[i]->name);
delete cv->biases[i];
}
cv->biases.clear();
// colvar destructor is tasked with the cleanup
delete cv;
// TODO this could be done by the destructors
@ -373,6 +382,23 @@ int colvarscript::proc_colvar(colvar *cv, int objc, unsigned char *const objv[])
return COLVARS_OK;
}
if (subcmd == "modifycvcs") {
if (objc < 4) {
result = "cvcflags: missing parameter: vector of strings";
return COLVARSCRIPT_ERROR;
}
std::vector<std::string> const confs(proxy->script_obj_to_str_vector(objv[3]));
cvm::increase_depth();
int res = cv->update_cvc_config(confs);
cvm::decrease_depth();
if (res != COLVARS_OK) {
result = "Error setting CVC flags";
return COLVARSCRIPT_ERROR;
}
result = "0";
return COLVARS_OK;
}
if ((subcmd == "get") || (subcmd == "set") || (subcmd == "state")) {
return proc_features(cv, objc, objv);
}
@ -547,6 +573,8 @@ std::string colvarscript::help_string() const
Managing the Colvars module:\n\
configfile <file name> -- read configuration from a file\n\
config <string> -- read configuration from the given string\n\
getconfig -- get the module's configuration string\n\
resetindexgroups -- clear the index groups loaded so far\n\
reset -- delete all internal configuration\n\
delete -- delete this Colvars module instance\n\
version -- return version of Colvars code\n\
@ -579,6 +607,7 @@ Accessing collective variables:\n\
colvar <name> gettotalforce -- return total force of colvar <name>\n\
colvar <name> getconfig -- return config string of colvar <name>\n\
colvar <name> cvcflags <fl> -- enable or disable cvcs according to 0/1 flags\n\
colvar <name> modifycvcs <str> -- pass new config strings to each CVC\n\
colvar <name> get <f> -- get the value of the colvar feature <f>\n\
colvar <name> set <f> <val> -- set the value of the colvar feature <f>\n\
\n\

View File

@ -71,8 +71,10 @@ public:
cv_help,
cv_version,
cv_config,
cv_getconfig,
cv_configfile,
cv_reset,
cv_resetindexgroups,
cv_delete,
cv_list,
cv_list_biases,
@ -254,6 +256,23 @@ extern "C" {
return COLVARSCRIPT_ERROR;
)
CVSCRIPT(cv_getconfig,
"Get the module's configuration string read so far",
0, 0,
{ },
script->set_str_result(cvm::main()->get_config());
return COLVARS_OK;
)
CVSCRIPT(cv_resetindexgroups,
"Clear the index groups loaded so far, allowing to replace them",
0, 0,
{ },
cvm::main()->index_group_names.clear();
cvm::main()->index_groups.clear();
return COLVARS_OK;
)
CVSCRIPT(cv_addenergy,
"Add an energy to the MD engine",
1, 1,

View File

@ -379,6 +379,40 @@ void colvarvalue::set_random()
}
void colvarvalue::set_ones(cvm::real assigned_value)
{
size_t ic;
switch (this->type()) {
case colvarvalue::type_scalar:
this->real_value = assigned_value;
break;
case colvarvalue::type_3vector:
case colvarvalue::type_unit3vector:
case colvarvalue::type_unit3vectorderiv:
this->rvector_value.x = assigned_value;
this->rvector_value.y = assigned_value;
this->rvector_value.z = assigned_value;
break;
case colvarvalue::type_quaternion:
case colvarvalue::type_quaternionderiv:
this->quaternion_value.q0 = assigned_value;
this->quaternion_value.q1 = assigned_value;
this->quaternion_value.q2 = assigned_value;
this->quaternion_value.q3 = assigned_value;
break;
case colvarvalue::type_vector:
for (ic = 0; ic < this->vector1d_value.size(); ic++) {
this->vector1d_value[ic] = assigned_value;
}
break;
case colvarvalue::type_notset:
default:
undef_op();
break;
}
}
void colvarvalue::undef_op() const
{
cvm::error("Error: Undefined operation on a colvar of type \""+

View File

@ -187,6 +187,12 @@ public:
return std::sqrt(this->norm2());
}
/// Sum of the components of this colvarvalue (if more than one dimension)
cvm::real sum() const;
/// Return a colvarvalue object of the same type and all components set to 1
colvarvalue ones() const;
/// Square distance between this \link colvarvalue \endlink and another
cvm::real dist2(colvarvalue const &x2) const;
@ -272,17 +278,21 @@ public:
/// Get a single colvarvalue out of elements of the vector
colvarvalue const get_elem(int const i_begin, int const i_end, Type const vt) const;
/// Get a single colvarvalue out of elements of the vector
colvarvalue const get_elem(int const icv) const;
/// Set elements of the vector from a single colvarvalue (uses the rank of x
/// to compute the length)
void set_elem(int const icv, colvarvalue const &x);
/// Set elements of the vector from a single colvarvalue
void set_elem(int const i_begin, int const i_end, colvarvalue const &x);
/// Make each element a random number in N(0,1)
void set_random();
/// Get a single colvarvalue out of elements of the vector
colvarvalue const get_elem(int const icv) const;
/// Set elements of the vector from a single colvarvalue
void set_elem(int const icv, colvarvalue const &x);
/// Make each element equal to the given argument
void set_ones(cvm::real assigned_value = 1.0);
/// Get a scalar number out of an element of the vector
cvm::real operator [] (int const i) const;
@ -683,6 +693,29 @@ inline cvm::real colvarvalue::norm2() const
}
inline cvm::real colvarvalue::sum() const
{
switch (value_type) {
case colvarvalue::type_scalar:
return (this->real_value);
case colvarvalue::type_3vector:
case colvarvalue::type_unit3vector:
case colvarvalue::type_unit3vectorderiv:
return (this->rvector_value).x + (this->rvector_value).y +
(this->rvector_value).z;
case colvarvalue::type_quaternion:
case colvarvalue::type_quaternionderiv:
return (this->quaternion_value).q0 + (this->quaternion_value).q1 +
(this->quaternion_value).q2 + (this->quaternion_value).q3;
case colvarvalue::type_vector:
return (this->vector1d_value).sum();
case colvarvalue::type_notset:
default:
return 0.0;
}
}
inline cvm::real colvarvalue::dist2(colvarvalue const &x2) const
{
colvarvalue::check_types(*this, x2);

View File

@ -78,7 +78,6 @@ def geturl(url,fname):
if which('curl') != None:
cmd = 'curl -L -o "%s" %s' % (fname,url)
print(cmd)
try:
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
success = True
@ -87,7 +86,6 @@ def geturl(url,fname):
if not success and which('wget') != None:
cmd = 'wget -O "%s" %s' % (fname,url)
print(cmd)
try:
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
success = True

4
lib/plumed/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/plumed2*
/includelink
/liblink
/plumed-*

206
lib/plumed/Install.py Normal file
View File

@ -0,0 +1,206 @@
#!/usr/bin/env python
# Install.py tool to download, unpack, build, and link to the plumed2 library
# used to automate the steps described in the README file in this dir
from __future__ import print_function
import sys,os,re,subprocess,hashlib
# help message
help = """
Syntax from src dir: make lib-plumed args="-b"
or: make lib-plumed args="-b -v 2.4.3"
or: make lib-plumed args="-p /usr/local/plumed2-2.4.3"
Syntax from lib dir: python Install.py -b -v 2.4.3
or: python Install.py -b
or: python Install.py -p /usr/local/plumed2-2.4.3
specify one or more options, order does not matter
-b = download and build the plumed2 library
-p = specify folder of existing plumed2 installation
-v = set version of plumed2 to download and build (default: 2.4.3)
Example:
make lib-plumed args="-b" # download/build in lib/plumed/plumed2
make lib-plumed args="-p $HOME/plumed-2.4.3" # use existing Plumed2 installation in $HOME/plumed-2.4.3
"""
# settings
version = "2.4.3"
# known checksums for different PLUMED versions. used to validate the download.
checksums = { \
'2.4.2' : '88188743a6e03ef076e5377d03ebb0e7', \
'2.4.3' : 'b1be7c48971627febc11c61b70767fc5', \
'2.5b' : 'e341bdef469be1da058b8a0b97a3db22', \
}
#checksums = { \
# '2.4.2' : '0f66f24b4c763ae8b2f39574113e9935', \
# '2.4.3' : 'dc38de0ffd59d13950d8f1ef1ce05574', \
# }
# print error message or help
def error(str=None):
if not str: print(help)
else: print("ERROR",str)
sys.exit()
# expand to full path name
# process leading '~' or relative path
def fullpath(path):
return os.path.abspath(os.path.expanduser(path))
def which(program):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def geturl(url,fname):
success = False
if which('curl') != None:
cmd = 'curl -L -o "%s" %s' % (fname,url)
try:
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
success = True
except subprocess.CalledProcessError as e:
print("Calling curl failed with: %s" % e.output.decode('UTF-8'))
if not success and which('wget') != None:
cmd = 'wget -O "%s" %s' % (fname,url)
try:
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
success = True
except subprocess.CalledProcessError as e:
print("Calling wget failed with: %s" % e.output.decode('UTF-8'))
if not success:
error("Failed to download source code with 'curl' or 'wget'")
return
def checkmd5sum(md5sum,fname):
with open(fname,'rb') as fh:
m = hashlib.md5()
while True:
data = fh.read(81920)
if not data:
break
m.update(data)
fh.close()
return m.hexdigest() == md5sum
# parse args
args = sys.argv[1:]
nargs = len(args)
if nargs == 0: error()
homepath = "."
buildflag = False
pathflag = False
suffixflag = False
linkflag = True
iarg = 0
while iarg < nargs:
if args[iarg] == "-v":
if iarg+2 > nargs: error()
version = args[iarg+1]
iarg += 2
elif args[iarg] == "-p":
if iarg+2 > nargs: error()
plumedpath = fullpath(args[iarg+1])
pathflag = True
iarg += 2
elif args[iarg] == "-b":
buildflag = True
iarg += 1
else: error()
homepath = fullpath(homepath)
if (pathflag):
if not os.path.isdir(plumedpath): error("Plumed2 path does not exist")
homedir = plumedpath
if (buildflag and pathflag):
error("Cannot use -b and -p flag at the same time")
if (not buildflag and not pathflag):
error("Have to use either -b or -p flag")
# download and unpack plumed2 tarball
if buildflag:
url = "https://github.com/plumed/plumed2/releases/download/v%s/plumed-src-%s.tgz" % (version,version)
filename = "plumed-src-%s.tar.gz" %version
#url = "https://github.com/plumed/plumed2/archive/v%s.tar.gz" % version
#filename = "v%s.tar.gz" %version
print("Downloading plumed ...")
geturl(url,filename)
# verify downloaded archive integrity via md5 checksum, if known.
if version in checksums:
if not checkmd5sum(checksums[version],filename):
error("Checksum for plumed2 library does not match")
print("Unpacking plumed2 source tarball ...")
if os.path.exists("%s/plumed-%s" % (homepath,version)):
cmd = 'rm -rf "%s/plumed-%s"' % (homepath,version)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
#if os.path.exists("%s/plumed2-%s" % (homepath,version)):
# cmd = 'rm -rf "%s/plumed2-%s"' % (homepath,version)
# subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
if os.path.exists("%s/plumed2" % (homepath)):
cmd = 'rm -rf "%s/plumed2"' % (homepath)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
cmd = 'cd "%s"; tar -xzvf %s' % (homepath,filename)
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
os.remove("%s/%s" % (homepath,filename))
# build plumed
if buildflag:
print("Building plumed ...")
cmd = 'cd %s/plumed-%s; ./configure --prefix=%s/plumed2 --enable-static-patch ; make ; make install' % (homepath,version,homepath)
#cmd = 'cd %s/plumed2-%s; ./configure --prefix=%s/plumed2 --enable-static-patch ; make ; make install' % (homepath,version,homepath)
txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
print(txt.decode('UTF-8'))
#
# create 2 links in lib/plumed to plumed2 installation dir
if linkflag:
print("Creating links to plumed2 include and lib files")
if os.path.isfile("includelink") or os.path.islink("includelink"):
os.remove("includelink")
if os.path.isfile("liblink") or os.path.islink("liblink"):
os.remove("liblink")
cmd = 'ln -s "%s/plumed2/include" includelink' % homepath
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
cmd = 'ln -s "%s/plumed2/lib" liblink' % homepath
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
if os.path.isfile("Makefile.lammps.static"):
print("Creating Makefile.lammps")
cmd = 'cat liblink/plumed/src/lib/Plumed.inc.static Makefile.lammps.static > Makefile.lammps'
subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)

View File

@ -0,0 +1,5 @@
# Settings that the LAMMPS build will import when this package library is used
plumed_SYSINC =
plumed_SYSLIB = $(PLUMED_LOAD)
plumed_SYSPATH =

56
lib/plumed/README Normal file
View File

@ -0,0 +1,56 @@
This directory contains links to the PLUMED library which is required
to use the PLUMED package and its fix plumed command in a
LAMMPS input script. PLUMED should only be downloaded into this directory if
you wish to statically link the library. If you wish to link PLUMED as
a dynamic library (as we recommend) then you can compile and build PLUMED
separately to LAMMPS. To use PLUMED in conjuction with LAMMPS you then simply
need to ensure that the PLUMED library is in your path at runtime.
More info about the PLUMED library can be found at http://www.plumed.org.
You can type "make lib-plumed" from the src directory to see help on
how to download, build and statically link PLUMED via make commands, or you can
do the same thing by typing "python Install.py" from within this
directory. Alternatively you can download and build PLUMED manually by following the instructions
below.
-----------------
Instructions:
1. Download PLUMED either as a tarball from
http://www.plumed.org/get-it
or clone it using git clone https://github.com/plumed/plumed2.git.
If you download the tarball
unpack it in unpack it in this /lib/plumed directory.
Similarly if you clone it clone it to the /lib/plumed
directory.
2. Compile PLUMED from within its home directory. In the
simplest cases this be done by issuing the commands
% ./configure
% make
More detailed instructions can be found at
http://plumed.github.io/doc-master/user-doc/html/_installation.html
3. There is no need to install PLUMED if you only wish
to use it from LAMMPS. You should thus only run
make install if you want to use PLUMED as a stand-alone
code or from some other code. To install it you can
run the following commands:
a) install under the default /usr/local
% sudo make install
b) install under a user-writeable location by first
changing the PREFIX variable when running the
configure command file, then
% make install
-----------------
When these steps are complete you can build LAMMPS
with the PLUMED package installed:
% cd lammps/src
% make yes-user-plumed
% make mpi (or whatever target you wish)

8
src/.gitignore vendored
View File

@ -59,6 +59,8 @@
/colvarproxy_lammps_version.h
/fix_colvars.cpp
/fix_colvars.h
/fix_plumed.cpp
/fix_plumed.h
/dump_molfile.cpp
/dump_molfile.h
/molfile_interface.cpp
@ -485,6 +487,8 @@
/fix_load_report.h
/fix_meso.cpp
/fix_meso.h
/fix_meso_move.cpp
/fix_meso_move.h
/fix_meso_stationary.cpp
/fix_meso_stationary.h
/fix_mscg.cpp
@ -573,6 +577,8 @@
/fix_rhok.h
/fix_rigid.cpp
/fix_rigid.h
/fix_rigid_meso.cpp
/fix_rigid_meso.h
/fix_rigid_nh.cpp
/fix_rigid_nh.h
/fix_rigid_nph.cpp
@ -901,6 +907,8 @@
/pair_rebo.h
/pair_resquared.cpp
/pair_resquared.h
/pair_sdpd_taitwater_isothermal.cpp
/pair_sdpd_taitwater_isothermal.h
/pair_sph_heatconduction.cpp
/pair_sph_heatconduction.h
/pair_sph_idealgas.cpp

View File

@ -107,6 +107,7 @@ fi
if (test $1 = "RIGID") then
depend USER-OMP
depend USER-SDPD
fi
if (test $1 = "SNAP") then

View File

@ -61,21 +61,22 @@ PACKUSER = user-atc user-awpmd user-bocs user-cgdna user-cgsdk user-colvars \
user-diffraction user-dpd user-drude user-eff user-fep user-h5md \
user-intel user-lb user-manifold user-meamc user-meso \
user-mgpt user-misc user-mofff user-molfile \
user-netcdf user-omp user-phonon user-ptm user-qmmm user-qtb \
user-quip user-reaxc user-scafacos user-smd user-smtbq \
user-sph user-tally user-uef user-vtk
user-netcdf user-omp user-phonon user-plumed user-ptm user-qmmm \
user-qtb user-quip user-reaxc user-scafacos user-smd user-smtbq \
user-sdpd user-sph user-tally user-uef user-vtk
PACKLIB = compress gpu kim kokkos latte meam message mpiio mscg poems \
python reax voronoi \
user-atc user-awpmd user-colvars user-h5md user-lb user-molfile \
user-netcdf user-qmmm user-quip user-scafacos user-smd user-vtk
user-netcdf user-plumed user-qmmm user-quip user-scafacos \
user-smd user-vtk
PACKSYS = compress mpiio python user-lb
PACKINT = gpu kokkos meam message poems reax user-atc user-awpmd user-colvars
PACKEXT = kim latte mscg voronoi \
user-h5md user-molfile user-netcdf user-qmmm user-quip \
user-h5md user-molfile user-netcdf user-plumed user-qmmm user-quip \
user-smd user-vtk
PACKALL = $(PACKAGE) $(PACKUSER)

View File

@ -60,8 +60,11 @@ static const char cite_fix_nve_spin[] =
"dynamics and molecular dynamics},\n"
"author={Tranchida, J and Plimpton, SJ and Thibaudeau, P and Thompson, AP},\n"
"journal={Journal of Computational Physics},\n"
"volume={372},\n"
"pages={406-425},\n"
"year={2018},\n"
"publisher={Elsevier}\n"
"doi={10.1016/j.jcp.2018.06.042}\n"
"}\n\n";
enum{NONE};

View File

@ -1,5 +1,5 @@
#ifndef COLVARPROXY_VERSION
#define COLVARPROXY_VERSION "2018-04-29"
#define COLVARPROXY_VERSION "2018-08-29"
// This file is part of the Collective Variables module (Colvars).
// The original version of Colvars and its updates are located at:
// https://github.com/colvars/colvars

View File

@ -78,6 +78,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
fix1 = NULL;
fix2 = NULL;
fix3 = NULL;
if (narg < 8) error->all(FLERR,"Illegal fix bond/react command: "
"too few arguments");
@ -163,6 +164,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
memory->create(seed,nreacts,"bond/react:seed");
memory->create(limit_duration,nreacts,"bond/react:limit_duration");
memory->create(stabilize_steps_flag,nreacts,"bond/react:stabilize_steps_flag");
memory->create(update_edges_flag,nreacts,"bond/react:update_edges_flag");
memory->create(iatomtype,nreacts,"bond/react:iatomtype");
memory->create(jatomtype,nreacts,"bond/react:jatomtype");
memory->create(ibonding,nreacts,"bond/react:ibonding");
@ -178,6 +180,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
fraction[i] = 1;
seed[i] = 12345;
stabilize_steps_flag[i] = 0;
update_edges_flag[i] = 0;
// set default limit duration to 60 timesteps
limit_duration[i] = 60;
reaction_count[i] = 0;
@ -249,6 +252,14 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
limit_duration[rxn] = force->numeric(FLERR,arg[iarg+1]);
stabilize_steps_flag[rxn] = 1;
iarg += 2;
} else if (strcmp(arg[iarg],"update_edges") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix bond/react command: "
"'update_edges' has too few arguments");
if (strcmp(arg[iarg+1],"none") == 0) update_edges_flag[rxn] = 0;
else if (strcmp(arg[iarg+1],"charges") == 0) update_edges_flag[rxn] = 1;
else if (strcmp(arg[iarg+1],"custom") == 0) update_edges_flag[rxn] = 2;
else error->all(FLERR,"Illegal value for 'update_edges' keyword'");
iarg += 2;
} else error->all(FLERR,"Illegal fix bond/react command: unknown keyword");
}
}
@ -263,15 +274,23 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
memory->create(reverse_equiv,max_natoms,2,nreacts,"bond/react:reverse_equiv");
memory->create(edge,max_natoms,nreacts,"bond/react:edge");
memory->create(landlocked_atoms,max_natoms,nreacts,"bond/react:landlocked_atoms");
memory->create(custom_edges,max_natoms,nreacts,"bond/react:custom_edges");
for (int j = 0; j < nreacts; j++)
for (int i = 0; i < max_natoms; i++) edge[i][j] = 0;
for (int i = 0; i < max_natoms; i++) {
edge[i][j] = 0;
if (update_edges_flag[j] == 1) custom_edges[i][j] = 1;
else custom_edges[i][j] = 0;
}
// read all superimpose files afterward
// read all map files afterward
for (int i = 0; i < nreacts; i++) {
open(files[i]);
onemol = atom->molecules[unreacted_mol[i]];
twomol = atom->molecules[reacted_mol[i]];
if (onemol->natoms != twomol->natoms)
error->all(FLERR,"Post-reacted template must contain the same "
"number of atoms as the pre-reacted template");
get_molxspecials();
read(i);
fclose(fp);
@ -347,6 +366,9 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
id_fix1 = NULL;
id_fix2 = NULL;
id_fix3 = NULL;
statted_id = NULL;
custom_exclude_flag = 0;
}
/* ---------------------------------------------------------------------- */
@ -370,6 +392,7 @@ FixBondReact::~FixBondReact()
memory->destroy(edge);
memory->destroy(equivalences);
memory->destroy(reverse_equiv);
memory->destroy(custom_edges);
memory->destroy(nevery);
memory->destroy(cutsq);
@ -379,6 +402,7 @@ FixBondReact::~FixBondReact()
memory->destroy(seed);
memory->destroy(limit_duration);
memory->destroy(stabilize_steps_flag);
memory->destroy(update_edges_flag);
memory->destroy(iatomtype);
memory->destroy(jatomtype);
@ -418,11 +442,15 @@ FixBondReact::~FixBondReact()
// check nfix in case all fixes have already been deleted
if (id_fix1 == NULL && modify->nfix) modify->delete_fix(id_fix1);
delete [] id_fix1;
if (id_fix3 == NULL && modify->nfix) modify->delete_fix(id_fix3);
delete [] id_fix3;
}
if (id_fix2 == NULL && modify->nfix) modify->delete_fix(id_fix2);
delete [] id_fix2;
delete [] statted_id;
delete [] guess_branch;
delete [] pioneer_count;
}
@ -453,61 +481,126 @@ void FixBondReact::post_constructor()
int ifix = modify->find_fix(id_fix2);
if (ifix == -1) {
char **newarg = new char*[8];
char **newarg = new char*[7];
newarg[0] = (char *) "bond_react_props_internal";
newarg[1] = (char *) "all"; // group ID is ignored
newarg[2] = (char *) "property/atom";
newarg[3] = (char *) "i_limit_tags";
newarg[4] = (char *) "i_statted_tags";
newarg[5] = (char *) "i_react_tags";
newarg[6] = (char *) "ghost";
newarg[7] = (char *) "yes";
modify->add_fix(8,newarg);
fix2 = modify->fix[modify->nfix-1];
newarg[4] = (char *) "i_react_tags";
newarg[5] = (char *) "ghost";
newarg[6] = (char *) "yes";
modify->add_fix(7,newarg);
delete [] newarg;
}
// create master_group if not already existing
if (group->find(master_group) == -1) {
group->find_or_create(master_group);
char **newarg;
newarg = new char*[5];
newarg[0] = master_group;
newarg[1] = (char *) "dynamic";
newarg[2] = (char *) "all";
newarg[3] = (char *) "property";
newarg[4] = (char *) "limit_tags";
group->assign(5,newarg);
delete [] newarg;
}
// on to statted_tags (system-wide thermostat)
// intialize per-atom statted_flags to 1
// (only if not already initialized by restart)
// NOTE: limit_tags and react_tags automaticaly intitialized to zero (unless read from restart)
if (fix2->restart_reset != 1) {
int flag;
int index = atom->find_custom("statted_tags",flag);
int *i_statted_tags = atom->ivector[index];
for (int i = 0; i < atom->nlocal; i++)
i_statted_tags[i] = 1;
}
group->find_or_create(master_group);
char **newarg;
newarg = new char*[5];
newarg[0] = master_group;
newarg[1] = (char *) "dynamic";
newarg[2] = (char *) "all";
newarg[3] = (char *) "property";
newarg[4] = (char *) "limit_tags";
group->assign(5,newarg);
delete [] newarg;
if (stabilization_flag == 1) {
// create exclude_group if not already existing
if (group->find(exclude_group) == -1) {
int igroup = group->find(exclude_group);
// create exclude_group if not already existing, or use as parent group if static
if (igroup == -1 || group->dynamic[igroup] == 0) {
// create stabilization per-atom property
len = strlen("bond_react_stabilization_internal") + 1;
id_fix3 = new char[len];
strcpy(id_fix3,"bond_react_stabilization_internal");
ifix = modify->find_fix(id_fix3);
if (ifix == -1) {
char **newarg = new char*[6];
newarg[0] = (char *) id_fix3;
newarg[1] = (char *) "all"; // group ID is ignored
newarg[2] = (char *) "property/atom";
newarg[3] = (char *) "i_statted_tags";
newarg[4] = (char *) "ghost";
newarg[5] = (char *) "yes";
modify->add_fix(6,newarg);
fix3 = modify->fix[modify->nfix-1];
delete [] newarg;
}
len = strlen("statted_tags") + 1;
statted_id = new char[len];
strcpy(statted_id,"statted_tags");
// if static group exists, use as parent group
// also, rename dynamic exclude_group by appending '_REACT'
char *exclude_PARENT_group;
int n = strlen(exclude_group) + 1;
exclude_PARENT_group = new char[n];
strcpy(exclude_PARENT_group,exclude_group);
n += strlen("_REACT");
delete [] exclude_group;
exclude_group = new char[n];
strcpy(exclude_group,exclude_PARENT_group);
strcat(exclude_group,"_REACT");
group->find_or_create(exclude_group);
char **newarg;
newarg = new char*[5];
newarg[0] = exclude_group;
newarg[1] = (char *) "dynamic";
newarg[2] = (char *) "all";
if (igroup == -1) newarg[2] = (char *) "all";
else newarg[2] = (char *) exclude_PARENT_group;
newarg[3] = (char *) "property";
newarg[4] = (char *) "statted_tags";
group->assign(5,newarg);
delete [] newarg;
}
delete [] exclude_PARENT_group;
// on to statted_tags (system-wide thermostat)
// intialize per-atom statted_flags to 1
// (only if not already initialized by restart)
if (fix3->restart_reset != 1) {
int flag;
int index = atom->find_custom("statted_tags",flag);
int *i_statted_tags = atom->ivector[index];
for (int i = 0; i < atom->nlocal; i++)
i_statted_tags[i] = 1;
}
} else {
// sleeping code, for future capabilities
custom_exclude_flag = 1;
// first we have to find correct fix group reference
int n = strlen("GROUP_") + strlen(exclude_group) + 1;
char *fix_group = new char[n];
strcpy(fix_group,"GROUP_");
strcat(fix_group,exclude_group);
int ifix = modify->find_fix(fix_group);
Fix *fix = modify->fix[ifix];
delete [] fix_group;
// this returns names of corresponding property
int unused;
char * idprop;
idprop = (char *) fix->extract("property",unused);
if (idprop == NULL)
error->all(FLERR,"Exclude group must be a per-atom property group");
len = strlen(idprop) + 1;
statted_id = new char[len];
strcpy(statted_id,idprop);
// intialize per-atom statted_tags to 1
// need to correct for smooth restarts
//int flag;
//int index = atom->find_custom(statted_id,flag);
//int *i_statted_tags = atom->ivector[index];
//for (int i = 0; i < atom->nlocal; i++)
// i_statted_tags[i] = 1;
}
// let's create a new nve/limit fix to limit newly reacted atoms
len = strlen("bond_react_MASTER_nve_limit") + 1;
@ -526,40 +619,6 @@ void FixBondReact::post_constructor()
fix1 = modify->fix[modify->nfix-1];
delete [] newarg;
}
}
// currently must redefine dynamic groups so they are updated at proper time
// -> should double check as to why
int must_redefine_groups = 1;
if (must_redefine_groups) {
group->find_or_create(master_group);
char **newarg;
newarg = new char*[5];
newarg[0] = master_group;
newarg[1] = (char *) "dynamic";
newarg[2] = (char *) "all";
newarg[3] = (char *) "property";
newarg[4] = (char *) "limit_tags";
group->assign(5,newarg);
delete [] newarg;
}
if (stabilization_flag == 1) {
if (must_redefine_groups) {
group->find_or_create(exclude_group);
char **newarg;
newarg = new char*[5];
newarg[0] = exclude_group;
newarg[1] = (char *) "dynamic";
newarg[2] = (char *) "all";
newarg[3] = (char *) "property";
newarg[4] = (char *) "statted_tags";
group->assign(5,newarg);
delete [] newarg;
}
}
}
@ -1804,8 +1863,11 @@ void FixBondReact::limit_bond(int limit_bond_mode)
int index1 = atom->find_custom("limit_tags",flag);
int *i_limit_tags = atom->ivector[index1];
int index2 = atom->find_custom("statted_tags",flag);
int *i_statted_tags = atom->ivector[index2];
int *i_statted_tags;
if (stabilization_flag == 1) {
int index2 = atom->find_custom(statted_id,flag);
i_statted_tags = atom->ivector[index2];
}
int index3 = atom->find_custom("react_tags",flag);
int *i_react_tags = atom->ivector[index3];
@ -1813,7 +1875,7 @@ void FixBondReact::limit_bond(int limit_bond_mode)
for (int i = 0; i < temp_limit_num; i++) {
// update->ntimestep could be 0. so add 1 throughout
i_limit_tags[atom->map(temp_limit_glove[i])] = update->ntimestep + 1;
i_statted_tags[atom->map(temp_limit_glove[i])] = 0;
if (stabilization_flag == 1) i_statted_tags[atom->map(temp_limit_glove[i])] = 0;
i_react_tags[atom->map(temp_limit_glove[i])] = rxnID;
}
@ -1834,8 +1896,11 @@ void FixBondReact::unlimit_bond()
int index1 = atom->find_custom("limit_tags",flag);
int *i_limit_tags = atom->ivector[index1];
int index2 = atom->find_custom("statted_tags",flag);
int *i_statted_tags = atom->ivector[index2];
int *i_statted_tags;
if (stabilization_flag == 1) {
int index2 = atom->find_custom(statted_id,flag);
i_statted_tags = atom->ivector[index2];
}
int index3 = atom->find_custom("react_tags",flag);
int *i_react_tags = atom->ivector[index3];
@ -1845,7 +1910,7 @@ void FixBondReact::unlimit_bond()
// first '1': indexing offset, second '1': for next step
if (i_limit_tags[i] != 0 && (update->ntimestep + 1 - i_limit_tags[i]) > limit_duration[i_react_tags[i]]) { // + 1
i_limit_tags[i] = 0;
i_statted_tags[i] = 1;
if (stabilization_flag == 1) i_statted_tags[i] = 1;
i_react_tags[i] = 0;
}
}
@ -2022,13 +2087,13 @@ void FixBondReact::update_everything()
}
// update charges and types of landlocked atoms
// here, add check for charge instead of requiring it
for (int i = 0; i < update_num_mega; i++) {
rxnID = update_mega_glove[0][i];
twomol = atom->molecules[reacted_mol[rxnID]];
for (int j = 0; j < twomol->natoms; j++) {
int jj = equivalences[j][1][rxnID]-1;
if (landlocked_atoms[j][rxnID] == 1 && atom->map(update_mega_glove[jj+1][i]) >= 0 &&
if ((landlocked_atoms[j][rxnID] == 1 || custom_edges[jj][rxnID] == 1) &&
atom->map(update_mega_glove[jj+1][i]) >= 0 &&
atom->map(update_mega_glove[jj+1][i]) < nlocal) {
type[atom->map(update_mega_glove[jj+1][i])] = twomol->type[j];
if (twomol->qflag && atom->q_flag) {
@ -2470,6 +2535,7 @@ void FixBondReact::read(int myrxn)
if (strstr(line,"edgeIDs")) sscanf(line,"%d",&nedge);
else if (strstr(line,"equivalences")) sscanf(line,"%d",&nequivalent);
else if (strstr(line,"customIDs")) sscanf(line,"%d",&ncustom);
else break;
}
@ -2482,7 +2548,7 @@ void FixBondReact::read(int myrxn)
// loop over sections of superimpose file
int equivflag = 0, edgeflag = 0, bondflag = 0;
int equivflag = 0, edgeflag = 0, bondflag = 0, customedgesflag = 0;
while (strlen(keyword)) {
if (strcmp(keyword,"BondingIDs") == 0) {
bondflag = 1;
@ -2496,6 +2562,9 @@ void FixBondReact::read(int myrxn)
} else if (strcmp(keyword,"Equivalences") == 0) {
equivflag = 1;
Equivalences(line, myrxn);
} else if (strcmp(keyword,"Custom Edges") == 0) {
customedgesflag = 1;
CustomEdges(line, myrxn);
} else error->one(FLERR,"Unknown section in superimpose file");
parse_keyword(1,line,keyword);
@ -2505,6 +2574,12 @@ void FixBondReact::read(int myrxn)
// error check
if (bondflag == 0 || equivflag == 0)
error->all(FLERR,"Superimpose file missing BondingIDs or Equivalences section\n");
if (update_edges_flag[myrxn] == 2 && customedgesflag == 0)
error->all(FLERR,"Map file must have a Custom Edges section when using 'update_edges custom'\n");
if (update_edges_flag[myrxn] != 2 && customedgesflag == 1)
error->all(FLERR,"Specify 'update_edges custom' to include Custom Edges section in map file\n");
}
void FixBondReact::EdgeIDs(char *line, int myrxn)
@ -2535,6 +2610,26 @@ void FixBondReact::Equivalences(char *line, int myrxn)
}
}
void FixBondReact::CustomEdges(char *line, int myrxn)
{
// 0 for 'none', 1 for 'charges'
int tmp;
int n = MAX(strlen("none"),strlen("charges")) + 1;
char *edgemode = new char[n];
for (int i = 0; i < ncustom; i++) {
readline(line);
sscanf(line,"%d %s",&tmp,edgemode);
if (strcmp(edgemode,"none") == 0)
custom_edges[tmp-1][myrxn] = 0;
else if (strcmp(edgemode,"charges") == 0)
custom_edges[tmp-1][myrxn] = 1;
else
error->one(FLERR,"Illegal value in 'Custom Edges' section of map file");
}
delete [] edgemode;
}
void FixBondReact::open(char *file)
{
fp = fopen(file,"r");

View File

@ -57,7 +57,9 @@ class FixBondReact : public Fix {
double **cutsq,*fraction;
tagint lastcheck;
int stabilization_flag;
int custom_exclude_flag;
int *stabilize_steps_flag;
int *update_edges_flag;
int status;
int *groupbits;
@ -76,9 +78,9 @@ class FixBondReact : public Fix {
class Molecule *onemol; // pre-reacted molecule template
class Molecule *twomol; // post-reacted molecule template
Fix *fix1; // nve/limit used to relax reaction sites
Fix *fix2; // properties/atom used to indicate 1) indicate relaxing atoms
// 2) system-wide thermostat
// 3) to which 'react' atom belongs
Fix *fix2; // properties/atom used to indicate 1) relaxing atoms
// 2) to which 'react' atom belongs
Fix *fix3; // property/atom used for system-wide thermostat
class RanMars **random;
class NeighList *list;
@ -87,6 +89,8 @@ class FixBondReact : public Fix {
char *nve_limit_xmax; // indicates max distance allowed to move when relaxing
char *id_fix1; // id of internally created fix nve/limit
char *id_fix2; // id of internally created fix per-atom properties
char *id_fix3; // id of internally created 'stabilization group' per-atom property fix
char *statted_id; // name of 'stabilization group' per-atom property
char *master_group; // group containing relaxing atoms from all fix rxns
char *exclude_group; // group for system-wide thermostat
@ -97,7 +101,7 @@ class FixBondReact : public Fix {
int *ibonding,*jbonding;
int *closeneigh; // indicates if bonding atoms of a rxn are 1-2, 1-3, or 1-4 neighbors
int nedge,nequivalent; // number of edge, equivalent atoms in mapping file
int nedge,nequivalent,ncustom; // number of edge, equivalent, custom atoms in mapping file
int attempted_rxn; // there was an attempt!
int *local_rxn_count;
int *ghostly_rxn_count;
@ -111,6 +115,7 @@ class FixBondReact : public Fix {
int ***equivalences; // relation between pre- and post-reacted templates
int ***reverse_equiv; // re-ordered equivalences
int **landlocked_atoms; // all atoms at least three bonds away from edge atoms
int **custom_edges; // atoms in molecule templates with incorrect valences
int **nxspecial,**onemol_nxspecial,**twomol_nxspecial; // full number of 1-4 neighbors
tagint **xspecial,**onemol_xspecial,**twomol_xspecial; // full 1-4 neighbor list
@ -132,6 +137,7 @@ class FixBondReact : public Fix {
void read(int);
void EdgeIDs(char *,int);
void Equivalences(char *,int);
void CustomEdges(char *,int);
void make_a_guess ();
void neighbor_loop();

65
src/USER-PLUMED/Install.sh Executable file
View File

@ -0,0 +1,65 @@
# Install/unInstall package files in LAMMPS
# mode = 0/1/2 for uninstall/install/update
mode=$1
# enforce using portable C locale
LC_ALL=C
export LC_ALL
# arg1 = file, arg2 = file it depends on
action () {
if (test $mode = 0) then
rm -f ../$1
elif (! cmp -s $1 ../$1) then
if (test -z "$2" || test -e ../$2) then
cp $1 ..
if (test $mode = 2) then
echo " updating src/$1"
fi
fi
elif (test -n "$2") then
if (test ! -e ../$2) then
rm -f ../$1
fi
fi
}
# all package files with no dependencies
for file in *.cpp *.h; do
test -f ${file} && action $file
done
# edit 2 Makefile.package files to include/exclude package info
if (test $1 = 1) then
if (test -e ../Makefile.package) then
sed -i -e 's/[^ \t]*plumed[^ \t]* //' ../Makefile.package
sed -i -e 's|^PKG_INC =[ \t]*|&-I../../lib/plumed/includelink |' ../Makefile.package
sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(plumed_SYSINC) |' ../Makefile.package
sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(plumed_SYSLIB) |' ../Makefile.package
sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(plumed_SYSPATH) |' ../Makefile.package
fi
if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*plumed.*$/d' ../Makefile.package.settings
# multiline form needed for BSD sed on Macs
sed -i -e '4 i \
include ..\/..\/lib\/plumed\/Makefile.lammps
' ../Makefile.package.settings
fi
elif (test $1 = 0) then
if (test -e ../Makefile.package) then
sed -i -e 's/[^ \t]*plumed[^ \t]* //' ../Makefile.package
fi
if (test -e ../Makefile.package.settings) then
sed -i -e '/^include.*plumed.*$/d' ../Makefile.package.settings
fi
fi

70
src/USER-PLUMED/README Normal file
View File

@ -0,0 +1,70 @@
This package implements the "fix plumed" command, which can be used
in a LAMMPS input script.
The fix allows enhanced sampling methods such as umbrella sampling and
metadynamics to be used. Furthermore, PLUMED can be used to perform a
wide range of analyses on trajectories on the fly as they are generated.
The package uses the "PLUMED" library, whose source code is not included
in the LAMMPS source code distribution. The files in the USER-PLUMED package
folder implement an interface between LAMMPS and PLUMED, that are written
and maintained by Gareth Tribello (gareth.tribello@gmail.com).
PLUMED must instead be downloaded and compiled separately to LAMMPS. This building
and compiling of PLUMED can be done before or after the building of LAMMPS as LAMMPS
can call PLUMED as a dynamic library. There is also the possibility to link PLUEMD
statically. In this case a copy of PLUMED must be downloaded into the lib/plumed
directory. This copy of PLUMED will then always be linked into the code at compile
time.
However you decide to link PLUMED (statically or dynamically) you must run the command:
make yes-user-plumed
before compiling LAMMPS in order to enable the module. In addition, if you have chosen to
link PLUMED dynamically you must ensure that PLUMED is in your
PATH when running a LAMMPS calculation that takes advantage of PLUMED. If
PLUMED is linked as a runtime library and if PLUMED is not in the PATH an error will be returned whenever LAMMPS encounters
the fix plumed command in its input. To be clear, however, a LAMMPS executable that was dynamically linked with PLUMED will run
even if PLUMED is not in the path if as long as the input does not contain a fix
plumed command.
If you wish to statically link PLUMED you must download PLUMED to the /lib/plumed directory before compiling LAMMPS. You can
download a tar ball into that directory or you can clone the plumed2 repository from github there. Once you have created a
directory containing a distribution of PLUMED within /lib/plumed you then must build PLUMED within that directory by issuing
the usual commands. It is worth noting that we have provided a script that will download and build PLUMED for you with
a minimal set of options. To run this script you need to issue the following command:
make lib-plumed args="-b"
in the src directory.
More info about the PLUMED library can be found at:
www.plumed.org
and in the reference articles:
PLUMED2: New feathers for an old bird
G.A. Tribello, M. Bonomi, D. Branduardi, C. Camilloni and G. Bussi,
Comp. Phys. Comm 185, 604 (2014)
https://doi.org/10.1016/j.cpc.2013.09.018
PLUMED: a portable plugin for free energy calculations with molecular dynamics
M. Bonomi, D. Branduardi, G. Bussi, C. Camilloni, D. Provasi, P. Raiteri, D. Donadio, F. Marinelli, F. Pietrucci, R.A. Broglia and M. Parrinello
Comp. Phys. Comm. 180, 1961 (2009)
https://doi.org/10.1016/j.cpc.2009.05.011
Instructions explaining how to use PLUMED and LAMMPS in tandem can be found on the PLUMED website, which also gives
numerous example scripts for PLUMED as well as citations to articles that dcoment the various methods that are
implemented within PLUMED.
There are also example scripts for using this package in the folder
examples/USER/plumed, as well as on the GitHub page for PLUMED.
Please contact Gareth Tribello (gareth.tribello@gmail.com) for questions
regarding this package.
---------------------------------
Version: 2016-12-22

View File

@ -0,0 +1,559 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing authors: Gareth Tribello (Queens U, Belfast)
Pablo Piaggi (EPFL)
------------------------------------------------------------------------- */
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "atom.h"
#include "comm.h"
#include "update.h"
#include "force.h"
#include "respa.h"
#include "domain.h"
#include "error.h"
#include "group.h"
#include "fix_plumed.h"
#include "universe.h"
#include "compute.h"
#include "modify.h"
#include "pair.h"
/*
Use statically linked C++ interface to plumed
*/
#define __PLUMED_WRAPPER_CXX 1
#include "plumed/wrapper/Plumed.h"
/* -------------------------------------------------------------------- */
using namespace LAMMPS_NS;
using namespace FixConst;
#define INVOKED_SCALAR 1
FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg),
p(NULL), nlocal(0), gatindex(NULL), masses(NULL), charges(NULL),
id_pe(NULL), id_press(NULL)
{
if (!atom->tag_enable)
error->all(FLERR,"Fix plumed requires atom tags");
if (atom->tag_consecutive() == 0)
error->all(FLERR,"Fix plumed requires consecutive atom IDs");
if (igroup != 0 && comm->me == 0)
error->warning(FLERR,"Fix group for fix plumed is not 'all'. "
"Group will be ignored.");
p=new PLMD::Plumed;
// Check API version
int api_version;
p->cmd("getApiVersion",&api_version);
if (api_version > 6)
error->all(FLERR,"Incompatible API version for PLUMED in fix plumed");
// If the -partition option is activated then enable
// inter-partition communication
if (universe->existflag == 1) {
int me;
MPI_Comm inter_comm;
MPI_Comm_rank(world,&me);
// Change MPI_COMM_WORLD to universe->uworld which seems more appropriate
MPI_Comm_split(universe->uworld,me,0,&inter_comm);
p->cmd("GREX setMPIIntracomm",&world);
if (me == 0) {
// The inter-partition communicator is only defined for the root in
// each partition (a.k.a. world). This is due to the way in which
// it is defined inside plumed.
p->cmd("GREX setMPIIntercomm",&inter_comm);
}
p->cmd("GREX init",NULL);
}
// The general communicator is independent of the existence of partitions,
// if there are partitions, world is defined within each partition,
// whereas if partitions are not defined then world is equal to
// MPI_COMM_WORLD.
p->cmd("setMPIComm",&world);
// Set up units
// LAMMPS units wrt kj/mol - nm - ps
// Set up units
if(strcmp(update->unit_style,"lj") == 0) {
// LAMMPS units lj
p->cmd("setNaturalUnits");
} else {
// Conversion factor from LAMMPS energy units to kJ/mol (units of PLUMED)
double energyUnits=1.0;
// LAMMPS units real :: kcal/mol;
if (strcmp(update->unit_style,"real") == 0) {
energyUnits=4.184;
// LAMMPS units metal :: eV;
} else if (strcmp(update->unit_style,"metal") == 0) {
energyUnits=96.48530749925792;
// LAMMPS units si :: Joule;
} else if (strcmp(update->unit_style,"si") == 0) {
energyUnits=0.001;
// LAMMPS units cgs :: erg;
} else if (strcmp(update->unit_style,"cgs") == 0) {
energyUnits=6.0221418e13;
// LAMMPS units electron :: Hartree;
} else if (strcmp(update->unit_style,"electron") == 0) {
energyUnits=2625.5257;
} else error->all(FLERR,"Fix plumed cannot handle your choice of units");
// Conversion factor from LAMMPS length units to nm (units of PLUMED)
double lengthUnits=0.1/force->angstrom;
// Conversion factor from LAMMPS time unit to ps (units of PLUMED)
double timeUnits=0.001/force->femtosecond;
p->cmd("setMDEnergyUnits",&energyUnits);
p->cmd("setMDLengthUnits",&lengthUnits);
p->cmd("setMDTimeUnits",&timeUnits);
}
// Read fix parameters:
int next=0;
for (int i=3;i<narg;++i) {
if (!strcmp(arg[i],"outfile")) {
next=1;
} else if (next==1) {
if (universe->existflag == 1) {
// Each replica writes an independent log file
// with suffix equal to the replica id
char str_num[32], logFile[1024];
sprintf(str_num,".%d",universe->iworld);
strncpy(logFile,arg[i],1024-32);
strcat(logFile,str_num);
p->cmd("setLogFile",logFile);
next=0;
} else {
// partition option not used
p->cmd("setLogFile",arg[i]);
next=0;
}
} else if (!strcmp(arg[i],"plumedfile")) {
next=2;
} else if (next==2) {
p->cmd("setPlumedDat",arg[i]);
next=0;
} else error->all(FLERR,"Syntax error - use 'fix <fix-ID> plumed "
"plumedfile plumed.dat outfile plumed.out' ");
}
if (next==1) error->all(FLERR,"missing argument for outfile option");
if (next==2) error->all(FLERR,"missing argument for plumedfile option");
p->cmd("setMDEngine","LAMMPS");
if (atom->natoms > MAXSMALLINT)
error->all(FLERR,"Fix plumed can only handle up to 2.1 billion atoms");
natoms=int(atom->natoms);
p->cmd("setNatoms",&natoms);
double dt=update->dt;
p->cmd("setTimestep",&dt);
virial_flag=1;
thermo_virial=1;
scalar_flag = 1;
// This is the real initialization:
p->cmd("init");
// Define compute to calculate potential energy
id_pe = new char[7];
id_pe = (char *) "plmd_pe";
char **newarg = new char*[3];
newarg[0] = id_pe;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pe";
modify->add_compute(3,newarg);
delete [] newarg;
int ipe = modify->find_compute(id_pe);
c_pe = modify->compute[ipe];
// Define compute to calculate pressure tensor
id_press = new char[9];
id_press = (char *) "plmd_press";
newarg = new char*[5];
newarg[0] = id_press;
newarg[1] = (char *) "all";
newarg[2] = (char *) "pressure";
newarg[3] = (char *) "NULL";
newarg[4] = (char *) "virial";
modify->add_compute(5,newarg);
delete [] newarg;
int ipress = modify->find_compute(id_press);
c_press = modify->compute[ipress];
for (int i = 0; i < modify->nfix; i++) {
const char * const check_style = modify->fix[i]->style;
// There must be only one
if (strcmp(check_style,"plumed") == 0)
error->all(FLERR,"There must be only one instance of fix plumed");
// Avoid conflict with fixes that define internal pressure computes.
// See comment in the setup method
if ((strncmp(check_style,"nph",3) == 0) ||
(strncmp(check_style,"npt",3) == 0) ||
(strncmp(check_style,"rigid/nph",9) == 0) ||
(strncmp(check_style,"rigid/npt",9) == 0) ||
(strncmp(check_style,"msst",4) == 0) ||
(strncmp(check_style,"nphug",5) == 0) ||
(strncmp(check_style,"ipi",3) == 0) ||
(strncmp(check_style,"press/berendsen",15) == 0) ||
(strncmp(check_style,"qbmsst",6) == 0))
error->all(FLERR,"Fix plumed must be defined before any other fixes, "
"that compute pressure internally");
}
}
FixPlumed::~FixPlumed()
{
delete p;
modify->delete_compute(id_pe);
modify->delete_compute(id_press);
delete[] masses;
delete[] charges;
delete[] gatindex;
}
int FixPlumed::setmask()
{
// set with a bitmask how and when apply the force from plumed
int mask = 0;
mask |= POST_FORCE;
mask |= THERMO_ENERGY;
mask |= POST_FORCE_RESPA;
mask |= MIN_POST_FORCE;
return mask;
}
void FixPlumed::init()
{
if (strcmp(update->integrate_style,"respa") == 0)
nlevels_respa = ((Respa *) update->integrate)->nlevels;
// This avoids nan pressure if compute_pressure is called
// in a setup method
for (int i=0;i<6;i++) virial[i] = 0.;
}
void FixPlumed::setup(int vflag)
{
// Here there is a crucial issue connected to constant pressure
// simulations. The fix_nh will call the compute_pressure inside
// the setup method, that is executed once and for all at the
// beginning of the simulation. Since our fix has a contribution
// to the virial, when this happens the variable virial must have
// been calculated. In other words, the setup method of fix_plumed
// has to be executed first. This creates a race condition with the
// setup method of fix_nh. This is why in the constructor I check if
// nh fixes have already been called.
if (strcmp(update->integrate_style,"verlet") == 0)
post_force(vflag);
else {
((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1);
post_force_respa(vflag,nlevels_respa-1,0);
((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1);
}
}
void FixPlumed::min_setup(int vflag)
{
// This has to be checked.
// For instance it might have problems with fix_box_relax
post_force(vflag);
}
void FixPlumed::post_force(int /* vflag */)
{
int update_gatindex=0;
if (natoms != int(atom->natoms))
error->all(FLERR,"Fix plumed does not support simulations with varying "
"numbers of atoms");
// Try to find out if the domain decomposition has been updated:
if (nlocal != atom->nlocal) {
if (charges) delete [] charges;
if (masses) delete [] masses;
if (gatindex) delete [] gatindex;
nlocal=atom->nlocal;
gatindex=new int [nlocal];
masses=new double [nlocal];
charges=new double [nlocal];
update_gatindex=1;
} else {
for (int i=0;i<nlocal;i++) {
if (gatindex[i]!=atom->tag[i]-1) {
update_gatindex=1;
break;
}
}
}
MPI_Allreduce(MPI_IN_PLACE,&update_gatindex,1,MPI_INT,MPI_SUM,world);
// In case it has been updated, rebuild the local mass/charges array
// and tell plumed about the change:
if (update_gatindex) {
for (int i=0;i<nlocal;i++) gatindex[i]=atom->tag[i]-1;
// Get masses
if (atom->rmass_flag) {
for (int i=0;i<nlocal;i++) masses[i]=atom->rmass[i];
} else {
for (int i=0;i<nlocal;i++) masses[i]=atom->mass[atom->type[i]];
}
// Get charges
if (atom->q_flag) {
for (int i=0;i<nlocal;i++) charges[i]=atom->q[i];
} else {
for (int i=0;i<nlocal;i++) charges[i]=0.0;
}
p->cmd("setAtomsNlocal",&nlocal);
p->cmd("setAtomsGatindex",gatindex);
}
// set up local virial/box. plumed uses full 3x3 matrices
double plmd_virial[3][3];
for (int i=0;i<3;i++) for (int j=0;j<3;j++) plmd_virial[i][j]=0.0;
double box[3][3];
for (int i=0;i<3;i++) for (int j=0;j<3;j++) box[i][j]=0.0;
box[0][0]=domain->h[0];
box[1][1]=domain->h[1];
box[2][2]=domain->h[2];
box[2][1]=domain->h[3];
box[2][0]=domain->h[4];
box[1][0]=domain->h[5];
// Make initial of virial of this fix zero
// The following line is very important, otherwise
// the compute pressure will include
for (int i=0;i<6;++i) virial[i] = 0.;
// local variable with timestep:
if (update->ntimestep > MAXSMALLINT)
error->all(FLERR,"Fix plumed can only handle up to 2.1 billion timesteps");
int step=int(update->ntimestep);
// pass all pointers to plumed:
p->cmd("setStep",&step);
p->cmd("setPositions",&atom->x[0][0]);
p->cmd("setBox",&box[0][0]);
p->cmd("setForces",&atom->f[0][0]);
p->cmd("setMasses",&masses[0]);
p->cmd("setCharges",&charges[0]);
p->cmd("getBias",&bias);
// Pass virial to plumed
// If energy is needed virial_plmd is equal to Lammps' virial
// If energy is not needed virial_plmd is initialized to zero
// In the first case the virial will be rescaled and an extra term will be added
// In the latter case only an extra term will be added
p->cmd("setVirial",&plmd_virial[0][0]);
p->cmd("prepareCalc");
plumedNeedsEnergy=0;
p->cmd("isEnergyNeeded",&plumedNeedsEnergy);
// Pass potential energy and virial if needed
double *virial_lmp;
if (plumedNeedsEnergy) {
// Error if tail corrections are included
if (force->pair && force->pair->tail_flag && comm->me == 0)
error->warning(FLERR,"Tail corrections to the pair potential included."
" The energy cannot be biased correctly in this case."
" Remove the tail corrections by removing the"
" command: pair_modify tail yes");
// compute the potential energy
double pot_energy = 0.;
c_pe->compute_scalar();
pot_energy = c_pe->scalar;
// Divide energy by number of processes
// Plumed wants it this way
int nprocs;
MPI_Comm_size(world,&nprocs);
pot_energy /= nprocs;
p->cmd("setEnergy",&pot_energy);
// Compute pressure due to the virial (no kinetic energy term!)
c_press->compute_vector();
virial_lmp = c_press->vector;
// Check if pressure is finite
if (!std::isfinite(virial_lmp[0]) || !std::isfinite(virial_lmp[1])
|| !std::isfinite(virial_lmp[2]) || !std::isfinite(virial_lmp[3])
|| !std::isfinite(virial_lmp[4]) || !std::isfinite(virial_lmp[5]))
error->all(FLERR,"Non-numeric virial - Plumed cannot work with that");
// Convert pressure to virial per number of MPI processes
// From now on all virials are divided by the number of MPI processes
double nktv2p = force->nktv2p;
double inv_volume;
if (domain->dimension == 3) {
inv_volume = 1.0 / (domain->xprd * domain->yprd * domain->zprd);
} else {
inv_volume = 1.0 / (domain->xprd * domain->yprd);
}
for (int i=0;i<6;i++) virial_lmp[i] /= (inv_volume * nktv2p * nprocs);
// Convert virial from lammps to plumed representation
plmd_virial[0][0]=-virial_lmp[0];
plmd_virial[1][1]=-virial_lmp[1];
plmd_virial[2][2]=-virial_lmp[2];
plmd_virial[0][1]=-virial_lmp[3];
plmd_virial[0][2]=-virial_lmp[4];
plmd_virial[1][2]=-virial_lmp[5];
} else {
virial_lmp = new double[6];
for (int i=0;i<6;i++) virial_lmp[i] = 0.;
}
// do the real calculation:
p->cmd("performCalc");
// retransform virial to lammps representation and assign it to this
// fix's virial. Plumed is giving back the full virial and therefore
// we have to subtract the initial virial i.e. virial_lmp.
// The vector virial contains only the contribution added by plumed.
// The calculation of the pressure will be done by a compute pressure
// and will include this contribution.
virial[0] = -plmd_virial[0][0]-virial_lmp[0];
virial[1] = -plmd_virial[1][1]-virial_lmp[1];
virial[2] = -plmd_virial[2][2]-virial_lmp[2];
virial[3] = -plmd_virial[0][1]-virial_lmp[3];
virial[4] = -plmd_virial[0][2]-virial_lmp[4];
virial[5] = -plmd_virial[1][2]-virial_lmp[5];
// Ask for the computes in the next time step
// such that the virial and energy are tallied.
// This should be changed to something that triggers the
// calculation only if plumed needs it.
c_pe->addstep(update->ntimestep+1);
c_press->addstep(update->ntimestep+1);
}
void FixPlumed::post_force_respa(int vflag, int ilevel, int /* iloop */)
{
if (ilevel == nlevels_respa-1) post_force(vflag);
}
void FixPlumed::min_post_force(int vflag)
{
post_force(vflag);
}
void FixPlumed::reset_dt()
{
error->all(FLERR,"Cannot change the time step when fix plumed is active");
}
double FixPlumed::compute_scalar()
{
return bias;
}
int FixPlumed::modify_param(int narg, char **arg)
{
if (strcmp(arg[0],"pe") == 0) {
if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
modify->delete_compute(id_pe); delete [] id_pe;
int n = strlen(arg[1]) + 1;
id_pe = new char[n];
strcpy(id_pe,arg[1]);
int icompute = modify->find_compute(arg[1]);
if (icompute < 0) error->all(FLERR,"Could not find fix_modify potential energy ID");
c_pe = modify->compute[icompute];
if (c_pe->peflag == 0)
error->all(FLERR,"Fix_modify plmd_pe ID does not compute potential energy");
if (c_pe->igroup != 0 && comm->me == 0)
error->warning(FLERR,"Potential for fix PLUMED is not for group all");
return 2;
} else if (strcmp(arg[0],"press") == 0) {
if (narg < 2) error->all(FLERR,"Illegal fix_modify command");
modify->delete_compute(id_press); delete [] id_press;
int n = strlen(arg[1]) + 1;
id_press = new char[n];
strcpy(id_press,arg[1]);
int icompute = modify->find_compute(arg[1]);
if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID");
c_press = modify->compute[icompute];
if (c_press->pressflag == 0)
error->all(FLERR,"Fix_modify pressure ID does not compute pressure");
if (c_press->igroup != 0 && comm->me == 0)
error->warning(FLERR,"Virial for fix PLUMED is not for group all");
return 2;
}
return 0;
}
double FixPlumed::memory_usage()
{
return double((8+8+4)*atom->nlocal);
}

View File

@ -0,0 +1,68 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(plumed,FixPlumed)
#else
#ifndef LMP_FIX_PLUMED_H
#define LMP_FIX_PLUMED_H
#include "fix.h"
// forward declaration
namespace PLMD {
class Plumed;
}
namespace LAMMPS_NS {
class FixPlumed : public Fix {
public:
FixPlumed(class LAMMPS *, int, char **);
~FixPlumed();
int setmask();
void init();
void setup(int);
void min_setup(int);
void post_force(int);
void post_force_respa(int, int, int);
void min_post_force(int);
double compute_scalar();
void reset_dt();
int modify_param(int narg, char **arg);
double memory_usage();
private:
PLMD::Plumed *p; // pointer to plumed object
int nlocal; // number of atoms local to this process
int natoms; // total number of atoms
int *gatindex; // array of atom indexes local to this process
double *masses; // array of masses for local atoms
double *charges; // array of charges for local atoms
int nlevels_respa; // this is something to enable respa
double bias; // output bias potential
class Compute *c_pe; // Compute for the energy
class Compute *c_press; // Compute for the pressure
int plumedNeedsEnergy; // Flag to trigger calculation of the
// energy and virial
char *id_pe, *id_press; // ID for potential energy and pressure compute
};
};
#endif
#endif

37
src/USER-SDPD/Install.sh Normal file
View File

@ -0,0 +1,37 @@
# Install/Uninstall package files in LAMMPS
# mode = 0/1/2 for uninstall/install/update
mode=$1
# enforce using portable C locale
LC_ALL=C
export LC_ALL
# arg1 = file, arg2 = file it depends on
action () {
if (test $mode = 0) then
rm -f ../$1
elif (! cmp -s $1 ../$1) then
if (test -z "$2" || test -e ../$2) then
cp $1 ..
if (test $mode = 2) then
echo " updating src/$1"
fi
fi
elif (test -n "$2") then
if (test ! -e ../$2) then
rm -f ../$1
fi
fi
}
# package files without dependencies
action pair_sdpd_taitwater_isothermal.h
action pair_sdpd_taitwater_isothermal.cpp
action fix_meso_move.h
action fix_meso_move.cpp
# package files with dependencies
action fix_rigid_meso.h fix_rigid.h
action fix_rigid_meso.cpp fix_rigid.h

13
src/USER-SDPD/README Normal file
View File

@ -0,0 +1,13 @@
This package implements the Smoothed Dissipative Particle Dynamics (SDPD)
method for modelling fluids at mesoscale and diffusion of colloids.
Currently it adds pair style sdpd/taitwater/isothermal for modelling water
at isothermal conditions using the Tait equation of state.
It also adds fix meso/move command to move mesoscopic SPH/SDPD particles with
prescribed velocity and fix rigid/meso command to integrate rigid bodies
composed of mesoscopic SPH/SDPD particles.
Creator of this package is:
Morteza Jalalvand
Institute for Advanced Studies in Basic Sciences
jalalvand.m AT gmail DOT com

View File

@ -0,0 +1,997 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author:
Morteza Jalalvand (IASBS) jalalvand.m AT gmail.com
------------------------------------------------------------------------- */
#include <cstring>
#include <cmath>
#include "fix_meso_move.h"
#include "atom.h"
#include "group.h"
#include "update.h"
#include "modify.h"
#include "force.h"
#include "domain.h"
#include "lattice.h"
#include "comm.h"
#include "input.h"
#include "variable.h"
#include "math_const.h"
#include "memory.h"
#include "error.h"
using namespace LAMMPS_NS;
using namespace FixConst;
using namespace MathConst;
enum{LINEAR,WIGGLE,ROTATE,VARIABLE};
enum{EQUAL,ATOM};
/* ---------------------------------------------------------------------- */
FixMesoMove::FixMesoMove (LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg),
xvarstr(NULL), yvarstr(NULL), zvarstr(NULL),
vxvarstr(NULL), vyvarstr(NULL), vzvarstr(NULL),
xoriginal(NULL), displace(NULL), velocity(NULL) {
if ((atom->e_flag != 1) || (atom->rho_flag != 1))
error->all(FLERR,
"fix meso/move command requires atom_style with both energy and density");
if (narg < 4) error->all(FLERR,"Illegal fix meso/move command");
restart_global = 1;
restart_peratom = 1;
peratom_flag = 1;
size_peratom_cols = 3;
peratom_freq = 1;
time_integrate = 1;
create_attribute = 1;
displaceflag = 0;
velocityflag = 0;
maxatom = 0;
// parse args
int iarg;
if (strcmp(arg[3],"linear") == 0) {
if (narg < 7) error->all(FLERR,"Illegal fix meso/move command");
iarg = 7;
mstyle = LINEAR;
if (strcmp(arg[4],"NULL") == 0) vxflag = 0;
else {
vxflag = 1;
vx = force->numeric(FLERR,arg[4]);
}
if (strcmp(arg[5],"NULL") == 0) vyflag = 0;
else {
vyflag = 1;
vy = force->numeric(FLERR,arg[5]);
}
if (strcmp(arg[6],"NULL") == 0) vzflag = 0;
else {
vzflag = 1;
vz = force->numeric(FLERR,arg[6]);
}
} else if (strcmp(arg[3],"wiggle") == 0) {
if (narg < 8) error->all(FLERR,"Illegal fix meso/move command");
iarg = 8;
mstyle = WIGGLE;
if (strcmp(arg[4],"NULL") == 0) axflag = 0;
else {
axflag = 1;
ax = force->numeric(FLERR,arg[4]);
}
if (strcmp(arg[5],"NULL") == 0) ayflag = 0;
else {
ayflag = 1;
ay = force->numeric(FLERR,arg[5]);
}
if (strcmp(arg[6],"NULL") == 0) azflag = 0;
else {
azflag = 1;
az = force->numeric(FLERR,arg[6]);
}
period = force->numeric(FLERR,arg[7]);
if (period <= 0.0) error->all(FLERR,"Illegal fix meso/move command");
} else if (strcmp(arg[3],"rotate") == 0) {
if (narg < 11) error->all(FLERR,"Illegal fix meso/move command");
iarg = 11;
mstyle = ROTATE;
point[0] = force->numeric(FLERR,arg[4]);
point[1] = force->numeric(FLERR,arg[5]);
point[2] = force->numeric(FLERR,arg[6]);
axis[0] = force->numeric(FLERR,arg[7]);
axis[1] = force->numeric(FLERR,arg[8]);
axis[2] = force->numeric(FLERR,arg[9]);
period = force->numeric(FLERR,arg[10]);
if (period <= 0.0) error->all(FLERR,"Illegal fix meso/move command");
} else if (strcmp(arg[3],"variable") == 0) {
if (narg < 10) error->all(FLERR,"Illegal fix meso/move command");
iarg = 10;
mstyle = VARIABLE;
if (strcmp(arg[4],"NULL") == 0) xvarstr = NULL;
else if (strstr(arg[4],"v_") == arg[4]) {
int n = strlen(&arg[4][2]) + 1;
xvarstr = new char[n];
strcpy(xvarstr,&arg[4][2]);
} else error->all(FLERR,"Illegal fix meso/move command");
if (strcmp(arg[5],"NULL") == 0) yvarstr = NULL;
else if (strstr(arg[5],"v_") == arg[5]) {
int n = strlen(&arg[5][2]) + 1;
yvarstr = new char[n];
strcpy(yvarstr,&arg[5][2]);
} else error->all(FLERR,"Illegal fix meso/move command");
if (strcmp(arg[6],"NULL") == 0) zvarstr = NULL;
else if (strstr(arg[6],"v_") == arg[6]) {
int n = strlen(&arg[6][2]) + 1;
zvarstr = new char[n];
strcpy(zvarstr,&arg[6][2]);
} else error->all(FLERR,"Illegal fix meso/move command");
if (strcmp(arg[7],"NULL") == 0) vxvarstr = NULL;
else if (strstr(arg[7],"v_") == arg[7]) {
int n = strlen(&arg[7][2]) + 1;
vxvarstr = new char[n];
strcpy(vxvarstr,&arg[7][2]);
} else error->all(FLERR,"Illegal fix meso/move command");
if (strcmp(arg[8],"NULL") == 0) vyvarstr = NULL;
else if (strstr(arg[8],"v_") == arg[8]) {
int n = strlen(&arg[8][2]) + 1;
vyvarstr = new char[n];
strcpy(vyvarstr,&arg[8][2]);
} else error->all(FLERR,"Illegal fix meso/move command");
if (strcmp(arg[9],"NULL") == 0) vzvarstr = NULL;
else if (strstr(arg[9],"v_") == arg[9]) {
int n = strlen(&arg[9][2]) + 1;
vzvarstr = new char[n];
strcpy(vzvarstr,&arg[9][2]);
} else error->all(FLERR,"Illegal fix meso/move command");
} else error->all(FLERR,"Illegal fix meso/move command");
// optional args
int scaleflag = 1;
while (iarg < narg) {
if (strcmp(arg[iarg],"units") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix meso/move command");
if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1;
else error->all(FLERR,"Illegal fix meso/move command");
iarg += 2;
} else error->all(FLERR,"Illegal fix meso/move command");
}
// error checks and warnings
if (domain->dimension == 2) {
if (mstyle == LINEAR && vzflag && vz != 0.0)
error->all(FLERR,"Fix meso/move cannot set linear z motion for 2d problem");
if (mstyle == WIGGLE && azflag && az != 0.0)
error->all(FLERR,"Fix meso/move cannot set wiggle z motion for 2d problem");
if (mstyle == ROTATE && (axis[0] != 0.0 || axis[1] != 0.0))
error->all(FLERR, "Fix meso/move cannot rotate aroung non z-axis for 2d problem");
if (mstyle == VARIABLE && (zvarstr || vzvarstr))
error->all(FLERR, "Fix meso/move cannot define z or vz variable for 2d problem");
}
// setup scaling and apply scaling factors to velocity & amplitude
if ((mstyle == LINEAR || mstyle == WIGGLE || mstyle == ROTATE) &&
scaleflag) {
double xscale = domain->lattice->xlattice;
double yscale = domain->lattice->ylattice;
double zscale = domain->lattice->zlattice;
if (mstyle == LINEAR) {
if (vxflag) vx *= xscale;
if (vyflag) vy *= yscale;
if (vzflag) vz *= zscale;
} else if (mstyle == WIGGLE) {
if (axflag) ax *= xscale;
if (ayflag) ay *= yscale;
if (azflag) az *= zscale;
} else if (mstyle == ROTATE) {
point[0] *= xscale;
point[1] *= yscale;
point[2] *= zscale;
}
}
// set omega_rotate from period
if (mstyle == WIGGLE || mstyle == ROTATE) omega_rotate = MY_2PI / period;
// runit = unit vector along rotation axis
if (mstyle == ROTATE) {
double len = sqrt(axis[0]*axis[0] + axis[1]*axis[1] + axis[2]*axis[2]);
if (len == 0.0)
error->all(FLERR,"Zero length rotation vector with fix meso/move");
runit[0] = axis[0]/len;
runit[1] = axis[1]/len;
runit[2] = axis[2]/len;
}
// perform initial allocation of atom-based array
// register with Atom class
grow_arrays(atom->nmax);
atom->add_callback(0);
atom->add_callback(1);
displace = velocity = NULL;
// xoriginal = initial unwrapped positions of atoms
double **x = atom->x;
imageint *image = atom->image;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) domain->unmap(x[i],image[i],xoriginal[i]);
else xoriginal[i][0] = xoriginal[i][1] = xoriginal[i][2] = 0.0;
}
time_origin = update->ntimestep;
}
/* ---------------------------------------------------------------------- */
FixMesoMove::~FixMesoMove () {
// unregister callbacks to this fix from Atom class
atom->delete_callback(id,0);
atom->delete_callback(id,1);
// delete locally stored arrays
memory->destroy(xoriginal);
memory->destroy(displace);
memory->destroy(velocity);
delete [] xvarstr;
delete [] yvarstr;
delete [] zvarstr;
delete [] vxvarstr;
delete [] vyvarstr;
delete [] vzvarstr;
}
/* ---------------------------------------------------------------------- */
int FixMesoMove::setmask () {
int mask = 0;
mask |= INITIAL_INTEGRATE;
mask |= FINAL_INTEGRATE;
mask |= PRE_FORCE;
return mask;
}
/* ---------------------------------------------------------------------- */
void FixMesoMove::init () {
dt = update->dt;
dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v;
// set indices and style of all variables
displaceflag = velocityflag = 0;
if (mstyle == VARIABLE) {
if (xvarstr) {
xvar = input->variable->find(xvarstr);
if (xvar < 0) error->all(FLERR, "Variable name for fix meso/move does not exist");
if (input->variable->equalstyle(xvar)) xvarstyle = EQUAL;
else if (input->variable->atomstyle(xvar)) xvarstyle = ATOM;
else error->all(FLERR,"Variable for fix meso/move is invalid style");
}
if (yvarstr) {
yvar = input->variable->find(yvarstr);
if (yvar < 0) error->all(FLERR, "Variable name for fix meso/move does not exist");
if (input->variable->equalstyle(yvar)) yvarstyle = EQUAL;
else if (input->variable->atomstyle(yvar)) yvarstyle = ATOM;
else error->all(FLERR,"Variable for fix meso/move is invalid style");
}
if (zvarstr) {
zvar = input->variable->find(zvarstr);
if (zvar < 0) error->all(FLERR, "Variable name for fix meso/move does not exist");
if (input->variable->equalstyle(zvar)) zvarstyle = EQUAL;
else if (input->variable->atomstyle(zvar)) zvarstyle = ATOM;
else error->all(FLERR,"Variable for fix meso/move is invalid style");
}
if (vxvarstr) {
vxvar = input->variable->find(vxvarstr);
if (vxvar < 0) error->all(FLERR, "Variable name for fix meso/move does not exist");
if (input->variable->equalstyle(vxvar)) vxvarstyle = EQUAL;
else if (input->variable->atomstyle(vxvar)) vxvarstyle = ATOM;
else error->all(FLERR,"Variable for fix meso/move is invalid style");
}
if (vyvarstr) {
vyvar = input->variable->find(vyvarstr);
if (vyvar < 0) error->all(FLERR, "Variable name for fix meso/move does not exist");
if (input->variable->equalstyle(vyvar)) vyvarstyle = EQUAL;
else if (input->variable->atomstyle(vyvar)) vyvarstyle = ATOM;
else error->all(FLERR,"Variable for fix meso/move is invalid style");
}
if (vzvarstr) {
vzvar = input->variable->find(vzvarstr);
if (vzvar < 0) error->all(FLERR, "Variable name for fix meso/move does not exist");
if (input->variable->equalstyle(vzvar)) vzvarstyle = EQUAL;
else if (input->variable->atomstyle(vzvar)) vzvarstyle = ATOM;
else error->all(FLERR,"Variable for fix meso/move is invalid style");
}
if (xvarstr && xvarstyle == ATOM) displaceflag = 1;
if (yvarstr && yvarstyle == ATOM) displaceflag = 1;
if (zvarstr && zvarstyle == ATOM) displaceflag = 1;
if (vxvarstr && vxvarstyle == ATOM) velocityflag = 1;
if (vyvarstr && vyvarstyle == ATOM) velocityflag = 1;
if (vzvarstr && vzvarstyle == ATOM) velocityflag = 1;
}
maxatom = atom->nmax;
memory->destroy(displace);
memory->destroy(velocity);
if (displaceflag) memory->create(displace,maxatom,3,"move:displace");
else displace = NULL;
if (velocityflag) memory->create(velocity,maxatom,3,"move:velocity");
else velocity = NULL;
}
void FixMesoMove::setup_pre_force (int /*vflag*/) {
// set vest equal to v
double **v = atom->v;
double **vest = atom->vest;
int *mask = atom->mask;
int nlocal = atom->nlocal;
if (igroup == atom->firstgroup)
nlocal = atom->nfirst;
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
vest[i][0] = v[i][0];
vest[i][1] = v[i][1];
vest[i][2] = v[i][2];
}
}
}
/* ----------------------------------------------------------------------
set x,v of particles
------------------------------------------------------------------------- */
void FixMesoMove::initial_integrate (int /*vflag*/) {
double ddotr,dx,dy,dz;
double dtfm;
double xold[3],a[3],b[3],c[3],d[3],disp[3],disp_next[3];
double delta = (update->ntimestep - time_origin) * dt;
double delta_next = (update->ntimestep - time_origin + 1) * dt;
double **x = atom->x;
double **v = atom->v;
double **vest = atom->vest;
double *rho = atom->rho;
double *drho = atom->drho;
double *e = atom->e;
double *de = atom->de;
double **f = atom->f;
double *rmass = atom->rmass;
double *mass = atom->mass;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
int rmass_flag = atom->rmass_flag;
if (igroup == atom->firstgroup)
nlocal = atom->nfirst;
// for linear: X = X0 + V*dt
if (mstyle == LINEAR) {
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
xold[0] = x[i][0];
xold[1] = x[i][1];
xold[2] = x[i][2];
e[i] += dtf * de[i]; // half-step update of particle internal energy
rho[i] += dtf * drho[i]; // ... and density
if (vxflag) {
vest[i][0] = v[i][0] = vx;
x[i][0] = xoriginal[i][0] + vx*delta;
} else {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
vest[i][0] = v[i][0] + 2.0 * dtfm * f[i][0];
v[i][0] += dtfm * f[i][0];
x[i][0] += dtv * v[i][0];
}
if (vyflag) {
vest[i][1] = v[i][1] = vy;
x[i][1] = xoriginal[i][1] + vy*delta;
} else {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
vest[i][1] = v[i][1] + 2.0 * dtfm * f[i][1];
v[i][1] += dtfm * f[i][1];
x[i][1] += dtv * v[i][1];
}
if (vzflag) {
vest[i][2] = v[i][2] = vz;
x[i][2] = xoriginal[i][2] + vz*delta;
} else {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
vest[i][2] = v[i][2] + 2.0 * dtfm * f[i][2];
v[i][2] += dtfm * f[i][2];
x[i][2] += dtv * v[i][2];
}
domain->remap_near(x[i],xold);
}
}
// for wiggle: X = X0 + A sin(w*dt)
} else if (mstyle == WIGGLE) {
double arg = omega_rotate * delta;
double arg_next = omega_rotate * delta_next;
double sine = sin(arg);
double cosine = cos(arg);
double cosine_next = cos(arg_next);
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
xold[0] = x[i][0];
xold[1] = x[i][1];
xold[2] = x[i][2];
e[i] += dtf * de[i]; // half-step update of particle internal energy
rho[i] += dtf * drho[i]; // ... and density
if (axflag) {
v[i][0] = ax*omega_rotate*cosine;
vest[i][0] = ax*omega_rotate*cosine_next;
x[i][0] = xoriginal[i][0] + ax*sine;
} else {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
vest[i][0] = v[i][0] + 2.0 * dtfm * f[i][0];
v[i][0] += dtfm * f[i][0];
x[i][0] += dtv * v[i][0];
}
if (ayflag) {
v[i][1] = ay*omega_rotate*cosine;
vest[i][1] = ay*omega_rotate*cosine_next;
x[i][1] = xoriginal[i][1] + ay*sine;
} else {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
vest[i][1] = v[i][1] + 2.0 * dtfm * f[i][1];
v[i][1] += dtfm * f[i][1];
x[i][1] += dtv * v[i][1];
}
if (azflag) {
v[i][2] = az*omega_rotate*cosine;
vest[i][2] = az*omega_rotate*cosine_next;
x[i][2] = xoriginal[i][2] + az*sine;
} else {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
vest[i][2] = v[i][2] + 2.0 * dtfm * f[i][2];
v[i][2] += dtfm * f[i][2];
x[i][2] += dtv * v[i][2];
}
domain->remap_near(x[i],xold);
}
}
// for rotate by right-hand rule around omega:
// P = point = vector = point of rotation
// R = vector = axis of rotation
// w = omega of rotation (from period)
// X0 = xoriginal = initial coord of atom
// R0 = runit = unit vector for R
// D = X0 - P = vector from P to X0
// C = (D dot R0) R0 = projection of atom coord onto R line
// A = D - C = vector from R line to X0
// B = R0 cross A = vector perp to A in plane of rotation
// A,B define plane of circular rotation around R line
// X = P + C + A cos(w*dt) + B sin(w*dt)
// V = w R0 cross (A cos(w*dt) + B sin(w*dt))
} else if (mstyle == ROTATE) {
double arg = omega_rotate * delta;
double arg_next = omega_rotate * delta_next;
double sine = sin(arg);
double cosine = cos(arg);
double sine_next = sin(arg_next);
double cosine_next = cos(arg_next);
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
xold[0] = x[i][0];
xold[1] = x[i][1];
xold[2] = x[i][2];
e[i] += dtf * de[i]; // half-step update of particle internal energy
rho[i] += dtf * drho[i]; // ... and density
d[0] = xoriginal[i][0] - point[0];
d[1] = xoriginal[i][1] - point[1];
d[2] = xoriginal[i][2] - point[2];
ddotr = d[0]*runit[0] + d[1]*runit[1] + d[2]*runit[2];
c[0] = ddotr*runit[0];
c[1] = ddotr*runit[1];
c[2] = ddotr*runit[2];
a[0] = d[0] - c[0];
a[1] = d[1] - c[1];
a[2] = d[2] - c[2];
b[0] = runit[1]*a[2] - runit[2]*a[1];
b[1] = runit[2]*a[0] - runit[0]*a[2];
b[2] = runit[0]*a[1] - runit[1]*a[0];
disp[0] = a[0]*cosine + b[0]*sine;
disp[1] = a[1]*cosine + b[1]*sine;
disp[2] = a[2]*cosine + b[2]*sine;
disp_next[0] = a[0]*cosine_next + b[0]*sine_next;
disp_next[1] = a[1]*cosine_next + b[1]*sine_next;
disp_next[2] = a[2]*cosine_next + b[2]*sine_next;
x[i][0] = point[0] + c[0] + disp[0];
x[i][1] = point[1] + c[1] + disp[1];
x[i][2] = point[2] + c[2] + disp[2];
v[i][0] = omega_rotate * (runit[1]*disp[2] - runit[2]*disp[1]);
v[i][1] = omega_rotate * (runit[2]*disp[0] - runit[0]*disp[2]);
v[i][2] = omega_rotate * (runit[0]*disp[1] - runit[1]*disp[0]);
vest[i][0] = omega_rotate * (runit[1]*disp_next[2] - runit[2]*disp_next[1]);
vest[i][1] = omega_rotate * (runit[2]*disp_next[0] - runit[0]*disp_next[2]);
vest[i][2] = omega_rotate * (runit[0]*disp_next[1] - runit[1]*disp_next[0]);
domain->remap_near(x[i],xold);
}
}
// for variable: compute x,v from variables
} else if (mstyle == VARIABLE) {
// reallocate displace and velocity arrays as necessary
if ((displaceflag || velocityflag) && atom->nmax > maxatom) {
maxatom = atom->nmax;
if (displaceflag) {
memory->destroy(displace);
memory->create(displace,maxatom,3,"move:displace");
}
if (velocityflag) {
memory->destroy(velocity);
memory->create(velocity,maxatom,3,"move:velocity");
}
}
// pre-compute variable values, wrap with clear/add
modify->clearstep_compute();
if (xvarstr) {
if (xvarstyle == EQUAL) dx = input->variable->compute_equal(xvar);
else input->variable->compute_atom(xvar,igroup,&displace[0][0],3,0);
}
if (yvarstr) {
if (yvarstyle == EQUAL) dy = input->variable->compute_equal(yvar);
else input->variable->compute_atom(yvar,igroup,&displace[0][1],3,0);
}
if (zvarstr) {
if (zvarstyle == EQUAL) dz = input->variable->compute_equal(zvar);
else input->variable->compute_atom(zvar,igroup,&displace[0][2],3,0);
}
if (vxvarstr) {
if (vxvarstyle == EQUAL) vx = input->variable->compute_equal(vxvar);
else input->variable->compute_atom(vxvar,igroup,&velocity[0][0],3,0);
}
if (vyvarstr) {
if (vyvarstyle == EQUAL) vy = input->variable->compute_equal(vyvar);
else input->variable->compute_atom(vyvar,igroup,&velocity[0][1],3,0);
}
if (vzvarstr) {
if (vzvarstyle == EQUAL) vz = input->variable->compute_equal(vzvar);
else input->variable->compute_atom(vzvar,igroup,&velocity[0][2],3,0);
}
modify->addstep_compute(update->ntimestep + 1);
// update x,v
// vest (velocity in next step) could be different from v in the next
// step, but this is the best we could do
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
xold[0] = x[i][0];
xold[1] = x[i][1];
xold[2] = x[i][2];
if (xvarstr && vxvarstr) {
if (vxvarstyle == EQUAL) {
vest[i][0] = 2*vx - v[i][0];
v[i][0] = vx;
}
else {
vest[i][0] = 2*velocity[i][0] - v[i][0];
v[i][0] = velocity[i][0];
}
if (xvarstyle == EQUAL) x[i][0] = xoriginal[i][0] + dx;
else x[i][0] = xoriginal[i][0] + displace[i][0];
} else if (xvarstr) {
if (xvarstyle == EQUAL) x[i][0] = xoriginal[i][0] + dx;
else x[i][0] = xoriginal[i][0] + displace[i][0];
} else if (vxvarstr) {
if (vxvarstyle == EQUAL) {
vest[i][0] = 2*vx - v[i][0];
v[i][0] = vx;
}
else {
vest[i][0] = 2*velocity[i][0] - v[i][0];
v[i][0] = velocity[i][0];
}
x[i][0] += dtv * v[i][0];
} else {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
vest[i][0] = v[i][0] + 2.0 * dtfm * f[i][0];
v[i][0] += dtfm * f[i][0];
x[i][0] += dtv * v[i][0];
}
if (yvarstr && vyvarstr) {
if (vyvarstyle == EQUAL) {
vest[i][1] = 2*vy - v[i][1];
v[i][1] = vy;
}
else {
vest[i][1] = 2*velocity[i][1] - v[i][1];
v[i][1] = velocity[i][1];
}
if (yvarstyle == EQUAL) x[i][1] = xoriginal[i][1] + dy;
else x[i][1] = xoriginal[i][1] + displace[i][1];
} else if (yvarstr) {
if (yvarstyle == EQUAL) x[i][1] = xoriginal[i][1] + dy;
else x[i][1] = xoriginal[i][1] + displace[i][1];
} else if (vyvarstr) {
if (vyvarstyle == EQUAL) {
vest[i][1] = 2*vy - v[i][1];
v[i][1] = vy;
}
else {
vest[i][1] = 2*velocity[i][1] - v[i][1];
v[i][1] = velocity[i][1];
}
x[i][1] += dtv * v[i][1];
} else {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
vest[i][1] = v[i][1] + 2.0 * dtfm * f[i][1];
v[i][1] += dtfm * f[i][1];
x[i][1] += dtv * v[i][1];
}
if (zvarstr && vzvarstr) {
if (vzvarstyle == EQUAL) {
vest[i][2] = 2*vz - v[i][2];
v[i][2] = vz;
}
else {
vest[i][2] = 2*velocity[i][2] - v[i][2];
v[i][2] = velocity[i][2];
}
if (zvarstyle == EQUAL) x[i][2] = xoriginal[i][2] + dz;
else x[i][2] = xoriginal[i][2] + displace[i][2];
} else if (zvarstr) {
if (zvarstyle == EQUAL) x[i][2] = xoriginal[i][2] + dz;
else x[i][2] = xoriginal[i][2] + displace[i][2];
} else if (vzvarstr) {
if (vzvarstyle == EQUAL) {
vest[i][2] = 2*vz - v[i][2];
v[i][2] = vz;
}
else {
vest[i][2] = 2*velocity[i][2] - v[i][2];
v[i][2] = velocity[i][2];
}
x[i][2] += dtv * v[i][2];
} else {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
vest[i][2] = v[i][2] + 2.0 * dtfm * f[i][2];
v[i][2] += dtfm * f[i][2];
x[i][2] += dtv * v[i][2];
}
domain->remap_near(x[i],xold);
}
}
}
}
/* ----------------------------------------------------------------------
final NVE of particles with NULL components
------------------------------------------------------------------------- */
void FixMesoMove::final_integrate () {
double dtfm;
int xflag = 1;
if (mstyle == LINEAR && vxflag) xflag = 0;
else if (mstyle == WIGGLE && axflag) xflag = 0;
else if (mstyle == ROTATE) xflag = 0;
else if (mstyle == VARIABLE && (xvarstr || vxvarstr)) xflag = 0;
int yflag = 1;
if (mstyle == LINEAR && vyflag) yflag = 0;
else if (mstyle == WIGGLE && ayflag) yflag = 0;
else if (mstyle == ROTATE) yflag = 0;
else if (mstyle == VARIABLE && (yvarstr || vyvarstr)) yflag = 0;
int zflag = 1;
if (mstyle == LINEAR && vzflag) zflag = 0;
else if (mstyle == WIGGLE && azflag) zflag = 0;
else if (mstyle == ROTATE) zflag = 0;
else if (mstyle == VARIABLE && (zvarstr || vzvarstr)) zflag = 0;
double **v = atom->v;
double **f = atom->f;
double *e = atom->e;
double *de = atom->de;
double *rho = atom->rho;
double *drho = atom->drho;
double *rmass = atom->rmass;
double *mass = atom->mass;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
int rmass_flag = atom->rmass_flag;
if (igroup == atom->firstgroup)
nlocal = atom->nfirst;
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
e[i] += dtf * de[i];
rho[i] += dtf * drho[i];
if (xflag) {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
v[i][0] += dtfm * f[i][0];
}
if (yflag) {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
v[i][1] += dtfm * f[i][1];
}
if (zflag) {
dtfm = rmass_flag ? dtf / rmass[i] : dtf / mass[type[i]];
v[i][2] += dtfm * f[i][2];
}
}
}
}
/* ----------------------------------------------------------------------
memory usage of local atom-based array
------------------------------------------------------------------------- */
double FixMesoMove::memory_usage () {
double bytes = atom->nmax*3 * sizeof(double);
if (displaceflag) bytes += atom->nmax*3 * sizeof(double);
if (velocityflag) bytes += atom->nmax*3 * sizeof(double);
return bytes;
}
/* ----------------------------------------------------------------------
pack entire state of Fix into one write
------------------------------------------------------------------------- */
void FixMesoMove::write_restart (FILE *fp) {
int n = 0;
double list[1];
list[n++] = time_origin;
if (comm->me == 0) {
int size = n * sizeof(double);
fwrite(&size,sizeof(int),1,fp);
fwrite(list,sizeof(double),n,fp);
}
}
/* ----------------------------------------------------------------------
use state info from restart file to restart the Fix
------------------------------------------------------------------------- */
void FixMesoMove::restart (char *buf) {
int n = 0;
double *list = (double *) buf;
time_origin = static_cast<int> (list[n++]);
}
/* ----------------------------------------------------------------------
allocate atom-based array
------------------------------------------------------------------------- */
void FixMesoMove::grow_arrays (int nmax) {
memory->grow(xoriginal,nmax,3,"move:xoriginal");
array_atom = xoriginal;
}
/* ----------------------------------------------------------------------
copy values within local atom-based array
------------------------------------------------------------------------- */
void FixMesoMove::copy_arrays (int i, int j, int /*delflag*/) {
xoriginal[j][0] = xoriginal[i][0];
xoriginal[j][1] = xoriginal[i][1];
xoriginal[j][2] = xoriginal[i][2];
}
/* ----------------------------------------------------------------------
initialize one atom's array values, called when atom is created
------------------------------------------------------------------------- */
void FixMesoMove::set_arrays (int i) {
double **x = atom->x;
imageint *image = atom->image;
int *mask = atom->mask;
// particle not in group
if (!(mask[i] & groupbit)) {
xoriginal[i][0] = xoriginal[i][1] = xoriginal[i][2] = 0.0;
return;
}
// current time still equal fix creation time
if (update->ntimestep == time_origin) {
domain->unmap(x[i],image[i],xoriginal[i]);
return;
}
// backup particle to time_origin
if (mstyle == VARIABLE)
error->all(FLERR,"Cannot add atoms to fix meso/move variable");
domain->unmap(x[i],image[i],xoriginal[i]);
double delta = (update->ntimestep - time_origin) * update->dt;
if (mstyle == LINEAR) {
if (vxflag) xoriginal[i][0] -= vx * delta;
if (vyflag) xoriginal[i][1] -= vy * delta;
if (vzflag) xoriginal[i][2] -= vz * delta;
} else if (mstyle == WIGGLE) {
double arg = omega_rotate * delta;
double sine = sin(arg);
if (axflag) xoriginal[i][0] -= ax*sine;
if (ayflag) xoriginal[i][1] -= ay*sine;
if (azflag) xoriginal[i][2] -= az*sine;
} else if (mstyle == ROTATE) {
double a[3],b[3],c[3],d[3],disp[3],ddotr;
double arg = - omega_rotate * delta;
double sine = sin(arg);
double cosine = cos(arg);
d[0] = x[i][0] - point[0];
d[1] = x[i][1] - point[1];
d[2] = x[i][2] - point[2];
ddotr = d[0]*runit[0] + d[1]*runit[1] + d[2]*runit[2];
c[0] = ddotr*runit[0];
c[1] = ddotr*runit[1];
c[2] = ddotr*runit[2];
a[0] = d[0] - c[0];
a[1] = d[1] - c[1];
a[2] = d[2] - c[2];
b[0] = runit[1]*a[2] - runit[2]*a[1];
b[1] = runit[2]*a[0] - runit[0]*a[2];
b[2] = runit[0]*a[1] - runit[1]*a[0];
disp[0] = a[0]*cosine + b[0]*sine;
disp[1] = a[1]*cosine + b[1]*sine;
disp[2] = a[2]*cosine + b[2]*sine;
xoriginal[i][0] = point[0] + c[0] + disp[0];
xoriginal[i][1] = point[1] + c[1] + disp[1];
xoriginal[i][2] = point[2] + c[2] + disp[2];
}
}
/* ----------------------------------------------------------------------
pack values in local atom-based array for exchange with another proc
------------------------------------------------------------------------- */
int FixMesoMove::pack_exchange (int i, double *buf) {
buf[0] = xoriginal[i][0];
buf[1] = xoriginal[i][1];
buf[2] = xoriginal[i][2];
return 3;
}
/* ----------------------------------------------------------------------
unpack values in local atom-based array from exchange with another proc
------------------------------------------------------------------------- */
int FixMesoMove::unpack_exchange (int nlocal, double *buf) {
xoriginal[nlocal][0] = buf[0];
xoriginal[nlocal][1] = buf[1];
xoriginal[nlocal][2] = buf[2];
return 3;
}
/* ----------------------------------------------------------------------
pack values in local atom-based arrays for restart file
------------------------------------------------------------------------- */
int FixMesoMove::pack_restart (int i, double *buf) {
buf[0] = 4;
buf[1] = xoriginal[i][0];
buf[2] = xoriginal[i][1];
buf[3] = xoriginal[i][2];
return 4;
}
/* ----------------------------------------------------------------------
unpack values from atom->extra array to restart the fix
------------------------------------------------------------------------- */
void FixMesoMove::unpack_restart (int nlocal, int nth) {
double **extra = atom->extra;
// skip to Nth set of extra values
int m = 0;
for (int i = 0; i < nth; i++) m += static_cast<int> (extra[nlocal][m]);
m++;
xoriginal[nlocal][0] = extra[nlocal][m++];
xoriginal[nlocal][1] = extra[nlocal][m++];
xoriginal[nlocal][2] = extra[nlocal][m++];
}
/* ----------------------------------------------------------------------
maxsize of any atom's restart data
------------------------------------------------------------------------- */
int FixMesoMove::maxsize_restart () {
return 4;
}
/* ----------------------------------------------------------------------
size of atom nlocal's restart data
------------------------------------------------------------------------- */
int FixMesoMove::size_restart (int /* nlocal */) {
return 4;
}
/* ---------------------------------------------------------------------- */
void FixMesoMove::reset_dt () {
error->all(FLERR,"Resetting timestep size is not allowed with fix meso/move");
}

View File

@ -0,0 +1,127 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(meso/move,FixMesoMove)
#else
#ifndef LMP_FIX_MESO_MOVE_H
#define LMP_FIX_MESO_MOVE_H
#include "fix.h"
namespace LAMMPS_NS {
class FixMesoMove : public Fix {
public:
FixMesoMove (class LAMMPS *, int, char **);
~FixMesoMove ();
int setmask ();
void init ();
void setup_pre_force (int);
void initial_integrate (int);
void final_integrate ();
double memory_usage ();
void write_restart (FILE *);
void restart (char *);
void grow_arrays (int);
void copy_arrays (int, int, int);
void set_arrays (int);
int pack_exchange (int, double *);
int unpack_exchange (int, double *);
int pack_restart (int, double *);
void unpack_restart (int, int);
int maxsize_restart ();
int size_restart (int);
void reset_dt ();
private:
char *xvarstr,*yvarstr,*zvarstr,*vxvarstr,*vyvarstr,*vzvarstr;
int mstyle;
int vxflag,vyflag,vzflag,axflag,ayflag,azflag;
double vx,vy,vz,ax,ay,az;
double period,omega_rotate;
double point[3],axis[3],runit[3];
double dt,dtv,dtf;
int xvar,yvar,zvar,vxvar,vyvar,vzvar;
int xvarstyle,yvarstyle,zvarstyle,vxvarstyle,vyvarstyle,vzvarstyle;
int time_origin;
double **xoriginal; // original coords of atoms
int displaceflag,velocityflag;
int maxatom;
double **displace,**velocity;
};
}
#endif
#endif
/* ERROR/WARNING messages:
E: Illegal ... command
Self-explanatory. Check the input script syntax and compare to the
documentation for the command. You can use -echo screen as a
command-line option when running LAMMPS to see the offending line.
E: Fix meso/move cannot set linear z motion for 2d problem
Self-explanatory.
E: Fix meso/move cannot set wiggle z motion for 2d problem
Self-explanatory.
E: Fix meso/move cannot rotate aroung non z-axis for 2d problem
Self-explanatory.
E: Fix meso/move cannot define z or vz variable for 2d problem
Self-explanatory.
W: Fix meso/move does not update angular momentum
Atoms store this quantity, but fix meso/move does not (yet) update it.
W: Fix meso/move does not update quaternions
Atoms store this quantity, but fix meso/move does not (yet) update it.
E: Zero length rotation vector with fix meso/move
Self-explanatory.
E: Variable name for fix meso/move does not exist
Self-explanatory.
E: Variable for fix meso/move is invalid style
Only equal-style variables can be used.
E: Cannot add atoms to fix meso/move variable
Atoms can not be added afterwards to this fix option.
E: Resetting timestep size is not allowed with fix meso/move
This is because fix meso/move is moving atoms based on elapsed time.
*/

View File

@ -0,0 +1,500 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Tony Sheh (U Michigan), Trung Dac Nguyen (U Michigan)
references: Kamberaj et al., J. Chem. Phys. 122, 224114 (2005)
Miller et al., J Chem Phys. 116, 8649-8659 (2002)
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author:
Morteza Jalalvand (IASBS) jalalvand.m AT gmail.com
This is an extension of fix/rigid/nve to SPH/SDPD particles
You can see the original copyright notice of fix/rigid authors above
Note that the Kamberaj paper was related to the nvt variant
and all codes relevant to that has been removed
------------------------------------------------------------------------- */
#include <cmath>
#include "fix_rigid_meso.h"
#include "math_extra.h"
#include "atom.h"
#include "compute.h"
#include "domain.h"
#include "update.h"
#include "modify.h"
#include "group.h"
#include "force.h"
#include "output.h"
#include "memory.h"
#include "error.h"
using namespace LAMMPS_NS;
using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixRigidMeso::FixRigidMeso (LAMMPS *lmp, int narg, char **arg) :
FixRigid (lmp, narg, arg) {
scalar_flag = 0;
size_array_cols = 28;
if ((atom->e_flag != 1) || (atom->rho_flag != 1))
error->all (FLERR, "fix rigid/meso command requires atom_style with"
" both energy and density");
if (langflag || tstat_flag)
error->all (FLERR,"Can not use thermostat with fix rigid/meso");
if (pstat_flag)
error->all (FLERR,"Can not use barostat with fix rigid/meso");
// memory allocation and initialization
memory->create(conjqm,nbody,4,"rigid_nh:conjqm");
}
/* ---------------------------------------------------------------------- */
FixRigidMeso::~FixRigidMeso () {
memory->destroy(conjqm);
}
/* ---------------------------------------------------------------------- */
int FixRigidMeso::setmask () {
int mask = 0;
mask |= INITIAL_INTEGRATE;
mask |= FINAL_INTEGRATE;
mask |= PRE_NEIGHBOR;
return mask;
}
/* ---------------------------------------------------------------------- */
void FixRigidMeso::setup (int vflag) {
FixRigid::setup(vflag);
double mbody[3];
for (int ibody = 0; ibody < nbody; ibody++) {
MathExtra::transpose_matvec (ex_space[ibody],ey_space[ibody],ez_space[ibody],
angmom[ibody],mbody);
MathExtra::quatvec (quat[ibody],mbody,conjqm[ibody]);
conjqm[ibody][0] *= 2.0;
conjqm[ibody][1] *= 2.0;
conjqm[ibody][2] *= 2.0;
conjqm[ibody][3] *= 2.0;
}
}
/* ----------------------------------------------------------------------
perform preforce velocity Verlet integration
see Kamberaj paper for step references
------------------------------------------------------------------------- */
void FixRigidMeso::initial_integrate (int vflag) {
double dtfm,mbody[3],tbody[3],fquat[4];
double dtf2 = dtf * 2.0;
// update xcm, vcm, quat, conjqm and angmom
for (int ibody = 0; ibody < nbody; ibody++) {
// step 1.1 - update vcm by 1/2 step
dtfm = dtf / masstotal[ibody];
vcm[ibody][0] += dtfm * fcm[ibody][0] * fflag[ibody][0];
vcm[ibody][1] += dtfm * fcm[ibody][1] * fflag[ibody][1];
vcm[ibody][2] += dtfm * fcm[ibody][2] * fflag[ibody][2];
// step 1.2 - update xcm by full step
xcm[ibody][0] += dtv * vcm[ibody][0];
xcm[ibody][1] += dtv * vcm[ibody][1];
xcm[ibody][2] += dtv * vcm[ibody][2];
// step 1.3 - apply torque (body coords) to quaternion momentum
torque[ibody][0] *= tflag[ibody][0];
torque[ibody][1] *= tflag[ibody][1];
torque[ibody][2] *= tflag[ibody][2];
MathExtra::transpose_matvec (ex_space[ibody],ey_space[ibody],ez_space[ibody],
torque[ibody],tbody);
MathExtra::quatvec (quat[ibody],tbody,fquat);
conjqm[ibody][0] += dtf2 * fquat[0];
conjqm[ibody][1] += dtf2 * fquat[1];
conjqm[ibody][2] += dtf2 * fquat[2];
conjqm[ibody][3] += dtf2 * fquat[3];
// step 1.4 to 1.13 - use no_squish rotate to update p and q
MathExtra::no_squish_rotate (3,conjqm[ibody],quat[ibody],inertia[ibody],dtq);
MathExtra::no_squish_rotate (2,conjqm[ibody],quat[ibody],inertia[ibody],dtq);
MathExtra::no_squish_rotate (1,conjqm[ibody],quat[ibody],inertia[ibody],dtv);
MathExtra::no_squish_rotate (2,conjqm[ibody],quat[ibody],inertia[ibody],dtq);
MathExtra::no_squish_rotate (3,conjqm[ibody],quat[ibody],inertia[ibody],dtq);
// update exyz_space
// transform p back to angmom
// update angular velocity
MathExtra::q_to_exyz (quat[ibody],ex_space[ibody],ey_space[ibody],
ez_space[ibody]);
MathExtra::invquatvec (quat[ibody],conjqm[ibody],mbody);
MathExtra::matvec (ex_space[ibody],ey_space[ibody],ez_space[ibody],
mbody,angmom[ibody]);
angmom[ibody][0] *= 0.5;
angmom[ibody][1] *= 0.5;
angmom[ibody][2] *= 0.5;
MathExtra::angmom_to_omega (angmom[ibody],ex_space[ibody],ey_space[ibody],
ez_space[ibody],inertia[ibody],omega[ibody]);
}
// virial setup before call to set_xv
if (vflag) v_setup(vflag);
else evflag = 0;
// set coords/orient and velocity/rotation of atoms in rigid bodies
// from quarternion and omega
set_xv();
}
/* ---------------------------------------------------------------------- */
void FixRigidMeso::final_integrate () {
int ibody;
double dtfm;
double mbody[3],tbody[3],fquat[4];
double dtf2 = dtf * 2.0;
// late calculation of forces and torques (if requested)
if (!earlyflag) compute_forces_and_torques();
// update vcm and angmom
// fflag,tflag = 0 for some dimensions in 2d
for (ibody = 0; ibody < nbody; ibody++) {
// update vcm by 1/2 step
dtfm = dtf / masstotal[ibody];
vcm[ibody][0] += dtfm * fcm[ibody][0] * fflag[ibody][0];
vcm[ibody][1] += dtfm * fcm[ibody][1] * fflag[ibody][1];
vcm[ibody][2] += dtfm * fcm[ibody][2] * fflag[ibody][2];
// update conjqm, then transform to angmom, set velocity again
// virial is already setup from initial_integrate
torque[ibody][0] *= tflag[ibody][0];
torque[ibody][1] *= tflag[ibody][1];
torque[ibody][2] *= tflag[ibody][2];
MathExtra::transpose_matvec (ex_space[ibody],ey_space[ibody],
ez_space[ibody],torque[ibody],tbody);
MathExtra::quatvec (quat[ibody],tbody,fquat);
conjqm[ibody][0] += dtf2 * fquat[0];
conjqm[ibody][1] += dtf2 * fquat[1];
conjqm[ibody][2] += dtf2 * fquat[2];
conjqm[ibody][3] += dtf2 * fquat[3];
MathExtra::invquatvec (quat[ibody],conjqm[ibody],mbody);
MathExtra::matvec (ex_space[ibody],ey_space[ibody],ez_space[ibody],
mbody,angmom[ibody]);
angmom[ibody][0] *= 0.5;
angmom[ibody][1] *= 0.5;
angmom[ibody][2] *= 0.5;
MathExtra::angmom_to_omega (angmom[ibody],ex_space[ibody],ey_space[ibody],
ez_space[ibody],inertia[ibody],omega[ibody]);
}
// set velocity/rotation of atoms in rigid bodies
// virial is already setup from initial_integrate
set_v();
}
/* ----------------------------------------------------------------------
set space-frame coords and velocity of each atom in each rigid body
set orientation and rotation of extended particles
x = Q displace + Xcm, mapped back to periodic box
v = Vcm + (W cross (x - Xcm))
------------------------------------------------------------------------- */
void FixRigidMeso::set_xv () {
int ibody;
int xbox,ybox,zbox;
double x0,x1,x2,v0,v1,v2,fc0,fc1,fc2,massone;
double xy,xz,yz;
double vr[6];
double **x = atom->x;
double **v = atom->v;
double **vest = atom->vest;
double **f = atom->f;
double *e = atom->e;
double *de = atom->de;
double *rho = atom->rho;
double *drho = atom->drho;
double *rmass = atom->rmass;
double *mass = atom->mass;
int *type = atom->type;
int nlocal = atom->nlocal;
double xprd = domain->xprd;
double yprd = domain->yprd;
double zprd = domain->zprd;
if (triclinic) {
xy = domain->xy;
xz = domain->xz;
yz = domain->yz;
}
// set x and v of each atom
for (int i = 0; i < nlocal; i++) {
if (body[i] < 0) continue;
// half-step update of particle internal energy and density
e[i] += dtf * de[i];
rho[i] += dtf * drho[i];
ibody = body[i];
xbox = (xcmimage[i] & IMGMASK) - IMGMAX;
ybox = (xcmimage[i] >> IMGBITS & IMGMASK) - IMGMAX;
zbox = (xcmimage[i] >> IMG2BITS) - IMGMAX;
// save old positions and velocities for virial
if (evflag) {
if (triclinic == 0) {
x0 = x[i][0] + xbox*xprd;
x1 = x[i][1] + ybox*yprd;
x2 = x[i][2] + zbox*zprd;
} else {
x0 = x[i][0] + xbox*xprd + ybox*xy + zbox*xz;
x1 = x[i][1] + ybox*yprd + zbox*yz;
x2 = x[i][2] + zbox*zprd;
}
}
v0 = v[i][0];
v1 = v[i][1];
v2 = v[i][2];
// x = displacement from center-of-mass, based on body orientation
// v = vcm + omega around center-of-mass
// vest = 2*v - v_old
MathExtra::matvec (ex_space[ibody],ey_space[ibody],
ez_space[ibody],displace[i],x[i]);
v[i][0] = omega[ibody][1]*x[i][2] - omega[ibody][2]*x[i][1] +
vcm[ibody][0];
v[i][1] = omega[ibody][2]*x[i][0] - omega[ibody][0]*x[i][2] +
vcm[ibody][1];
v[i][2] = omega[ibody][0]*x[i][1] - omega[ibody][1]*x[i][0] +
vcm[ibody][2];
vest[i][0] = 2*v[i][0] - v0;
vest[i][1] = 2*v[i][1] - v1;
vest[i][2] = 2*v[i][2] - v2;
// add center of mass to displacement
// map back into periodic box via xbox,ybox,zbox
// for triclinic, add in box tilt factors as well
if (triclinic == 0) {
x[i][0] += xcm[ibody][0] - xbox*xprd;
x[i][1] += xcm[ibody][1] - ybox*yprd;
x[i][2] += xcm[ibody][2] - zbox*zprd;
} else {
x[i][0] += xcm[ibody][0] - xbox*xprd - ybox*xy - zbox*xz;
x[i][1] += xcm[ibody][1] - ybox*yprd - zbox*yz;
x[i][2] += xcm[ibody][2] - zbox*zprd;
}
// virial = unwrapped coords dotted into body constraint force
// body constraint force = implied force due to v change minus f external
// assume f does not include forces internal to body
// 1/2 factor b/c final_integrate contributes other half
// assume per-atom contribution is due to constraint force on that atom
if (evflag) {
if (rmass) massone = rmass[i];
else massone = mass[type[i]];
fc0 = massone*(v[i][0] - v0)/dtf - f[i][0];
fc1 = massone*(v[i][1] - v1)/dtf - f[i][1];
fc2 = massone*(v[i][2] - v2)/dtf - f[i][2];
vr[0] = 0.5*x0*fc0;
vr[1] = 0.5*x1*fc1;
vr[2] = 0.5*x2*fc2;
vr[3] = 0.5*x0*fc1;
vr[4] = 0.5*x0*fc2;
vr[5] = 0.5*x1*fc2;
v_tally(1,&i,1.0,vr);
}
}
// set orientation, omega, angmom of each extended particle
if (extended) {
// TBD
}
}
/* ----------------------------------------------------------------------
set space-frame velocity of each atom in a rigid body
set omega and angmom of extended particles
v = Vcm + (W cross (x - Xcm))
------------------------------------------------------------------------- */
void FixRigidMeso::set_v () {
int xbox,ybox,zbox;
double x0,x1,x2,v0,v1,v2,fc0,fc1,fc2,massone;
double xy,xz,yz;
double delta[3],vr[6];
double **x = atom->x;
double **v = atom->v;
double **f = atom->f;
double *e = atom->e;
double *de = atom->de;
double *rho = atom->rho;
double *drho = atom->drho;
double *rmass = atom->rmass;
double *mass = atom->mass;
int *type = atom->type;
int nlocal = atom->nlocal;
double xprd = domain->xprd;
double yprd = domain->yprd;
double zprd = domain->zprd;
if (triclinic) {
xy = domain->xy;
xz = domain->xz;
yz = domain->yz;
}
// set v of each atom
for (int i = 0; i < nlocal; i++) {
if (body[i] < 0) continue;
// half-step update of particle internal energy and density
e[i] += dtf * de[i];
rho[i] += dtf * drho[i];
const int ibody = body[i];
MathExtra::matvec (ex_space[ibody],ey_space[ibody],
ez_space[ibody],displace[i],delta);
// save old velocities for virial
if (evflag) {
v0 = v[i][0];
v1 = v[i][1];
v2 = v[i][2];
}
v[i][0] = omega[ibody][1]*delta[2] - omega[ibody][2]*delta[1] +
vcm[ibody][0];
v[i][1] = omega[ibody][2]*delta[0] - omega[ibody][0]*delta[2] +
vcm[ibody][1];
v[i][2] = omega[ibody][0]*delta[1] - omega[ibody][1]*delta[0] +
vcm[ibody][2];
// virial = unwrapped coords dotted into body constraint force
// body constraint force = implied force due to v change minus f external
// assume f does not include forces internal to body
// 1/2 factor b/c initial_integrate contributes other half
// assume per-atom contribution is due to constraint force on that atom
if (evflag) {
if (rmass) massone = rmass[i];
else massone = mass[type[i]];
fc0 = massone*(v[i][0] - v0)/dtf - f[i][0];
fc1 = massone*(v[i][1] - v1)/dtf - f[i][1];
fc2 = massone*(v[i][2] - v2)/dtf - f[i][2];
xbox = (xcmimage[i] & IMGMASK) - IMGMAX;
ybox = (xcmimage[i] >> IMGBITS & IMGMASK) - IMGMAX;
zbox = (xcmimage[i] >> IMG2BITS) - IMGMAX;
if (triclinic == 0) {
x0 = x[i][0] + xbox*xprd;
x1 = x[i][1] + ybox*yprd;
x2 = x[i][2] + zbox*zprd;
} else {
x0 = x[i][0] + xbox*xprd + ybox*xy + zbox*xz;
x1 = x[i][1] + ybox*yprd + zbox*yz;
x2 = x[i][2] + zbox*zprd;
}
vr[0] = 0.5*x0*fc0;
vr[1] = 0.5*x1*fc1;
vr[2] = 0.5*x2*fc2;
vr[3] = 0.5*x0*fc1;
vr[4] = 0.5*x0*fc2;
vr[5] = 0.5*x1*fc2;
v_tally(1,&i,1.0,vr);
}
}
// set omega, angmom of each extended particle
if (extended) {
// TBD
}
}
/* ----------------------------------------------------------------------
return attributes of a rigid body
19 values per body
xcm = 0,1,2; vcm = 3,4,5; fcm = 6,7,8;
quat = 9,10,11,12; omega = 13,14,15; torque = 16,17,18;
inertia = 19,20,21; angmom = 22,23,24;
image = 25,26,27
------------------------------------------------------------------------- */
double FixRigidMeso::compute_array (int i, int j) {
if (j < 3) return xcm[i][j];
if (j < 6) return vcm[i][j-3];
if (j < 9) return fcm[i][j-6];
if (j < 13) return quat[i][j-9];
if (j < 16) return omega[i][j-13];
if (j < 19) return torque[i][j-16];
if (j < 22) return inertia[i][j-19];
if (j < 25) return angmom[i][j-22];
if (j == 25) return (imagebody[i] & IMGMASK) - IMGMAX;
if (j == 26) return (imagebody[i] >> IMGBITS & IMGMASK) - IMGMAX;
return (imagebody[i] >> IMG2BITS) - IMGMAX;
}

View File

@ -0,0 +1,69 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef FIX_CLASS
FixStyle(rigid/meso,FixRigidMeso)
#else
#ifndef LMP_FIX_RIGID_MESO_H
#define LMP_FIX_RIGID_MESO_H
#include "fix_rigid.h"
namespace LAMMPS_NS {
class FixRigidMeso : public FixRigid {
public:
FixRigidMeso (class LAMMPS *, int, char **);
~FixRigidMeso ();
int setmask ();
void setup (int);
void initial_integrate (int);
void final_integrate ();
double compute_scalar () { return 0.0; }
double compute_array (int, int);
protected:
void set_xv ();
void set_v ();
double **conjqm; // conjugate quaternion momentum
};
}
#endif
#endif
/* ERROR/WARNING messages:
E: fix rigid/meso command requires atom_style with both energy and density
You should use atom_style meso with this fix
E: Can not use thermostat with fix rigid/meso
Self-explanatory
E: Can not use barostat with fix rigid/meso
Self-explanatory
E: Illegal ... command
Self-explanatory. Check the input script syntax and compare to the
documentation for the command. You can use -echo screen as a
command-line option when running LAMMPS to see the offending line.
*/

View File

@ -0,0 +1,314 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author:
Morteza Jalalvand (IASBS) jalalvand.m AT gmail.com
references: Espanol and Revenga, Phys Rev E 67, 026705 (2003)
------------------------------------------------------------------------- */
#include <cmath>
#include <cstdlib>
#include "pair_sdpd_taitwater_isothermal.h"
#include "atom.h"
#include "force.h"
#include "comm.h"
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "domain.h"
#include "update.h"
#ifndef USE_ZEST
#include "random_mars.h"
#endif
using namespace LAMMPS_NS;
static const double sqrt_2_inv = std::sqrt(0.5);
/* ---------------------------------------------------------------------- */
PairSDPDTaitwaterIsothermal::PairSDPDTaitwaterIsothermal (LAMMPS *lmp)
: Pair (lmp) {
restartinfo = 0;
single_enable =0;
}
/* ---------------------------------------------------------------------- */
PairSDPDTaitwaterIsothermal::~PairSDPDTaitwaterIsothermal () {
if (allocated) {
memory->destroy (setflag);
memory->destroy (cutsq);
memory->destroy (cut);
memory->destroy (rho0);
memory->destroy (soundspeed);
memory->destroy (B);
}
}
/* ---------------------------------------------------------------------- */
void PairSDPDTaitwaterIsothermal::compute (int eflag, int vflag) {
int i, j, ii, jj, inum, jnum, itype, jtype;
double xtmp, ytmp, ztmp, delx, dely, delz, fpair;
int *ilist, *jlist, *numneigh, **firstneigh;
double vxtmp, vytmp, vztmp, imass, jmass, fi, fj, fvisc;
double h, ih, ihsq, velx, vely, velz;
double rsq, tmp, wfd, delVdotDelR;
double prefactor, wiener[3][3], f_random[3];
if (eflag || vflag) ev_setup (eflag, vflag);
else evflag = vflag_fdotr = 0;
double **v = atom->vest;
double **x = atom->x;
double **f = atom->f;
double *rho = atom->rho;
double *mass = atom->mass;
double *drho = atom->drho;
int *type = atom->type;
int nlocal = atom->nlocal;
int newton_pair = force->newton_pair;
int dimension = domain->dimension;
double dtinv = 1.0 / update->dt;
double kBoltzmann = force->boltz;
inum = list->inum;
ilist = list->ilist;
numneigh = list->numneigh;
firstneigh = list->firstneigh;
// loop over neighbors of my atoms
for (ii = 0; ii < inum; ii++) {
i = ilist[ii];
xtmp = x[i][0];
ytmp = x[i][1];
ztmp = x[i][2];
vxtmp = v[i][0];
vytmp = v[i][1];
vztmp = v[i][2];
itype = type[i];
jlist = firstneigh[i];
jnum = numneigh[i];
imass = mass[itype];
// compute pressure of atom i with Tait EOS
tmp = rho[i] / rho0[itype];
fi = tmp * tmp * tmp;
fi = B[itype] * (fi * fi * tmp - 1.0) / (rho[i] * rho[i]);
for (jj = 0; jj < jnum; jj++) {
j = jlist[jj];
j &= NEIGHMASK;
delx = xtmp - x[j][0];
dely = ytmp - x[j][1];
delz = ztmp - x[j][2];
rsq = delx * delx + dely * dely + delz * delz;
jtype = type[j];
jmass = mass[jtype];
if (rsq < cutsq[itype][jtype]) {
h = cut[itype][jtype];
ih = 1.0 / h;
ihsq = ih * ih;
double r = sqrt (rsq);
wfd = h - r;
if (dimension == 3) {
// Lucy Kernel, 3d
// Note that wfd, the derivative of the weight function with respect to r,
// is lacking a factor of r.
// The missing factor of r is recovered by
// (1) using delV . delX instead of delV . (delX/r) and
// (2) using f[i][0] += delx * fpair instead of f[i][0] += (delx/r) * fpair
wfd = -25.066903536973515383e0 * wfd * wfd * ihsq * ihsq * ihsq * ih;
} else {
// Lucy Kernel, 2d
wfd = -19.098593171027440292e0 * wfd * wfd * ihsq * ihsq * ihsq;
}
// compute pressure of atom j with Tait EOS
tmp = rho[j] / rho0[jtype];
fj = tmp * tmp * tmp;
fj = B[jtype] * (fj * fj * tmp - 1.0) / (rho[j] * rho[j]);
velx=vxtmp - v[j][0];
vely=vytmp - v[j][1];
velz=vztmp - v[j][2];
// dot product of velocity delta and distance vector
delVdotDelR = delx * velx + dely * vely + delz * velz;
// Espanol Viscosity (Espanol, 2003)
fvisc = (5. / 3.) * viscosity * imass * jmass * wfd / (rho[i]*rho[j]);
// total pair force
fpair = -imass * jmass * (fi + fj) * wfd;
// random force calculation
// independent increments of a Wiener process matrix
#ifdef USE_ZEST
wiener[0][0] = gaussian (generator);
wiener[1][1] = gaussian (generator);
wiener[2][2] = gaussian (generator);
wiener[0][1] = wiener[1][0] = sqrt_2_inv * gaussian (generator);
wiener[0][2] = wiener[2][0] = sqrt_2_inv * gaussian (generator);
wiener[1][2] = wiener[2][1] = sqrt_2_inv * gaussian (generator);
#else
wiener[0][0] = random->gaussian ();
wiener[1][1] = random->gaussian ();
wiener[2][2] = random->gaussian ();
wiener[0][1] = wiener[1][0] = sqrt_2_inv * random->gaussian ();
wiener[0][2] = wiener[2][0] = sqrt_2_inv * random->gaussian ();
wiener[1][2] = wiener[2][1] = sqrt_2_inv * random->gaussian ();
#endif
prefactor = sqrt (-4. * kBoltzmann*temperature * fvisc * dtinv) / r;
f_random[0] = prefactor * (wiener[0][0]*delx + wiener[0][1]*dely + wiener[0][2]*delz);
f_random[1] = prefactor * (wiener[1][0]*delx + wiener[1][1]*dely + wiener[1][2]*delz);
f_random[2] = prefactor * (wiener[2][0]*delx + wiener[2][1]*dely + wiener[2][2]*delz);
f[i][0] += delx * fpair + (velx + delx * delVdotDelR / rsq) * fvisc + f_random[0];
f[i][1] += dely * fpair + (vely + dely * delVdotDelR / rsq) * fvisc + f_random[1];
f[i][2] += delz * fpair + (velz + delz * delVdotDelR / rsq) * fvisc + f_random[2];
// and change in density
drho[i] += jmass * delVdotDelR * wfd;
if (newton_pair || j < nlocal) {
f[j][0] -= delx * fpair + (velx + delx * delVdotDelR / rsq) * fvisc + f_random[0];
f[j][1] -= dely * fpair + (vely + dely * delVdotDelR / rsq) * fvisc + f_random[1];
f[j][2] -= delz * fpair + (velz + delz * delVdotDelR / rsq) * fvisc + f_random[2];
drho[j] += imass * delVdotDelR * wfd;
}
if (evflag)
ev_tally (i, j, nlocal, newton_pair, 0.0, 0.0, fpair, delx, dely, delz);
}
}
}
if (vflag_fdotr) virial_fdotr_compute ();
}
/* ----------------------------------------------------------------------
allocate all arrays
------------------------------------------------------------------------- */
void PairSDPDTaitwaterIsothermal::allocate () {
allocated = 1;
int n = atom->ntypes;
memory->create (setflag, n + 1, n + 1, "pair:setflag");
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
setflag[i][j] = 0;
memory->create (cutsq, n + 1, n + 1, "pair:cutsq");
memory->create (rho0, n + 1, "pair:rho0");
memory->create (soundspeed, n + 1, "pair:soundspeed");
memory->create (B, n + 1, "pair:B");
memory->create (cut, n + 1, n + 1, "pair:cut");
}
/* ----------------------------------------------------------------------
global settings
------------------------------------------------------------------------- */
void PairSDPDTaitwaterIsothermal::settings (int narg, char **arg) {
if (narg != 2 && narg != 3)
error->all (FLERR, "Illegal number of arguments for "
"pair_style sdpd/taitwater/morris/isothermal");
temperature = force->numeric (FLERR, arg[0]);
viscosity = force->numeric (FLERR, arg[1]);
if (temperature <= 0) error->all (FLERR, "Temperature must be positive");
if (viscosity <= 0) error->all (FLERR, "Viscosity must be positive");
// seed is immune to underflow/overflow because it is unsigned
seed = comm->nprocs + comm->me + atom->nlocal;
if (narg == 3) seed += force->inumeric (FLERR, arg[2]);
#ifdef USE_ZEST
generator.seed (seed);
#else
random = new RanMars (lmp, seed);
#endif
}
/* ----------------------------------------------------------------------
set coeffs for one or more type pairs
------------------------------------------------------------------------- */
void PairSDPDTaitwaterIsothermal::coeff (int narg, char **arg) {
if (narg != 5)
error->all (FLERR, "Incorrect args for pair_style "
"sph/taitwater/morris coefficients");
if (!allocated) allocate();
int ilo, ihi, jlo, jhi;
force->bounds (FLERR, arg[0], atom->ntypes, ilo, ihi);
force->bounds (FLERR, arg[1], atom->ntypes, jlo, jhi);
double rho0_one = force->numeric (FLERR,arg[2]);
double soundspeed_one = force->numeric (FLERR,arg[3]);
double cut_one = force->numeric (FLERR,arg[4]);
double B_one = soundspeed_one * soundspeed_one * rho0_one / 7.0;
if (rho0_one <= 0) error->all (FLERR, "Density must be positive");
if (soundspeed_one <= 0) error->all (FLERR, "Sound speed must be positive");
if (cut_one <= 0) error->all (FLERR, "Cutoff must be positive");
int count = 0;
for (int i = ilo; i <= ihi; i++) {
rho0[i] = rho0_one;
soundspeed[i] = soundspeed_one;
B[i] = B_one;
for (int j = MAX(jlo,i); j <= jhi; j++) {
cut[i][j] = cut_one;
setflag[i][j] = 1;
count++;
}
}
if (count == 0)
error->all(FLERR,"Incorrect args for pair coefficients");
}
/* ----------------------------------------------------------------------
init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */
double PairSDPDTaitwaterIsothermal::init_one (int i, int j) {
if (setflag[i][j] == 0)
error->all(FLERR,"Not all pair sph/taitwater/morris coeffs are set");
cut[j][i] = cut[i][j];
return cut[i][j];
}

View File

@ -0,0 +1,59 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(sdpd/taitwater/isothermal,PairSDPDTaitwaterIsothermal)
#else
#ifndef LMP_PAIR_SDPD_TAITWATER_MORRIS_ISOTHERMAL_H
#define LMP_PAIR_SDPD_TAITWATER_MORRIS_ISOTHERMAL_H
#include "pair.h"
#ifdef USE_ZEST
#include <random>
#include "zest.hpp"
#endif
namespace LAMMPS_NS {
class PairSDPDTaitwaterIsothermal : public Pair {
public:
PairSDPDTaitwaterIsothermal (class LAMMPS *);
virtual ~PairSDPDTaitwaterIsothermal ();
virtual void compute (int, int);
void settings (int, char **);
void coeff (int, char **);
virtual double init_one (int, int);
protected:
double viscosity, temperature;
double *rho0, *soundspeed, *B;
double **cut;
void allocate ();
unsigned int seed;
#ifdef USE_ZEST
std::mt19937_64 generator;
Ziggurat<zest::StandardNormal,std::mt19937_64> gaussian;
#else
class RanMars *random;
#endif
};
}
#endif
#endif

View File

@ -158,7 +158,7 @@ void PairSPHHeatConduction::allocate() {
void PairSPHHeatConduction::settings(int narg, char **/*arg*/) {
if (narg != 0)
error->all(FLERR,
"Illegal number of setting arguments for pair_style sph/heatconduction");
"Illegal number of arguments for pair_style sph/heatconduction");
}
/* ----------------------------------------------------------------------

View File

@ -200,7 +200,7 @@ void PairSPHIdealGas::allocate() {
void PairSPHIdealGas::settings(int narg, char **/*arg*/) {
if (narg != 0)
error->all(FLERR,
"Illegal number of setting arguments for pair_style sph/idealgas");
"Illegal number of arguments for pair_style sph/idealgas");
}
/* ----------------------------------------------------------------------

View File

@ -207,7 +207,7 @@ void PairSPHLJ::allocate() {
void PairSPHLJ::settings(int narg, char **/*arg*/) {
if (narg != 0)
error->all(FLERR,
"Illegal number of setting arguments for pair_style sph/lj");
"Illegal number of arguments for pair_style sph/lj");
}
/* ----------------------------------------------------------------------

Some files were not shown because too many files have changed in this diff Show More