diff --git a/modules/mol/mm/doc/settings.rst b/modules/mol/mm/doc/settings.rst index d8b3a13b4a713791172284bb79ed797374f7ef70..acb3938eebdf1bbf6369cd4383a063126b3ce110 100644 --- a/modules/mol/mm/doc/settings.rst +++ b/modules/mol/mm/doc/settings.rst @@ -231,12 +231,14 @@ of the :class:`Simulation` object. Path where OpenMM specific plugins are searched. If you want to use other platforms than Reference, this has to be set. - default: "/usr/local/openmm/lib/plugins" + Defaults to *OPEN_MM_PLUGIN_DIR* which was set when + :ref:`configuring the compilation <cmake-flags>`. .. attribute:: custom_plugin_directory - Path where custom plugins are searched for. - default: "/usr/local/openmm/lib/plugins" + Path where custom plugins are searched for. Defaults to + "share/openstructure/openmm_plugins" within the OST installation or to + :attr:`openmm_plugin_directory` if the OST path could not be determined. diff --git a/modules/mol/mm/src/settings.hh.in b/modules/mol/mm/src/settings.hh.in index 50dd9b71abcbd4eb2e9f9229642f40a4843585a1..d94e516424b97402367720221b2c1c3eaf7b3b55 100644 --- a/modules/mol/mm/src/settings.hh.in +++ b/modules/mol/mm/src/settings.hh.in @@ -30,6 +30,9 @@ #include <limits> #include <ost/mol/residue_handle.hh> #include <ost/mol/mm/forcefield.hh> +#include <ost/platform.hh> +#include <boost/filesystem/path.hpp> +#include <ost/log.hh> namespace OpenMM{ class Integrator;//hacky way of telling the Integrator us around @@ -91,7 +94,7 @@ typedef std::map<String,String> PropertyMap; struct Settings{ - Settings(): add_bonds(true), + Settings(): add_bonds(true), add_angles(true), add_dihedrals(true), add_impropers(true), @@ -134,10 +137,22 @@ struct Settings{ reaction_field_dielectric(78.3), use_dispersion_correction(true), keep_ff_specific_naming(true), - openmm_plugin_directory("@OPEN_MM_PLUGIN_DIR@"), - custom_plugin_directory("@STAGE_DIR@/share/openstructure/openmm_plugins") + openmm_plugin_directory("@OPEN_MM_PLUGIN_DIR@") { + + try { + // try to guess custom_plugin_directory + boost::filesystem::path shared_path(GetSharedDataPath()); + custom_plugin_directory = (shared_path / "openmm_plugins").string(); + } catch (std::runtime_error& e) { + // fallback to OpenMM path (used to be default in OST before 1.7) + LOG_WARNING("Failed to find shared data path for openmm_plugins. " + "Please set custom_plugin_directory of Settings object " + "manually or ensure that OST_ROOT is set properly. " + "Caught exception: " << e.what()); + custom_plugin_directory = openmm_plugin_directory; + } - { } + } // bool add_bonds;