- Main Page
- Related Pages
- Classes
- Files

- File List

# CustomTorsionForce.h

    00001 #ifndef OPENMM_CUSTOMTORSIONFORCE_H_
    00002 #define OPENMM_CUSTOMTORSIONFORCE_H_
    00003
    00004 /* -------------------------------------------------------------------------- *
    00005  *                                   OpenMM                                   *
    00006  * -------------------------------------------------------------------------- *
    00007  * This is part of the OpenMM molecular simulation toolkit originating from   *
    00008  * Simbios, the NIH National Center for Physics-Based Simulation of           *
    00009  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
    00010  * Medical Research, grant U54 GM072970. See https://simtk.org.               *
    00011  *                                                                            *
    00012  * Portions copyright (c) 2010-2012 Stanford University and the Authors.      *
    00013  * Authors: Peter Eastman                                                     *
    00014  * Contributors:                                                              *
    00015  *                                                                            *
    00016  * Permission is hereby granted, free of charge, to any person obtaining a    *
    00017  * copy of this software and associated documentation files (the "Software"), *
    00018  * to deal in the Software without restriction, including without limitation  *
    00019  * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
    00020  * and/or sell copies of the Software, and to permit persons to whom the      *
    00021  * Software is furnished to do so, subject to the following conditions:       *
    00022  *                                                                            *
    00023  * The above copyright notice and this permission notice shall be included in *
    00024  * all copies or substantial portions of the Software.                        *
    00025  *                                                                            *
    00026  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
    00027  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
    00028  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
    00029  * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
    00030  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
    00031  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
    00032  * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
    00033  * -------------------------------------------------------------------------- */
    00034
    00035 #include "Force.h"
    00036 #include "Vec3.h"
    00037 #include <vector>
    00038 #include "internal/windowsExport.h"
    00039
    00040 namespace OpenMM {
    00041
    00072 class OPENMM_EXPORT CustomTorsionForce : public Force {
    00073 public:
    00080     explicit CustomTorsionForce(const std::string& energy);
    00084     int getNumTorsions() const {
    00085         return torsions.size();
    00086     }
    00090     int getNumPerTorsionParameters() const {
    00091         return parameters.size();
    00092     }
    00096     int getNumGlobalParameters() const {
    00097         return globalParameters.size();
    00098     }
    00102     const std::string& getEnergyFunction() const;
    00106     void setEnergyFunction(const std::string& energy);
    00113     int addPerTorsionParameter(const std::string& name);
    00120     const std::string& getPerTorsionParameterName(int index) const;
    00127     void setPerTorsionParameterName(int index, const std::string& name);
    00135     int addGlobalParameter(const std::string& name, double defaultValue);
    00142     const std::string& getGlobalParameterName(int index) const;
    00149     void setGlobalParameterName(int index, const std::string& name);
    00156     double getGlobalParameterDefaultValue(int index) const;
    00163     void setGlobalParameterDefaultValue(int index, double defaultValue);
    00174     int addTorsion(int particle1, int particle2, int particle3, int particle4, const std::vector<double>& parameters);
    00185     void getTorsionParameters(int index, int& particle1, int& particle2, int& particle3, int& particle4, std::vector<double>& parameters) const;
    00196     void setTorsionParameters(int index, int particle1, int particle2, int particle3, int particle4, const std::vector<double>& parameters);
    00207     void updateParametersInContext(Context& context);
    00208 protected:
    00209     ForceImpl* createImpl() const;
    00210 private:
    00211     class TorsionInfo;
    00212     class TorsionParameterInfo;
    00213     class GlobalParameterInfo;
    00214     std::string energyExpression;
    00215     std::vector<TorsionParameterInfo> parameters;
    00216     std::vector<GlobalParameterInfo> globalParameters;
    00217     std::vector<TorsionInfo> torsions;
    00218 };
    00219
    00224 class CustomTorsionForce::TorsionInfo {
    00225 public:
    00226     int particle1, particle2, particle3, particle4;
    00227     std::vector<double> parameters;
    00228     TorsionInfo() : particle1(-1), particle2(-1), particle3(-1), particle4(-1) {
    00229     }
    00230     TorsionInfo(int particle1, int particle2, int particle3, int particle4, const std::vector<double>& parameters) :
    00231             particle1(particle1), particle2(particle2), particle3(particle3), particle4(particle4), parameters(parameters) {
    00232     }
    00233 };
    00234
    00239 class CustomTorsionForce::TorsionParameterInfo {
    00240 public:
    00241     std::string name;
    00242     TorsionParameterInfo() {
    00243     }
    00244     TorsionParameterInfo(const std::string& name) : name(name) {
    00245     }
    00246 };
    00247
    00252 class CustomTorsionForce::GlobalParameterInfo {
    00253 public:
    00254     std::string name;
    00255     double defaultValue;
    00256     GlobalParameterInfo() {
    00257     }
    00258     GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
    00259     }
    00260 };
    00261
    00262 } // namespace OpenMM
    00263
    00264 #endif /*OPENMM_CUSTOMTORSIONFORCE_H_*/