Skip to content

Commit fa80099

Browse files
authored
Merge pull request #6 from d-SEAMS/noGSL
ENH: No GSL
2 parents f4cd021 + 44b289d commit fa80099

File tree

9 files changed

+77
-35
lines changed

9 files changed

+77
-35
lines changed

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
the data-sets (trajectories) <a
2222
href="https://figshare.com/projects/d-SEAMS_Datasets/73545">from figshare</a>.
2323

24-
\warning **If** you are unwilling to use the `nix` build system, then **please note** that you must manage the dependencies MANUALLY, including the compiler versions.
24+
\warning **If** you are unwilling to use the `nix` build system, then **please note** that you must manage the dependencies MANUALLY, including the compiler versions. Optionally, use the provided `conda` environment.
2525

2626
# Citation
2727

@@ -49,15 +49,44 @@ The corresponding `bibtex` entry is:
4949
url={https://doi.org/10.1021/acs.jcim.0c00031}
5050
}
5151

52-
# Compilation with Nix
52+
# Compilation
5353

5454
We use a deterministic build system to generate both bug reports and uniform
5555
usage statistics. This also handles the `lua` scripting engine.
5656

5757
\note The lua functions are documented on the [on the API Docs](https://docs.dseams.info/md_markdown_luafunctions)
5858

59+
We also provide a `conda` environment as a fallback, which is also recommended for MacOS users.
60+
5961
## Build
6062

63+
### Conda
64+
65+
Although we strongly suggest using `nix`, for MacOS systems, the following
66+
instructions may be more suitable. We will assume the presence of [micromamba](https://mamba.readthedocs.io/en/latest/installation.html):
67+
68+
```bash
69+
micromamba create -f environment.yml
70+
micromamba activate dseams
71+
```
72+
73+
Now the installation can proceed.
74+
75+
\note we do not install a new version of `cmake` within the `conda` environment because of conflicts with `lua`
76+
77+
```bash
78+
mkdir build
79+
cd build
80+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=YES -DCMAKE_INSTALL_PREFIX:PATH=$CONDA_PREFIX ../
81+
make -j$(nproc)
82+
make install
83+
```
84+
85+
We have opted to install into the `conda` environment, if this is not the
86+
intended behavior, use `/usr/local` instead.
87+
88+
### Nix
89+
6190
Since this project is built with `nix`, we can simply do the following from the
6291
root directory (longer method):
6392

@@ -87,6 +116,14 @@ nix-env -if . # Required
87116
yodaStruct -c lua_inputs/config.yml
88117
```
89118

119+
### Usage
120+
121+
Having installed the `yodaStruct` binary and library, we can now use it.
122+
123+
```bash
124+
yodaStruct -c lua_inputs/config.yml
125+
```
126+
90127
\note The paths in the `.yml` should be **relative to the folder from which the binary is called**.
91128

92129
If you're confused about how to handle the relative paths, run the command `yodaStruct -c lua_inputs/config.yml` in the top-level directory, and set the paths relative to the top-level directory. This is the convention used in the examples as well.

environment.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# To use:
2+
#
3+
# $ micromamba create -f environment.yml
4+
# $ micromamba activate dseams
5+
#
6+
name: dseams
7+
channels:
8+
- conda-forge
9+
dependencies:
10+
- compilers
11+
- gfortran
12+
- catch2
13+
- fmt
14+
- yaml-cpp
15+
- liblapack
16+
- libblas
17+
- boost-cpp
18+
- cmake
19+
- lua-luafilesystem
20+
# Pinned
21+
- eigen==3.3.9
22+
- lua==5.2.*

nix/yodaStruct.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
, blas
2222
, lib
2323
, boost
24-
, gsl
2524
, cmake }:
2625
clangStdenv.mkDerivation {
2726
name = "yodaStruct";
@@ -38,7 +37,6 @@
3837
eigen
3938
catch2
4039
boost
41-
gsl
4240
liblapack
4341
blas
4442
lua

src/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
1717
include(FindBLAS)
1818
include(FindLAPACK)
1919
include(FindBoost)
20-
include(FindGSL)
2120
add_compile_options(
2221
# "-Wall" "-Wpedantic" "-Wextra" "-fexceptions"
2322
"$<$<CONFIG:Debug>:-O0;-g3;-ggdb>"
@@ -34,12 +33,10 @@ include_directories(
3433
${LUA_INCLUDE_DIR}
3534
${Boost_INCLUDE_DIRS}
3635
${Eigen3_INCLUDE_DIRS}
37-
${GSL_INCLUDE_DIRS}
3836
)
3937
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
4038
find_package(
4139
"Lua" REQUIRED
42-
"GSL" REQUIRED
4340
"Boost" REQUIRED COMPONENTS system filesystem
4441
"Eigen3 3.3" REQUIRED
4542
"yaml-cpp"
@@ -52,8 +49,6 @@ target_link_libraries(
5249
${Boost_LIBRARIES}
5350
${Eigen3_LIBRARIES}
5451
${LUA_LIBRARIES}
55-
${GSL_LIBRARIES}
56-
stdc++fs
5752
fmt
5853
yaml-cpp
5954
yodaLib

src/bond.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,12 @@ bond::populateHbonds(std::string filename,
292292
} // end of applying PBCs to the O-H and O--O vectors
293293
//
294294
// Get the angle between the O--O and O-H vectors
295-
double gslAngle = gen::gslVecAngle(ooVec, ohVec);
296-
double gslAngleDeg = gen::radDeg(gslAngle);
295+
double eigenAngle = gen::eigenVecAngle(ooVec, ohVec);
296+
double eigenAngleDeg = gen::radDeg(eigenAngle);
297297

298298
//
299299
// A hydrogen bond is formed if the angle is less than 30 degrees
300-
if (gslAngleDeg > angleCutoff) {
300+
if (eigenAngleDeg > angleCutoff) {
301301
continue;
302302
} // not a hydrogen bond
303303

src/generic.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,27 +140,18 @@ int gen::unwrappedCoordShift(
140140

141141
/**
142142
* @details Function for obtaining the angle between two input vectors
143-
* (std::vector). Internally, the vectors are converted to GSL vectors. The dot
144-
* product between the input vectors is used to calculate the angle between
143+
* (std::vector). Internally, the vectors are converted to Eigen vectors. The
144+
* dot product between the input vectors is used to calculate the angle between
145145
* them.
146146
* @param[in] OO The O--O vector (but can be any vector, in general).
147147
* @param[in] OH The O-H vector (but can be any vector, in general).
148148
* @return The output angle between the input vectors, in radians
149149
*/
150-
double gen::gslVecAngle(std::vector<double> OO, std::vector<double> OH) {
151-
gsl_vector *gOO = gsl_vector_alloc(3);
152-
gsl_vector *gOH = gsl_vector_alloc(3);
153-
double norm_gOO, norm_gOH, xDummy, angle;
154-
for (int i = 0; i < 3; i++) {
155-
gsl_vector_set(gOO, i, OO[i]);
156-
gsl_vector_set(gOH, i, OH[i]);
157-
}
158-
norm_gOO = gsl_blas_dnrm2(gOO);
159-
norm_gOH = gsl_blas_dnrm2(gOH);
160-
gsl_blas_ddot(gOO, gOH, &xDummy);
161-
angle = acos(xDummy / (norm_gOO * norm_gOH));
162-
gsl_vector_free(gOO);
163-
gsl_vector_free(gOH);
150+
double gen::eigenVecAngle(std::vector<double> OO, std::vector<double> OH) {
151+
Eigen::Vector3d eigOO = Eigen::Map<Eigen::Vector3d>(OO.data(), OO.size());
152+
Eigen::Vector3d eigOH = Eigen::Map<Eigen::Vector3d>(OH.data(), OH.size());
153+
double angle;
154+
angle = acos(eigOO.dot(eigOH) / (eigOO.norm() * eigOH.norm()));
164155
return angle;
165156
}
166157

src/include/internal/generic.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
// Boost
2020
#include <boost/math/constants/constants.hpp>
21-
#include <gsl/gsl_blas.h>
21+
// Eigen
22+
#include <eigen3/Eigen/Core>
23+
#include <eigen3/Eigen/Dense>
2224

2325
/** @file generic.hpp
2426
* @brief File for containing generic or common functions.
@@ -54,8 +56,8 @@ const double pi = boost::math::constants::pi<double>();
5456
*/
5557
inline double radDeg(double angle) { return (angle * 180) / gen::pi; }
5658

57-
//! GSL for getting the angle (in radians) between the O--O and O-H vectors
58-
double gslVecAngle(std::vector<double> OO, std::vector<double> OH);
59+
//! Eigen function for getting the angle (in radians) between the O--O and O-H vectors
60+
double eigenVecAngle(std::vector<double> OO, std::vector<double> OH);
5961

6062
//! Get the average, after excluding the outliers, using quartiles
6163
double getAverageWithoutOutliers(std::vector<double> inpVec);

src/include/internal/mol_sys.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <string>
2121
#include <sys/stat.h>
2222
#include <vector>
23+
#include<unordered_map>
2324

2425
// For debugging, instantiate the unordered map [consider removal for
2526
// production]

tests/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ add_executable(yodaStruct_test
3131
# include(FindBLAS)
3232
# include(FindLAPACK)
3333
# include(FindBoost)
34-
include(FindGSL)
3534

3635
# Find packages
3736
find_package(
3837
"Lua" REQUIRED
3938
"Boost" REQUIRED
4039
"Eigen3 3.3" REQUIRED
4140
"Catch2" REQUIRED
42-
"GSL" REQUIRED
4341
"yaml-cpp"
4442
"fmt"
4543
)
@@ -49,7 +47,6 @@ target_link_libraries(yodaStruct_test
4947
${Boost_LIBRARIES}
5048
${Eigen3_LIBRARIES}
5149
${LUA_LIBRARIES}
52-
${GSL_LIBRARIES}
5350
fmt
5451
yaml-cpp
5552
yodaLib
@@ -60,7 +57,6 @@ target_link_libraries(yodaStruct_test
6057
include_directories(
6158
${PROJECT_SOURCE_DIR}/src/include/internal
6259
${PROJECT_SOURCE_DIR}/src/include/external
63-
${GSL_INCLUDE_DIRS}
6460
${Eigen3_INCLUDE_DIRS}
6561
)
6662
# Run unit tests

0 commit comments

Comments
 (0)