AmoebaVdwForce.h 8.14 KB
Newer Older
Mark Friedrichs's avatar
Mark Friedrichs committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef OPENMM_AMOEBA_VDW_FORCE_H_
#define OPENMM_AMOEBA_VDW_FORCE_H_

/* -------------------------------------------------------------------------- *
 *                              AmoebaOpenMM                                  *
 * -------------------------------------------------------------------------- *
 * This is part of the OpenMM molecular simulation toolkit originating from   *
 * Simbios, the NIH National Center for Physics-Based Simulation of           *
 * Biological Structures at Stanford, funded under the NIH Roadmap for        *
 * Medical Research, grant U54 GM072970. See https://simtk.org.               *
 *                                                                            *
 * Portions copyright (c) 2008-2009 Stanford University and the Authors.      *
 * Authors:                                                                   *
 * Contributors:                                                              *
 *                                                                            *
 * Permission is hereby granted, free of charge, to any person obtaining a    *
 * copy of this software and associated documentation files (the "Software"), *
 * to deal in the Software without restriction, including without limitation  *
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
 * and/or sell copies of the Software, and to permit persons to whom the      *
 * Software is furnished to do so, subject to the following conditions:       *
 *                                                                            *
 * The above copyright notice and this permission notice shall be included in *
 * all copies or substantial portions of the Software.                        *
 *                                                                            *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
 * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
 * -------------------------------------------------------------------------- */

#include "openmm/Force.h"
#include <vector>
#include "openmm/internal/windowsExport.h"

namespace OpenMM {

/**
 * This class implements an interaction between pairs of particles that varies harmonically with the distance
 * between them.  To use it, create a VdwForce object then call addAngle() once for each angle.  After
 * a angle has been added, you can modify its force field parameters by calling setAngleParameters().
 */

 class OPENMM_EXPORT AmoebaVdwForce : public Force {
public:
    /**
     * Create a Amoeba VdwForce.
     */
    AmoebaVdwForce();

    /**
     * Get the number of particles
     */
    int getNumParticles() const {
        return parameters.size();
    }

    /**
     * Set the force field parameters for a vdw particle.
     * 
     * @param particleIndex   the particle index
     * @param ivIndex         the iv index
     * @param classIndex      the class index into the sig-eps table
     * @param sigma           vdw sigma
     * @param epsilon         vdw epsilon
69
     * @param reductionFactor the reduction factor 
Mark Friedrichs's avatar
Mark Friedrichs committed
70
71
     */
    void setParticleParameters(int particleIndex, int ivIndex, int classIndex,
72
                               double sigma, double epsilon, double reductionFactor );
Mark Friedrichs's avatar
Mark Friedrichs committed
73
74
75
76
77
78
79
80
81

