molecule.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef MOLECULE_HEADER
00029 #define MOLECULE_HEADER
00030
00031 #include <cmath>
00032 #include <assert.h>
00033
00034 #include "realtype.h"
00035
00039 struct Atom {
00040 ergo_real charge;
00041 ergo_real coords[3];
00042 };
00043
00048 struct Vector3D {
00049 ergo_real v[3];
00050 Vector3D() {}
00051 Vector3D(ergo_real x, ergo_real y, ergo_real z) {
00052 v[0] = x; v[1] = y; v[2] = z;
00053 }
00054 ergo_real& operator[](unsigned i) { return v[i]; }
00055 ergo_real operator[](unsigned i) const { return v[i]; }
00057 ergo_real dist2(const ergo_real b[]) const {
00058 ergo_real d, r;
00059 d = v[0]-b[0]; r = d*d;
00060 d = v[1]-b[1]; r += d*d;
00061 d = v[2]-b[2]; r += d*d;
00062 return r;
00063 }
00065 ergo_real dist(const Vector3D& b) const
00066 { return std::sqrt(dist2(b.v)); }
00067 ergo_real dist(const ergo_real b[]) const
00068 { return std::sqrt(dist2(b)); }
00069 };
00070
00075 class Molecule {
00076 public:
00077 static const int MAX_NO_OF_ATOMS=200000;
00078 Atom atoms[MAX_NO_OF_ATOMS];
00079 ergo_real netCharge;
00080 int noOfAtoms;
00081
00082 Molecule() : netCharge(0), noOfAtoms(0) {}
00083
00084 void addAtom(ergo_real c, ergo_real x, ergo_real y, ergo_real z) {
00085 assert(noOfAtoms < MAX_NO_OF_ATOMS);
00086 atoms[noOfAtoms].charge = c;
00087 atoms[noOfAtoms].coords[0] = x;
00088 atoms[noOfAtoms].coords[1] = y;
00089 atoms[noOfAtoms].coords[2] = z;
00090 noOfAtoms++;
00091 }
00092
00094 void getExtremeInternuclearDistances(ergo_real & minDist, ergo_real & maxDist) const;
00096 ergo_real getNuclearRepulsionEnergy() const;
00098 ergo_real getNuclearElectricFieldEnergy(const Vector3D& electricField) const;
00101 int getNumberOfElectrons() const;
00102
00106 int setFromMoleculeFile(const char* fileName,
00107 int netCharge,
00108 char **basissetFile);
00109
00110 };
00111
00112
00113 #endif