- Main Page
- Related Pages
- Classes
- Files

- File List

# CustomExternalForce.h

    00001 #ifndef OPENMM_CUSTOMEXTERNALFORCE_H_
    00002 #define OPENMM_CUSTOMEXTERNALFORCE_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-2012 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 "Vec3.h"
    00037 #include <vector>
    00038 #include "internal/windowsExport.h"
    00039
    00040 namespace OpenMM {
    00041
    00075 class OPENMM_EXPORT CustomExternalForce : public Force {
    00076 public:
    00083     explicit CustomExternalForce(const std::string& energy);
    00087     int getNumParticles() const {
    00088         return particles.size();
    00089     }
    00093     int getNumPerParticleParameters() const {
    00094         return parameters.size();
    00095     }
    00099     int getNumGlobalParameters() const {
    00100         return globalParameters.size();
    00101     }
    00105     const std::string& getEnergyFunction() const;
    00109     void setEnergyFunction(const std::string& energy);
    00116     int addPerParticleParameter(const std::string& name);
    00123     const std::string& getPerParticleParameterName(int index) const;
    00130     void setPerParticleParameterName(int index, const std::string& name);
    00138     int addGlobalParameter(const std::string& name, double defaultValue);
    00145     const std::string& getGlobalParameterName(int index) const;
    00152     void setGlobalParameterName(int index, const std::string& name);
    00159     double getGlobalParameterDefaultValue(int index) const;
    00166     void setGlobalParameterDefaultValue(int index, double defaultValue);
    00174     int addParticle(int particle, const std::vector<double>& parameters);
    00182     void getParticleParameters(int index, int& particle, std::vector<double>& parameters) const;
    00190     void setParticleParameters(int index, int particle, const std::vector<double>& parameters);
    00201     void updateParametersInContext(Context& context);
    00202 protected:
    00203     ForceImpl* createImpl() const;
    00204 private:
    00205     class ParticleInfo;
    00206     class ParticleParameterInfo;
    00207     class GlobalParameterInfo;
    00208     std::string energyExpression;
    00209     std::vector<ParticleParameterInfo> parameters;
    00210     std::vector<GlobalParameterInfo> globalParameters;
    00211     std::vector<ParticleInfo> particles;
    00212 };
    00213
    00218 class CustomExternalForce::ParticleInfo {
    00219 public:
    00220     int particle;
    00221     std::vector<double> parameters;
    00222     ParticleInfo() : particle(-1) {
    00223     }
    00224     ParticleInfo(int particle, const std::vector<double>& parameters) : particle(particle), parameters(parameters) {
    00225     }
    00226 };
    00227
    00232 class CustomExternalForce::ParticleParameterInfo {
    00233 public:
    00234     std::string name;
    00235     ParticleParameterInfo() {
    00236     }
    00237     ParticleParameterInfo(const std::string& name) : name(name) {
    00238     }
    00239 };
    00240
    00245 class CustomExternalForce::GlobalParameterInfo {
    00246 public:
    00247     std::string name;
    00248     double defaultValue;
    00249     GlobalParameterInfo() {
    00250     }
    00251     GlobalParameterInfo(const std::string& name, double defaultValue) : name(name), defaultValue(defaultValue) {
    00252     }
    00253 };
    00254
    00255 } // namespace OpenMM
    00256
    00257 #endif /*OPENMM_CUSTOMEXTERNALFORCE_H_*/