- Main Page
- Related Pages
- Classes
- Files

- File List

# CustomCompoundBondForce.h

    00001 #ifndef OPENMM_CUSTOMCOMPOUNDBONDFORCE_H_
    00002 #define OPENMM_CUSTOMCOMPOUNDBONDFORCE_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-2014 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 "TabulatedFunction.h"
    00036 #include "Force.h"
    00037 #include "Vec3.h"
    00038 #include <vector>
    00039 #include "internal/windowsExport.h"
    00040
    00041 namespace OpenMM {
    00042
    00099 class OPENMM_EXPORT CustomCompoundBondForce : public Force {
    00100 public:
    00109     explicit CustomCompoundBondForce(int numParticles, const std::string& energy);
    00110     ~CustomCompoundBondForce();
    00114     int getNumParticlesPerBond() const {
    00115         return particlesPerBond;
    00116     }
    00120     int getNumBonds() const {
    00121         return bonds.size();
    00122     }
    00126     int getNumPerBondParameters() const {
    00127         return bondParameters.size();
    00128     }
    00132     int getNumGlobalParameters() const {
    00133         return globalParameters.size();
    00134     }
    00138     int getNumTabulatedFunctions() const {
    00139         return functions.size();
    00140     }
    00146     int getNumFunctions() const {
    00147         return functions.size();
    00148     }
    00152     const std::string& getEnergyFunction() const;
    00156     void setEnergyFunction(const std::string& energy);
    00163     int addPerBondParameter(const std::string& name);
    00170     const std::string& getPerBondParameterName(int index) const;
    00177     void setPerBondParameterName(int index, const std::string& name);
    00185     int addGlobalParameter(const std::string& name, double defaultValue);
    00192     const std::string& getGlobalParameterName(int index) const;
    00199     void setGlobalParameterName(int index, const std::string& name);
    00206     double getGlobalParameterDefaultValue(int index) const;
    00213     void setGlobalParameterDefaultValue(int index, double defaultValue);
    00221     int addBond(const std::vector<int>& particles, const std::vector<double>& parameters);
    00229     void getBondParameters(int index, std::vector<int>& particles, std::vector<double>& parameters) const;
    00237     void setBondParameters(int index, const std::vector<int>& particles, const std::vector<double>& parameters);
    00247     int addTabulatedFunction(const std::string& name, TabulatedFunction* function);
    00254     const TabulatedFunction& getTabulatedFunction(int index) const;
    00261     TabulatedFunction& getTabulatedFunction(int index);
    00268     const std::string& getTabulatedFunctionName(int index) const;
    00274     int addFunction(const std::string& name, const std::vector<double>& values, double min, double max);
    00281     void getFunctionParameters(int index, std::string& name, std::vector<double>& values, double& min, double& max) const;
    00288     void setFunctionParameters(int index, const std::string& name, const std::vector<double>& values, double min, double max);
    00299     void updateParametersInContext(Context& context);
    00300 protected:
    00301     ForceImpl* createImpl() const;
    00302 private:
    00303     class BondInfo;
    00304     class BondParameterInfo;
    00305     class GlobalParameterInfo;
    00306     class FunctionInfo;
    00307     int particlesPerBond;
    00308     std::string energyExpression;
    00309     std::vector<BondParameterInfo> bondParameters;
    00310     std::vector<GlobalParameterInfo> globalParameters;
    00311     std::vector<BondInfo> bonds;
    00312     std::vector<FunctionInfo> functions;
    00313 };
    00314
    00319 class CustomCompoundBondForce::BondInfo {
    00320 public:
    00321     std::vector<int> particles;
    00322     std::vector<double> parameters;
    00323     BondInfo() {
    00324     }
    00325     BondInfo(const std::vector<int>& particles, const std::vector<double>& parameters) :
    00326         particles(particles), parameters(parameters) {
    00327     }
    00328 };
    00329
    00334 class CustomCompoundBondForce::BondParameterInfo {
    00335 public:
    00336     std::string name;
    00337     BondParameterInfo() {
    00338     }
    00339     BondParameterInfo(const std::string& name) : name(name) {
    00340     }
    00341 };
    00342
    00347 class CustomCompoundBondForce::GlobalParameterInfo {
    00348 public:
    00349     std::string name;
    00350     double defaultValue;
    00351     GlobalParameterInfo() {
    00352     }
    00353     GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
    00354     }
    00355 };
    00356
    00361 class CustomCompoundBondForce::FunctionInfo {
    00362 public:
    00363     std::string name;
    00364     TabulatedFunction* function;
    00365     FunctionInfo() {
    00366     }
    00367     FunctionInfo(const std::string& name, TabulatedFunction* function) : name(name), function(function) {
    00368     }
    00369 };
    00370
    00371 } // namespace OpenMM
    00372
    00373 #endif /*OPENMM_CUSTOMCOMPOUNDBONDFORCE_H_*/