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