- Main Page
- Related Pages
- Classes
- Files

- File List

# CustomNonbondedForce.h

    00001 #ifndef OPENMM_CUSTOMNONBONDEDFORCE_H_
    00002 #define OPENMM_CUSTOMNONBONDEDFORCE_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
    00132 class OPENMM_EXPORT CustomNonbondedForce : public Force {
    00133 public:
    00137     enum NonbondedMethod {
    00142         NoCutoff = 0,
    00146         CutoffNonPeriodic = 1,
    00151         CutoffPeriodic = 2,
    00152     };
    00159     explicit CustomNonbondedForce(const std::string& energy);
    00160     CustomNonbondedForce(const CustomNonbondedForce& rhs); // copy constructor
    00161     ~CustomNonbondedForce();
    00165     int getNumParticles() const {
    00166         return particles.size();
    00167     }
    00171     int getNumExclusions() const {
    00172         return exclusions.size();
    00173     }
    00177     int getNumPerParticleParameters() const {
    00178         return parameters.size();
    00179     }
    00183     int getNumGlobalParameters() const {
    00184         return globalParameters.size();
    00185     }
    00189     int getNumTabulatedFunctions() const {
    00190         return functions.size();
    00191     }
    00197     int getNumFunctions() const {
    00198         return functions.size();
    00199     }
    00203     int getNumInteractionGroups() const {
    00204         return interactionGroups.size();
    00205     }
    00209     const std::string& getEnergyFunction() const;
    00213     void setEnergyFunction(const std::string& energy);
    00217     NonbondedMethod getNonbondedMethod() const;
    00221     void setNonbondedMethod(NonbondedMethod method);
    00228     double getCutoffDistance() const;
    00235     void setCutoffDistance(double distance);
    00240     bool getUseSwitchingFunction() const;
    00245     void setUseSwitchingFunction(bool use);
    00250     double getSwitchingDistance() const;
    00255     void setSwitchingDistance(double distance);
    00260     bool getUseLongRangeCorrection() const;
    00265     void setUseLongRangeCorrection(bool use);
    00272     int addPerParticleParameter(const std::string& name);
    00279     const std::string& getPerParticleParameterName(int index) const;
    00286     void setPerParticleParameterName(int index, const std::string& name);
    00294     int addGlobalParameter(const std::string& name, double defaultValue);
    00301     const std::string& getGlobalParameterName(int index) const;
    00308     void setGlobalParameterName(int index, const std::string& name);
    00315     double getGlobalParameterDefaultValue(int index) const;
    00322     void setGlobalParameterDefaultValue(int index, double defaultValue);
    00330     int addParticle(const std::vector<double>& parameters);
    00337     void getParticleParameters(int index, std::vector<double>& parameters) const;
    00344     void setParticleParameters(int index, const std::vector<double>& parameters);
    00354     int addExclusion(int particle1, int particle2);
    00362     void getExclusionParticles(int index, int& particle1, int& particle2) const;
    00370     void setExclusionParticles(int index, int particle1, int particle2);
    00379     void createExclusionsFromBonds(const std::vector<std::pair<int, int> >& bonds, int bondCutoff);
    00389     int addTabulatedFunction(const std::string& name, TabulatedFunction* function);
    00396     const TabulatedFunction& getTabulatedFunction(int index) const;
    00403     TabulatedFunction& getTabulatedFunction(int index);
    00410     const std::string& getTabulatedFunctionName(int index) const;
    00416     int addFunction(const std::string& name, const std::vector<double>& values, double min, double max);
    00423     void getFunctionParameters(int index, std::string& name, std::vector<double>& values, double& min, double& max) const;
    00430     void setFunctionParameters(int index, const std::string& name, const std::vector<double>& values, double min, double max);
    00438     int addInteractionGroup(const std::set<int>& set1, const std::set<int>& set2);
    00446     void getInteractionGroupParameters(int index, std::set<int>& set1, std::set<int>& set2) const;
    00454     void setInteractionGroupParameters(int index, const std::set<int>& set1, const std::set<int>& set2);
    00466     void updateParametersInContext(Context& context);
    00467 protected:
    00468     ForceImpl* createImpl() const;
    00469 private:
    00470     // REMEMBER TO UPDATE THE COPY CONSTRUCTOR IF YOU ADD ANY NEW FIELDS !!
    00471     class ParticleInfo;
    00472     class PerParticleParameterInfo;
    00473     class GlobalParameterInfo;
    00474     class ExclusionInfo;
    00475     class FunctionInfo;
    00476     class InteractionGroupInfo;
    00477     NonbondedMethod nonbondedMethod;
    00478     double cutoffDistance, switchingDistance;
    00479     bool useSwitchingFunction, useLongRangeCorrection;
    00480     std::string energyExpression;
    00481     std::vector<PerParticleParameterInfo> parameters;
    00482     std::vector<GlobalParameterInfo> globalParameters;
    00483     std::vector<ParticleInfo> particles;
    00484     std::vector<ExclusionInfo> exclusions;
    00485     std::vector<FunctionInfo> functions;
    00486     std::vector<InteractionGroupInfo> interactionGroups;
    00487 };
    00488
    00493 class CustomNonbondedForce::ParticleInfo {
    00494 public:
    00495     std::vector<double> parameters;
    00496     ParticleInfo() {
    00497     }
    00498     ParticleInfo(const std::vector<double>& parameters) : parameters(parameters) {
    00499     }
    00500 };
    00501
    00506 class CustomNonbondedForce::PerParticleParameterInfo {
    00507 public:
    00508     std::string name;
    00509     PerParticleParameterInfo() {
    00510     }
    00511     PerParticleParameterInfo(const std::string& name) : name(name) {
    00512     }
    00513 };
    00514
    00519 class CustomNonbondedForce::GlobalParameterInfo {
    00520 public:
    00521     std::string name;
    00522     double defaultValue;
    00523     GlobalParameterInfo() {
    00524     }
    00525     GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
    00526     }
    00527 };
    00528
    00533 class CustomNonbondedForce::ExclusionInfo {
    00534 public:
    00535     int particle1, particle2;
    00536     ExclusionInfo() {
    00537         particle1 = particle2 = -1;
    00538     }
    00539     ExclusionInfo(int particle1, int particle2) :
    00540         particle1(particle1), particle2(particle2) {
    00541     }
    00542 };
    00543
    00548 class CustomNonbondedForce::FunctionInfo {
    00549 public:
    00550     std::string name;
    00551     TabulatedFunction* function;
    00552     FunctionInfo() {
    00553     }
    00554     FunctionInfo(const std::string& name, TabulatedFunction* function) : name(name), function(function) {
    00555     }
    00556 };
    00557
    00562 class CustomNonbondedForce::InteractionGroupInfo {
    00563 public:
    00564     std::set<int> set1, set2;
    00565     InteractionGroupInfo() {
    00566     }
    00567     InteractionGroupInfo(const std::set<int>& set1, const std::set<int>& set2) :
    00568         set1(set1), set2(set2) {
    00569     }
    00570 };
    00571
    00572 } // namespace OpenMM
    00573
    00574 #endif /*OPENMM_CUSTOMNONBONDEDFORCE_H_*/