Psi4
interfrag.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_interfrag_h_
34 #define _opt_interfrag_h_
35 
36 #include "linear_algebra.h"
37 #include "psi4/optking/physconst.h"
38 
39 namespace opt {
40 /*
41 INTERFRAG is a set of coordinates between two fragments (A and B).
42 Up to 3 reference atoms on each fragment (dA[3] and dB[3]) are defined
43 as either
44  If INTERFRAGMENT_MODE == FIXED,
45  linear combinations of the atoms in A and B, using A_weight and B_weight,
46  or if INTERFRAGMENT_MODE == PRINCIPAL_AXES
47  1. the center of mass
48  2. a point a unit distance along the principal axis corresponding to the largest moment.
49  3. a point a unit distance along the principal axis corresponding to the 2nd largest moment.
50 
51 For now, the six coordinates formed from the d_K^{A,B} sets are assumed to be the
52 following in this canonical order:
53 D[0], RAB = distance between dA[0] and dB[0]
54 D[1], theta_A = angle, dA[1]-dA[0]-dB[0]
55 D[2], theta_B = angle, dA[0]-dB[0]-dB[1]
56 D[3], tau = dihedral angle, dA[1]-dA[0]-dB[0]-dB[1]
57 D[4], phi_A = dihedral angle, dA[2]-dA[1]-dA[0]-dB[0]
58 D[5], phi_B = dihedral angle, dA[0]-dB[0]-dB[1]-dB[2]
59 
60 inter_geom[0] = dA[2]; // For simplicity, we sort the atoms in the 'inter_geom'
61 inter_geom[1] = dA[1]; // according to the assumed connectivity of the coordinates.
62 inter_geom[2] = dA[0]; // For A, this reverses the order in which weights are
63 inter_geom[3] = dB[0]; // provided to the constructor.
64 inter_geom[4] = dB[1];
65 inter_geom[5] = dB[2];
66 */
67 
68 class INTERFRAG {
69 
70  FRAG *A; // pointer to fragment A
71  FRAG *B; // pointer to fragment B
72 
73  int A_index; // index of fragment A in MOLECULE fragments, vector<FRAG *>
74  int B_index; // index of fragment B in MOLECULE fragments, vector<FRAG *>
75 
76  int ndA; // number of reference points used on A (<= 3)
77  int ndB; // number of reference points used on B (<= 3)
78 
79  // weights on the atoms of fragment A/B, defining the reference points
80  double **weightA; // dimension [ndA][A->natom]
81  double **weightB; // dimension [ndB][B->natom]
82 
83  FRAG *inter_frag; // pseudo-fragment that contains the 6 reference points as its atoms
84 
85  bool D_on[6]; // indicates which coordinates [0-5] are present;
86  // if ndA or ndB <3, then not all 6 coordinates are defined
87 
88  // whether to use COM, and 2 points on principal axes - instead of fixed weights
90 
91  public:
92 
93  // Constructor for fixed, linear-combination reference points.
94  // Memory provided by calling function.
95  INTERFRAG(FRAG *A_in, FRAG *B_in, int A_index_in, int B_index_in,
96  double **weightA_in, double **weightB_in, int ndA_in=3, int ndB_in=3,
97  bool use_principal_axes=false);
98 
99 
100  ~INTERFRAG() { delete inter_frag; }
101 
102  // update location of reference points using fragment member geometries
105  }
106 
107  // update location of reference points using given geometries
108  void update_reference_points(GeomType new_geom_A, GeomType new_geom_B);
109 
110  int Ncoord(void) const;
111 
112  // return vector index of fragments in molecule vector
113  int g_A_index(void) const { return A_index; }
114  int g_B_index(void) const { return B_index; }
115 
116  int g_ndA(void) const { return ndA; }
117  int g_ndB(void) const { return ndB; }
118 
119  // compute and return coordinate values - using fragment member geometries
120  double *coord_values(void) {
121  double *q = coord_values(A->geom, B->geom);
122  return q;
123  }
124 
125  // freeze coordinate i if D_freeze[i]; index runs 0->6 as does D_on
126  //void freeze(bool *D_freeze);
127 
128  // freeze coordinate i; index is among 'on' (well-defined) coordinates
129  void freeze(int J);
130 
131  // freeze all interfragment coordinates in this set
132  void freeze(void);
133 
134  // is coordinate J frozen? J runs over only active coordinates.
135  bool is_frozen(int J);
136 
137  // are all of these interfragment coordinates frozen?
138  bool is_frozen(void);
139 
140  // compute and return coordinate values - using given fragment geometries
141  double *coord_values(GeomType new_geom_A, GeomType new_geom_B);
142 
143  // check nearness to 180 and save value
144  void fix_tors_near_180(void) {
147  }
148 
149  void fix_oofp_near_180(void) {
152  }
153 
154  void fix_bend_axes(void) {
157  }
158  void unfix_bend_axes(void) {
161  }
162 
163  // Fills in B matrix rows. Provide geometries.
164  void compute_B(GeomType new_geom_A, GeomType new_geom_B, double **Bin, int coord_offset,
165  int A_off, int B_off);
166 
167  // Fills in B matrix rows.
168  void compute_B(double **Bin, int coord_offset, int A_offset, int B_offset) {
169  compute_B(A->geom, B->geom, Bin, coord_offset, A_offset, B_offset);
170  return;
171  }
172 
173  // allocate and return B matrix only for this interfragment.
174  double **compute_B(void) {
175  double **Bout = init_matrix(Ncoord(), 3*g_natom());
176  compute_B(A->geom, B->geom, Bout, 0, 0, 0);
177  return Bout;
178  }
179 
180 /*
181  // Returns derivative B matrix from member geometries
182 // This would have to contain both fragments
183  double **compute_derivative_B(int coord_index) {
184  double **Bder = init_matrix ( , )
185  compute_derivative_B(coord_index, A->geom, B->geom, **Bdir, 0, 0);
186  return Bder;
187  }
188 */
189  // returns derivative B matrix for one internal, returns 3*natomA x 3*natomA
190  void compute_derivative_B(int coord_index, GeomType new_geom_A, GeomType new_geom_B,
191  double **Bprim, int A_offset, int B_offset);
192 
193  // print reference point definitions and values of coordinates
194  void print_coords(std::string psi_fp, FILE *qc_fp, int A_off=0, int B_off=0) const;
195 
196  // print coordinate definitions
197  void print_intco_dat(std::string psi_fp, FILE *qc_fp, int atom_offset_A=0, int atom_offset_B=0) const;
198 
199  // return string of coord definition
200  std::string get_coord_definition(int coord_index, int atom_offset_A=0, int atom_offset_B=0) const;
201 
202  // get number of atoms in the two fragments
203  int g_natom(void) const { return (A->g_natom() + B->g_natom()); }
204  int g_natom_A(void) const { return (A->g_natom()); }
205  int g_natom_B(void) const { return (B->g_natom()); }
206 
207  bool coordinate_on(int i) const { return D_on[i]; }
208 
209  double ** H_guess(void); // guess Hessian
210 
211  // orient fragments and displace by dq; forces are just for printing
212  bool orient_fragment(double *dq, double *f_q=NULL);
213 
214  double ** compute_constraints(void) const;
215 
217 
219 
220 }; // class INTERFRAG
221 
222 } // opt
223 
224 #endif
~INTERFRAG()
Definition: interfrag.h:100
FRAG * A
Definition: interfrag.h:70
double ** weightB
Definition: interfrag.h:81
double * coord_values(void)
Definition: interfrag.h:120
void fix_tors_near_180(void)
Definition: frag.cc:735
int g_natom_A(void) const
Definition: interfrag.h:204
void fix_bend_axes(void)
Definition: interfrag.h:154
std::string get_coord_definition(int coord_index, int atom_offset_A=0, int atom_offset_B=0) const
Definition: interfrag.cc:714
const double *const *const GeomType
Definition: simple_base.h:44
bool orient_fragment(double *dq, double *f_q=NULL)
Definition: interfrag_orient.cc:68
bool principal_axes
Definition: interfrag.h:89
void fix_bend_axes(void)
Definition: frag.cc:742
double ** compute_constraints(void) const
Definition: interfrag.cc:787
bool D_on[6]
Definition: interfrag.h:85
void fix_oofp_near_180(void)
Definition: interfrag.h:149
void unfix_bend_axes(void)
Definition: interfrag.h:158
int g_ndB(void) const
Definition: interfrag.h:117
int Ncoord(void) const
Definition: interfrag.cc:284
double ** H_guess(void)
Definition: interfrag.cc:736
void unfix_bend_axes(void)
Definition: frag.cc:756
void add_coordinates_of_reference_pts(void)
Definition: interfrag.cc:77
Definition: pointgrp.h:105
int g_ndA(void) const
Definition: interfrag.h:116
void print_intco_dat(std::string psi_fp, FILE *qc_fp, int atom_offset_A=0, int atom_offset_B=0) const
Definition: interfrag.cc:698
int g_natom_B(void) const
Definition: interfrag.h:205
A group of atoms, its geometry, and its internal coordinates.
Definition: frag.h:53
double ** weightA
Definition: interfrag.h:80
int ndA
Definition: interfrag.h:76
double ** compute_B(void)
Definition: interfrag.h:174
void fix_oofp_near_180(void)
Definition: frag.cc:765
int B_index
Definition: interfrag.h:74
void update_reference_points(void)
Definition: interfrag.h:103
int g_B_index(void) const
Definition: interfrag.h:114
bool is_frozen(void)
Definition: interfrag.cc:326
double ** init_matrix(long int m, long int n)
Definition: mem.cc:102
FRAG * B
Definition: interfrag.h:71
int A_index
Definition: interfrag.h:73
int ndB
Definition: interfrag.h:77
void compute_derivative_B(int coord_index, GeomType new_geom_A, GeomType new_geom_B, double **Bprim, int A_offset, int B_offset)
INTERFRAG(FRAG *A_in, FRAG *B_in, int A_index_in, int B_index_in, double **weightA_in, double **weightB_in, int ndA_in=3, int ndB_in=3, bool use_principal_axes=false)
Definition: interfrag.cc:49
void fix_tors_near_180(void)
Definition: interfrag.h:144
int form_trivial_coord_combinations(void)
Definition: interfrag.cc:799
int g_natom(void) const
Definition: frag.h:84
int g_A_index(void) const
Definition: interfrag.h:113
double ** geom
cartesian coordinates
Definition: frag.h:58
void print_coords(std::string psi_fp, FILE *qc_fp, int A_off=0, int B_off=0) const
Definition: interfrag.cc:672
Definition: interfrag.h:68
void compute_B(double **Bin, int coord_offset, int A_offset, int B_offset)
Definition: interfrag.h:168
FRAG * inter_frag
Definition: interfrag.h:83
bool coordinate_on(int i) const
Definition: interfrag.h:207
int g_natom(void) const
Definition: interfrag.h:203
void freeze(void)
Definition: interfrag.cc:314