    /**
     * Get the force field parameters for a vdw particle.
     * 
     * @param particleIndex   the particle index
     * @param ivIndex         the iv index
     * @param classIndex      the class index into the sig-eps table
     * @param sigma           vdw sigma
     * @param epsilon         vdw epsilon
82
     * @param reductionFactor the reduction factor 
Mark Friedrichs's avatar
Mark Friedrichs committed
83
84
     */
    void getParticleParameters(int particleIndex, int& ivIndex, int& classIndex,
85
                               double& sigma, double& epsilon, double& reductionFactor ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
86
87
88
89
90
91
92
93
94
95


    /**
     * Set the force field parameters for a vdw particle.
     * 
     * @param particleIndex   the particle index
     * @param ivIndex         the iv index
     * @param classIndex      the class index into the sig-eps table
     * @param sigma           vdw sigma
     * @param epsilon         vdw epsilon
96
     * @param reductionFactor the reduction factor
Mark Friedrichs's avatar
Mark Friedrichs committed
97
98
99
     * @return index of added particle
     */
    int addParticle(int ivIndex, int classIndex, 
100
                    double sigma, double epsilon, double reductionFactor );
Mark Friedrichs's avatar
Mark Friedrichs committed
101
102
103
104
105
106

    /**
     * Set sigma combining rule
     * 
     * @param sigmaCombiningRule   sigma combining rule:  'ARITHMETIC', 'GEOMETRIC'. 'CUBIC-MEAN'
     */
107
    void setSigmaCombiningRule( const std::string& sigmaCombiningRule );
Mark Friedrichs's avatar
Mark Friedrichs committed
108
109
110
111
112
113

    /**
     * Get sigma combining rule
     * 
     * @return sigmaCombiningRule   sigma combining rule:  'ARITHMETIC', 'GEOMETRIC'. 'CUBIC-MEAN'
     */
114
    const std::string& getSigmaCombiningRule( void ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
115
116
117
118
119
120

    /**
     * Set epsilon combining rule
     * 
     * @param epsilonCombiningRule   epsilon combining rule:  'ARITHMETIC', 'GEOMETRIC'. 'CUBIC-MEAN'
     */
121
    void setEpsilonCombiningRule( const std::string& epsilonCombiningRule );
Mark Friedrichs's avatar
Mark Friedrichs committed
122
123
124
125
126
127

    /**
     * Get epsilon combining rule
     * 
     * @return epsilonCombiningRule   epsilon combining rule:  'ARITHMETIC', 'GEOMETRIC'. 'HARMONIC', 'HHG'
     */
128
    const std::string& getEpsilonCombiningRule( void ) const;
Mark Friedrichs's avatar
Mark Friedrichs committed
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

    /**
     * Set exclusions for specified particle
     * 
     * @param particleIndex particle index
     * @param exclusions output vector of exclusions
     */
    void setParticleExclusions( int particleIndex, std::vector< int >& exclusions );

    /**
     * Get exclusions for specified particle
     * 
     * @param particleIndex particle index
     * @param exclusions output vector of exclusions
     */
    void getParticleExclusions( int particleIndex, std::vector< int >& exclusions ) const;

Mark Friedrichs's avatar
Mark Friedrichs committed
146
147
148
149
150
151
152
153
154
155
156
157
158
159
    /**
     * Set cutoff
     * 
     * @param cutoff cutoff
     */
    void setCutoff( double cutoff );

    /**
     * Get cutoff
     * 
     * @return cutoff
     */
    double getCutoff( void ) const;

160
161
162
163
164
165
166
167
168
169
170
171
172
173
    /**
     * Set flag for using neighbor list for vdw ixn
     * 
     * @param neighboristFlag neighbor list flag
     */
    void setUseNeighborList( int neighborListFlag );

    /**
     * Get neighbor list flag for vdw ixn
     * 
     * @return neighbor list flag
     */
    int getUseNeighborList( void ) const;

Mark Friedrichs's avatar
Mark Friedrichs committed
174
175
176
177
178
179
180
181
182
183
184
185
186
187
    /**
     * Set flag for employing periodic boundary conditions
     * 
     * @param pbcFlag if nonozero, use periodic boundary conditions
     */
    void setPBC( int pbcFlag );

    /**
     * Get periodic boundary conditions flag
     * 
     * @return periodic boundary conditions flag (nonzero -> use PBC)
     */
    int getPBC( void ) const;

Mark Friedrichs's avatar
Mark Friedrichs committed
188
189
190
191
192
protected:
    ForceImpl* createImpl();
private:

    class VdwInfo;
Mark Friedrichs's avatar
Mark Friedrichs committed
193
    int usePBC;
194
    int useNeighborList; double cutoff;
Mark Friedrichs's avatar
Mark Friedrichs committed
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
    std::string sigmaCombiningRule;
    std::string epsilonCombiningRule;
    std::vector< std::vector<int> > exclusions;

// Retarded visual studio compiler complains about being unable to 
// export private stl class members.
// This stanza explains that it should temporarily shut up.
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4251)
#endif
    std::vector<VdwInfo> parameters;
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

    std::vector< std::vector< std::vector<double> > > sigEpsTable;
};

class AmoebaVdwForce::VdwInfo {
public:
    int ivIndex, classIndex;
Mark Friedrichs's avatar
Mark Friedrichs committed
217
    double reductionFactor, sigma, epsilon, cutoff;
Mark Friedrichs's avatar
Mark Friedrichs committed
218
219
220
    VdwInfo() {
        ivIndex = classIndex = -1;
        reductionFactor      = 0.0;
221
        sigma                = 1.0;
Mark Friedrichs's avatar
Mark Friedrichs committed
222
223
        epsilon              = 0.0;
    }
224
225
    VdwInfo(int ivIndex, int classIndex, double sigma, double epsilon, double  reductionFactor ) :
        ivIndex(ivIndex), classIndex(classIndex), sigma(sigma), epsilon(epsilon), reductionFactor(reductionFactor)  {
Mark Friedrichs's avatar
Mark Friedrichs committed
226
227
228
229
230
231
    }
};

} // namespace OpenMM

#endif /*OPENMM_AMOEBA_VDW_FORCE_H_*/