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