- Main Page
- Related Pages
- Classes
- Files

- File List

# CustomGBForce.h

    00001 #ifndef OPENMM_CUSTOMGBFORCE_H_
    00002 #define OPENMM_CUSTOMGBFORCE_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 <map>
    00039 #include <set>
    00040 #include <utility>
    00041 #include <vector>
    00042 #include "internal/windowsExport.h"
    00043
    00044 namespace OpenMM {
    00045
    00142 class OPENMM_EXPORT CustomGBForce : public Force {
    00143 public:
    00147     enum NonbondedMethod {
    00152         NoCutoff = 0,
    00156         CutoffNonPeriodic = 1,
    00161         CutoffPeriodic = 2,
    00162     };
    00166     enum ComputationType {
    00170         SingleParticle = 0,
    00174         ParticlePair = 1,
    00179         ParticlePairNoExclusions = 2
    00180     };
    00184     CustomGBForce();
    00185     ~CustomGBForce();
    00189     int getNumParticles() const {
    00190         return particles.size();
    00191     }
    00195     int getNumExclusions() const {
    00196         return exclusions.size();
    00197     }
    00201     int getNumPerParticleParameters() const {
    00202         return parameters.size();
    00203     }
    00207     int getNumGlobalParameters() const {
    00208         return globalParameters.size();
    00209     }
    00213     int getNumTabulatedFunctions() const {
    00214         return functions.size();
    00215     }
    00221     int getNumFunctions() const {
    00222         return functions.size();
    00223     }
    00227     int getNumComputedValues() const {
    00228         return computedValues.size();
    00229     }
    00233     int getNumEnergyTerms() const {
    00234         return energyTerms.size();
    00235     }
    00239     NonbondedMethod getNonbondedMethod() const;
    00243     void setNonbondedMethod(NonbondedMethod method);
    00250     double getCutoffDistance() const;
    00257     void setCutoffDistance(double distance);
    00264     int addPerParticleParameter(const std::string& name);
    00271     const std::string& getPerParticleParameterName(int index) const;
    00278     void setPerParticleParameterName(int index, const std::string& name);
    00286     int addGlobalParameter(const std::string& name, double defaultValue);
    00293     const std::string& getGlobalParameterName(int index) const;
    00300     void setGlobalParameterName(int index, const std::string& name);
    00307     double getGlobalParameterDefaultValue(int index) const;
    00314     void setGlobalParameterDefaultValue(int index, double defaultValue);
    00322     int addParticle(const std::vector<double>& parameters);
    00329     void getParticleParameters(int index, std::vector<double>& parameters) const;
    00336     void setParticleParameters(int index, const std::vector<double>& parameters);
    00353     int addComputedValue(const std::string& name, const std::string& expression, ComputationType type);
    00371     void getComputedValueParameters(int index, std::string& name, std::string& expression, ComputationType& type) const;
    00389     void setComputedValueParameters(int index, const std::string& name, const std::string& expression, ComputationType type);
    00405     int addEnergyTerm(const std::string& expression, ComputationType type);
    00422     void getEnergyTermParameters(int index, std::string& expression, ComputationType& type) const;
    00439     void setEnergyTermParameters(int index, const std::string& expression, ComputationType type);
    00447     int addExclusion(int particle1, int particle2);
    00455     void getExclusionParticles(int index, int& particle1, int& particle2) const;
    00463     void setExclusionParticles(int index, int particle1, int particle2);
    00473     int addTabulatedFunction(const std::string& name, TabulatedFunction* function);
    00480     const TabulatedFunction& getTabulatedFunction(int index) const;
    00487     TabulatedFunction& getTabulatedFunction(int index);
    00494     const std::string& getTabulatedFunctionName(int index) const;
    00500     int addFunction(const std::string& name, const std::vector<double>& values, double min, double max);
    00507     void getFunctionParameters(int index, std::string& name, std::vector<double>& values, double& min, double& max) const;
    00514     void setFunctionParameters(int index, const std::string& name, const std::vector<double>& values, double min, double max);
    00525     void updateParametersInContext(Context& context);
    00526 protected:
    00527     ForceImpl* createImpl() const;
    00528 private:
    00529     class ParticleInfo;
    00530     class PerParticleParameterInfo;
    00531     class GlobalParameterInfo;
    00532     class ExclusionInfo;
    00533     class FunctionInfo;
    00534     class ComputationInfo;
    00535     NonbondedMethod nonbondedMethod;
    00536     double cutoffDistance;
    00537     std::vector<PerParticleParameterInfo> parameters;
    00538     std::vector<GlobalParameterInfo> globalParameters;
    00539     std::vector<ParticleInfo> particles;
    00540     std::vector<ExclusionInfo> exclusions;
    00541     std::vector<FunctionInfo> functions;
    00542     std::vector<ComputationInfo> computedValues;
    00543     std::vector<ComputationInfo> energyTerms;
    00544 };
    00545
    00550 class CustomGBForce::ParticleInfo {
    00551 public:
    00552     std::vector<double> parameters;
    00553     ParticleInfo() {
    00554     }
    00555     ParticleInfo(const std::vector<double>& parameters) : parameters(parameters) {
    00556     }
    00557 };
    00558
    00563 class CustomGBForce::PerParticleParameterInfo {
    00564 public:
    00565     std::string name;
    00566     PerParticleParameterInfo() {
    00567     }
    00568     PerParticleParameterInfo(const std::string& name) : name(name) {
    00569     }
    00570 };
    00571
    00576 class CustomGBForce::GlobalParameterInfo {
    00577 public:
    00578     std::string name;
    00579     double defaultValue;
    00580     GlobalParameterInfo() {
    00581     }
    00582     GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
    00583     }
    00584 };
    00585
    00590 class CustomGBForce::ExclusionInfo {
    00591 public:
    00592     int particle1, particle2;
    00593     ExclusionInfo() {
    00594         particle1 = particle2 = -1;
    00595     }
    00596     ExclusionInfo(int particle1, int particle2) :
    00597         particle1(particle1), particle2(particle2) {
    00598     }
    00599 };
    00600
    00605 class CustomGBForce::FunctionInfo {
    00606 public:
    00607     std::string name;
    00608     TabulatedFunction* function;
    00609     FunctionInfo() {
    00610     }
    00611     FunctionInfo(const std::string& name, TabulatedFunction* function) : name(name), function(function) {
    00612     }
    00613 };
    00614
    00619 class CustomGBForce::ComputationInfo {
    00620 public:
    00621     std::string name;
    00622     std::string expression;
    00623     CustomGBForce::ComputationType type;
    00624     ComputationInfo() {
    00625     }
    00626     ComputationInfo(const std::string& name, const std::string& expression, CustomGBForce::ComputationType type) :
    00627         name(name), expression(expression), type(type) {
    00628     }
    00629 };
    00630
    00631 } // namespace OpenMM
    00632
    00633 #endif /*OPENMM_CUSTOMGBFORCE_H_*/