"platforms/opencl/tests/TestOpenCLSettle.cpp" did not exist on "27a2456b0fa62eb3df0c3dedbcd3af9ff86a1ec8"
System.h 6.65 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
#ifndef OPENMM_SYSTEM_H_
#define OPENMM_SYSTEM_H_

/* -------------------------------------------------------------------------- *
 *                                   OpenMM                                   *
 * -------------------------------------------------------------------------- *
 * 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.               *
 *                                                                            *
12
 * Portions copyright (c) 2008-2009 Stanford University and the Authors.      *
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 * 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 <vector>
36
#include "internal/windowsExport.h"
37
38
39

namespace OpenMM {

40
class OPENMM_EXPORT Force;
41
42
43
44
45
46

/**
 * This class represents a molecular system.  The definition of a System involves
 * three elements:
 * 
 * <ol>
Peter Eastman's avatar
Peter Eastman committed
47
 * <li>The set of particles in the system</li>
48
 * <li>The forces acting on them</li>
49
 * <li>Pairs of particles whose separation should be constrained to a fixed value</li>
50
51
 * </ol>
 * 
Peter Eastman's avatar
Peter Eastman committed
52
 * The particles and constraints are defined directly by the System object.
53
 * The forces are defined by objects that extend the Force class.  The System
Peter Eastman's avatar
Peter Eastman committed
54
 * stores a list of Force objects that determine the motion of the particles.
55
56
 */

57
class OPENMM_EXPORT System {
58
59
60
61
public:
    /**
     * Create a new System.
     * 
Peter Eastman's avatar
Peter Eastman committed
62
     * @param numParticles   the number of particles in the System
63
64
     * @param numConstraints the number of distance constraints in the System.
     */
Peter Eastman's avatar
Peter Eastman committed
65
    System(int numParticles, int numConstraints);
66
67
    ~System();
    /**
Peter Eastman's avatar
Peter Eastman committed
68
     * Get the number of particles in this System.
69
     */
Peter Eastman's avatar
Peter Eastman committed
70
    int getNumParticles() const {
71
72
73
        return masses.size();
    }
    /**
Peter Eastman's avatar
Peter Eastman committed
74
     * Get the mass (in atomic mass units) of a particle.
75
     * 
Peter Eastman's avatar
Peter Eastman committed
76
     * @param index the index of the particle for which to get the mass
77
     */
Peter Eastman's avatar
Peter Eastman committed
78
    double getParticleMass(int index) const {
79
80
81
        return masses[index];
    }
    /**
Peter Eastman's avatar
Peter Eastman committed
82
     * Set the mass (in atomic mass units) of a particle.
83
     * 
Peter Eastman's avatar
Peter Eastman committed
84
85
     * @param index  the index of the particle for which to set the mass
     * @param mass   the mass of the particle
86
     */
Peter Eastman's avatar
Peter Eastman committed
87
    void setParticleMass(int index, double mass) {
88
89
90
91
92
93
94
95
96
97
98
99
        masses[index] = mass;
    }
    /**
     * Get the number of distance constraints in this System.
     */
    int getNumConstraints() const {
        return constraints.size();
    }
    /**
     * Get the parameters defining a distance constraint.
     * 
     * @param index     the index of the constraint for which to get parameters
Peter Eastman's avatar
Peter Eastman committed
100
101
102
     * @param particle1 the index of the first particle involved in the constraint
     * @param particle2 the index of the second particle involved in the constraint
     * @param distance  the required distance between the two particles, measured in nm
103
     */
Peter Eastman's avatar
Peter Eastman committed
104
    void getConstraintParameters(int index, int& particle1, int& particle2, double& distance) const;
105
106
107
108
    /**
     * Set the parameters defining a distance constraint.
     * 
     * @param index     the index of the constraint for which to set parameters
Peter Eastman's avatar
Peter Eastman committed
109
110
111
     * @param particle1 the index of the first particle involved in the constraint
     * @param particle2 the index of the second particle involved in the constraint
     * @param distance  the required distance between the two particles, measured in nm
112
     */
Peter Eastman's avatar
Peter Eastman committed
113
    void setConstraintParameters(int index, int particle1, int particle2, double distance);
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    /**
     * Add a Force to the System.  The Force should have been created on the heap with the
     * "new" operator.  The System takes over ownership of it, and deletes the Force when the
     * System itself is deleted.
     */
    void addForce(Force* force) {
        forces.push_back(force);
    }
    /**
     * Get the number of Force objects that have been added to the System.
     */
    int getNumForces() const {
        return forces.size();
    }
    /**
     * Get a reference to one of the Forces in this System.
     * 
     * @param index  the index of the Force to get
     */
133
134
135
136
137
138
139
140
    const Force& getForce(int index) const {
        return *forces[index];
    }
    /**
     * Get a reference to one of the Forces in this System.
     *
     * @param index  the index of the Force to get
     */
141
142
143
144
145
    Force& getForce(int index) {
        return *forces[index];
    }
private:
    class ConstraintInfo;
146

Peter Eastman's avatar
Peter Eastman committed
147
148
149
150
151
152
// 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)
153
154
#endif

Peter Eastman's avatar
Peter Eastman committed
155
    std::vector<double> masses;
156
157
    std::vector<ConstraintInfo> constraints;
    std::vector<Force*> forces;
158

Peter Eastman's avatar
Peter Eastman committed
159
160
161
162
#if defined(_MSC_VER)
#pragma warning(pop)
#endif

163
164
165
166
};

class System::ConstraintInfo {
public:
Peter Eastman's avatar
Peter Eastman committed
167
    int particle1, particle2;
168
169
    double distance;
    ConstraintInfo() {
Peter Eastman's avatar
Peter Eastman committed
170
        particle1 = particle2 = -1;
171
172
173
174
175
176
177
        distance = 0.0;
    }
};

} // namespace OpenMM

#endif /*OPENMM_SYSTEM_H_*/