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