ergo
scf_utils.h
Go to the documentation of this file.
1 /* Ergo, version 3.2, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2012 Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Primary academic reference:
19  * Kohn−Sham Density Functional Theory Electronic Structure Calculations
20  * with Linearly Scaling Computational Time and Memory Usage,
21  * Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek,
22  * J. Chem. Theory Comput. 7, 340 (2011),
23  * <http://dx.doi.org/10.1021/ct100611z>
24  *
25  * For further information about Ergo, see <http://www.ergoscf.org>.
26  */
27 
28 #ifndef SCF_UTILS_HEADER
29 #define SCF_UTILS_HEADER
30 
31 #include "molecule.h"
32 #include "basisinfo.h"
33 #include "integrals_2el.h"
34 #include "matrix_typedefs.h"
35 #include "densityfitting.h"
36 #include "grid_stream.h"
37 #include "SCF_statistics.h"
38 
39 
40 void output_sparsity(int n, const normalMatrix & M, const char* matrixName);
41 void output_sparsity_symm(int n, const symmMatrix & M, const char* matrixName);
42 void output_sparsity_triang(int n, const triangMatrix & M, const char* matrixName);
43 
44 int
45 compute_h_core_matrix_sparse(const IntegralInfo& integralInfo,
46  const Molecule& molecule,
47  const Molecule& extraCharges,
48  ergo_real electric_field_x,
49  ergo_real electric_field_y,
50  ergo_real electric_field_z,
51  const BasisInfoStruct& basisInfo,
52  symmMatrix & H_core_Matrix_sparse,
53  ergo_real threshold_integrals_1el,
54  int noOfThreadsForV,
55  mat::SizesAndBlocks const & matrix_size_block_info,
56  std::vector<int> const & permutationHML,
57  int const create_dipole_mtx = 0,
58  std::vector<int> const * const inversePermutationHML = 0,
59  std::string const * const calculation_identifier = 0,
60  std::string const * const method_and_basis_set = 0);
61 
62 int
64  const Molecule& molecule,
65  const BasisInfoStruct& basisInfo,
66  symmMatrix & H_core_Matrix_sparse,
67  ergo_real threshold_integrals_1el,
68  int noOfThreadsForV,
69  mat::SizesAndBlocks const & matrix_size_block_info,
70  std::vector<int> const & permutationHML);
71 
73  const BasisInfoStruct & basisInfo,
74  const char *name,
75  std::vector<int> const & inversePermutationHML);
76 
77 int
79  symmMatrix & A,
80  ergo_real disturbance,
81  int specificElementCount,
82  const int* elementIndexVector,
83  std::vector<int> const & permutationHML);
84 
85 int
87  int noOfElectrons,
88  symmMatrix & densityMatrix);
89 
90 int
92  const symmMatrix & M,
93  const char* fileName,
94  std::vector<int> const & permutationHML);
95 
96 int
98  symmMatrix & M,
99  const char* fileName,
100  std::vector<int> const & permutationHML);
101 
102 int
103 write_full_matrix(int n,
104  const symmMatrix & M,
105  const char* fileName,
106  std::vector<int> const & inversePermutationHML);
107 
108 int
110 
111 int
113  const BasisInfoStruct & basisInfoDensFit,
114  const Molecule& molecule,
115  const IntegralInfo& integralInfo,
116  symmMatrix & twoelMatrix_sparse,
117  symmMatrix & densityMatrix_sparse,
118  const JK::Params& J_K_params,
119  const JK::ExchWeights & CAM_params,
120  const Dft::GridParams& gridParams,
121  int do_xc,
122  ergo_real* energy_2el,
123  int noOfElectrons,
124  DensfitData* df_data,
125  mat::SizesAndBlocks const & matrix_size_block_info,
126 
127  std::vector<int> const & permutationHML,
128  std::vector<int> const & inversePermutationHML,
129  int get_J_K_Fxc_matrices,
130  symmMatrix & J_matrix,
131  symmMatrix & K_matrix,
132  symmMatrix & Fxc_matrix,
133  SCF_statistics & stats);
134 
135 int
137  const BasisInfoStruct & basisInfoDensFit,
138  const Molecule& molecule,
139  const IntegralInfo& integralInfo,
140  const JK::ExchWeights & CAM_params,
141  symmMatrix & twoelMatrix_sparse_alpha,
142  symmMatrix & twoelMatrix_sparse_beta,
143  symmMatrix & densityMatrix_sparse_alpha,
144  symmMatrix & densityMatrix_sparse_beta,
145  const JK::Params& J_K_params,
146  const Dft::GridParams& gridParams,
147  int do_xc,
148  ergo_real* energy_2el,
149  int noOfElectrons,
150  DensfitData* df_data,
151  mat::SizesAndBlocks const & matrix_size_block_info,
152  std::vector<int> const & permutationHML,
153  std::vector<int> const & inversePermutationHML);
154 
155 int
157  const BasisInfoStruct & basisInfoDensFit,
158  const Molecule& molecule,
159  const IntegralInfo& integralInfo,
160  const JK::ExchWeights & CAM_params,
161  symmMatrix & twoelMatrix_Fc,
162  symmMatrix & twoelMatrix_Fo,
163  symmMatrix & densityMatrix_sparse_alpha,
164  symmMatrix & densityMatrix_sparse_beta,
165  const JK::Params& J_K_params,
166  const Dft::GridParams& gridParams,
167  int do_xc,
168  ergo_real* energy_2el,
169  int noOfElectrons,
170  DensfitData* df_data,
171  mat::SizesAndBlocks const & matrix_size_block_info,
172  std::vector<int> const & permutationHML,
173  std::vector<int> const & inversePermutationHML);
174 
175 int
177  symmMatrix & F_symm,
178  symmMatrix & D_symm,
179  symmMatrix & S_symm,
180  normalMatrix & result,
181  ergo_real sparse_threshold);
182 
183 int
185  int alpha_beta_diff,
186  int* noOfElectrons_alpha,
187  int* noOfElectrons_beta);
188 
189 void
190 get_hf_weight_and_cam_params(int use_dft,
191  ergo_real* exch_param_alpha,
192  ergo_real* exch_param_beta,
193  ergo_real* exch_param_mu);
194 
195 int
197  int alpha_beta_diff,
198  int* noOfElectrons_alpha,
199  int* noOfElectrons_beta);
200 
201 void
202 get_dipole_moment(const symmMatrix & densityMatrix,
203  const BasisInfoStruct & basisInfo,
204  mat::SizesAndBlocks const & matrix_size_block_info,
205  std::vector<int> const & permutationHML,
206  const Molecule& molecule);
207 
208 void
209 do_mulliken_atomic_charges(const symmMatrix & densityMatrix,
210  const symmMatrix & S_symm,
211  const BasisInfoStruct & basisInfo,
212  mat::SizesAndBlocks const & matrix_size_block_info,
213  std::vector<int> const & permutationHML,
214  std::vector<int> const & inversePermutationHML,
215  const Molecule& molecule);
216 
217 void
218 do_mulliken_spin_densities(const symmMatrix & spinDensityMatrix,
219  const symmMatrix & S_symm,
220  const BasisInfoStruct & basisInfo,
221  mat::SizesAndBlocks const & matrix_size_block_info,
222  std::vector<int> const & permutationHML,
223  std::vector<int> const & inversePermutationHML,
224  const Molecule& molecule);
225 
226 void
227 do_acc_scan_J(const symmMatrix & D,
228  const IntegralInfo & integralInfo,
229  const BasisInfoStruct & basisInfo,
230  triangMatrix & invCholFactor,
231  bool doInvCholFactorTransformation,
232  const JK::Params & J_K_params,
233  mat::SizesAndBlocks const & matrix_size_block_info,
234  std::vector<int> const & permutationHML,
235  int nSteps,
236  ergo_real startThresh,
237  ergo_real stepFactor);
238 
239 void
241  const IntegralInfo & integralInfo,
242  const BasisInfoStruct & basisInfo,
243  triangMatrix & invCholFactor,
244  bool doInvCholFactorTransformation,
245  const JK::ExchWeights & CAM_params,
246  const JK::Params & J_K_params,
247  mat::SizesAndBlocks const & matrix_size_block_info,
248  std::vector<int> const & permutationHML,
249  std::vector<int> const & inversePermutationHML,
250  int nSteps,
251  ergo_real startThresh,
252  ergo_real stepFactor);
253 
254 void
256  const IntegralInfo & integralInfo,
257  const BasisInfoStruct & basisInfo,
258  const Molecule & molecule,
259  const Dft::GridParams & gridParams,
260  int noOfElectrons,
261  triangMatrix & invCholFactor,
262  bool doInvCholFactorTransformation,
263  mat::SizesAndBlocks const & matrix_size_block_info,
264  std::vector<int> const & permutationHML,
265  std::vector<int> const & inversePermutationHML,
266  int nSteps,
267  ergo_real startThresh,
268  ergo_real stepFactor);
269 
270 
271 #endif