"plugins/vscode:/vscode.git/clone" did not exist on "8d0d1d13b65892811aa2ab7db7f667674b431fe6"
ReferenceCCMAAlgorithm.h 4.8 KB
Newer Older
1

2
/* Portions copyright (c) 2006-2015 Stanford University and Simbios.
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 * Contributors: Pande Group
 *
 * 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.
 */

25
26
#ifndef __ReferenceCCMAAlgorithm_H__
#define __ReferenceCCMAAlgorithm_H__
27
28

#include "ReferenceConstraintAlgorithm.h"
29
#include <utility>
30
31
32
#include <vector>
#include <set>

33
namespace OpenMM {
34

35
class OPENMM_EXPORT ReferenceCCMAAlgorithm : public ReferenceConstraintAlgorithm {
36

37
protected:
38

39
    int _maximumNumberOfIterations;
40
    RealOpenMM _elementCutoff;
41

42
43
44
    int _numberOfConstraints;
    std::vector<std::pair<int, int> > _atomIndices;
    std::vector<RealOpenMM> _distance;
45

46
47
48
49
50
51
    std::vector<OpenMM::RealVec> _r_ij;
    RealOpenMM* _d_ij2;
    RealOpenMM* _distanceTolerance;
    RealOpenMM* _reducedMasses;
    bool _hasInitializedMasses;
    std::vector<std::vector<std::pair<int, RealOpenMM> > > _matrix;
52

53
private:
54

55
    void applyConstraints(std::vector<OpenMM::RealVec>& atomCoordinates,
56
                       std::vector<OpenMM::RealVec>& atomCoordinatesP, std::vector<RealOpenMM>& inverseMasses, bool constrainingVelocities, RealOpenMM tolerance);
57
          
58
59
60
61
62
63
64
65
66
67
68
69
public:
    class AngleInfo;

    /**
     * Create a ReferenceCCMAAlgorithm object.
     * 
     * @param numberOfAtoms            the number of atoms in the system
     * @param numberOfConstraints      the number of constraints
     * @param atomIndices              atom indices for contraints
     * @param distance                 distances for constraints
     * @param masses                   atom masses
     * @param angles                   angle force field terms
70
     * @param elementCutoff            the cutoff for which elements of the inverse matrix to keep
71
     */
72
    ReferenceCCMAAlgorithm(int numberOfAtoms, int numberOfConstraints, const std::vector<std::pair<int, int> >& atomIndices, const std::vector<RealOpenMM>& distance, std::vector<RealOpenMM>& masses, std::vector<AngleInfo>& angles, RealOpenMM elementCutoff);
73

74
    ~ReferenceCCMAAlgorithm();
75
76
77
78

    /**
     * Get the number of constraints.
     */
79
    int getNumberOfConstraints() const;
80
81
82
83

    /**
     * Get the maximum number of iterations to perform.
     */
84
    int getMaximumNumberOfIterations() const;
85
86
87
88

    /**
     * Set the maximum number of iterations to perform.
     */
89
    void setMaximumNumberOfIterations(int maximumNumberOfIterations);
90
91
92
93
94
95
96

    /**
     * Apply the constraint algorithm.
     * 
     * @param atomCoordinates  the original atom coordinates
     * @param atomCoordinatesP the new atom coordinates
     * @param inverseMasses    1/mass
97
     * @param tolerance        the constraint tolerance
98
99
     */
    void apply(std::vector<OpenMM::RealVec>& atomCoordinates,
100
                       std::vector<OpenMM::RealVec>& atomCoordinatesP, std::vector<RealOpenMM>& inverseMasses, RealOpenMM tolerance);
101
102
103
104
105
106
107

    /**
     * Apply the constraint algorithm to velocities.
     * 
     * @param atomCoordinates  the atom coordinates
     * @param atomCoordinatesP the velocities to modify
     * @param inverseMasses    1/mass
108
     * @param tolerance        the constraint tolerance
109
110
     */
    void applyToVelocities(std::vector<OpenMM::RealVec>& atomCoordinates,
111
                     std::vector<OpenMM::RealVec>& velocities, std::vector<RealOpenMM>& inverseMasses, RealOpenMM tolerance);
112
113
114
115
116
117
118

    /**
     * Get the inverse constraint matrix.  Each element represents one column, and contains a list
     * of all non-zero elements in the form (index, value).
     */
    const std::vector<std::vector<std::pair<int, RealOpenMM> > >& getMatrix() const;

119
120
};

121
class ReferenceCCMAAlgorithm::AngleInfo
122
123
124
125
126
127
128
129
130
131
{
public:
    int atom1, atom2, atom3;
    RealOpenMM angle;
    AngleInfo(int atom1, int atom2, int atom3, RealOpenMM angle) :
        atom1(atom1), atom2(atom2), atom3(atom3), angle(angle)
    {
    }
};

132
} // namespace OpenMM
133

134
#endif // __ReferenceCCMAAlgorithm_H__