Skip to content

Commit

Permalink
Merge pull request #20 from libefp2/lyuda_Jan6
Browse files Browse the repository at this point in the history
Lyuda jan6
  • Loading branch information
slipchenko authored Jan 7, 2025
2 parents 86383d6 + 978ce1e commit c7377d7
Show file tree
Hide file tree
Showing 77 changed files with 7,690 additions and 422 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@
/include/
tags
build*/
cmake-build-debug/
/installed/
/cmake-build-debug/
compilation.log

38 changes: 35 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,23 @@ if (POLICY CMP0135)
endif ()

# extract project version from source

if(NOT DEFINED torch_switch)
if(DEFINED ENV{TORCH_SWITCH})
set(torch_switch $ENV{TORCH_SWITCH})
else()
set(torch_switch OFF)
endif()
endif()

option(torch_switch "Enable Torch library integration" ${TORCH_SWITCH})

if(torch_switch)
add_definitions(-DTORCH_SWITCH)
endif()

file(STRINGS "src/efp.h" _src_efp_h REGEX "LIBEFP_VERSION_STRING")

if (${_src_efp_h} MATCHES "^#define LIBEFP_VERSION_STRING \"(.*)\"$")
set(_libefp_VERSION ${CMAKE_MATCH_1})
endif()
Expand All @@ -13,9 +29,17 @@ project(
libefp
# someday when Makefile dropped, configure efp.h.in from cmake
VERSION ${_libefp_VERSION}
LANGUAGES C
LANGUAGES C CXX
)
set(libefp_AUTHORS "Ilya A. Kaliman, Lori A. Burns, Dmitry Morozov, Carlos H. Borca, Yen (Terri) Bui, Yongbin Kim, Lyudmila V. Slipchenko")

#set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/installed" CACHE PATH "Installation directory" FORCE)
#set(CMAKE_INSTALL_PREFIX "${LIBEFP_DIR}" CACHE PATH "Installation directory")
set(CMAKE_INSTALL_LIBDIR "lib")

### LVS needs this on MacOS silicon
set(CMAKE_CXX_STANDARD 17)

set(libefp_AUTHORS "Ilya A. Kaliman, Lori A. Burns, Suranjan Paul, Dmitry Morozov, Carlos H. Borca, Yen (Terri) Bui, Yongbin Kim, Lyudmila V. Slipchenko")
set(libefp_DESCRIPTION "Parallel implementation of the Effective Fragment Potential method")
set(libefp_URL "https://github.com/libefp2/libefp")
set(libefp_LICENSE "BSD 2-clause")
Expand All @@ -24,6 +48,7 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

set(efp libefp) # Namespace


