AmoebaGeneralizedKirkwoodForce.cpp 5.55 KB
Newer Older
Mark Friedrichs's avatar
Mark Friedrichs committed
1
2
3
/* -------------------------------------------------------------------------- *
 *                                   OpenMM                                   *
 * -------------------------------------------------------------------------- *
Evan Pretti's avatar
Evan Pretti committed
4
5
 * This is part of the OpenMM molecular simulation toolkit.                   *
 * See https://openmm.org/development.                                        *
Mark Friedrichs's avatar
Mark Friedrichs committed
6
 *                                                                            *
7
 * Portions copyright (c) 2008-2026 Stanford University and the Authors.      *
Mark Friedrichs's avatar
Mark Friedrichs committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 * Authors: Peter Eastman                                                     *
 * 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"
32
33
#include "openmm/AmoebaGeneralizedKirkwoodForce.h"
#include "openmm/internal/AmoebaGeneralizedKirkwoodForceImpl.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
34
35
36

using namespace OpenMM;

37
38
39
AmoebaGeneralizedKirkwoodForce::AmoebaGeneralizedKirkwoodForce() :
    solventDielectric(78.3), soluteDielectric(1.0), dielectricOffset(0.009), includeCavityTerm(1), probeRadius(0.14),
    tanhRescaling(false), beta0(0.9563), beta1(0.2578), beta2(0.0810), descreenOffset(0.0) {
Mark Friedrichs's avatar
Mark Friedrichs committed
40
41
42
     surfaceAreaFactor = -6.0* 3.1415926535*0.0216*1000.0*0.4184;
}

43
44
45
46
int AmoebaGeneralizedKirkwoodForce::getNumParticles() const {
    return particles.size();
}

Mark Friedrichs's avatar
Mark Friedrichs committed
47
int AmoebaGeneralizedKirkwoodForce::addParticle(double charge, double radius, double scalingFactor) {
48
    particles.push_back(ParticleInfo(charge, radius, scalingFactor, radius, 0.0));
Mark Friedrichs's avatar
Mark Friedrichs committed
49
50
51
    return particles.size()-1;
}

52
53
54
55
56
57
int AmoebaGeneralizedKirkwoodForce::addParticle(double charge, double radius, double scalingFactor, double descreenRadius, double neckFactor) {
    particles.push_back(ParticleInfo(charge, radius, scalingFactor, descreenRadius, neckFactor));
    return particles.size()-1;
}

void AmoebaGeneralizedKirkwoodForce::getParticleParameters(int index, double& charge, double& radius, double& scalingFactor, double& descreenRadius, double& neckFactor) const {
Mark Friedrichs's avatar
Mark Friedrichs committed
58
59
60
    charge = particles[index].charge;
    radius = particles[index].radius;
    scalingFactor = particles[index].scalingFactor;
61
62
    descreenRadius = particles[index].descreenRadius;
    neckFactor = particles[index].neckFactor;
Mark Friedrichs's avatar
Mark Friedrichs committed
63
64
}

65
void AmoebaGeneralizedKirkwoodForce::setParticleParameters(int index, double charge, double radius, double scalingFactor, double descreenRadius, double neckFactor) {
Mark Friedrichs's avatar
Mark Friedrichs committed
66
67
68
    particles[index].charge = charge;
    particles[index].radius = radius;
    particles[index].scalingFactor = scalingFactor;
69
70
    particles[index].descreenRadius = descreenRadius;
    particles[index].neckFactor = neckFactor;
Mark Friedrichs's avatar
Mark Friedrichs committed
71
}
72

Mark Friedrichs's avatar
Mark Friedrichs committed
73
74
75
76
double AmoebaGeneralizedKirkwoodForce::getDielectricOffset() const {
    return dielectricOffset;
}

77
void AmoebaGeneralizedKirkwoodForce::setDielectricOffset(double inputDielectricOffset) {
Mark Friedrichs's avatar
Mark Friedrichs committed
78
    dielectricOffset = inputDielectricOffset;
79
}
Mark Friedrichs's avatar
Mark Friedrichs committed
80
81
82
83
84

int AmoebaGeneralizedKirkwoodForce::getIncludeCavityTerm() const {
    return includeCavityTerm;
}

85
void AmoebaGeneralizedKirkwoodForce::setIncludeCavityTerm(int inputIncludeCavityTerm) {
Mark Friedrichs's avatar
Mark Friedrichs committed
86
87
88
89
90
91
92
    includeCavityTerm = inputIncludeCavityTerm;
}

double AmoebaGeneralizedKirkwoodForce::getProbeRadius() const {
    return probeRadius;
}

93
void AmoebaGeneralizedKirkwoodForce::setProbeRadius(double inputProbeRadius) {
Mark Friedrichs's avatar
Mark Friedrichs committed
94
95
96
97
98
99
100
    probeRadius = inputProbeRadius;
}

double AmoebaGeneralizedKirkwoodForce::getSurfaceAreaFactor() const {
    return surfaceAreaFactor;
}

101
void AmoebaGeneralizedKirkwoodForce::setSurfaceAreaFactor(double inputSurfaceAreaFactor) {
Mark Friedrichs's avatar
Mark Friedrichs committed
102
103
104
    surfaceAreaFactor = inputSurfaceAreaFactor;
}

105
106
107
108
109
110
111
112
double AmoebaGeneralizedKirkwoodForce::getDescreenOffset() const {
    return descreenOffset;
}

void AmoebaGeneralizedKirkwoodForce::setDescreenOffset(double inputDescreenOffet) {
    descreenOffset = inputDescreenOffet;
}

113
ForceImpl* AmoebaGeneralizedKirkwoodForce::createImpl() const {
Mark Friedrichs's avatar
Mark Friedrichs committed
114
115
    return new AmoebaGeneralizedKirkwoodForceImpl(*this);
}
116
117
118
119

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