00001 // 00002 // fdhess.h 00003 // 00004 // Copyright (C) 1997 Limit Point Systems, Inc. 00005 // 00006 // Author: Curtis Janssen <cljanss@limitpt.com> 00007 // Maintainer: LPS 00008 // 00009 // This file is part of the SC Toolkit. 00010 // 00011 // The SC Toolkit is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Library General Public License as published by 00013 // the Free Software Foundation; either version 2, or (at your option) 00014 // any later version. 00015 // 00016 // The SC Toolkit is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU Library General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Library General Public License 00022 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to 00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 00024 // 00025 // The U.S. Government is granted a limited license as per AL 91-7. 00026 // 00027 00028 #ifndef _chemistry_molecule_fdhess_h 00029 #define _chemistry_molecule_fdhess_h 00030 00031 #ifdef __GNUC__ 00032 #pragma interface 00033 #endif 00034 00035 #include <iostream> 00036 00037 #include <chemistry/molecule/hess.h> 00038 #include <chemistry/molecule/energy.h> 00039 00041 class FinDispMolecularHessian: public MolecularHessian { 00042 protected: 00043 Ref<MolecularEnergy> mole_; 00044 // In case molecule must be given in lower symmetry, its actual 00045 // symmetry and the symmetry used to compute displacements is this 00046 Ref<PointGroup> displacement_point_group_; 00047 // The molecule's original point group for restoration at the end. 00048 Ref<PointGroup> original_point_group_; 00049 // The molecule's original geometry for restoration at the end and 00050 //computing displacements. 00051 RefSCVector original_geometry_; 00052 // the cartesian displacement size in bohr 00053 double disp_; 00054 // the accuracy for gradient calculations 00055 double accuracy_; 00056 // the number of completed displacements 00057 int ndisp_; 00058 // the number of irreps in the displacement point group 00059 int nirrep_; 00060 // whether or not to attempt a restart 00061 int restart_; 00062 // the name of the restart file 00063 char *restart_file_; 00064 // whether or not to checkpoint 00065 int checkpoint_; 00066 // the name of the checkpoint file 00067 char *checkpoint_file_; 00068 // only do the totally symmetric displacements 00069 int only_totally_symmetric_; 00070 // eliminate the cubic terms by doing an extra displacement for 00071 //each of the totally symmetry coordinates 00072 int eliminate_cubic_terms_; 00073 // use the gradient at the initial geometry to remove first order terms 00074 // (important if not at equilibrium geometry) 00075 int do_null_displacement_; 00076 // print flag 00077 int debug_; 00078 // a basis for the symmetrized cartesian coordinates 00079 RefSCMatrix symbasis_; 00080 // the gradients at each of the displacements 00081 RefSCVector *gradients_; 00082 00083 void get_disp(int disp, int &irrep, int &index, double &coef); 00084 void do_hess_for_irrep(int irrep, 00085 const RefSymmSCMatrix &dhessian, 00086 const RefSymmSCMatrix &xhessian); 00087 void init(); 00088 void restart(); 00089 public: 00090 FinDispMolecularHessian(const Ref<MolecularEnergy>&); 00091 FinDispMolecularHessian(const Ref<KeyVal>&); 00092 FinDispMolecularHessian(StateIn&); 00093 ~FinDispMolecularHessian(); 00094 void save_data_state(StateOut&); 00095 00098 RefSymmSCMatrix compute_hessian_from_gradients(); 00099 int ndisplace() const; 00100 int ndisplacements_done() const { return ndisp_; } 00101 RefSCMatrix displacements(int irrep) const; 00102 void displace(int disp); 00103 void original_geometry(); 00104 void set_gradient(int disp, const RefSCVector &grad); 00105 void checkpoint_displacements(StateOut&); 00106 void restore_displacements(StateIn&); 00107 00110 RefSymmSCMatrix cartesian_hessian(); 00111 00113 void set_checkpoint(int c) { checkpoint_ = c; } 00115 int checkpoint() const { return checkpoint_; } 00116 00117 void set_energy(const Ref<MolecularEnergy> &energy); 00118 MolecularEnergy* energy() const; 00119 00120 Ref<SCMatrixKit> matrixkit() const { return mole_->matrixkit(); } 00121 RefSCDimension d3natom() const { return mole_->moldim(); } 00122 }; 00123 00124 #endif 00125 00126 // Local Variables: 00127 // mode: c++ 00128 // c-file-style: "CLJ" 00129 // End: