AmoebaWcaDispersionForce.cpp 5.32 KB
Newer Older
Mark Friedrichs's avatar
Mark Friedrichs committed
1
/* -------------------------------------------------------------------------- *
2
 *                                 OpenMMAmoeba                               *
Mark Friedrichs's avatar
Mark Friedrichs committed
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
 * -------------------------------------------------------------------------- *
 * 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 "openmm/OpenMMException.h"
34
35
#include "openmm/AmoebaWcaDispersionForce.h"
#include "openmm/internal/AmoebaWcaDispersionForceImpl.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
36
37
38
39
40
#include <cmath>

using namespace OpenMM;

AmoebaWcaDispersionForce::AmoebaWcaDispersionForce() {
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    // Amoeba Water '03 vdW parameters (Diameters in Angstroms; Well depth in kcal/mole)
    // vdw           1               3.4050     0.1100
    // vdw           2               2.6550     0.0135      0.910

    // Convert kcal/mol to kJ/mol
    epso = 0.1100 * 4.184e0;
    epsh = 0.0135 * 4.184e0;
    // Convert A to nm.
    rmino = 1.7025e-01;
    rminh = 1.3275e-01;
    dispoff = 1.056e-01;
    // Convert water number density from water / A^3 to water / nm^3.
    awater = 0.033428e03;
    // No units.
    slevy = 1.0;
    shctd = 0.82;
Mark Friedrichs's avatar
Mark Friedrichs committed
57
58
}

59
60
int AmoebaWcaDispersionForce::addParticle(double radius, double epsilon) {
    parameters.push_back(WcaDispersionInfo(radius, epsilon));
Mark Friedrichs's avatar
Mark Friedrichs committed
61
62
63
    return parameters.size()-1;
}

64
void AmoebaWcaDispersionForce::getParticleParameters(int particleIndex, double& radius, double& epsilon) const {
Mark Friedrichs's avatar
Mark Friedrichs committed
65
66
67
68
    radius          = parameters[particleIndex].radius;
    epsilon         = parameters[particleIndex].epsilon;
}

69
void AmoebaWcaDispersionForce::setParticleParameters(int particleIndex, double radius, double epsilon) {
Mark Friedrichs's avatar
Mark Friedrichs committed
70
71
72
73
    parameters[particleIndex].radius          = radius;
    parameters[particleIndex].epsilon         = epsilon;
}

peastman's avatar
peastman committed
74
double AmoebaWcaDispersionForce::getEpso() const {
Mark Friedrichs's avatar
Mark Friedrichs committed
75
76
77
    return epso;
}

peastman's avatar
peastman committed
78
double AmoebaWcaDispersionForce::getEpsh() const {
Mark Friedrichs's avatar
Mark Friedrichs committed
79
80
81
    return epsh;
}

peastman's avatar
peastman committed
82
double AmoebaWcaDispersionForce::getRmino() const {
Mark Friedrichs's avatar
Mark Friedrichs committed
83
84
85
    return rmino;
}

peastman's avatar
peastman committed
86
double AmoebaWcaDispersionForce::getRminh() const {
Mark Friedrichs's avatar
Mark Friedrichs committed
87
88
89
    return rminh;
}

peastman's avatar
peastman committed
90
double AmoebaWcaDispersionForce::getAwater() const {
Mark Friedrichs's avatar
Mark Friedrichs committed
91
92
93
    return awater;
}

peastman's avatar
peastman committed
94
double AmoebaWcaDispersionForce::getShctd() const {
Mark Friedrichs's avatar
Mark Friedrichs committed
95
96
97
    return shctd;
}

peastman's avatar
peastman committed
98
double AmoebaWcaDispersionForce::getDispoff() const {
Mark Friedrichs's avatar
Mark Friedrichs committed
99
100
101
    return dispoff;
}

peastman's avatar
peastman committed
102
double AmoebaWcaDispersionForce::getSlevy() const {
Mark Friedrichs's avatar
Mark Friedrichs committed
103
104
105
    return slevy;
}

106
void AmoebaWcaDispersionForce::setEpso(double inputEpso) {
Mark Friedrichs's avatar
Mark Friedrichs committed
107
108
109
    epso = inputEpso;
}

110
void AmoebaWcaDispersionForce::setEpsh(double inputEpsh) {
Mark Friedrichs's avatar
Mark Friedrichs committed
111
112
113
    epsh = inputEpsh;
}

114
void AmoebaWcaDispersionForce::setRmino(double inputRmino) {
Mark Friedrichs's avatar
Mark Friedrichs committed
115
116
117
    rmino = inputRmino;
}

118
void AmoebaWcaDispersionForce::setRminh(double inputRminh) {
Mark Friedrichs's avatar
Mark Friedrichs committed
119
120
121
    rminh = inputRminh;
}

122
void AmoebaWcaDispersionForce::setAwater(double inputAwater) {
Mark Friedrichs's avatar
Mark Friedrichs committed
123
124
125
    awater = inputAwater;
}

126
void AmoebaWcaDispersionForce::setShctd(double inputShctd) {
Mark Friedrichs's avatar
Mark Friedrichs committed
127
128
129
    shctd = inputShctd;
}

130
void AmoebaWcaDispersionForce::setDispoff(double inputDispoff) {
Mark Friedrichs's avatar
Mark Friedrichs committed
131
132
133
    dispoff = inputDispoff;
}

134
void AmoebaWcaDispersionForce::setSlevy(double inputSlevy) {
Mark Friedrichs's avatar
Mark Friedrichs committed
135
136
137
    slevy = inputSlevy;
}

138
ForceImpl* AmoebaWcaDispersionForce::createImpl() const {
Mark Friedrichs's avatar
Mark Friedrichs committed
139
140
    return new AmoebaWcaDispersionForceImpl(*this);
}
141
142
143
144

void AmoebaWcaDispersionForce::updateParametersInContext(Context& context) {
    dynamic_cast<AmoebaWcaDispersionForceImpl&>(getImplInContext(context)).updateParametersInContext(getContextImpl(context));
}