- Main Page
- Related Pages
- Classes
- Files

- File List

# CustomManyParticleForce.h

    00001 #ifndef OPENMM_CUSTOMTHREEBODYFORCE_H_
    00002 #define OPENMM_CUSTOMTHREEBODYFORCE_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 "Force.h"
    00036 #include "TabulatedFunction.h"
    00037 #include "internal/windowsExport.h"
    00038 #include <set>
    00039 #include <string>
    00040 #include <vector>
    00041
    00042 namespace OpenMM {
    00043
    00162 class OPENMM_EXPORT CustomManyParticleForce : public Force {
    00163 public:
    00167     enum NonbondedMethod {
    00172         NoCutoff = 0,
    00176         CutoffNonPeriodic = 1,
    00181         CutoffPeriodic = 2,
    00182     };
    00187     enum PermutationMode {
    00194         SinglePermutation = 0,
    00201         UniqueCentralParticle = 1
    00202     };
    00210     explicit CustomManyParticleForce(int particlesPerSet, const std::string& energy);
    00211     ~CustomManyParticleForce();
    00215     int getNumParticlesPerSet() const {
    00216         return particlesPerSet;
    00217     }
    00221     int getNumParticles() const {
    00222         return particles.size();
    00223     }
    00227     int getNumExclusions() const {
    00228         return exclusions.size();
    00229     }
    00233     int getNumPerParticleParameters() const {
    00234         return particleParameters.size();
    00235     }
    00239     int getNumGlobalParameters() const {
    00240         return globalParameters.size();
    00241     }
    00245     int getNumTabulatedFunctions() const {
    00246         return functions.size();
    00247     }
    00251     const std::string& getEnergyFunction() const;
    00255     void setEnergyFunction(const std::string& energy);
    00259     NonbondedMethod getNonbondedMethod() const;
    00263     void setNonbondedMethod(NonbondedMethod method);
    00267     PermutationMode getPermutationMode() const;
    00271     void setPermutationMode(PermutationMode mode);
    00278     double getCutoffDistance() const;
    00285     void setCutoffDistance(double distance);
    00292     int addPerParticleParameter(const std::string& name);
    00299     const std::string& getPerParticleParameterName(int index) const;
    00306     void setPerParticleParameterName(int index, const std::string& name);
    00314     int addGlobalParameter(const std::string& name, double defaultValue);
    00321     const std::string& getGlobalParameterName(int index) const;
    00328     void setGlobalParameterName(int index, const std::string& name);
    00335     double getGlobalParameterDefaultValue(int index) const;
    00342     void setGlobalParameterDefaultValue(int index, double defaultValue);
    00351     int addParticle(const std::vector<double>& parameters, int type=0);
    00359     void getParticleParameters(int index, std::vector<double>& parameters, int& type) const;
    00367     void setParticleParameters(int index, const std::vector<double>& parameters, int type);
    00377     int addExclusion(int particle1, int particle2);
    00385     void getExclusionParticles(int index, int& particle1, int& particle2) const;
    00393     void setExclusionParticles(int index, int particle1, int particle2);
    00402     void createExclusionsFromBonds(const std::vector<std::pair<int, int> >& bonds, int bondCutoff);
    00411     void getTypeFilter(int index, std::set<int>& types) const;
    00420     void setTypeFilter(int index, const std::set<int>& types);
    00430     int addTabulatedFunction(const std::string& name, TabulatedFunction* function);
    00437     const TabulatedFunction& getTabulatedFunction(int index) const;
    00444     TabulatedFunction& getTabulatedFunction(int index);
    00451     const std::string& getTabulatedFunctionName(int index) const;
    00463     void updateParametersInContext(Context& context);
    00464 protected:
    00465     ForceImpl* createImpl() const;
    00466 private:
    00467     class ParticleInfo;
    00468     class ParticleParameterInfo;
    00469     class GlobalParameterInfo;
    00470     class ExclusionInfo;
    00471     class FunctionInfo;
    00472     int particlesPerSet;
    00473     NonbondedMethod nonbondedMethod;
    00474     PermutationMode permutationMode;
    00475     double cutoffDistance;
    00476     std::string energyExpression;
    00477     std::vector<ParticleParameterInfo> particleParameters;
    00478     std::vector<GlobalParameterInfo> globalParameters;
    00479     std::vector<ParticleInfo> particles;
    00480     std::vector<ExclusionInfo> exclusions;
    00481     std::vector<FunctionInfo> functions;
    00482     std::vector<std::set<int> > typeFilters;
    00483 };
    00484
    00485
    00490 class CustomManyParticleForce::ParticleInfo {
    00491 public:
    00492     std::vector<double> parameters;
    00493     int type;
    00494     ParticleInfo() {
    00495     }
    00496     ParticleInfo(const std::vector<double>& parameters, int type) : parameters(parameters), type(type) {
    00497     }
    00498 };
    00499
    00504 class CustomManyParticleForce::ParticleParameterInfo {
    00505 public:
    00506     std::string name;
    00507     ParticleParameterInfo() {
    00508     }
    00509     ParticleParameterInfo(const std::string& name) : name(name) {
    00510     }
    00511 };
    00512
    00517 class CustomManyParticleForce::GlobalParameterInfo {
    00518 public:
    00519     std::string name;
    00520     double defaultValue;
    00521     GlobalParameterInfo() {
    00522     }
    00523     GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
    00524     }
    00525 };
    00526
    00531 class CustomManyParticleForce::ExclusionInfo {
    00532 public:
    00533     int particle1, particle2;
    00534     ExclusionInfo() {
    00535         particle1 = particle2 = -1;
    00536     }
    00537     ExclusionInfo(int particle1, int particle2) :
    00538         particle1(particle1), particle2(particle2) {
    00539     }
    00540 };
    00541
    00546 class CustomManyParticleForce::FunctionInfo {
    00547 public:
    00548     std::string name;
    00549     TabulatedFunction* function;
    00550     FunctionInfo() {
    00551     }
    00552     FunctionInfo(const std::string& name, TabulatedFunction* function) : name(name), function(function) {
    00553     }
    00554 };
    00555
    00556 } // namespace OpenMM
    00557
    00558 #endif /*OPENMM_CUSTOMTHREEBODYFORCE_H_*/