Unverified Commit 090778c4 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer Committed by GitHub
Browse files

Merge pull request #1204 from lammps/doc-plumed

Linkage mode improvements and documentation updates for USER-PLUMED package
parents db935dba 4d9e2a01
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ src/USER-MEAMC/* @martok
src/USER-MOFFF/*      @hheenen
src/USER-MOLFILE/*    @akohlmey
src/USER-NETCDF/*     @pastewka
src/USER-PLUMED/*     @gtribello
src/USER-PHONON/*     @lingtikong
src/USER-PTM/*        @pmla
src/USER-OMP/*        @akohlmey
+26 −4
Original line number Diff line number Diff line
@@ -349,7 +349,7 @@ if(PKG_KSPACE)
  endif()
endif()

if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE)
if(PKG_MSCG OR PKG_USER-ATC OR PKG_USER-AWPMD OR PKG_USER-QUIP OR PKG_LATTE OR PKG_USER-PLUMED)
  find_package(LAPACK)
  find_package(BLAS)
  if(NOT LAPACK_FOUND OR NOT BLAS_FOUND)
@@ -531,6 +531,12 @@ endif()

if(PKG_USER-PLUMED)
  find_package(GSL REQUIRED)
  set(PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library")
  set(PLUMED_MODE_VALUES static shared runtime)
  set_property(CACHE PLUMED_MODE PROPERTY STRINGS ${PLUMED_MODE_VALUES})
  validate_option(PLUMED_MODE PLUMED_MODE_VALUES)
  string(TOUPPER ${PLUMED_MODE} PLUMED_MODE)

  option(DOWNLOAD_PLUMED "Download Plumed (instead of using the system's one)" OFF)
  if(DOWNLOAD_PLUMED)
    include(ExternalProject)
@@ -543,13 +549,29 @@ if(PKG_USER-PLUMED)
    ExternalProject_get_property(plumed_build INSTALL_DIR)
    set(PLUMED_INSTALL_DIR ${INSTALL_DIR})
    list(APPEND LAMMPS_DEPS plumed_build)
    if(PLUMED_MODE STREQUAL "STATIC")
      add_definitions(-D__PLUMED_WRAPPER_CXX=1)
      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})
        "${PLUMED_INSTALL_DIR}/lib/plumed/obj/PlumedStatic.o" ${GSL_LIBRARIES} ${CMAKE_DL_LIBS} ${LAPACK_LIBRARIES})
    elseif(PLUMED_MODE STREQUAL "SHARED")
      list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumed.so ${CMAKE_DL_LIBS})
    elseif(PLUMED_MODE STREQUAL "RUNTIME")
      add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_INSTALL_DIR}/lib/libplumedKernel.so)
      list(APPEND LAMMPS_LINK_LIBS ${PLUMED_INSTALL_DIR}/lib/libplumedWrapper.a -rdynamic ${CMAKE_DL_LIBS})
    endif()
    set(PLUMED_INCLUDE_DIRS "${PLUMED_INSTALL_DIR}/include")
  else()
    find_package(PkgConfig REQUIRED)
    pkg_check_modules(PLUMED plumed REQUIRED)
    if(PLUMED_MODE STREQUAL "STATIC")
      add_definitions(-D__PLUMED_WRAPPER_CXX=1)
      include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.static)
    elseif(PLUMED_MODE STREQUAL "SHARED")
      include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.shared)
    elseif(PLUMED_MODE STREQUAL "RUNTIME")
      add_definitions(-D__PLUMED_HAS_DLOPEN=1 -D__PLUMED_DEFAULT_KERNEL=${PLUMED_LIBDIR}/libplumedKernel.so)
      include(${PLUMED_LIBDIR}/plumed/src/lib/Plumed.cmake.runtime)
    endif()
    list(APPEND LAMMPS_LINK_LIBS ${PLUMED_LOAD})
  endif()
  include_directories(${PLUMED_INCLUDE_DIRS})
+84 −43
Original line number Diff line number Diff line
@@ -41,11 +41,11 @@ 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,
"USER-NETCDF"_#user-netcdf,
"USER-PLUMED"_#user-plumed,
"USER-OMP"_#user-omp,
"USER-QMMM"_#user-qmmm,
"USER-QUIP"_#user-quip,
@@ -715,57 +715,98 @@ a corresponding Makefile.lammps.machine file.

USER-PLUMED package :h4,link(user-plumed)

Before building LAMMPS with this package, you must first build PLUMED.
PLUMED can be built as part of the LAMMPS build or installed separately
from LAMMPS using the generic "plumed installation instructions"_plumedinstall.
:link(plumedinstall,http://plumed.github.io/doc-master/user-doc/html/_installation.html)

PLUMED can be linked into MD codes in three different modes: static,
shared, and runtime.  With the "static" mode, all required PLUMED code
is linked statically into the MD code. The MD code is then fully
independent from the PLUMED installation, but also you have to
rebuild/relink the MD code to update the PLUMED code inside it.  With
"shared" linkage mode, the MD code is linked to a shared library
containing the PLUMED code, preferably after it was installed in a
globally accessible location. This way the same installed PLUMED code
can be shared across multiple MD packages and can be updated, for as
long as the shared PLUMED library is ABI-compatible. The third linkage
mode is "runtime" which allows to switch the PLUMED kernel at runtime
between different variants through setting the PLUMED_KERNEL environment
varible, which has to point to the location of the libplumedKernel.so
dynamical shared object, which is then loaded at runtime. This is
particularly convenient for doing PLUMED development and comparing
multiple PLUMED versions without having to recompile the hosting MD
code. All three linkage modes are supported by LAMMPS on selected
operating systems (e.g. Linux) and using either CMake or traditional
make build. The "static" mode should be most portable, the "runtime"
mode support in LAMMPS makes the most assumptions about operating
system and compiler environment. If one mode does not work, try a
different one, or switch to a different build system, or consider
a global PLUMED installation or downloading it during building LAMMPS.

[CMake build]:

[Traditional make]:
-D DOWNLOAD_PLUMED=value   # download PLUMED for build, value = no (default) or yes
-D PLUMED_MODE=value       # Linkage mode for PLUMED, value = static (default), shared, or runtime :pre

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:
If DOWNLOAD_PLUMED is set to "yes", the PLUMED library will be
downloaded (the version of that is hardcoded to a vetted version of
PLUMED, usually a recent stable release version) and built inside the
CMake build directory.  If DOWNLOAD_PLUMED is set to "no" (the default),
CMake will try to detect an installed version of PLUMED and link to
that. For this to work, the PLUMED library has to be installed into a
location where the pkg-config tool can find it or the PKG_CONFIG_PATH
environment variable has to be set up accordingly.

make yes-user-plumed 
make machine :pre
The PLUMED_MODE setting determines the linkage mode of the PLUMED
library.  Allowed values are "static" (default), "shared", or "runtime".
For a discussion of PLUMED linkage modes, please see above.  When
enabling DOWNLOAD_PLUMED, the static linkage mode is recommended.

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:
[Traditional make]:

Before installing the USER-PLUMED package, first the PLUMED library
needs to be configured so that LAMMPS can find the right settings when
compiling and linking the LAMMPS executable itself. You can either
download and build PLUMED inside the LAMMPS plumed library folder or use
a previously installed PLUMED library and point LAMMPS to its
location. You also have to choose the linkage mode: "static" (default),
"shared" or "runtime".  For a discussion of PLUMED linkage modes, please
see above.

Download/compilation/configuration of the plumed library can be done
from the src folder through the following make args:

make lib-plumed                         # print help message
make lib-plumed  args="-b"            # download and build the latest stable version of PLUMED
make lib-plumed args="-b"               # download and build PLUMED in lib/plumed/plumed2
make lib-plumed args="-p $HOME/.local"  # use existing PLUMED installation in $HOME/.local
make lib-plumed args="-p /usr/local -m shared"  # use existing PLUMED installation in
                                                # /usr/local and use shared linkage mode
:pre

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:
Note that 2 symbolic (soft) links, "includelink" and "liblink" are
created in lib/plumed to point into the location of the PLUMED build to
use and also a new file lib/plumed/Makefile.lammps is created with
settings suitable for LAMMPS to compile and link PLUMED in the desired
linkage mode. After this step is compleded, you can install the
USER-PLUMED package and compile LAMMPS in the usual manner:

make yes-user-plumed 
make machine :pre

make no-user-plumed
make machine :pre
Once this compilation completes you should be able to run LAMMPS in the
usual way.  For shared linkage mode, libplumed.so must be found by the
LAMMPS executable, which on many operating systems means, you have to
set the LD_LIBRARY_PATH environment variable accordingly.

Support for the different linkage modes in LAMMPS varies for different
operating systems, using the static linkage is expected to be the most
portable, and thus set to be the default.

If you want to change the linkage mode, you have to re-run "make
lib-plumed" with the desired settings [and] do a reinstall if the
USER-PLUMED package with "make yes-user-plumed" to update the required
makefile settings with the changes in the lib/plumed folder.

:line

+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ packages:
"USER-INTEL"_Build_extras.html#user-intel,
"USER-MOLFILE"_Build_extras.html#user-molfile,
"USER-NETCDF"_Build_extras.html#user-netcdf,
"USER-PLUMED"_Build_extras.html#user-plumed,
"USER-OMP"_Build_extras.html#user-omp,
"USER-QMMM"_Build_extras.html#user-qmmm,
"USER-QUIP"_Build_extras.html#user-quip,
+13 −10
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ as contained in the file name.
"USER-NETCDF"_#PKG-USER-NETCDF,
"USER-OMP"_#PKG-USER-OMP,
"USER-PHONON"_#PKG-USER-PHONON,
"USER-PLUMED"_#PKG-USER-PLUMED,
"USER-PTM"_#PKG-USER-PTM,
"USER-QMMM"_#PKG-USER-QMMM,
"USER-QTB"_#PKG-USER-QTB,
@@ -1187,7 +1188,7 @@ the NAMD MD code, but with portability in mind. Axel Kohlmeyer
[Install:] 

This package has "specific installation
instructions"_Build_extras.html#gpu on the "Build
instructions"_Build_extras.html#user-colvars on the "Build
extras"_Build_extras.html doc page.

[Supporting info:]
@@ -1201,18 +1202,20 @@ examples/USER/colvars :ul

:line

USER-PLUMED package :link(USER-PLUMED),h4
USER-PLUMED package :link(PKG-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.
The fix plumed command allows you to use the PLUMED free energy plugin
for molecular dynamics to analyse and bias your LAMMPS trajectory on
the fly.  The PLUMED library is called from within the LAMMPS input
script by using the "fix plumed _fix_plumed.html command.

[Authors:] The "PLUMED library"_#PLUMED is written and maintained by
Massimilliano Bonomi, Giovanni Bussi, Carlo Camiloni and Gareth
Tribello.

[Authors:] The PLUMED library is written and maintained by
Massimilliano Bonomi, Giovanni Bussi, Carlo Camiloni and
Gareth Tribello. 
:link(PLUMED,http://www.plumed.org)

[Install:]

Loading