ergo
|
00001 /* Ergo, version 3.2, a program for linear scaling electronic structure 00002 * calculations. 00003 * Copyright (C) 2012 Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek. 00004 * 00005 * This program is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation, either version 3 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 * 00018 * Primary academic reference: 00019 * KohnâSham Density Functional Theory Electronic Structure Calculations 00020 * with Linearly Scaling Computational Time and Memory Usage, 00021 * Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek, 00022 * J. Chem. Theory Comput. 7, 340 (2011), 00023 * <http://dx.doi.org/10.1021/ct100611z> 00024 * 00025 * For further information about Ergo, see <http://www.ergoscf.org>. 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 /* MOLECULE_HEADER */