Psi4
oeprop.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 
28 #ifndef _psi_src_lib_oeprop_h
29 #define _psi_src_lib_oeprop_h
30 
31 #include <set>
32 #include <vector>
33 #include <map>
34 #include <string>
35 
36 #include "typedefs.h"
37 #include "psi4/libmints/vector3.h"
38 
39 namespace psi {
40 
41 class Matrix;
42 class Wavefunction;
43 class IntegralFactory;
44 class MatrixFactory;
45 class BasisSet;
46 
64 class Prop {
65 
66 protected:
68  int print_;
70  int debug_;
71 
73  std::string title_;
74 
76  std::set<std::string> tasks_;
77 
79  std::shared_ptr<Wavefunction> wfn_;
81  std::shared_ptr<BasisSet> basisset_;
83  bool same_orbs_; // This allows pointers to be duplicated/computation skipped
84  bool same_dens_; // This allows pointers to be duplicated/computation skipped
86  std::shared_ptr<IntegralFactory> integral_;
88  std::shared_ptr<MatrixFactory> factory_;
89 
92 
109 
111  void common_init();
112 
114  virtual void print_header() = 0;
115 
116  int max_noon_ = 3;
117 
118 public:
119 
121  Prop(std::shared_ptr<Wavefunction> wfn);
123  virtual ~Prop();
124 
125  // => Wavefunction Modifiers (rarely called, C is usually fixed at HF) <= //
126 
127  // Change restricted flag. Resets C/D/epsilon matrices from wfn
128  void set_wavefunction(std::shared_ptr<Wavefunction> wfn);
129  // Change restricted flag. Resets C/D/epsilon matrices from wfn
130  void set_restricted(bool restricted);
131  // Set alpha eigenvalues, MO pitzer order basis
133  // Set beta eigenvalues, MO pitzer order basis. Throws if restricted
135  // Set alpha C matrix, SO/MO pitzer order basis.
136  void set_Ca(SharedMatrix Ca);
137  // Set beta C matrix, SO/MO pitzer order basis. Throws if restricted
138  void set_Cb(SharedMatrix Cb);
139 
140  // => Set OPDM/TDM/DDM (often called). These need not be totally symmetric. Note, you are setting Da and/or Db, I do the adding to Dt <= //
141 
142  // TODO Add symmetry is irrep number
143  void set_Da_ao(SharedMatrix Da, int symmetry = 0);
144  void set_Db_ao(SharedMatrix Db, int symmetry = 0);
145  void set_Da_so(SharedMatrix Da);
146  void set_Db_so(SharedMatrix Db);
147  void set_Da_mo(SharedMatrix Da);
148  void set_Db_mo(SharedMatrix Db);
149 
150  // => Get routines (useful to quickly change bases) <= //
151 
156 
165 
178 
180  SharedMatrix Dt_so(bool total = true);
182  SharedMatrix Dt_mo(bool total = true);
183 
185  std::pair<SharedMatrix, SharedVector> Na_mo();
187  std::pair<SharedMatrix, SharedVector> Nb_mo();
189  std::pair<SharedMatrix, SharedVector> Nt_mo();
191  std::pair<SharedMatrix, SharedVector> Na_so();
193  std::pair<SharedMatrix, SharedVector> Nb_so();
195  std::pair<SharedMatrix, SharedVector> Nt_so();
197  std::pair<SharedMatrix, SharedVector> Na_ao();
199  std::pair<SharedMatrix, SharedVector> Nb_ao();
201  std::pair<SharedMatrix, SharedVector> Nt_ao();
202 
203  // => Some integral helpers <= //
205 
206  // => Queue/Compute Routines <= //
207 
209  void add(const std::string& task);
211  void add(std::vector<std::string> tasks);
213  void clear();
214 
216  void set_title(const std::string& title) { title_ = title; }
217 
219  virtual void compute() = 0;
220 
221  // => Utility Routines <= //
222 
223  void set_print(int print) { print_ = print; }
224  void set_debug(int debug) { debug_ = debug; }
225 
226 };
227 
228 
233 class OEProp : public Prop {
234 
235 protected:
237  void common_init();
239  void print_header();
240 
241  // Compute routines
243  void compute_dipole(bool transition = false);
245  void compute_quadrupole(bool transition = false);
247  void compute_multipoles(int order, bool transition = false);
249  void compute_mo_extents();
253  void compute_lowdin_charges();
255  void compute_mayer_indices();
259  void compute_no_occupations();
263  void compute_esp_at_nuclei();
265  void compute_esp_over_grid();
268 
269 
274 
276  std::vector<double> Vvals_;
278  std::vector<double> Exvals_;
279  std::vector<double> Eyvals_;
280  std::vector<double> Ezvals_;
281 
283  Vector3 compute_center(const double *property) const;
284 public:
286  OEProp(std::shared_ptr<Wavefunction> wfn);
288  OEProp();
290  virtual ~OEProp();
291 
293  void oepy_add(const std::string& task) { add(task); }
294  void oepy_compute() { compute(); }
295  void oepy_set_title(const std::string& title) { set_title(title); }
296 
298  void compute();
299 
300  std::vector<double> Vvals() const { return Vvals_; }
301  std::vector<double> Exvals() const { return Exvals_; }
302  std::vector<double> Eyvals() const { return Eyvals_; }
303  std::vector<double> Ezvals() const { return Ezvals_; }
304 };
305 
316 //class GridProp : public Prop {
317 //
318 //protected:
319 // /// The absolute file path where results from this analysis will be stored
320 // std::string filename_;
321 // /// The format for the output (defaults to df3)
322 // std::string format_;
323 //
324 // /// Is the grid initialized
325 // bool initialized_;
326 //
327 // /// The grid (grid_["x"] = <double***> x, for instance)
328 // std::map<std::string, double***> grid_;
329 // /// The BasisPoints object to evaluate basis functions on the grid
330 // //std::shared_ptr<BasisPoints> points_;
331 //
332 //
333 // /// The number of subintervals
334 // int n_[3];
335 // /// The dimensions of the grid (bohr)
336 // double l_[3];
337 // /// The origin of the final grid (bohr)
338 // double o_[3];
339 // /// The number of points to compute at once (5000 seems reasonable)
340 // int block_size_;
341 // /// The max/min for d3f writes
342 // double caxis_[2];
343 //
344 // /// An nbf x nbf scratch array
345 // double** temp_tens_;
346 //
347 // /// AO basis matrices (everything on grids is AO)
348 // SharedMatrix Da_ao_;
349 // SharedMatrix Db_ao_;
350 // SharedMatrix Ca_ao_;
351 // SharedMatrix Cb_ao_;
352 // /// irrep offsets (for orbitals)
353 // int irrep_offsets_[8];
354 //
355 // /// The array of alpha MOs to store
356 // std::vector<std::pair<int, int> > alpha_mos_;
357 // /// The array of beta MOs to store
358 // std::vector<std::pair<int, int> > beta_mos_;
359 // /// The array of basis functions to plot (use C1 if you want AO, otherwise SO will be done)
360 // std::vector<std::pair<int, int> > basis_funs_;
361 //
362 // /// Common initialization
363 // void common_init();
364 //
365 // /// Print header
366 // void print_header();
367 //
368 // // Deprecated
369 // // // Compute routines (these all work on a block of points)
370 // // /// Compute mo values
371 // // void compute_mos(std::shared_ptr<GridBlock> g, unsigned long int offset);
372 // // /// Compute basis function values
373 // // void compute_basis_funs(std::shared_ptr<GridBlock> g, unsigned long int offset);
374 // // /// Compute total density
375 // // void compute_rho(std::shared_ptr<GridBlock> g, double* results);
376 // // /// Compute spin density (rho_a - rho_b)
377 // // void compute_rho_s(std::shared_ptr<GridBlock> g, double* results);
378 // // /// Compute rho_a (alpha density)
379 // // void compute_rho_a(std::shared_ptr<GridBlock> g, double* results);
380 // // /// Compute rho_b (beta density)
381 // // void compute_rho_b(std::shared_ptr<GridBlock> g, double* results);
382 // // /// Compute gamma_aa (\nabla rho_a ^2)
383 // // void compute_gamma_aa(std::shared_ptr<GridBlock> g, double* results);
384 // // /// Compute gamma_ab (\nabla rho_a \nabla rho_b)
385 // // void compute_gamma_ab(std::shared_ptr<GridBlock> g, double* results);
386 // // /// Compute gamma_bb (\nabla rho_b ^2)
387 // // void compute_gamma_bb(std::shared_ptr<GridBlock> g, double* results);
388 // // /// Compute tau_a (KE density)
389 // // void compute_tau_a(std::shared_ptr<GridBlock> g, double* results);
390 // // /// Compute tau_b (KE density)
391 // // void compute_tau_b(std::shared_ptr<GridBlock> g, double* results);
392 //
393 // /// Compute ESP (perhaps more involved, might need a fast Poisson solver)
394 // void compute_ESP();
395 //
396 // /// Allocate a grid3 (and zero it out)
397 // double*** block_grid(int nx, int ny, int nz);
398 // /// Free a grid3
399 // void free_grid(double*** grid);
400 // /// Actually build the grid
401 // void build_grid();
402 // /// allocate all the registers
403 // void allocate_arrays();
404 // /// Write the grid out in data format
405 // void write_data_grid();
406 // /// Write the grid out in df3 files
407 // void write_df3_grid();
408 //
409 //
410 //public:
411 // /// Constructor, uses globals
412 // GridProp(std::shared_ptr<Wavefunction> wfn);
413 // /// Constructor, uses globals and Process::environment::reference wavefunction
414 // GridProp();
415 // /// Destructor
416 // virtual ~GridProp();
417 //
418 // /// Python issue
419 // void gridpy_add(const std::string& task) { add(task); }
420 // void gridpy_compute() { compute(); }
421 //
422 // /// Set the output filename
423 // void set_filename(const std::string& file) { filename_ = file; }
424 // /// Set the format
425 // void set_format(const std::string& form) { format_ = form; }
426 // /// Set a desired MO (use for restricted)
427 // void add_alpha_mo(int irrep, int index);
428 // /// Set a desired MO
429 // void add_beta_mo(int irrep, int index);
430 // /// Set a desired basis function
431 // void add_basis_fun(int irrep, int index);
432 // /// Compute and print/save the properties
433 // void compute();
434 //
435 // /**
436 // * Grid specification
437 // */
438 //
439 // // High-Level
440 //
441 // /// Set the number of subintervals on the grid
442 // /// Setting 0 for one index will graph a plane (origin centered)
443 // /// Setting 0 for two indices will graph a line (origin centered)
444 // /// Defaults to nx,ny,nz = 40
445 // void set_n(int nx, int ny, int nz) { n_[0] = nx; n_[1] = ny; n_[2] = nz; }
446 //
447 // /// build the best grid for a given set of overages (bohr) at the edges
448 // void build_grid_overages(double overages);
449 //
450 // /// The maximum/minimum data values to plot for the current properties (clamp)
451 // void set_caxis(double min, double max) { caxis_[0] = min; caxis_[1] = max; }
452 //
453 // // Low-Level
454 //
455 // /// Set the dimensions of the grid (in bohr)
456 // void set_l(double lx, double ly, double lz) { l_[0] = lx; l_[1] = ly; l_[2] = lz; }
457 //
458 // /// Set the origin of the grid (in bohr)
459 // void set_o(double ox, double oy, double oz) { o_[0] = ox; o_[1] = oy; o_[2] = oz; }
460 //
461 // /// Get the k-th element of n_
462 // int get_n(int k) const { return n_[k]; }
463 //
464 // /// Get the k-th element of l_
465 // double get_l(int k) const { return l_[k]; }
466 //
467 // /// Get the k-th element of o_
468 // double get_o(int k) const { return o_[k]; }
469 //
470 // /// Free the grid (useful if doing properties sequentially)
471 // void reset();
472 //
473 //};
474 
475 
476 }
477 
478 #endif
void title(void)
Definition: ccdensity.cc:647
virtual void print_header()=0
Print header.
bool same_dens_
Definition: oeprop.h:84
SharedVector epsilon_a_
The alpha eigenvalues in the MO basis (used to form Pitzer ordering)
Definition: oeprop.h:98
void compute_lowdin_charges()
Compute Lowdin Charges.
Definition: oeprop.cc:1606
void set_Db_ao(SharedMatrix Db, int symmetry=0)
Definition: oeprop.cc:191
void set_Ca(SharedMatrix Ca)
Definition: oeprop.cc:152
void add(const std::string &task)
Add a single task to the queue.
Definition: oeprop.cc:282
void set_Db_so(SharedMatrix Db)
Definition: oeprop.cc:222
std::vector< double > Eyvals_
Definition: oeprop.h:279
void compute_dipole(bool transition=false)
Compute dipole.
Definition: oeprop.cc:1184
SharedMatrix Cb_so()
The beta C matrix in the SO basis.
Definition: oeprop.cc:351
virtual void compute()=0
Compute properties.
std::pair< SharedMatrix, SharedVector > Nt_so()
The total natural orbital occupations and orbitals in the SO basis.
Definition: oeprop.cc:652
void compute_esp_over_grid()
Compute electrostatic potential at specified grid points.
Definition: oeprop.cc:1044
int max_noon_
Definition: oeprop.h:116
std::vector< double > Ezvals() const
Definition: oeprop.h:303
void compute_mulliken_charges()
Compute Mulliken Charges.
Definition: oeprop.cc:1523
SharedVector epsilon_b()
The alpha eigenvalues in the MO basis (used to form Pitzer ordering)
Definition: oeprop.cc:300
void compute_no_occupations()
Compute/display natural orbital occupations around the bandgap. Displays max_num above and below the ...
Definition: oeprop.cc:1911
std::pair< SharedMatrix, SharedVector > Na_so()
The alpha natural orbital occupations and orbitals in the SO basis.
Definition: oeprop.cc:492
Definition: vector3.h:36
void compute_field_over_grid()
Compute field at specified grid points.
Definition: oeprop.cc:1089
int print_
Print flag.
Definition: oeprop.h:68
SharedMatrix Dt_mo(bool total=true)
The total/spin density matrix in the ao basis, depending on if true or false.
Definition: oeprop.cc:455
SharedMatrix Da_so_
The alpha density matrix in the SO basis.
Definition: oeprop.h:102
std::vector< double > Vvals() const
Definition: oeprop.h:300
Vector3 origin_
The center about which properties are computed.
Definition: oeprop.h:271
void set_debug(int debug)
Definition: oeprop.h:224
std::shared_ptr< IntegralFactory > integral_
The integral factory for this wavefunction&#39;s basisset.
Definition: oeprop.h:86
void common_init()
Common initialization.
Definition: oeprop.cc:761
void oepy_add(const std::string &task)
Python issue.
Definition: oeprop.h:293
void compute_quadrupole(bool transition=false)
Compute quadrupole.
Definition: oeprop.cc:1277
bool same_orbs_
Is this wavefunction object spin-restricted? (Actually closed-shell, but this is wavefunction&#39;s conve...
Definition: oeprop.h:83
std::pair< SharedMatrix, SharedVector > Nt_mo()
The total natural orbital occupations and orbitals in the MO basis.
Definition: oeprop.cc:642
void set_Cb(SharedMatrix Cb)
Definition: oeprop.cc:159
SharedMatrix Ca_so_
The alpha C matrix in the SO basis.
Definition: oeprop.h:106
std::vector< double > Exvals_
The field components in a.u. computed at each grid point.
Definition: oeprop.h:278
void set_Da_mo(SharedMatrix Da)
Definition: oeprop.cc:229
std::pair< SharedMatrix, SharedVector > Nb_so()
The beta natural orbital occupations and orbitals in the SO basis. Throws if restricted.
Definition: oeprop.cc:515
bool origin_preserves_symmetry_
Whether the origin is on a symmetry axis or not.
Definition: oeprop.h:273
virtual ~Prop()
Virtual destructor.
Definition: oeprop.cc:72
void set_Da_so(SharedMatrix Da)
Definition: oeprop.cc:215
void oepy_set_title(const std::string &title)
Definition: oeprop.h:295
Definition: oeprop.h:64
SharedMatrix Dt_so(bool total=true)
The total/spin density matrix in the ao basis, depending on if true or false.
Definition: oeprop.cc:440
SharedMatrix Db_mo()
The beta density matrix in the MO basis.
Definition: oeprop.cc:404
int debug_
Debug flag.
Definition: oeprop.h:70
SharedMatrix Ca_so()
The alpha C matrix in the SO basis.
Definition: oeprop.cc:347
std::pair< SharedMatrix, SharedVector > Nt_ao()
The total natural orbital occupations and orbitals in the AO basis.
Definition: oeprop.cc:675
void set_title(const std::string &title)
Set title for use in saving information.
Definition: oeprop.h:216
SharedMatrix Da_ao()
The alpha density matrix in the AO (Spherical Harmonics, C1) basis.
Definition: oeprop.cc:304
void compute_esp_at_nuclei()
Compute electrostatic potentials at the nuclei.
Definition: oeprop.cc:1141
void set_Da_ao(SharedMatrix Da, int symmetry=0)
Definition: oeprop.cc:166
void oepy_compute()
Definition: oeprop.h:294
std::pair< SharedMatrix, SharedVector > Nb_mo()
The beta natural orbital occupations and orbitals in the MO basis. Throws if restricted.
Definition: oeprop.cc:479
SharedMatrix overlap_so()
Definition: oeprop.cc:724
void compute_multipoles(int order, bool transition=false)
Compute arbitrary-order multipoles up to (and including) l=order.
Definition: oeprop.cc:906
void compute_electric_field_and_gradients()
Compute electric field and electric field gradients.
std::shared_ptr< Wavefunction > wfn_
The wavefunction object this Prop is built around.
Definition: oeprop.h:79
Vector3 compute_center(const double *property) const
Computes the center for a given property, for the current molecule.
Definition: oeprop.cc:740
void compute_mayer_indices()
Compute Mayer Bond Indices (non-orthogoal basis)
Definition: oeprop.cc:1689
void print_header()
Print header and information.
Definition: oeprop.cc:842
std::vector< double > Ezvals_
Definition: oeprop.h:280
SharedMatrix AO2USO_
The AO to USO matrix.
Definition: oeprop.h:91
std::pair< SharedMatrix, SharedVector > Nb_ao()
The beta natural orbital occupations and orbitals in the AO basis. Throws if restricted.
Definition: oeprop.cc:590
void set_epsilon_b(SharedVector epsilon_a)
Definition: oeprop.cc:146
std::string title_
The title of this Prop object, for use in saving info.
Definition: oeprop.h:73
Definition: oeprop.h:233
void compute_mo_extents()
Compute mo extents.
Definition: oeprop.cc:1379
std::pair< SharedMatrix, SharedVector > Na_ao()
The alpha natural orbital occupations and orbitals in the AO basis.
Definition: oeprop.cc:541
SharedMatrix Db_ao()
The beta density matrix in the AO (Spherical Harmonics, C1) basis.
Definition: oeprop.cc:324
OEProp()
Constructor, uses globals and Process::environment::reference wavefunction.
std::shared_ptr< Matrix > SharedMatrix
Definition: adc.h:50
std::shared_ptr< Wavefunction > wfn
Definition: dx_write.cc:59
SharedMatrix Db_so_
The beta density matrix in the SO basis.
Definition: oeprop.h:104
std::shared_ptr< BasisSet > basisset_
The basisset for this wavefunction.
Definition: oeprop.h:81
std::vector< double > Vvals_
The ESP in a.u., computed at each grid point.
Definition: oeprop.h:276
SharedMatrix Cb_so_
The beta C matrix in the SO basis.
Definition: oeprop.h:108
void set_restricted(bool restricted)
Definition: oeprop.cc:115
Prop(std::shared_ptr< Wavefunction > wfn)
Build a Prop object with C, epsilon, and restricted buit from wfn.
Definition: oeprop.cc:66
std::vector< double > Exvals() const
Definition: oeprop.h:301
SharedMatrix Cb_ao()
The beta C matrix in the AO (Spherical Harmonics, C1) basis. Ordered by eigenvalue.
Definition: oeprop.cc:359
void set_wavefunction(std::shared_ptr< Wavefunction > wfn)
Definition: oeprop.cc:83
SharedMatrix Ca_ao()
The alpha C matrix in the AO (Spherical Harmonics, C1) basis. Ordered by eigenvalue.
Definition: oeprop.cc:355
SharedMatrix Db_so()
The beta density matrix in the SO basis.
Definition: oeprop.cc:367
void set_epsilon_a(SharedVector epsilon_a)
Definition: oeprop.cc:139
SharedMatrix Da_so()
The alpha density matrix in the SO basis.
Definition: oeprop.cc:363
void compute()
Compute and print/save the properties.
Definition: oeprop.cc:858
virtual ~OEProp()
Destructor.
Definition: oeprop.cc:736
std::vector< double > Eyvals() const
Definition: oeprop.h:302
std::shared_ptr< MatrixFactory > factory_
The matrix factory for this wavefunction&#39;s basisset (SO)
Definition: oeprop.h:88
std::set< std::string > tasks_
The set of tasks to complete.
Definition: oeprop.h:76
SharedVector epsilon_a()
The alpha eigenvalues in the MO basis (used to form Pitzer ordering)
Definition: oeprop.cc:296
void clear()
Clear task queue.
Definition: oeprop.cc:292
void common_init()
Common initialization.
Definition: oeprop.cc:75
SharedMatrix Da_mo()
The alpha density matrix in the MO basis.
Definition: oeprop.cc:371
void set_print(int print)
Definition: oeprop.h:223
void set_Db_mo(SharedMatrix Db)
Definition: oeprop.cc:256
void compute_wiberg_lowdin_indices()
Compute Wiberg Bond Indices using Lowdin Orbitals (symmetrically orthogonal basis) ...
Definition: oeprop.cc:1798
SharedVector epsilon_b_
The alpha eigenvalues in the MO basis (used to form Pitzer ordering)
Definition: oeprop.h:100
std::shared_ptr< Vector > SharedVector
Definition: adc.h:52
std::pair< SharedMatrix, SharedVector > Na_mo()
The alpha natural orbital occupations and orbitals in the MO basis.
Definition: oeprop.cc:469