- Main Page
- Related Pages
- Classes
- Files

- File List

# CustomBondForce.h

    00001 #ifndef OPENMM_CUSTOMBONDEDFORCE_H_
    00002 #define OPENMM_CUSTOMBONDEDFORCE_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) 2008-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 CustomBondForce : public Force {
    00073 public:
    00080     explicit CustomBondForce(const std::string& energy);
    00084     int getNumBonds() const {
    00085         return bonds.size();
    00086     }
    00090     int getNumPerBondParameters() 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 addPerBondParameter(const std::string& name);
    00120     const std::string& getPerBondParameterName(int index) const;
    00127     void setPerBondParameterName(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);
    00172     int addBond(int particle1, int particle2, const std::vector<double>& parameters);
    00181     void getBondParameters(int index, int& particle1, int& particle2, std::vector<double>& parameters) const;
    00190     void setBondParameters(int index, int particle1, int particle2, const std::vector<double>& parameters);
    00201     void updateParametersInContext(Context& context);
    00202 protected:
    00203     ForceImpl* createImpl() const;
    00204 private:
    00205     class BondInfo;
    00206     class BondParameterInfo;
    00207     class GlobalParameterInfo;
    00208     std::string energyExpression;
    00209     std::vector<BondParameterInfo> parameters;
    00210     std::vector<GlobalParameterInfo> globalParameters;
    00211     std::vector<BondInfo> bonds;
    00212 };
    00213
    00218 class CustomBondForce::BondInfo {
    00219 public:
    00220     int particle1, particle2;
    00221     std::vector<double> parameters;
    00222     BondInfo() : particle1(-1), particle2(-1) {
    00223     }
    00224     BondInfo(int particle1, int particle2, const std::vector<double>& parameters) :
    00225             particle1(particle1), particle2(particle2), parameters(parameters) {
    00226     }
    00227 };
    00228
    00233 class CustomBondForce::BondParameterInfo {
    00234 public:
    00235     std::string name;
    00236     BondParameterInfo() {
    00237     }
    00238     BondParameterInfo(const std::string& name) : name(name) {
    00239     }
    00240 };
    00241
    00246 class CustomBondForce::GlobalParameterInfo {
    00247 public:
    00248     std::string name;
    00249     double defaultValue;
    00250     GlobalParameterInfo() {
    00251     }
    00252     GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
    00253     }
    00254 };
    00255
    00256 } // namespace OpenMM
    00257
    00258 #endif /*OPENMM_CUSTOMBONDEDFORCE_H_*/