Psi4
simple_base.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_simple_base_h_
34 #define _opt_simple_base_h_
35 
36 #include <cstdio>
37 #include <string>
38 #include "mem.h"
39 
40 namespace opt {
41 
43 
44 typedef const double * const * const GeomType;
45 
47 
48  protected:
49 
50  INTCO_TYPE s_type; // type of simple
51  int s_natom; // # of atoms in internal definition, i.e., # of
52  // atoms with non-zero s-vectors
53  int *s_atom; // atom indices in internal definition
54 
55  bool s_frozen; // is internal coordinate constrained frozen?
56 
57  double s_fixed_eq_val; // for adding artificial forces
59 
60  public:
61 
62  SIMPLE_COORDINATE (INTCO_TYPE s_type_in, int s_natom_in, bool freeze_in) {
63  s_type = s_type_in;
64  s_natom = s_natom_in;
66  s_frozen = freeze_in;
67  s_has_fixed_eq_val = false;
68  };
69 
70  virtual ~SIMPLE_COORDINATE() { // derived class destructors called first; then this one
72  }
73 
74  INTCO_TYPE g_type(void) const { return s_type; }
75  int g_natom(void) const { return s_natom; }
76  int g_atom(int a) const { return s_atom[a]; }
77 
78  bool is_frozen(void) { return s_frozen; }
79  void freeze(void) { s_frozen = true; }
80  void unfreeze(void) { s_frozen = false; }
81 
82  // do-nothing function overridden only by torsion class
83  virtual void fix_tors_near_180(GeomType) { return; }
84 
85  // do-nothing function overridden only by oofp class
86  virtual void fix_oofp_near_180(GeomType) { return; }
87 
88  // do-nothing function overridden by stretch class
89  virtual bool is_hbond(void) const { return false; }
90 
91  // do-nothing function overridden by stretch class
92  virtual void set_hbond(bool) { printf("base_hbond"); return; }
93 
94  // do-nothing function overridden by stretch class
95  virtual bool is_inverse_stre(void) const { return false; }
96 
97  // do-nothing function overridden by bend class
98  virtual int g_bend_type(void) const { return -1; }
99 
100  // do-nothing function overridden by cartesian class
101  virtual int g_xyz(void) const { return 0; }
102 
103  // each internal coordinate type must provide the following virtual functions:
104 
105  // function to print coordinate definitions to intco.dat
106  virtual void print_intco_dat(std::string psi_fp, FILE *qc_fc, int atom_offset=0) const = 0;
107 
108  // return value of internal coordinate
109  virtual double value(GeomType geom) const = 0;
110 
111  // compute s vector (dq/dx, dq/dy, dq/dz)
112  virtual double ** DqDx(GeomType geom) const = 0;
113 
114  // compute second derivative (B' matrix elements)
115  // dq_i dq_j / dx^2, dydx, dy^2, dzdx, dzdy, dz^2
116  virtual double ** Dq2Dx2(GeomType geom) const = 0;
117 
118  // print coordinates and value to output file
119  virtual void print(std::string psi_fp, FILE *qc_fp, GeomType geom, int atom_offset=0) const = 0;
120 
121  // print coordinates and displacements
122  virtual void print_disp(std::string psi_fp, FILE *qc_fp, const double old_q, const double f_q,
123  const double dq, const double new_q, int atom_offset = 0) const = 0;
124 
125  // for debugging, print s vectors to output file
126  virtual void print_s(std::string psi_fp, FILE *qc_fp, GeomType geom) const = 0;
127 
128  // function to return string of coordinate definition
129  virtual std::string get_definition_string(int atom_offset=0) const = 0;
130 
131  // each derived class should have an equality operator of this type that
132  // first checks types with g_type() and then, if true, compares
133  // the internal coordinates
134  virtual bool operator==(const SIMPLE_COORDINATE & s2) const = 0;
135 
136  // functions to save user-specified constrained eq_val
137  void set_fixed_eq_val(double val) {
138  s_fixed_eq_val = val;
139  s_has_fixed_eq_val = true;
140  }
141  double fixed_eq_val(void) {
142  return s_fixed_eq_val;
143  }
144  bool has_fixed_eq_val(void) { return s_has_fixed_eq_val; }
145 
146 };
147 
148 }
149 
150 #endif
const double *const *const GeomType
Definition: simple_base.h:44
virtual void print_intco_dat(std::string psi_fp, FILE *qc_fc, int atom_offset=0) const =0
INTCO_TYPE
Definition: simple_base.h:42
Definition: simple_base.h:42
Definition: simple_base.h:42
virtual double value(GeomType geom) const =0
INTCO_TYPE g_type(void) const
Definition: simple_base.h:74
virtual int g_bend_type(void) const
Definition: simple_base.h:98
int g_atom(int a) const
Definition: simple_base.h:76
int s_natom
Definition: simple_base.h:51
Definition: simple_base.h:46
Definition: simple_base.h:42
virtual void print_s(std::string psi_fp, FILE *qc_fp, GeomType geom) const =0
void freeze(void)
Definition: simple_base.h:79
SIMPLE_COORDINATE(INTCO_TYPE s_type_in, int s_natom_in, bool freeze_in)
Definition: simple_base.h:62
virtual void fix_tors_near_180(GeomType)
Definition: simple_base.h:83
void unfreeze(void)
Definition: simple_base.h:80
Definition: simple_base.h:42
virtual void set_hbond(bool)
Definition: simple_base.h:92
virtual int g_xyz(void) const
Definition: simple_base.h:101
virtual double ** Dq2Dx2(GeomType geom) const =0
Definition: simple_base.h:42
Definition: simple_base.h:42
void free_int_array(int *f)
Definition: mem.cc:93
virtual void print(std::string psi_fp, FILE *qc_fp, GeomType geom, int atom_offset=0) const =0
bool has_fixed_eq_val(void)
Definition: simple_base.h:144
virtual ~SIMPLE_COORDINATE()
Definition: simple_base.h:70
int * init_int_array(int m)
Definition: mem.cc:69
virtual std::string get_definition_string(int atom_offset=0) const =0
virtual bool is_inverse_stre(void) const
Definition: simple_base.h:95
bool s_frozen
Definition: simple_base.h:55
void set_fixed_eq_val(double val)
Definition: simple_base.h:137
double s_fixed_eq_val
Definition: simple_base.h:57
bool s_has_fixed_eq_val
Definition: simple_base.h:58
int * s_atom
Definition: simple_base.h:53
INTCO_TYPE s_type
Definition: simple_base.h:50
double fixed_eq_val(void)
Definition: simple_base.h:141
virtual bool operator==(const SIMPLE_COORDINATE &s2) const =0
int g_natom(void) const
Definition: simple_base.h:75
virtual double ** DqDx(GeomType geom) const =0
virtual void fix_oofp_near_180(GeomType)
Definition: simple_base.h:86
Definition: simple_base.h:42
virtual bool is_hbond(void) const
Definition: simple_base.h:89
bool is_frozen(void)
Definition: simple_base.h:78
virtual void print_disp(std::string psi_fp, FILE *qc_fp, const double old_q, const double f_q, const double dq, const double new_q, int atom_offset=0) const =0