Skip to content

Commit

Permalink
gmxapi-30 Tutorial / working Jupyter notebook examples
Browse files Browse the repository at this point in the history
Fix typos and bugs so the testing instructions in Dockerfile are true.

Build restraints as static libraries with position independent code to
make the myplugin.so object more portable.
  • Loading branch information
eirrgang committed Jun 6, 2018
1 parent 782daee commit 0b2f9a9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ endif()

# At some point this may be part of a CMake package with several components for which a single CMAKE_INSTALL_PREFIX does
# not make sense, so let's manage the install path separately.
set(GMXPLUGIN_INSTALL_PATH ${GMXPLUGIN_DEFAULT_SITE_PACKAGES}/gmx CACHE PATH
set(GMXPLUGIN_INSTALL_PATH ${GMXPLUGIN_DEFAULT_SITE_PACKAGES} CACHE PATH
"Path to Python module install location (site-packages). For an automatically determined install location based on \
the Python installation, leave undefined or explicitly undefined with -UGMXPLUGIN_INSTALL_PATH and, optionally, set \
GMXPLUGIN_USER_INSTALL on or off to specify the installation's site-packages directory or the 'user' site-packages \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# docker run -ti --name restraint_test sample_restraint
#
# Test with
# docker run --cpus 2 --rm -ti gmxapi/sample_restraint:devel bash -c "cd /home/jovyan/samplerestraint/tests && mpiexec -n 2 python -m mpi4py -m pytest"
# docker run --cpus 2 --rm -ti gmxapi/sample_restraint:devel bash -c "cd /home/jovyan/sample_restraint/tests && mpiexec -n 2 python -m mpi4py -m pytest"
# or replace `gmxapi/sample_restraint:devel` with your local image name


Expand Down
6 changes: 4 additions & 2 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# unit tests and by the Python module target defined in ../pythonmodule/CMakeLists.txt

# Create a shared object library for a simple restraint.
add_library(harmonicpotential SHARED
add_library(harmonicpotential STATIC
harmonicpotential.h
harmonicpotential.cpp)
set_target_properties(harmonicpotential PROPERTIES POSITION_INDEPENDENT_CODE ON)

target_include_directories(harmonicpotential PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Expand All @@ -23,9 +24,10 @@ target_link_libraries(harmonicpotential PRIVATE Gromacs::gmxapi)


# Create a shared object library for our restrained ensemble plugin.
add_library(ensemblepotential SHARED
add_library(ensemblepotential STATIC
ensemblepotential.h
ensemblepotential.cpp)
set_target_properties(ensemblepotential PROPERTIES POSITION_INDEPENDENT_CODE ON)

target_include_directories(ensemblepotential PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Expand Down
28 changes: 28 additions & 0 deletions src/cpp/ensemblepotential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,34 @@ gmx::PotentialPointData EnsembleHarmonic::calculate(gmx::Vector v,
return output;
}

std::unique_ptr<ensemble_input_param_type>
makeEnsembleParams(size_t nbins,
double binWidth,
double minDist,
double maxDist,
const std::vector<double> &experimental,
unsigned int nSamples,
double samplePeriod,
unsigned int nWindows,
double k,
double sigma)
{
using gmx::compat::make_unique;
auto params = make_unique<ensemble_input_param_type>();
params->nBins = nbins;
params->binWidth = binWidth;
params->minDist = minDist;
params->maxDist = maxDist;
params->experimental = experimental;
params->nSamples = nSamples;
params->samplePeriod = samplePeriod;
params->nWindows = nWindows;
params->k = k;
params->sigma = sigma;

return params;
};

EnsembleResourceHandle EnsembleResources::getHandle() const
{
auto handle = EnsembleResourceHandle();
Expand Down
18 changes: 1 addition & 17 deletions src/cpp/ensemblepotential.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,23 +281,7 @@ makeEnsembleParams(size_t nbins,
double samplePeriod,
unsigned int nWindows,
double k,
double sigma)
{
using gmx::compat::make_unique;
auto params = make_unique<ensemble_input_param_type>();
params->nBins = nbins;
params->binWidth = binWidth;
params->minDist = minDist;
params->maxDist = maxDist;
params->experimental = experimental;
params->nSamples = nSamples;
params->samplePeriod = samplePeriod;
params->nWindows = nWindows;
params->k = k;
params->sigma = sigma;

return params;
};
double sigma);

/*!
* \brief a residue-pair bias calculator for use in restrained-ensemble simulations.
Expand Down

0 comments on commit 0b2f9a9

Please sign in to comment.