- Main Page
- Related Pages
- Classes
- Files

- File List

# NonbondedForce.h

    00001 #ifndef OPENMM_NONBONDEDFORCE_H_
    00002 #define OPENMM_NONBONDEDFORCE_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 "Context.h"
    00036 #include "Force.h"
    00037 #include <map>
    00038 #include <set>
    00039 #include <utility>
    00040 #include <vector>
    00041 #include "internal/windowsExport.h"
    00042
    00043 namespace OpenMM {
    00044
    00081 class OPENMM_EXPORT NonbondedForce : public Force {
    00082 public:
    00086     enum NonbondedMethod {
    00091         NoCutoff = 0,
    00096         CutoffNonPeriodic = 1,
    00102         CutoffPeriodic = 2,
    00107         Ewald = 3,
    00112         PME = 4
    00113     };
    00117     NonbondedForce();
    00121     int getNumParticles() const {
    00122         return particles.size();
    00123     }
    00127     int getNumExceptions() const {
    00128         return exceptions.size();
    00129     }
    00133     NonbondedMethod getNonbondedMethod() const;
    00137     void setNonbondedMethod(NonbondedMethod method);
    00144     double getCutoffDistance() const;
    00151     void setCutoffDistance(double distance);
    00156     bool getUseSwitchingFunction() const;
    00161     void setUseSwitchingFunction(bool use);
    00166     double getSwitchingDistance() const;
    00171     void setSwitchingDistance(double distance);
    00175     double getReactionFieldDielectric() const;
    00179     void setReactionFieldDielectric(double dielectric);
    00189     double getEwaldErrorTolerance() const;
    00199     void setEwaldErrorTolerance(double tol);
    00209     void getPMEParameters(double& alpha, int& nx, int& ny, int& nz) const;
    00219     void setPMEParameters(double alpha, int nx, int ny, int nz);
    00232     int addParticle(double charge, double sigma, double epsilon);
    00241     void getParticleParameters(int index, double& charge, double& sigma, double& epsilon) const;
    00252     void setParticleParameters(int index, double charge, double sigma, double epsilon);
    00269     int addException(int particle1, int particle2, double chargeProd, double sigma, double epsilon, bool replace = false);
    00280     void getExceptionParameters(int index, int& particle1, int& particle2, double& chargeProd, double& sigma, double& epsilon) const;
    00293     void setExceptionParameters(int index, int particle1, int particle2, double chargeProd, double sigma, double epsilon);
    00306     void createExceptionsFromBonds(const std::vector<std::pair<int, int> >& bonds, double coulomb14Scale, double lj14Scale);
    00313     bool getUseDispersionCorrection() const {
    00314         return useDispersionCorrection;
    00315     }
    00322     void setUseDispersionCorrection(bool useCorrection) {
    00323         useDispersionCorrection = useCorrection;
    00324     }
    00331     int getReciprocalSpaceForceGroup() const;
    00341     void setReciprocalSpaceForceGroup(int group);
    00354     void updateParametersInContext(Context& context);
    00355 protected:
    00356     ForceImpl* createImpl() const;
    00357 private:
    00358     class ParticleInfo;
    00359     class ExceptionInfo;
    00360     NonbondedMethod nonbondedMethod;
    00361     double cutoffDistance, switchingDistance, rfDielectric, ewaldErrorTol, alpha;
    00362     bool useSwitchingFunction, useDispersionCorrection;
    00363     int recipForceGroup, nx, ny, nz;
    00364     void addExclusionsToSet(const std::vector<std::set<int> >& bonded12, std::set<int>& exclusions, int baseParticle, int fromParticle, int currentLevel) const;
    00365     std::vector<ParticleInfo> particles;
    00366     std::vector<ExceptionInfo> exceptions;
    00367     std::map<std::pair<int, int>, int> exceptionMap;
    00368 };
    00369
    00374 class NonbondedForce::ParticleInfo {
    00375 public:
    00376     double charge, sigma, epsilon;
    00377     ParticleInfo() {
    00378         charge = sigma = epsilon = 0.0;
    00379     }
    00380     ParticleInfo(double charge, double sigma, double epsilon) :
    00381         charge(charge), sigma(sigma), epsilon(epsilon) {
    00382     }
    00383 };
    00384
    00389 class NonbondedForce::ExceptionInfo {
    00390 public:
    00391     int particle1, particle2;
    00392     double chargeProd, sigma, epsilon;
    00393     ExceptionInfo() {
    00394         particle1 = particle2 = -1;
    00395         chargeProd = sigma = epsilon = 0.0;
    00396     }
    00397     ExceptionInfo(int particle1, int particle2, double chargeProd, double sigma, double epsilon) :
    00398         particle1(particle1), particle2(particle2), chargeProd(chargeProd), sigma(sigma), epsilon(epsilon) {
    00399     }
    00400 };
    00401
    00402 } // namespace OpenMM
    00403
    00404 #endif /*OPENMM_NONBONDEDFORCE_H_*/