# TODO: Remove when requiring cmake >= 3.21 # from LecrisUT/CMake-Template
if (NOT DEFINED ${efp}_IS_TOP_LEVEL)
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
Expand Down Expand Up @@ -54,7 +79,10 @@ option_with_default(BUILD_FPIC "Libraries will be compiled with position indepen
if((${BUILD_SHARED_LIBS}) AND NOT ${BUILD_FPIC})
message(FATAL_ERROR "BUILD_SHARED_LIBS ON and BUILD_FPIC OFF are incompatible, as shared library requires position independent code")
endif()
option_with_print(LIBEFP_ENABLE_OPENMP "Enable OpenMP parallelization. Psi4 wants OFF" OFF)

### This option turns OPENMP ON and OFF!
option_with_print(LIBEFP_ENABLE_OPENMP "Enable OpenMP parallelization. Psi4 wants OFF" ON)

option_with_print(ENABLE_GENERIC "Enable mostly static linking in shared library" OFF)
include(xhost) # defines: option(ENABLE_XHOST "Enable processor-specific optimization" ON)
option_with_print(FRAGLIB_UNDERSCORE_L "DEPRECATED: Installed fragment library has names ending in _L. Psi4 wants OFF" ON)
Expand Down Expand Up @@ -132,6 +160,7 @@ set(raw_sources_list
util.c
xr.c
)

set(src_prefix "src/")
string(REGEX REPLACE "([^;]+)" "${src_prefix}\\1" sources_list "${raw_sources_list}")

Expand Down Expand Up @@ -203,6 +232,9 @@ install(FILES fraglib/makefp.inp
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fraglib
DESTINATION ${CMAKE_INSTALL_DATADIR}/${efp})

install(DIRECTORY ${PROJECT_SOURCE_DIR}/nnlib
DESTINATION ${CMAKE_INSTALL_DATADIR}/${efp})

# headers NOT namespace protected
install(FILES ${src_prefix}/efp.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Libefp was written by Ilya Kaliman.
The following people contributed to libefp. Thanks!

Yen (Terri) Bui
Lori A. Burns
Dmitry Morozov
Carlos H. Borca
Yen (Terri) Bui
Yongbin Kim
Dmitry Morozov
Suranjan Paul
Lyudmila V. Slipchenko

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ all: efpmd
efpmd: libefp
cd efpmd/libff && CC="$(CC)" CFLAGS="$(MYCFLAGS)" $(MAKE)
cd efpmd/libopt && CC="$(CC)" CFLAGS="$(MYCFLAGS)" FC="$(FC)" FFLAGS="$(MYFFLAGS)" $(MAKE)
cd efpmd/torch && CC="$(CC)" CFLAGS="$(MYCFLAGS)" $(MAKE)
cd efpmd/src && $(MAKE)

libefp:
Expand All @@ -15,6 +16,7 @@ clean:
cd tests && $(MAKE) $@
cd efpmd/libff && $(MAKE) $@
cd efpmd/libopt && $(MAKE) $@
cd efpmd/torch && $(MAKE) $@
cd efpmd/src && $(MAKE) $@
rm -rf doxygen_html

Expand Down
56 changes: 56 additions & 0 deletions README-torch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

# Installation with LibTorch for ML/EFP models

## Required libraries

- cmake
- lapack math library
- C/C++ compiler (GCC 9 or newer)
- Fortran 77 compiler

An example of working setup at Purdue supercomputers
can be foound in *module.sh* script.

AppleClang 14 works on M2 MacOS Ventura.

## LibTorch library

For ML/EFP models, one needs to use LibTorch library.
Install LibTorch (C++ frontend) of PyTorch. Consult Libtorch/Pytorch
webpages for detail: https://pytorch.org/cppdocs/

You can opt out and configure with EFP-only installation - see the next section.

## Setup environmental variables

*setup.sh* or *setup.csh* are used to set up environmental
variables. The first two are mandatory:

`TORCH_SWITCH` is the variable governing compilation
with or without LibTorch.

`LIBEFP_DIR` is a path to LibEFP directory with source codes.

`INSTALLATION_DIR` is the installation directory.

`TORCH_INSTALLED_DIR` and `LIBTORCH_INCLUDE_DIRS` are paths to the LibTorch
installation and included directories.

## Compilation

Further tuning can be done in `CMakeLists.txt`. Otherwise,
run `./compile.sh` to compile.

Executable `efpmd` will be in `build/efpmd/efpmd` and in

## Running test jobs

Test jobs are contained in `tests` directory.To check the complilation,
do

`cd tests`

`make check`

This will run all the test jobs and report `SUCCESS/FAILURE`. Examine any failed jobs carefully.

42 changes: 6 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ The latest release can be downloaded

## Installation

**See [README-torch.md](README-torch.md) for the up-to-date installation instructions!
For additional CMake instructions, see [README-cmake.md](README-cmake.md).
The section below is outdated.**

To build LIBEFP from source you need the following:

- C compiler (with C99 standard and OpenMP support)
Expand Down Expand Up @@ -65,8 +69,6 @@ Finally, to install everything issue:

make install

For CMake instructions, see [README-cmake.md](README-cmake.md).

## Documentation

For a detailed documentation, tutorials, and EFP bibliography check out
Expand All @@ -85,7 +87,7 @@ Fortran bindings to LIBEFP are available in
The EFPMD program is a molecular simulation package based on LIBEFP.
It supports EFP-only molecular simulations such as geometry optimization
and molecular dynamics. EFPMD is a part of the LIBEFP distribution.
See [this](efpmd/README.md) file for more information.
See [EFPMD manual](https://libefp2.github.io/efpmd.html) for more information.

## Parallel scaling

Expand Down Expand Up @@ -142,36 +144,4 @@ More information can be found in [How to create EFP parameters](https://libefp2.

## References

1. Fragmentation Methods: A Route to Accurate Calculations on Large Systems.
M.S.Gordon, D.G.Fedorov, S.R.Pruitt, L.V.Slipchenko. Chem. Rev. 112, 632-672
(2012).

2. Effective fragment method for modeling intermolecular hydrogen bonding
effects on quantum mechanical calculations. J.H.Jensen, P.N.Day, M.S.Gordon,
H.Basch, D.Cohen, D.R.Garmer, M.Krauss, W.J.Stevens in "Modeling the
Hydrogen Bond" (D.A. Smith, ed.) ACS Symposium Series 569, 1994, pp
139-151.

3. An effective fragment method for modeling solvent effects in quantum
mechanical calculations. P.N.Day, J.H.Jensen, M.S.Gordon, S.P.Webb,
W.J.Stevens, M.Krauss, D.Garmer, H.Basch, D.Cohen. J.Chem.Phys. 105,
1968-1986 (1996).

4. Solvation of the Menshutkin Reaction: A Rigorous test of the Effective
Fragment Model. S.P.Webb, M.S.Gordon. J.Phys.Chem.A 103, 1265-73 (1999).

5. The Effective Fragment Potential Method: a QM-based MM approach to modeling
environmental effects in chemistry. M.S.Gordon, M.A.Freitag,
P.Bandyopadhyay, J.H.Jensen, V.Kairys, W.J.Stevens. J.Phys.Chem.A 105,
293-307 (2001).

6. The Effective Fragment Potential: a general method for predicting
intermolecular interactions. M.S.Gordon, L.V.Slipchenko, H.Li, J.H.Jensen.
Annual Reports in Computational Chemistry, Volume 3, pp 177-193 (2007).

7. Water-benzene interactions: An effective fragment potential and correlated
quantum chemistry study. L.V.Slipchenko, M.S.Gordon. J.Phys.Chem.A 113,
2092-2102 (2009).

8. Damping functions in the effective fragment potential method. L.V.Slipchenko,
M.S.Gordon. Mol.Phys. 107, 999-1016 (2009).
A complete list of references to the EFP method can be found [here](https://libefp2.github.io/papers.html#).
77 changes: 0 additions & 77 deletions bin/cubegen.pl

This file was deleted.

31 changes: 0 additions & 31 deletions bin/trajectory.pl

This file was deleted.

23 changes: 23 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/csh

rm -rf build
mkdir build

if ( "$TORCH_SWITCH" == "ON" ) then
echo "Building with Torch integration..."
echo "TORCH_DIR = ${TORCH_INSTALLED_DIR}"
cd build
setenv TORCH_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=0"
cmake -DCMAKE_INSTALL_PREFIX=${INSTALLATION_DIR} -DCMAKE_PREFIX_PATH=${TORCH_INSTALLED_DIR} -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ..
#cmake -DCMAKE_PREFIX_PATH=${TORCH_INSTALLED_DIR} -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ..
make VERBOSE=1
make install
else
echo "Building without Torch integration..."
cmake -H. -Bbuild -DCMAKE_INSTALL_PREFIX=${INSTALLATION_DIR}
cd build
make VERBOSE=1
make install
endif

echo "Compilation complete. You can now run test jobs as '${INSTALLATION_DIR}/bin/efpmd input.in' from the tests directory."
Loading

0 comments on commit c7377d7

Please sign in to comment.