00001 /*************************************************************************************************** 00002 ***** Copyright (C) 2005 John Schneiderman <JohnMS@member.fsf.org> ***** 00003 ***** ***** 00004 ***** This program is free software; you can redistribute it and/or modify ***** 00005 ***** it under the terms of the GNU General Public License as published by ***** 00006 ***** the Free Software Foundation; either version 2 of the License, or ***** 00007 ***** (at your option) any later version. ***** 00008 ***** ***** 00009 ***** This program is distributed in the hope that it will be useful, ***** 00010 ***** but WITHOUT ANY WARRANTY; without even the implied warranty of ***** 00011 ***** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ***** 00012 ***** GNU General Public License for more details. ***** 00013 ***** ***** 00014 ***** You should have received a copy of the GNU General Public License ***** 00015 ***** along with this program; if not, write to the Free Software ***** 00016 ***** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ***** 00017 ***************************************************************************************************/ 00018 #ifndef _CLUSTER_H_ 00019 #define _CLUSTER_H_ 00020 00021 #include "atom.h" 00022 #include "coordinate.h" 00023 00024 #include <string> 00025 using std::string; 00026 #include <fstream> 00027 using std::istream; 00028 using std::ostream; 00029 #include <vector> 00030 using std::vector; 00031 00037 class Cluster 00038 { 00039 public: 00044 static const int PRECISION = 10; 00049 static const int WIDTH = 18; 00050 00054 Cluster(); 00059 Cluster(const Cluster &cluster); 00064 double potentialEnergyTotal() const; 00069 double kineticEnergyTotal() const; 00074 Coordinate positionCentreMass() const; 00079 Coordinate velocityCentreMass() const; 00084 void setPotentialEnergyTotal(double potentialEnergyTotal); 00089 void setKineticEnergyTotal(double kineticEnergyTotal); 00094 void setPositionCentreMass(Coordinate positionCentreMass); 00099 void setVelocityCentreMass(Coordinate velocityCentreMass); 00103 void calculatePotentialEnergy(); 00107 void calculateKineticEnergy(); 00111 void calculateCentreMass(); 00118 void read(string baseName); 00125 void write(string baseName); 00129 void clear(); 00134 int size() const; 00140 Cluster& operator=(const Cluster &rhs); 00146 Atom& operator[](int index); 00152 const Atom& operator[](int index) const; 00157 void addAtom(const Atom &atom); 00179 friend ostream& operator<<(ostream &outStream, const Cluster &cluster); 00187 friend bool operator==(const Cluster &lhs, const Cluster &rhs); 00188 00189 private: 00191 Coordinate m_positionCentreMass; 00193 Coordinate m_velocityCentreMass; 00195 double m_potentialEnergyTotal; 00197 double m_kineticEnergyTotal; 00199 vector<Atom> m_atoms; 00200 }; 00201 #endif