| [0b990d] | 1 | //
 | 
|---|
 | 2 | // hess.h
 | 
|---|
 | 3 | //
 | 
|---|
 | 4 | // Copyright (C) 1997 Limit Point Systems, Inc.
 | 
|---|
 | 5 | //
 | 
|---|
 | 6 | // Author: Curtis Janssen <cljanss@limitpt.com>
 | 
|---|
 | 7 | // Maintainer: LPS
 | 
|---|
 | 8 | //
 | 
|---|
 | 9 | // This file is part of the SC Toolkit.
 | 
|---|
 | 10 | //
 | 
|---|
 | 11 | // The SC Toolkit is free software; you can redistribute it and/or modify
 | 
|---|
 | 12 | // it under the terms of the GNU Library General Public License as published by
 | 
|---|
 | 13 | // the Free Software Foundation; either version 2, or (at your option)
 | 
|---|
 | 14 | // any later version.
 | 
|---|
 | 15 | //
 | 
|---|
 | 16 | // The SC Toolkit is distributed in the hope that it will be useful,
 | 
|---|
 | 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
 | 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
 | 19 | // GNU Library General Public License for more details.
 | 
|---|
 | 20 | //
 | 
|---|
 | 21 | // You should have received a copy of the GNU Library General Public License
 | 
|---|
 | 22 | // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
 | 
|---|
 | 23 | // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
|---|
 | 24 | //
 | 
|---|
 | 25 | // The U.S. Government is granted a limited license as per AL 91-7.
 | 
|---|
 | 26 | //
 | 
|---|
 | 27 | 
 | 
|---|
 | 28 | #ifndef _chemistry_molecule_hess_h
 | 
|---|
 | 29 | #define _chemistry_molecule_hess_h
 | 
|---|
 | 30 | 
 | 
|---|
 | 31 | #ifdef __GNUC__
 | 
|---|
 | 32 | #pragma interface
 | 
|---|
 | 33 | #endif
 | 
|---|
 | 34 | 
 | 
|---|
 | 35 | #include <iostream>
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | #include <chemistry/molecule/molecule.h>
 | 
|---|
 | 38 | #include <chemistry/molecule/coor.h>
 | 
|---|
 | 39 | 
 | 
