OpenMM
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
System.h
1 #ifndef OPENMM_SYSTEM_H_
2 #define OPENMM_SYSTEM_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * OpenMM *
6  * -------------------------------------------------------------------------- *
7  * This is part of the OpenMM molecular simulation toolkit originating from *
8  * Simbios, the NIH National Center for Physics-Based Simulation of *
9  * Biological Structures at Stanford, funded under the NIH Roadmap for *
10  * Medical Research, grant U54 GM072970. See https://simtk.org. *
11  * *
12  * Portions copyright (c) 2008-2009 Stanford University and the Authors. *
13  * Authors: Peter Eastman *
14  * Contributors: *
15  * *
16  * Permission is hereby granted, free of charge, to any person obtaining a *
17  * copy of this software and associated documentation files (the "Software"), *
18  * to deal in the Software without restriction, including without limitation *
19  * the rights to use, copy, modify, merge, publish, distribute, sublicense, *
20  * and/or sell copies of the Software, and to permit persons to whom the *
21  * Software is furnished to do so, subject to the following conditions: *
22  * *
23  * The above copyright notice and this permission notice shall be included in *
24  * all copies or substantial portions of the Software. *
25  * *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
27  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
28  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
29  * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
30  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
31  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
32  * USE OR OTHER DEALINGS IN THE SOFTWARE. *
33  * -------------------------------------------------------------------------- */
34 
35 #include "Vec3.h"
36 #include <vector>
37 #include "internal/windowsExport.h"
38 
39 namespace OpenMM {
40 
41 class OPENMM_EXPORT Force;
42 class OPENMM_EXPORT VirtualSite;
43 
66 class OPENMM_EXPORT System {
67 public:
71  System();
72  ~System();
76  int getNumParticles() const {
77  return masses.size();
78  }
88  int addParticle(double mass) {
89  masses.push_back(mass);
90  return masses.size()-1;
91  }
100  double getParticleMass(int index) const;
110  void setParticleMass(int index, double mass);
120  void setVirtualSite(int index, VirtualSite* virtualSite);
126  bool isVirtualSite(int index) const {
127  return (index < (int) virtualSites.size() && virtualSites[index] != NULL);
128  }
135  const VirtualSite& getVirtualSite(int index) const;
139  int getNumConstraints() const {
140  return constraints.size();
141  }
151  int addConstraint(int particle1, int particle2, double distance);
160  void getConstraintParameters(int index, int& particle1, int& particle2, double& distance) const;
170  void setConstraintParameters(int index, int particle1, int particle2, double distance);
179  int addForce(Force* force) {
180  forces.push_back(force);
181  return forces.size()-1;
182  }
186  int getNumForces() const {
187  return forces.size();
188  }
194  const Force& getForce(int index) const;
200  Force& getForce(int index);
213  void getDefaultPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) const;
226  void setDefaultPeriodicBoxVectors(const Vec3& a, const Vec3& b, const Vec3& c);
227 private:
228  class ConstraintInfo;
229  Vec3 periodicBoxVectors[3];
230  std::vector<double> masses;
231  std::vector<ConstraintInfo> constraints;
232  std::vector<Force*> forces;
233  std::vector<VirtualSite*> virtualSites;
234 };
235 
240 class System::ConstraintInfo {
241 public:
242  int particle1, particle2;
243  double distance;
244  ConstraintInfo() {
245  particle1 = particle2 = -1;
246  distance = 0.0;
247  }
248  ConstraintInfo(int particle1, int particle2, double distance) :
249  particle1(particle1), particle2(particle2), distance(distance) {
250  }
251 };
252 
253 } // namespace OpenMM
254 
255 #endif /*OPENMM_SYSTEM_H_*/
int getNumConstraints() const
Get the number of distance constraints in this System.
Definition: System.h:139
A VirtualSite describes the rules for computing a particle&#39;s position based on other particles...
Definition: VirtualSite.h:47
Force objects apply forces to the particles in a System, or alter their behavior in other ways...
Definition: Force.h:65
int getNumForces() const
Get the number of Force objects that have been added to the System.
Definition: System.h:186
This class represents a molecular system.
Definition: System.h:66
This class represents a three component vector.
Definition: Vec3.h:45
int addForce(Force *force)
Add a Force to the System.
Definition: System.h:179
int addParticle(double mass)
Add a particle to the System.
Definition: System.h:88
bool isVirtualSite(int index) const
Get whether a particle is a VirtualSite.
Definition: System.h:126
int getNumParticles() const
Get the number of particles in this System.
Definition: System.h:76