1 /* 2 * (c) 2004 Iowa State University 3 * see the LICENSE file in the top level directory 4 */ 5 6 /* Frame.h 7 8 class to organize all data specific to one particular geometry point 9 10 BMB 4/1998 11 */ 12 13 #ifndef __Frame__ 14 #define __Frame__ 15 16 #include "MyTypes.h" 17 /* #include "MolDisplayWin.h" */ 18 19 typedef class MoleculeData MoleculeData; 20 typedef class WinPrefs WinPrefs; 21 typedef class Progress Progress; 22 typedef struct GaussHermiteData GaussHermiteData; 23 typedef class BasisSet BasisSet; 24 typedef class GradientData GradientData; 25 typedef class AtomTypeList AtomTypeList; 26 typedef class XMLElement XMLElement; 27 #ifdef USE_OPENBABEL 28 typedef class OBMol OBMol; 29 #endif 30 31 #if defined(WIN32) 32 #undef AddAtom 33 #endif 34 35 #include <vector> 36 #include <map> 37 38 typedef class Frame Frame; 39 class Frame { 40 friend class MolDisplayWin; 41 friend class SetPlaneDlg; 42 friend class ModeOffsetDlg; 43 friend class LLMDlg; 44 friend class FrameEnergyDlg; 45 friend class CoordWin; 46 friend class MoleculeData; 47 friend class EnergyPlotDialog; 48 friend class FrequenciesDialog; 49 friend class ZCalcWin; 50 friend class Surf2DBase; 51 friend class Surf3DBase; 52 friend class Orb2DSurface; 53 friend class Orb3DSurface; 54 friend class TEDensity3DSurface; 55 friend class TEDensity2DSurface; 56 friend class TEDensity1DSurface; 57 friend class MOPacInternals; 58 friend class DataGroup; 59 friend class ImportVecDlg; 60 friend class MpGLCanvas; 61 friend class FrameSnapShot; 62 private: 63 double Energy; 64 std::vector<EnergyValue> Energies; 65 float time; 66 long IRCPt; 67 mpAtom * Atoms; 68 Bond * Bonds; 69 long NumAtoms; 70 long AtomAllocation; 71 long NumBonds; 72 long BondAllocation; 73 CPoint3D * SpecialAtoms; 74 VibRec * Vibs; 75 std::vector<OrbitalRec *> Orbs; 76 Surface * SurfaceList; 77 GradientData * Gradient; 78 79 Frame * NextFrame; 80 Frame * PreviousFrame; 81 82 int natoms_selected; 83 MolDisplayWin *MolWin; 84 int targeted_atom; 85 86 public: 87 Frame(MolDisplayWin *MolWin); 88 ~Frame(void); 89 90 //Frame& operator= (const Frame& f); 91 //assignment operator overload -- not needed currently 92 93 void SetNextFrame(Frame *); 94 void SetPreviousFrame(Frame *); 95 Frame * GetNextFrame(void); 96 Frame * GetPreviousFrame(void); 97 Surface * GetSurface(long SurfaceNum); 98 Surface * GetSurfaceWithID(long SurfaceID); GetOrbitalSetVector(void)99 const std::vector<OrbitalRec *> * GetOrbitalSetVector(void) const {return &Orbs;}; 100 void DeleteSurface(long SurfaceNum); 101 void DeleteSurfaceWithID(long SurfaceID); 102 void AppendSurface(Surface * NewSurface); 103 long GetNumSurfaces(void); 104 double GetEnergy(TypeOfEnergy t) const; GetEnergy(void)105 inline double GetEnergy(void) const {return Energy;}; 106 void SetEnergy(const double & val, TypeOfEnergy t); 107 double GetKineticEnergy(void) const; 108 double GetMP2Energy(void) const; SetMP2Energy(const double & val)109 void SetMP2Energy(const double & val) {SetEnergy(val, PT2Energy);}; GetTime(void)110 inline float GetTime(void) const {return time;}; SetEnergy(const double & val)111 inline void SetEnergy(const double & val) {Energy = val;}; SetKineticEnergy(const double & val)112 void SetKineticEnergy(const double & val) {SetEnergy(val, KineticEnergy);}; SetTime(const float & val)113 inline void SetTime(const float & val) {time = val;}; 114 void ChangeBond(long TheBond, short WhichPart, long TheAtom); 115 long GetBondAtom(long WhichBond, short ThePart); 116 short GetAtomType(long theAtom) const; 117 bool SetAtomType(long theAtom, short atmType); 118 bool GetAtomPosition(long theAtom, CPoint3D & p) const; 119 bool SetAtomPosition(long theAtom, const CPoint3D & p); 120 mpAtom * AddAtom(long AtomType, const CPoint3D & AtomPosition, long index=-1); 121 mpAtom *AddAtom(const mpAtom& atm, long index=-1, const CPoint3D *pos = NULL); 122 bool IncreaseAtomAllocation(long NumAdditional); 123 //BondExists returns the id of the bond, -1 otherwise 124 long BondExists(long atom1, long atom2) const; 125 void DeleteAtom(long AtomNum); 126 //AddBond validates the two atom references and increases the BondAllocation as 127 //necessary, but does not check the uniqueness of the bond 128 bool AddBond(long Atom1, long Atom2, const BondOrder& b=kSingleBond); 129 bool IncreaseBondAllocation(long NumAdditional); 130 void DeleteBond(long BondNum); 131 /** 132 * Autmatically determines bonds based in atomic radii and interatomic distances 133 * along with user selected tolerances. 134 * @param Prefs The user preferences object. 135 * @param KeepOldBonds If true bonds will only be added to the existing set. 136 * @param ProgressInd A progress window to indicate long operational status 137 * @param selectedOnly If true bonds for the currently selected set of atoms will be 138 * erased and redetermined. 139 */ 140 void SetBonds(WinPrefs * Prefs, bool KeepOldBonds, Progress * ProgressInd, bool selectedOnly=false); 141 bool AddSpecialAtom(CPoint3D Vector, long AtomNum); 142 bool SurfaceExportPossible(void); 143 void ExportSurface(BufferFile * Buffer); 144 AtomTypeList * GetAtomTypes(void); GetNumBonds(void)145 inline long GetNumBonds(void) const {return NumBonds;}; GetNumAtoms(void)146 inline long GetNumAtoms(void) const {return NumAtoms;}; GetBondLoc(long ibond)147 inline Bond * GetBondLoc(long ibond) {return &(Bonds[ibond]);}; 148 float GetBondLength(long ibond); 149 long GetNumMMAtoms(void); 150 /** Toggle the visibility of MM atoms (ie in SiMOMM runs). 151 */ 152 void toggleMMAtomVisibility(void); 153 /** Toggle the visibility of ab initio atoms. 154 */ 155 void toggleAbInitioVisibility(void); 156 /** Toggle the visibility of effective fragments. 157 */ 158 void toggleEFPVisibility(void); 159 bool GetBondLength(long atom1, long atom2, float * length); 160 bool GetBondAngle(long atom1, long BondAtom, long AngleAtom, float * angle); 161 bool GetBondDihedral(long atom1, long BondAtom, long AngleAtom, long DihedralAtom, 162 float * angle); GetBondSelectState(long BondNum)163 inline bool GetBondSelectState(long BondNum) const {return ((BondNum<NumBonds)?Bonds[BondNum].GetSelectState():false);}; SetBondSelectState(long BondNum,bool state)164 inline void SetBondSelectState(long BondNum, bool state) 165 {if (BondNum<NumBonds) Bonds[BondNum].SetSelectState(state);}; GetBondOrder(long BondNum)166 inline BondOrder GetBondOrder(long BondNum) const {return Bonds[BondNum].Order;}; 167 long GetNumElectrons(void) const; SetBondOrder(long BondNum,BondOrder NewOrder)168 inline void SetBondOrder(long BondNum, BondOrder NewOrder) {Bonds[BondNum].Order = NewOrder;}; 169 void ParseGAMESSGuessVectors(BufferFile * Buffer, long NumFuncs, TypeOfWavefunction t, Progress * lProgress); 170 void ParseGAMESSMCSCFVectors(BufferFile * Buffer, long NumFuncs, long NumOrbs, Progress * lProgress); 171 /** Parse the GAMESS CAS-SCF Diabatic Molecular Orbitals 172 * @param Buffer the input buffer. 173 * @param NumFuncs the number of basis functions. 174 * @param NumOrbs the expected number of orbitals (will not parse more than this number). 175 * @param lProgress the progress indicator. 176 */ 177 void ParseGAMESSMCSCFDiabaticVectors(BufferFile * Buffer, long NumFuncs, long NumOrbs, Progress * lProgress); 178 void ParseGAMESSCIVectors(BufferFile * Buffer, long NumFuncs, Progress * lProgress); 179 /** Parse the GAMESS UHF natural orbitals and occupation numbers. 180 * @param Buffer the input buffer. 181 * @param NumFuncs the number of basis functions. 182 * @param lProgress the progress indicator. 183 */ 184 void ParseUHFNOs(BufferFile * Buffer, long NumFuncs, Progress * lProgress); 185 /** Parse the GAMESS TD-DFT natural orbitals and occupation numbers. 186 * @param Buffer the input buffer. 187 * @param NumFuncs the number of basis functions. 188 * @param lProgress the progress indicator. 189 */ 190 void ParseTDDFTNOs(BufferFile * Buffer, long NumFuncs, Progress * lProgress); 191 /** Parse the GAMESS EOM-CC natural orbitals and occupation numbers. 192 * @param Buffer the input buffer. 193 * @param NumFuncs the number of basis functions. 194 * @param lProgress the progress indicator. 195 */ 196 void ParseGAMESSEOM_CC_Vectors(BufferFile * Buffer, long NumFuncs, Progress * lProgress); 197 /** Parse the GAMESS GVB Pair orbitals. 198 * @param Buffer the input buffer. 199 * @param NumFuncs the number of basis functions. 200 * @param NumGVBPairs the number of GVB orbital pairs. 201 * @param lProgress the progress indicator. 202 */ 203 void ParseGVBGIOrbitals(BufferFile * Buffer, const long & NumFuncs, const long & NumGVBPairs, Progress * lProgress); 204 OrbitalRec * ParseGAMESSEigenVectors(BufferFile * Buffer, long NumFuncs, long NumOrbs, 205 long NumBetaOrbs, const long & NumOccAlpha, const long & NumOccBeta, const TypeOfWavefunction & method, Progress * lProgress); 206 OrbitalRec * ParseGAMESSLMOs(BufferFile * Buffer, long NumFuncs, long NumAlphaOrbs, 207 long NumOccBeta, Progress * lProgress, bool OrientedSet); 208 void ReadMolDenOrbitals(BufferFile * Buffer, long NumFuncs); 209 void ReadMP2Vectors(BufferFile * Buffer, BufferFile * DatBuffer, long NumFuncs, 210 Progress * lProgress, long * readflag); 211 float CalculateMEP(float x, float y, float z, BasisSet * Basis, 212 AODensity * TotalAODensity, GaussHermiteData * GHData, float * ElectronicMEP, float * NuclearMEP); 213 AODensity * GetAODensity(BasisSet * basis, const long & targetOrbSet); 214 void ReadGradient(BufferFile * Buffer, wxFileOffset SearchLength); 215 float GetRMSGradient(void) const; 216 float GetMaxGradient(void) const; 217 void SetRMSGradient(float val); 218 void SetMaximumGradient(float val); GetFrequencies(void)219 inline VibRec * GetFrequencies(void) const {return Vibs;}; GetNumberNormalModes(void)220 inline long GetNumberNormalModes(void) const {return ((Vibs!=NULL)?Vibs->GetNumModes():0);} 221 void ParseNormalModes(BufferFile * Buffer, Progress *, WinPrefs *); 222 void ParseMolDenFrequencies(BufferFile * Buffer, WinPrefs *); 223 void DeleteOrbitals(void); 224 bool ReadCMLMolecule(XMLElement * molElement); 225 bool ParseAtomXML(XMLElement * atomXML, std::map<std::string, long> & idList); 226 void ParseAtomArray(XMLElement * arrayXML, std::map<std::string, long> & idList); 227 bool ParseBondXML(XMLElement * bondXML, const std::map<std::string, long> & idList); 228 void ParseBondArrayXML(XMLElement * arrayXML, const std::map<std::string, long> & idList); 229 void ParseAtomAttributeArrayXML(XMLElement * atomXML, const std::map<std::string, long> & idList); 230 long WriteCMLFrame(XMLElement * parent, bool AllData); 231 232 void resetAllSelectState(); 233 bool SetAtomSelection(long atom_id, bool select_it); 234 bool GetAtomSelection(long atom_id) const; 235 int GetNumAtomsSelected(void) const; 236 int GetAtomNumBonds(int atom_id) const; 237 #ifdef USE_OPENBABEL 238 OBMol * ConvertToOBMol(void) const; 239 bool ConvertFromOBMol(const OBMol & mol); 240 #endif 241 bool SetAtomOxidationNumber(int atom_id, int ox_num); 242 int GetAtomOxidationNumber(int atom_id); 243 244 // GetTargetAtom()245 inline int GetTargetAtom() const { return targeted_atom; } SetTargetAtom(int id)246 inline void SetTargetAtom(int id) { targeted_atom = id; } 247 /// Test to see if the gradient vector is avalable for use for display 248 bool GradientVectorAvailable(void) const; 249 /* Retrive the gradient vector for theAtom, returns true if successful 250 * @param theAtom the atom to pull from the array 251 * @param GradientVector upon return contains the gradient vector for theAtom 252 */ 253 bool RetrieveAtomGradient(long theAtom, CPoint3D & gradVector) const; 254 }; 255 256 #endif 257