Psi4
findif.h
Go to the documentation of this file.
1 /*
2  * @BEGIN LICENSE
3  *
4  * Psi4: an open-source quantum chemistry software package
5  *
6  * Copyright (c) 2007-2017 The Psi4 Developers.
7  *
8  * The copyrights for code used from other parties are included in
9  * the corresponding files.
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program 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 General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * @END LICENSE
26  */
27 
28 #ifndef _findif_h_
29 #define _findif_h_
30 
31 #include <sstream>
32 #include <vector>
33 
34 #include "psi4/psi4-dec.h"
35 #include "psi4/libciomr/libciomr.h"
36 #include "psi4/libqt/qt.h"
37 
38 namespace psi {
39 class Molecule;
40 class CdSalcList;
41 
42 namespace findif {
43 
44 // functions to generate displacements
45 std::vector< SharedMatrix > fd_geoms_1_0(std::shared_ptr<Molecule> mol, Options &options);
46 // std::vector< SharedMatrix > fd_geoms_2_0(Options &options);
47 std::vector< SharedMatrix > fd_geoms_freq_0(std::shared_ptr<Molecule> mol, Options &options, int irrep=-1);
48 std::vector< SharedMatrix > fd_geoms_freq_1(std::shared_ptr<Molecule> mol, Options &options, int irrep=-1);
49 std::vector< SharedMatrix > atomic_displacements(std::shared_ptr<Molecule> mol, Options &options);
50 
51 // functions to carry out finite-differences
52 SharedMatrix fd_1_0(std::shared_ptr<Molecule> mol, Options &options, const py::list& energies);
53 //PsiReturnType fd_2_0(std::shared_ptr<Molecule> mol, Options &options, const py::list& energies);
54 SharedMatrix fd_freq_0(std::shared_ptr<Molecule> mol, Options &options,
55  const py::list& energies, int irrep=-1);
56 SharedMatrix fd_freq_1(std::shared_ptr<Molecule> mol, Options &options,
57  const py::list& E_list, int irrep=-1);
58 
59 // class to accumulate and print vibrations
60 class VIBRATION {
61  int irrep; // irrep
62  double km; // force constant
63  double *lx; // normal mode in mass-weighted cartesians
64  double cm; // harmonic frequency in wavenumbers
65 
66  public:
67  friend PsiReturnType fd_freq_0(Options &options, const py::list& energies, int irrep);
68  friend PsiReturnType fd_freq_1(Options &options, const py::list& gradients, int irrep);
69  friend bool ascending(const VIBRATION *, const VIBRATION *);
70  friend void print_vibrations(std::shared_ptr<Molecule> mol, std::vector<VIBRATION *> modes);
71 
72  double get_km() {return km;}
73  double get_cm() {return cm;}
74  double get_lx(int i) {return lx[i];}
75 
76  VIBRATION(int irrep_in, double km_in, double *lx_in) { irrep = irrep_in; km = km_in; lx = lx_in; }
77  ~VIBRATION() { free(lx); }
78 };
79 
80 // function to print vibrations
81 void print_vibrations(std::shared_ptr<Molecule> mol, std::vector<VIBRATION *> modes);
82 
83 // to order vibrations
84 bool ascending(const VIBRATION *vib1, const VIBRATION *vib2);
85 
86 // for displacing along a salc
87 void displace_cart(std::shared_ptr<Molecule> mol, SharedMatrix geom, const CdSalcList & salclist,
88  int salc_i, int disp_factor, double disp_size);
89 
90 void displace_cart(std::shared_ptr<Molecule> mol, SharedMatrix geom, const CdSalcList & salclist,
91  int salc_i, int salc_j, int disp_factor_i, int disp_factor_j, double disp_size);
92 
93 // to massweight columns of a shared matrix
95 
96 // displace an atomic coordinate
97 void displace_atom(SharedMatrix geom, const int atom, const int coord,
98  const int sign, const double disp_size);
99 
100 // save gemetry and normal modes to files
101 void save_normal_modes(std::shared_ptr<Molecule> mol,
102  std::vector<VIBRATION *> modes);
103 
104 
105 template <class T>
106 inline std::string to_string (const T& t)
107 {
108 std::stringstream ss;
109 ss << t;
110 return ss.str();
111 }
112 
113 }}
114 
115 #endif
double get_cm()
Definition: findif.h:73
void displace_cart(std::shared_ptr< Molecule > mol, SharedMatrix geom, const CdSalcList &salclist, int salc_i, int disp_factor, double disp_size)
Definition: fd_misc.cc:202
bool ascending(const VIBRATION *vib1, const VIBRATION *vib2)
Definition: fd_misc.cc:50
void mass_weight_columns_plus_one_half(std::shared_ptr< Molecule > mol, SharedMatrix B)
Definition: fd_misc.cc:252
Definition: cdsalclist.h:124
double cm
Definition: findif.h:64
void print_vibrations(std::shared_ptr< Molecule > mol, std::vector< VIBRATION * > modes)
Definition: fd_misc.cc:58
PsiReturnType
Definition: psi4-dec.h:48
SharedMatrix fd_freq_0(std::shared_ptr< Molecule >, Options &, const py::list &, int irrep=-1)
Definition: fd_freq_0.cc:62
Definition: pointgrp.h:105
SharedMatrix fd_freq_1(std::shared_ptr< Molecule >, Options &, const py::list &, int irrep=-1)
Definition: fd_freq_1.cc:49
double get_lx(int i)
Definition: findif.h:74
Definition: findif.h:60
void save_normal_modes(std::shared_ptr< Molecule > mol, std::vector< VIBRATION * > modes)
Definition: fd_misc.cc:156
double km
Definition: findif.h:62
double * lx
Definition: findif.h:63
VIBRATION(int irrep_in, double km_in, double *lx_in)
Definition: findif.h:76
SharedMatrix displace_atom(SharedMatrix geom, const int atom, const int coord, const int sign, const double disp_size)
Definition: fd_misc.cc:262
std::string to_string(const T &t)
Definition: findif.h:106
~VIBRATION()
Definition: findif.h:77
friend PsiReturnType fd_freq_1(Options &options, const py::list &gradients, int irrep)
double get_km()
Definition: findif.h:72
Definition: liboptions.h:359
Header file for the Quantum Trio LibraryDavid Sherrill 1994.
std::vector< SharedMatrix > fd_geoms_freq_1(std::shared_ptr< Molecule >, Options &, int irrep=-1)
Definition: fd_geoms_freq_1.cc:43
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:50
std::vector< SharedMatrix > fd_geoms_1_0(std::shared_ptr< Molecule >, Options &)
Definition: fd_geoms_1_0.cc:43
friend PsiReturnType fd_freq_0(Options &options, const py::list &energies, int irrep)
friend bool ascending(const VIBRATION *, const VIBRATION *)
Definition: fd_misc.cc:50
friend void print_vibrations(std::shared_ptr< Molecule > mol, std::vector< VIBRATION * > modes)
Definition: fd_misc.cc:58
SharedMatrix fd_1_0(std::shared_ptr< Molecule >, Options &, const py::list &)
Definition: fd_1_0.cc:46
Definition: PsiFileImpl.h:39
std::vector< SharedMatrix > fd_geoms_freq_0(std::shared_ptr< Molecule >, Options &, int irrep=-1)
Definition: fd_geoms_freq_0.cc:59
std::vector< SharedMatrix > atomic_displacements(std::shared_ptr< Molecule >, Options &)
Definition: fd_misc.cc:269
int irrep
Definition: findif.h:61