AmoebaStretchBendForce.cpp 4.46 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/AmoebaStretchBendForce.h"
#include "openmm/internal/AmoebaStretchBendForceImpl.h"
Mark Friedrichs's avatar
Mark Friedrichs committed
36
37
38
39
40
41
42

using namespace OpenMM;

AmoebaStretchBendForce::AmoebaStretchBendForce() {
}

int AmoebaStretchBendForce::addStretchBend(int particle1, int particle2, int particle3,
43
44
                                           double lengthAB,  double lengthCB, double angle, double k1, double k2) {
    stretchBends.push_back(StretchBendInfo(particle1, particle2, particle3, lengthAB,  lengthCB, angle, k1, k2));
Mark Friedrichs's avatar
Mark Friedrichs committed
45
46
47
48
    return stretchBends.size()-1;
}

void AmoebaStretchBendForce::getStretchBendParameters(int index, int& particle1, int& particle2, int& particle3,
49
                                                      double& lengthAB, double& lengthCB, double& angle, double& k1, double& k2 ) const {
Mark Friedrichs's avatar
Mark Friedrichs committed
50
51
52
53
54
55
    particle1       = stretchBends[index].particle1;
    particle2       = stretchBends[index].particle2;
    particle3       = stretchBends[index].particle3;
    lengthAB        = stretchBends[index].lengthAB;
    lengthCB        = stretchBends[index].lengthCB;
    angle           = stretchBends[index].angle;
56
57
    k1              = stretchBends[index].k1;
    k2              = stretchBends[index].k2;
Mark Friedrichs's avatar
Mark Friedrichs committed
58
59
}

60
61
void AmoebaStretchBendForce::setStretchBendParameters(int index, int particle1, int particle2, int particle3,
                                                      double lengthAB,  double lengthCB, double angle, double k1, double k2) {
Mark Friedrichs's avatar
Mark Friedrichs committed
62
63
64
65
66
67
    stretchBends[index].particle1  = particle1;
    stretchBends[index].particle2  = particle2;
    stretchBends[index].particle3  = particle3;
    stretchBends[index].lengthAB   = lengthAB;
    stretchBends[index].lengthCB   = lengthCB;
    stretchBends[index].angle      = angle;
68
    stretchBends[index].k1         = k1;
69
    stretchBends[index].k2         = k2;
Mark Friedrichs's avatar
Mark Friedrichs committed
70
71
}

72
ForceImpl* AmoebaStretchBendForce::createImpl() const {
Mark Friedrichs's avatar
Mark Friedrichs committed
73
74
    return new AmoebaStretchBendForceImpl(*this);
}
75
76
77
78

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