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