|---|
 | 40 | namespace sc {
 | 
|---|
 | 41 | 
 | 
|---|
 | 42 | class MolecularEnergy;
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 | /** MolecularHessian is an abstract class that computes a molecule's second
 | 
|---|
 | 45 |     derivatives of the energy with respect to changes in the nuclear
 | 
|---|
 | 46 |     coordinates. */
 | 
|---|
 | 47 | class MolecularHessian: virtual public SavableState {
 | 
|---|
 | 48 |   protected:
 | 
|---|
 | 49 |     Ref<Molecule> mol_;
 | 
|---|
 | 50 |     RefSCDimension d3natom_;
 | 
|---|
 | 51 |     Ref<SCMatrixKit> matrixkit_;
 | 
|---|
 | 52 |   public:
 | 
|---|
 | 53 |     MolecularHessian();
 | 
|---|
 | 54 |     /** The MolecularHessian KeyVal constructor is used to generate a
 | 
|---|
 | 55 |         MolecularHessian derivative object from the input.  It reads the
 | 
|---|
 | 56 |         keywords below.
 | 
|---|
 | 57 | 
 | 
|---|
 | 58 |         <table border="1">
 | 
|---|
 | 59 |         <tr><td>Keyword<td>Type<td>Default<td>Description
 | 
|---|
 | 60 |         <tr><td><tt>molecule</tt><td>Molecule<td>none<td>The Molecule object.
 | 
|---|
 | 61 |         </table>
 | 
|---|
 | 62 |     */
 | 
|---|
 | 63 |     MolecularHessian(const Ref<KeyVal>&);
 | 
|---|
 | 64 |     MolecularHessian(StateIn&);
 | 
|---|
 | 65 |     ~MolecularHessian();
 | 
|---|
 | 66 |     void save_data_state(StateOut&);
 | 
|---|
 | 67 | 
 | 
|---|
 | 68 |     RefSCDimension d3natom();
 | 
|---|
 | 69 |     Ref<SCMatrixKit> matrixkit() const { return matrixkit_; }
 | 
|---|
 | 70 | 
 | 
|---|
 | 71 |     /// Return the cartesian hessian.
 | 
|---|
 | 72 |     virtual RefSymmSCMatrix cartesian_hessian() = 0;
 | 
|---|
 | 73 | 
 | 
|---|
 | 74 |     /** Some MolecularHessian specializations require a molecular energy
 | 
|---|
 | 75 |         object.  The default implementations of this ignores the
 | 
|---|
 | 76 |         argument. */
 | 
|---|
 | 77 |     virtual void set_energy(const Ref<MolecularEnergy> &energy);
 | 
|---|
 | 78 |     /** This returns a MolecularEnergy object, if used by
 | 
|---|
 | 79 |         this specialization. Otherwise null is returned.  */
 | 
|---|
 | 80 |     virtual MolecularEnergy* energy() const;
 | 
|---|
 | 81 | 
 | 
|---|
 | 82 |     /** Find transformation matrix from cartesian to symmetry
 | 
|---|
 | 83 |         coordinates. */
 | 
|---|
 | 84 |     static RefSCMatrix cartesian_to_symmetry(const Ref<Molecule> &m,
 | 
|---|
 | 85 |                                              Ref<PointGroup> pg = 0,
 | 
|---|
 | 86 |                                              Ref<SCMatrixKit> kit = 0);
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 |     /// Write the hessian in a simple text format.
 | 
|---|
 | 89 |     static void write_cartesian_hessian(const char *filename,
 | 
|---|
 | 90 |                                         const Ref<Molecule> &m,
 | 
|---|
 | 91 |                                         const RefSymmSCMatrix &hess);
 | 
|---|
 | 92 | 
 | 
|---|
 | 93 |     /// Read the hessian from a simple text format.
 | 
|---|
 | 94 |     static void read_cartesian_hessian(const char *filename,
 | 
|---|
 | 95 |                                        const Ref<Molecule> &m,
 | 
|---|
 | 96 |                                        const RefSymmSCMatrix &hess);
 | 
|---|
 | 97 | };
 | 
|---|
 | 98 | 
 | 
|---|
 | 99 | 
 | 
|---|
 | 100 | /** ReadMolecularHessian is an implementation of MolecularHessian
 | 
|---|
 | 101 |     that reads the hessian from a file. */
 | 
|---|
 | 102 | class ReadMolecularHessian: public MolecularHessian {
 | 
|---|
 | 103 |   protected:
 | 
|---|
 | 104 |     char *filename_;
 | 
|---|
 | 105 |   public:
 | 
|---|
 | 106 |     /** The ReadMolecularHessian KeyVal constructor is used to generate a
 | 
|---|
 | 107 |         ReadMolecularHessian object from the input.  It reads the keywords
 | 
|---|
 | 108 |         below.
 | 
|---|
 | 109 | 
 | 
|---|
 | 110 |         <table border="1">
 | 
|---|
 | 111 | 
 | 
|---|
 | 112 |         <tr><td>Keyword<td>Type<td>Default<td>Description
 | 
|---|
 | 113 |         <tr><td><tt>filename</tt><td>string<td><em>basename</em>
 | 
|---|
 | 114 |         <tt>.hess</tt><td>The name of the file from which the hessian is
 | 
|---|
 | 115 |         read.
 | 
|---|
 | 116 | 
 | 
|---|
 | 117 |         </table>
 | 
|---|
 | 118 |     */
 | 
|---|
 | 119 |     ReadMolecularHessian(const Ref<KeyVal>&);
 | 
|---|
 | 120 |     ReadMolecularHessian(StateIn&);
 | 
|---|
 | 121 |     ~ReadMolecularHessian();
 | 
|---|
 | 122 |     void save_data_state(StateOut&);
 | 
|---|
 | 123 | 
 | 
|---|
 | 124 |     /// Return the hessian in cartesian coordinates.
 | 
|---|
 | 125 |     RefSymmSCMatrix cartesian_hessian();
 | 
|---|
 | 126 | };
 | 
|---|
 | 127 | 
 | 
|---|
 | 128 | /** GuessMolecularHessian is an implementation of MolecularHessian
 | 
|---|
 | 129 |     that estimates the hessian based on the internal coordinates. */
 | 
|---|
 | 130 | class GuessMolecularHessian: public MolecularHessian {
 | 
|---|
 | 131 |   protected:
 | 
|---|
 | 132 |     Ref<MolecularCoor> coor_;
 | 
|---|
 | 133 |   public:
 | 
|---|
 | 134 |     /** The GuessMolecularHessian KeyVal constructor is used to generate a
 | 
|---|
 | 135 |         GuessMolecularHessian object from the input.  It reads the keywords
 | 
|---|
 | 136 |         below.
 | 
|---|
 | 137 | 
 | 
|---|
 | 138 |         <table border="1">
 | 
|---|
 | 139 | 
 | 
|---|
 | 140 |         <tr><td>Keyword<td>Type<td>Default<td>Description
 | 
|---|
 | 141 |         <tr><td><tt>coor</tt><td>MolecularCoor<td>none<td>This gives
 | 
|---|
 | 142 |         the MolecularCoor object that is used to generate the guess
 | 
|---|
 | 143 |         hessian.  It does not have to be the same MolecularCoor
 | 
|---|
 | 144 |         object that is used to optimize the molecule.
 | 
|---|
 | 145 | 
 | 
|---|
 | 146 |         </table>
 | 
|---|
 | 147 |     */
 | 
|---|
 | 148 |     GuessMolecularHessian(const Ref<KeyVal>&);
 | 
|---|
 | 149 |     GuessMolecularHessian(StateIn&);
 | 
|---|
 | 150 |     ~GuessMolecularHessian();
 | 
|---|
 | 151 |     void save_data_state(StateOut&);
 | 
|---|
 | 152 | 
 | 
|---|
 | 153 |     /// Return the hessian in cartesian coordinates.
 | 
|---|
 | 154 |     RefSymmSCMatrix cartesian_hessian();
 | 
|---|
 | 155 | };
 | 
|---|
 | 156 | 
 | 
|---|
 | 157 | /** DiagMolecularHessian is an implementation of MolecularHessian
 | 
|---|
 | 158 |     that returns a hessian that is a diagonal matrix. */
 | 
|---|
 | 159 | class DiagMolecularHessian: public MolecularHessian {
 | 
|---|
 | 160 |   protected:
 | 
|---|
 | 161 |     double diag_;
 | 
|---|
 | 162 |   public:
 | 
|---|
 | 163 |     /** The DiagMolecularHessian KeyVal constructor is used to generate a
 | 
|---|
 | 164 |         DiagMolecularHessian object from the input.  It reads the keywords
 | 
|---|
 | 165 |         below.
 | 
|---|
 | 166 | 
 | 
|---|
 | 167 |         <table border="1">
 | 
|---|
 | 168 | 
 | 
|---|
 | 169 |         <tr><td>Keyword<td>Type<td>Default<td>Description
 | 
|---|
 | 170 |         <tr><td><tt>diag</tt><td>double<td>1.0<td>Specifies the diagonal
 | 
|---|
 | 171 |         elements of the hessian.
 | 
|---|
 | 172 | 
 | 
|---|
 | 173 |         </table>
 | 
|---|
 | 174 |     */
 | 
|---|
 | 175 |     DiagMolecularHessian(const Ref<KeyVal>&);
 | 
|---|
 | 176 |     DiagMolecularHessian(StateIn&);
 | 
|---|
 | 177 |     ~DiagMolecularHessian();
 | 
|---|
 | 178 |     void save_data_state(StateOut&);
 | 
|---|
 | 179 | 
 | 
|---|
 | 180 |     /// Return the hessian in cartesian coordinates.
 | 
|---|
 | 181 |     RefSymmSCMatrix cartesian_hessian();
 | 
|---|
 | 182 | };
 | 
|---|
 | 183 | 
 | 
|---|
 | 184 | }
 | 
|---|
 | 185 | 
 | 
|---|
 | 186 | #endif
 | 
|---|
 | 187 | 
 | 
|---|
 | 188 | // Local Variables:
 | 
|---|
 | 189 | // mode: c++
 | 
|---|
 | 190 | // c-file-style: "CLJ"
 | 
|---|
 | 191 | // End:
 | 
|---|