Psi4
IRC_data.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 
33 #ifndef _opt_irc_data_h_
34 #define _opt_irc_data_h_
35 
36 #include <fstream>
37 #include <vector>
38 
39 #include "linear_algebra.h"
40 #include "molecule.h"
41 #include "print.h"
42 
43 #include "io.h"
44 
45 namespace opt {
46 
47 using namespace std;
48 
49 // data for one optimization step
50 class IRC_POINT {
51 
53  double *q_pivot;//pivot point for step
54  double *x_pivot;//pivot point for step; we save so that q_pivot can be recomputed if necessary
55  double *q; // internal coordinate values
56  double *x; // cartesian coordinate values
57  double *f_q; // internal coordinate forces
58  double *f_x; // cartesian coordinate forces
59  double energy; // total energy
60  double step_dist;
61  double arc_dist;
62  double line_dist;
63 
64  public:
65 
66  IRC_POINT(int coord_in, double *q_p_in, double *x_p_in, double *q_in, double *x_in, double *f_q_in,
67  double *f_x_in, double E_in, double step, double arc, double line)
68  {
69  coord_step = coord_in;
70  q_pivot = q_p_in;
71  x_pivot = x_p_in;
72  q = q_in;
73  x = x_in;
74  f_q = f_q_in;
75  f_x = f_x_in;
76  energy = E_in;
77  step_dist = step;
78  arc_dist = arc;
79  line_dist = line;
80  }
81 
82  ~IRC_POINT() {free_array(q_pivot); free_array(x_pivot); free_array(q); free_array(x); free_array(f_q); free_array(f_x);}
83 
84  int g_coord_step(void) const { return coord_step; }
85  double *g_q_pivot(void) const { return q_pivot; }
86  double *g_x_pivot(void) const { return x_pivot; }
87  double *g_q(void) const { return q; }
88  double g_q(int i) const { return q[i]; }
89  double *g_x(void) const { return x; }
90  double *g_f_q(void) const { return f_q; }
91  double *g_f_x(void) const { return f_x; }
92  double g_energy(void) const { return energy; }
93  double g_step_dist(void) const { return step_dist; }
94  double g_arc_dist(void) const { return arc_dist; }
95  double g_line_dist(void) const { return line_dist; }
96 };
97 
98 // IRC reaction path data
99 class IRC_DATA {
102  double step_dist;
103  double arc_dist;
104  double line_dist;
105  double step_length;
106  double arc_length;
107  double line_length;
108 
109  std::vector<IRC_POINT *> steps;
110 
111  public:
112  bool go;
114 
116  sphere_step = 0;
117  go = 1;
118  in_min_range = 0;
119  step_dist = 0;
120  arc_dist = 0;
121  line_dist = 0;
122  arc_length = 0;
123  line_length = 0;
124  };
125 
126  // free memory
128  for (ULI i=0; i<steps.size(); ++i)
129  delete steps[i];
130  steps.clear();
131  }
132 
133  int size(void) { return steps.size(); }
134 
135  int g_next_coord_step(void) {
136  if(size() == 0)
137  return 0;
138  else
139  return steps.back()->g_coord_step() + 1;
140  }
141 
142  int g_coord_step(void) { return coord_step; }
143  int g_sphere_step(void) { return sphere_step; }
144  double g_arc_dist(void) { return arc_dist; }
145 
146  double g_energy(void) const { return steps.back()->g_energy() ; }
147  double g_step_dist(void) const { return steps.back()->g_step_dist(); }
148  double g_arc_dist(void) const { return steps.back()->g_arc_dist() ; }
149  double g_line_dist(void) const { return steps.back()->g_line_dist(); }
150 
151  double *g_q_pivot(void) const
152  {
153  return steps[steps.size()-1]->g_q_pivot();
154  }
155  double *g_x_pivot(void) const
156  {
157  return steps[steps.size()-1]->g_x_pivot();
158  }
159  double *g_q(void) const
160  {
161  return steps[steps.size()-1]->g_q();
162  }
163  //double g_q(int i) const
164  //{
165  //return g_q(i);
166  //}
167  double *g_x(void) const
168  {
169  return steps[steps.size()-1]->g_x();
170  }
171  double *g_f_q(void) const
172  {
173  return steps[steps.size()-1]->g_f_q();
174  }
175  double *g_f_x(void) const
176  {
177  return steps[steps.size()-1]->g_f_x();
178  }
179  double g_line_dist(int index) const
180  {
181  return steps[index]->g_line_dist();
182  }
183 
184  const IRC_POINT &g_step(int index) const { return *(steps[index]); }
185 
186  //use like irc_step->g_step(2)->g_x();
187 
188  // check convergence of current step
189 // bool conv_check(void) const;
190 
191  // summarize optimization up til now
192 // void summary(void) const;
193 
194  void add_irc_point(int coord_in, double *q_p_in, double *x_p_in, double *q_in, double *x_in, double *f_q_in,
195  double *f_x_in, double E_in)
196  //double *f_x_in, double E_in, double step, double arc, double line)
197  {
198  step_dist = coord_in * step_length;
199  arc_dist += arc_length;
200  line_dist += line_length;
201  IRC_POINT *onepoint = new IRC_POINT(coord_in, q_p_in, x_p_in, q_in, x_in, f_q_in, f_x_in, E_in,
202  step_dist, arc_dist, line_dist);
203  steps.push_back(onepoint);
204  }
205 
206  friend void MOLECULE::irc_step(void);
207 
208  void point_converged(opt::MOLECULE &mol);
209  void progress_report(opt::MOLECULE &mol);
210 
211 };
212 
213 }
214 
215 #endif
double arc_dist
Definition: IRC_data.h:103
double line_dist
Definition: IRC_data.h:104
void irc_step(void)
Definition: molecule_irc_step.cc:180
void add_irc_point(int coord_in, double *q_p_in, double *x_p_in, double *q_in, double *x_in, double *f_q_in, double *f_x_in, double E_in)
Definition: IRC_data.h:194
double * g_x_pivot(void) const
Definition: IRC_data.h:86
std::vector< IRC_POINT * > steps
Definition: IRC_data.h:109
double g_arc_dist(void)
Definition: IRC_data.h:144
~IRC_POINT()
Definition: IRC_data.h:82
double g_line_dist(void) const
Definition: IRC_data.h:95
int coord_step
Definition: IRC_data.h:52
const IRC_POINT & g_step(int index) const
Definition: IRC_data.h:184
Definition: pointgrp.h:105
~IRC_DATA()
Definition: IRC_data.h:127
double * g_f_x(void) const
Definition: IRC_data.h:91
double energy
Definition: IRC_data.h:59
int size(void)
Definition: IRC_data.h:133
double step_dist
Definition: IRC_data.h:60
Definition: optking/molecule.h:46
double g_arc_dist(void) const
Definition: IRC_data.h:94
double g_line_dist(void) const
Definition: IRC_data.h:149
double * f_x
Definition: IRC_data.h:58
double step_length
Definition: IRC_data.h:105
int g_next_coord_step(void)
Definition: IRC_data.h:135
double * g_f_q(void) const
Definition: IRC_data.h:90
bool in_min_range
Definition: IRC_data.h:113
int g_sphere_step(void)
Definition: IRC_data.h:143
double * x
Definition: IRC_data.h:56
double * q_pivot
Definition: IRC_data.h:53
int coord_step
Definition: IRC_data.h:100
double * g_q(void) const
Definition: IRC_data.h:87
double g_arc_dist(void) const
Definition: IRC_data.h:148
double * g_f_q(void) const
Definition: IRC_data.h:171
double * g_f_x(void) const
Definition: IRC_data.h:175
double * g_x(void) const
Definition: IRC_data.h:89
double g_step_dist(void) const
Definition: IRC_data.h:93
unsigned long int ULI
Definition: io.h:40
double arc_dist
Definition: IRC_data.h:61
void free_array(double *f)
Definition: mem.cc:88
double * g_q_pivot(void) const
Definition: IRC_data.h:151
double step_dist
Definition: IRC_data.h:102
IRC_DATA()
Definition: IRC_data.h:115
double g_step_dist(void) const
Definition: IRC_data.h:147
Definition: IRC_data.h:50
double g_energy(void) const
Definition: IRC_data.h:146
double * q
Definition: IRC_data.h:55
double arc_length
Definition: IRC_data.h:106
double * x_pivot
Definition: IRC_data.h:54
double g_q(int i) const
Definition: IRC_data.h:88
bool go
Definition: IRC_data.h:112
double * g_q(void) const
Definition: IRC_data.h:159
double line_dist
Definition: IRC_data.h:62
double g_energy(void) const
Definition: IRC_data.h:92
double line_length
Definition: IRC_data.h:107
Definition: IRC_data.h:99
int g_coord_step(void) const
Definition: IRC_data.h:84
double * g_q_pivot(void) const
Definition: IRC_data.h:85
int g_coord_step(void)
Definition: IRC_data.h:142
double * f_q
Definition: IRC_data.h:57
double * g_x_pivot(void) const
Definition: IRC_data.h:155
int sphere_step
Definition: IRC_data.h:101
IRC_POINT(int coord_in, double *q_p_in, double *x_p_in, double *q_in, double *x_in, double *f_q_in, double *f_x_in, double E_in, double step, double arc, double line)
Definition: IRC_data.h:66
double * g_x(void) const
Definition: IRC_data.h:167
void energy(struct RHO_Params)
Definition: ccdensity/energy.cc:75
double g_line_dist(int index) const
Definition: IRC_data.h:179