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 file is part of Psi4.
12  *
13  * Psi4 is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation, version 3.
16  *
17  * Psi4 is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License along
23  * with Psi4; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  *
26  * @END LICENSE
27  */
28 
29 #ifndef _findif_h_
30 #define _findif_h_
31 
32 #include <sstream>
33 #include <vector>
34 
35 #include "psi4/psi4-dec.h"
36 #include "psi4/libciomr/libciomr.h"
37 #include "psi4/libqt/qt.h"
38 #include "psi4/libmints/typedefs.h"
39 #include "psi4/pybind11.h"
40 
41 namespace psi {
42 class Molecule;
43 class CdSalcList;
44 
45 namespace findif {
46 
47 // functions to generate displacements
48 std::vector< SharedMatrix > fd_geoms_1_0(std::shared_ptr<Molecule> mol, Options &options);
49 // std::vector< SharedMatrix > fd_geoms_2_0(Options &options);
50 std::vector< SharedMatrix > fd_geoms_freq_0(std::shared_ptr<Molecule> mol, Options &options, int irrep=-1);
51 std::vector< SharedMatrix > fd_geoms_freq_1(std::shared_ptr<Molecule> mol, Options &options, int irrep=-1);
52 std::vector< SharedMatrix > atomic_displacements(std::shared_ptr<Molecule> mol, Options &options);
53 
54 // functions to carry out finite-differences
55 SharedMatrix fd_1_0(std::shared_ptr<Molecule> mol, Options &options, const py::list& energies);
56 //PsiReturnType fd_2_0(std::shared_ptr<Molecule> mol, Options &options, const py::list& energies);
57 SharedMatrix fd_freq_0(std::shared_ptr<Molecule> mol, Options &options,
58  const py::list& energies, int irrep=-1);
59 SharedMatrix fd_freq_1(std::shared_ptr<Molecule> mol, Options &options,
60  const py::list& E_list, int irrep=-1);
61 
62 // class to accumulate and print vibrations
63 class VIBRATION {
64  int irrep; // irrep
65  double km; // force constant
66  double *lx; // normal mode in mass-weighted cartesians
67  double cm; // harmonic frequency in wavenumbers
68 
69  public:
70  friend PsiReturnType fd_freq_0(Options &options, const py::list& energies, int irrep);
71  friend PsiReturnType fd_freq_1(Options &options, const py::list& gradients, int irrep);
72  friend bool ascending(const VIBRATION *, const VIBRATION *);
73  friend void print_vibrations(std::shared_ptr<Molecule> mol, std::vector<VIBRATION *> modes);
74 
75  double get_km() {return km;}
76  double get_cm() {return cm;}
77  double get_lx(int i) {return lx[i];}
78 
79  VIBRATION(int irrep_in, double km_in, double *lx_in) { irrep = irrep_in; km = km_in; lx = lx_in; }
80  ~VIBRATION() { free(lx); }
81 };
82 
83 // function to print vibrations
84 void print_vibrations(std::shared_ptr<Molecule> mol, std::vector<VIBRATION *> modes);
85 
86 // to order vibrations
87 bool ascending(const VIBRATION *vib1, const VIBRATION *vib2);
88 
89 // for displacing along a salc
90 void displace_cart(std::shared_ptr<Molecule> mol, SharedMatrix geom, const CdSalcList & salclist,
91  int salc_i, int disp_factor, double disp_size);
92 
93 void displace_cart(std::shared_ptr<Molecule> mol, SharedMatrix geom, const CdSalcList & salclist,
94  int salc_i, int salc_j, int disp_factor_i, int disp_factor_j, double disp_size);
95 
96 // to massweight columns of a shared matrix
98 
99 // displace an atomic coordinate
100 void displace_atom(SharedMatrix geom, const int atom, const int coord,
101  const int sign, const double disp_size);
102 
103 // save gemetry and normal modes to files
104 void save_normal_modes(std::shared_ptr<Molecule> mol,
105  std::vector<VIBRATION *> modes);
106 
107 
108 template <class T>
109 inline std::string to_string (const T& t)
110 {
111 std::stringstream ss;
112 ss << t;
113 return ss.str();
114 }
115 
116 }}
117 
118 #endif
double get_cm()
Definition: findif.h:76
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:204
bool ascending(const VIBRATION *vib1, const VIBRATION *vib2)
Definition: fd_misc.cc:52
void mass_weight_columns_plus_one_half(std::shared_ptr< Molecule > mol, SharedMatrix B)
Definition: fd_misc.cc:254
Definition: cdsalclist.h:124
double cm
Definition: findif.h:67
void print_vibrations(std::shared_ptr< Molecule > mol, std::vector< VIBRATION * > modes)
Definition: fd_misc.cc:60
PsiReturnType
Definition: psi4-dec.h:46
SharedMatrix fd_freq_0(std::shared_ptr< Molecule >, Options &, const py::list &, int irrep=-1)
Definition: fd_freq_0.cc:63
Definition: pointgrp.h:106
SharedMatrix fd_freq_1(std::shared_ptr< Molecule >, Options &, const py::list &, int irrep=-1)
Definition: fd_freq_1.cc:50
double get_lx(int i)
Definition: findif.h:77
Definition: findif.h:63
int * T
Definition: stringlist.cc:66
void save_normal_modes(std::shared_ptr< Molecule > mol, std::vector< VIBRATION * > modes)
Definition: fd_misc.cc:158
double km
Definition: findif.h:65
double * lx
Definition: findif.h:66
VIBRATION(int irrep_in, double km_in, double *lx_in)
Definition: findif.h:79
SharedMatrix displace_atom(SharedMatrix geom, const int atom, const int coord, const int sign, const double disp_size)
Definition: fd_misc.cc:264
std::string to_string(const T &t)
Definition: findif.h:109
~VIBRATION()
Definition: findif.h:80
friend PsiReturnType fd_freq_1(Options &options, const py::list &gradients, int irrep)
double get_km()
Definition: findif.h:75
Definition: liboptions.h:355
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:45
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:49
std::vector< SharedMatrix > fd_geoms_1_0(std::shared_ptr< Molecule >, Options &)
Definition: fd_geoms_1_0.cc:45
friend PsiReturnType fd_freq_0(Options &options, const py::list &energies, int irrep)
friend bool ascending(const VIBRATION *, const VIBRATION *)
Definition: fd_misc.cc:52
friend void print_vibrations(std::shared_ptr< Molecule > mol, std::vector< VIBRATION * > modes)
Definition: fd_misc.cc:60
SharedMatrix fd_1_0(std::shared_ptr< Molecule >, Options &, const py::list &)
Definition: fd_1_0.cc:48
std::vector< SharedMatrix > fd_geoms_freq_0(std::shared_ptr< Molecule >, Options &, int irrep=-1)
Definition: fd_geoms_freq_0.cc:61
std::vector< SharedMatrix > atomic_displacements(std::shared_ptr< Molecule >, Options &)
Definition: fd_misc.cc:271
int irrep
Definition: findif.h:64