Psi4
csg.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-2019 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 
29 #ifndef _psi_src_lib_libcubeprop_csg_h_
30 #define _psi_src_lib_libcubeprop_csg_h_
31 
32 #include <map>
33 #include <memory>
34 #include <string>
35 #include <vector>
36 
37 namespace psi {
38 
39 class BasisExtents;
40 class BasisSet;
41 class BlockOPoints;
42 class Matrix;
43 class Molecule;
44 class Options;
45 class RKSFunctions;
46 
48  protected:
49  // => Input Specification <= //
50 
54  std::shared_ptr<Molecule> mol_;
56  std::shared_ptr<BasisSet> primary_;
58  std::shared_ptr<BasisSet> auxiliary_;
60  std::string filepath_;
61 
62  // => Physical Grid <= //
63 
65  int* N_;
67  double* D_;
69  double* O_;
70 
72  size_t npoints_;
74  size_t nxyz_;
75 
77  double* x_;
79  double* y_;
81  double* z_;
83  double* w_;
84 
85  // => Grid Computers <= //
86 
88  std::vector<std::shared_ptr<BlockOPoints> > blocks_;
90  std::shared_ptr<BasisExtents> extents_;
92  std::shared_ptr<RKSFunctions> points_;
93 
94  // => Helper Routines <= //
95 
97  void populate_grid();
98 
99  public:
100  // => Constructors <= //
101 
102  CubicScalarGrid(std::shared_ptr<BasisSet> primary, Options& options);
103  virtual ~CubicScalarGrid();
104 
105  // => High-Level Setup Routines <= //
106 
108  void build_grid();
110  void build_grid(const std::string filepath, int* N, double* D, double* O);
112  void build_grid(std::shared_ptr<CubicScalarGrid> other);
114  void print_header();
115 
117  void set_auxiliary_basis(std::shared_ptr<BasisSet> aux) { auxiliary_ = aux; }
118 
119  // => High-Level Set Routines <= //
120 
122  void set_filepath(const std::string filepath) { filepath_ = filepath; }
123 
124  // => High-Level Accessor Routines <= //
125 
127  int* N() const { return N_; }
129  double* D() const { return D_; }
131  double* O() const { return O_; }
133  std::string filepath() const { return filepath_; }
134 
135  // => Low-Level Accessor Routines (Use only if you know what you are doing) <= //
136 
138  size_t npoints() const { return npoints_; }
140  size_t nxyz() const { return nxyz_; }
141 
143  double* x() const { return x_; }
145  double* y() const { return y_; }
147  double* z() const { return z_; }
149  double* w() const { return w_; }
150 
151  // => Low-Level Write Routines (Use only if you know what you are doing) <= //
152 
154  void write_gen_file(double* v, const std::string& name, const std::string& type, const std::string& comment = "");
156  void write_cube_file(double* v, const std::string& name, const std::string& comment = "");
157 
158  // => Low-Level Scalar Field Computation (Use only if you know what you are doing) <= //
159 
161  void add_density(double* v, std::shared_ptr<Matrix> D);
163  void add_esp(double* v, std::shared_ptr<Matrix> D, const std::vector<double>& nuc_weights = std::vector<double>());
165  void add_basis_functions(double** v, const std::vector<int>& indices);
167  void add_orbitals(double** v, std::shared_ptr<Matrix> C);
169  void add_LOL(double* v, std::shared_ptr<Matrix> D);
171  void add_ELF(double* v, std::shared_ptr<Matrix> D);
172 
173  // => High-Level Scalar Field Computation <= //
174 
176  void compute_density(std::shared_ptr<Matrix> D, const std::string& name, const std::string& type = "CUBE");
178  void compute_esp(std::shared_ptr<Matrix> D, const std::vector<double>& nuc_weights, const std::string& name,
179  const std::string& type = "CUBE");
181  void compute_basis_functions(const std::vector<int>& indices, const std::string& name,
182  const std::string& type = "CUBE");
184  void compute_orbitals(std::shared_ptr<Matrix> C, const std::vector<int>& indices,
185  const std::vector<std::string>& labels, const std::string& name,
186  const std::string& type = "CUBE");
188  void compute_difference(std::shared_ptr<Matrix> C, const std::vector<int>& indices,
189  const std::string& label, bool square = false, const std::string& type = "CUBE");
190 
192  void compute_LOL(std::shared_ptr<Matrix> D, const std::string& name, const std::string& type = "CUBE");
194  void compute_ELF(std::shared_ptr<Matrix> D, const std::string& name, const std::string& type = "CUBE");
195 
198  std::pair<double, double> compute_isocontour_range(double* v2, double exponent);
199 
201  std::string ecp_header();
202 };
203 
204 } // namespace psi
205 
206 #endif
double * y_
y coordinates of grid
Definition: csg.h:79
void compute_difference(std::shared_ptr< Matrix > C, const std::vector< int > &indices, const std::string &label, bool square=false, const std::string &type="CUBE")
Compute a set of orbital-type properties and drop files corresponding to name, index, symmetry label, and type.
Definition: csg.cc:654
void write_cube_file(double *v, const std::string &name, const std::string &comment="")
Write a Gaussian cube file of the scalar field v (in fast ordering) to filepath/name.cube.
Definition: csg.cc:239
size_t npoints_
number of points of grid
Definition: csg.h:72
std::string filepath_
File path for grid storage.
Definition: csg.h:60
double * w() const
w weights (rectangular) in fast ordering
Definition: csg.h:149
void set_filepath(const std::string filepath)
Set the directory for cube file storage (defaults to &quot;./&quot;)
Definition: csg.h:122
int * N() const
Number of voxels in [x,y,z]. Number of points along each dimensions in N_i + 1.
Definition: csg.h:127
int * N_
Voxel quanta in x, y, z [(N_x+1) x (N_y + 1) x (N_z + 1) points].
Definition: csg.h:65
void build_grid()
Build grid with options overages.
Definition: csg.cc:101
Definition: csg.h:47
double * z() const
z points in fast ordering
Definition: csg.h:147
std::string ecp_header()
A helper function to construct ECP comment in the cubefile header.
Definition: csg.cc:728
std::shared_ptr< BasisSet > auxiliary_
The auxiliary basisset for ESP contractions.
Definition: csg.h:58
std::string filepath() const
Filepath where grid output will be stored.
Definition: csg.h:133
void compute_orbitals(std::shared_ptr< Matrix > C, const std::vector< int > &indices, const std::vector< std::string > &labels, const std::string &name, const std::string &type="CUBE")
Compute a set of orbital-type properties and drop files corresponding to name, index, symmetry label, and type.
Definition: csg.cc:628
void compute_density(std::shared_ptr< Matrix > D, const std::string &name, const std::string &type="CUBE")
Compute a density-type property and drop a file corresponding to name and type.
Definition: csg.cc:594
virtual ~CubicScalarGrid()
Definition: csg.cc:70
size_t npoints() const
Total number of points in grid.
Definition: csg.h:138
void compute_ELF(std::shared_ptr< Matrix > D, const std::string &name, const std::string &type="CUBE")
Compute an ELF-type property and drop a file corresponding to name and type (TODO: this seems very un...
Definition: csg.cc:689
void add_LOL(double *v, std::shared_ptr< Matrix > D)
Add a LOL-type property to the scalar field.
Definition: csg.cc:536
void add_esp(double *v, std::shared_ptr< Matrix > D, const std::vector< double > &nuc_weights=std::vector< double >())
Add an ESP-type property to the scalar field (total density matrix, must set DF_BASIS_SCF option) ...
Definition: csg.cc:315
double * x() const
x points in fast ordering
Definition: csg.h:143
void add_basis_functions(double **v, const std::vector< int > &indices)
Add a basis function property for desired indices to the scalar fields in v (rows are basis functions...
Definition: csg.cc:493
size_t nxyz_
Sparsity blocking in all cardinal directions.
Definition: csg.h:74
std::shared_ptr< BasisSet > primary_
Basis set this grid is built around.
Definition: csg.h:56
std::vector< std::shared_ptr< BlockOPoints > > blocks_
Vector of blocks.
Definition: csg.h:88
void compute_esp(std::shared_ptr< Matrix > D, const std::vector< double > &nuc_weights, const std::string &name, const std::string &type="CUBE")
Compute an ESP-type property and drop a file corresponding to name and type.
Definition: csg.cc:608
void add_ELF(double *v, std::shared_ptr< Matrix > D)
Add an ELF-type property to the scalar field.
Definition: csg.cc:563
double * D() const
Voxel width in [x,y,z], in bohr.
Definition: csg.h:129
double * D_
Voxel spacing in x, y, z.
Definition: csg.h:67
void compute_LOL(std::shared_ptr< Matrix > D, const std::string &name, const std::string &type="CUBE")
Compute a LOL-type property and drop a file corresponding to name and type.
Definition: csg.cc:682
size_t nxyz() const
Number of points.
Definition: csg.h:140
void add_density(double *v, std::shared_ptr< Matrix > D)
Add a density-type property to the scalar field.
Definition: csg.cc:302
void populate_grid()
Setup grid from info in N_, D_, O_.
Definition: csg.cc:149
void set_auxiliary_basis(std::shared_ptr< BasisSet > aux)
Set the auxiliary for ESP if desired.
Definition: csg.h:117
std::shared_ptr< BasisExtents > extents_
Points to basis extents, built internally.
Definition: csg.h:90
std::pair< double, double > compute_isocontour_range(double *v2, double exponent)
Definition: csg.cc:696
Definition: liboptions.h:353
const char * labels[]
Definition: petitelist.cc:942
std::shared_ptr< Molecule > mol_
Molecule this grid is built around.
Definition: csg.h:54
void compute_basis_functions(const std::vector< int > &indices, const std::string &name, const std::string &type="CUBE")
Compute a set of basis function-type properties and drop files corresponding to name, index, and type.
Definition: csg.cc:616
double * O_
Voxel origin in x, y, z.
Definition: csg.h:69
Options & options_
Options object for overages and voxel spacing.
Definition: csg.h:52
void print_header()
Header info.
Definition: csg.cc:209
void write_gen_file(double *v, const std::string &name, const std::string &type, const std::string &comment="")
Write a general file of the scalar field v (in fast ordering) to filepath/name.ext.
Definition: csg.cc:231
double * x_
x coordinates of grid
Definition: csg.h:77
double * y() const
y points in fast ordering
Definition: csg.h:145
indices
Definition: libdpd/dpd.h:262
void add_orbitals(double **v, std::shared_ptr< Matrix > C)
Add orbital property for desired indices to the scalar fields in v (rows are orbitals) ...
Definition: csg.cc:517
std::shared_ptr< RKSFunctions > points_
RKS points object.
Definition: csg.h:92
double * w_
w quadrature weights of grid (rectangular)
Definition: csg.h:83
CubicScalarGrid(std::shared_ptr< BasisSet > primary, Options &options)
Definition: csg.cc:56
double * z_
z coordinates of grid
Definition: csg.h:81
double * O() const
Lower-left corner of th grid, in bohr.
Definition: csg.h:131