File: SCF_restricted.h

package info (click to toggle)
ergo 3.8.2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 17,568 kB
  • sloc: cpp: 94,763; ansic: 17,785; sh: 10,701; makefile: 1,403; yacc: 127; lex: 116; awk: 23
file content (161 lines) | stat: -rw-r--r-- 5,399 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* Ergo, version 3.8.2, a program for linear scaling electronic structure
 * calculations.
 * Copyright (C) 2023 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
 * and Anastasia Kruchinina.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Primary academic reference:
 * Ergo: An open-source program for linear-scaling electronic structure
 * calculations,
 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
 * Kruchinina,
 * SoftwareX 7, 107 (2018),
 * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
 * 
 * For further information about Ergo, see <http://www.ergoscf.org>.
 */

/** @file SCF_restricted.h

    @brief Class for self-consistent field (SCF) procedure;
    spin-restricted case.

    @author: Elias Rudberg <em>responsible</em>.
*/

#ifndef SCF_RESTRICTED_HEADER
#define SCF_RESTRICTED_HEADER

#include "SCF_general.h"

#include "GetDensFromFock.h"


class SCF_restricted : public SCF_general
{
 public:  

  // Constructor
  SCF_restricted(const Molecule& molecule_,
		 const Molecule& extraCharges_,
		 const BasisInfoStruct & basisInfo_, 
		 const IntegralInfo& integralInfo_,
		 const char* guessDmatFileNamePtr, // FIXME ELIAS: use std::string for this instead?
		 const JK::Params& J_K_paramsPtr,
		 const Dft::GridParams& gridParams_,
		 const SCF::Options& scfopts,
		 const SCF::MatOptions& matOpts,
		 ergo_real threshold_integrals_1el_input);

  // Destructor
  ~SCF_restricted();

  void get_Fock_matrix(symmMatrix & FockMatrix_);
  void get_density_matrix(symmMatrix & densityMatrix_);

 private:
  void initialize_matrices();
  void check_params();
  void get_starting_guess_density();
  void initialize_homo_lumo_limits();
  void write_matrices_to_file();
  void get_2e_part_and_energy();
  void output_sparsity_S_F_D(SCF_statistics & stats);
  void calculate_energy();
  void get_FDSminusSDF();
  void get_error_measure();
  void add_to_DIIS_list();
  void update_best_fock_so_far();
  void combine_old_fock_matrices(ergo_real stepLength);
  void use_diis_to_get_new_fock_matrix();
  void clear_diis_list();
  void clear_error_matrices();
  void save_current_fock_as_fprev();
  void get_new_density_matrix();
  void write_density_to_file();
  void save_final_potential();
  void add_random_disturbance_to_starting_guess();
  void output_expected_values_pos_operator();
  void get_expected_values_pos_operator(generalVector &eigVec, const char *vector_name);
  void output_density_images();
  void output_density_images_orbital(generalVector &eigVec, const std::string &filename_id);
  void write_diag_dens_to_file();
  void report_final_results();
  void save_density_as_prevdens();
  void update_subspace_diff();
  void disturb_fock_matrix(ergo_real subspaceError);
  void disturb_dens_matrix(ergo_real subspaceError);
  void do_spin_flip(int atomCount);
  void disturb_dens_matrix_exact(ergo_real subspaceError);
  void save_full_matrices_for_matlab();
  void report_density_difference();
  void create_mtx_files_F(int const scfIter);
  void create_mtx_files_D(int const scfIter);
  void create_homo_eigvec_file() const;
  void create_lumo_eigvec_file() const;
  void create_eigenvectors_files() const;
  void create_eigenvalues_files() const;
  void create_eigvec_file(const generalVector &eigVec, 
			  const char *vector_name, 
			  const char *filename_id) const;
  void create_gabedit_file() const;
  void create_gabedit_file_2() const;
  void compute_dipole_moment();
  void do_mulliken_pop_stuff();
  void compute_gradient_fixeddens();

  void get_non_ort_err_mat_normalized_in_ort_basis(symmMatrix & randomMatrix, int transform_with_S_also);
  void transform_with_S(symmMatrix & A);
  void transform_with_invChol(symmMatrix & A);
  
  void disturb_dens_matrix_exact_try(const symmMatrix & randomMatrix,
				     const symmMatrix & orgDensMatrix,
				     ergo_real disturbanceFactor,
				     ergo_real & resultSinTheta,
				     symmMatrix & resultDensMatrix);

  symmMatrix densityMatrix;
  symmMatrix densityMatrix_core;
  symmMatrix twoel_matrix_core;
  symmMatrix FockMatrix;
  symmMatrix Fprev;
  symmMatrix Dprev;
  symmMatrix F_ort_prev; // Used by purification
  symmMatrix D_ort_prev; // Used for computing eigenvectors
  symmMatrix bestFockMatrixSoFar;
  symmMatrix bestFockMatrixSoFar2;
  normalMatrix ErrorMatrix;
  // The following three matrices are only used when doing sparsity investigation, otherwise they are empty
  symmMatrix J_matrix;
  symmMatrix K_matrix;
  symmMatrix Fxc_matrix;

  std::vector<generalVector> eigVecOCC;
  std::vector<generalVector> eigVecUNOCC;
  std::vector<ergo_real> eigValOCC; 
  std::vector<ergo_real> eigValUNOCC;

  intervalType homoInterval_F_ort_prev;
  intervalType lumoInterval_F_ort_prev;
  intervalType homoInterval_Fprev;
  intervalType lumoInterval_Fprev;

};





#endif