1 /* Ergo, version 3.8, a program for linear scaling electronic structure 2 * calculations. 3 * Copyright (C) 2019 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, 4 * and Anastasia Kruchinina. 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * Primary academic reference: 20 * Ergo: An open-source program for linear-scaling electronic structure 21 * calculations, 22 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia 23 * Kruchinina, 24 * SoftwareX 7, 107 (2018), 25 * <http://dx.doi.org/10.1016/j.softx.2018.03.005> 26 * 27 * For further information about Ergo, see <http://www.ergoscf.org>. 28 */ 29 30 /** @file SCF_restricted.h 31 32 @brief Class for self-consistent field (SCF) procedure; 33 spin-restricted case. 34 35 @author: Elias Rudberg <em>responsible</em>. 36 */ 37 38 #ifndef SCF_RESTRICTED_HEADER 39 #define SCF_RESTRICTED_HEADER 40 41 #include "SCF_general.h" 42 43 #include "GetDensFromFock.h" 44 45 46 class SCF_restricted : public SCF_general 47 { 48 public: 49 50 // Constructor 51 SCF_restricted(const Molecule& molecule_, 52 const Molecule& extraCharges_, 53 const BasisInfoStruct & basisInfo_, 54 const IntegralInfo& integralInfo_, 55 const char* guessDmatFileNamePtr, // FIXME ELIAS: use std::string for this instead? 56 const JK::Params& J_K_paramsPtr, 57 const Dft::GridParams& gridParams_, 58 const SCF::Options& scfopts, 59 const SCF::MatOptions& matOpts, 60 ergo_real threshold_integrals_1el_input); 61 62 // Destructor 63 ~SCF_restricted(); 64 65 void get_Fock_matrix(symmMatrix & FockMatrix_); 66 void get_density_matrix(symmMatrix & densityMatrix_); 67 68 private: 69 void initialize_matrices(); 70 void check_params(); 71 void get_starting_guess_density(); 72 void initialize_homo_lumo_limits(); 73 void write_matrices_to_file(); 74 void get_2e_part_and_energy(); 75 void output_sparsity_S_F_D(SCF_statistics & stats); 76 void calculate_energy(); 77 void get_FDSminusSDF(); 78 void get_error_measure(); 79 void add_to_DIIS_list(); 80 void update_best_fock_so_far(); 81 void combine_old_fock_matrices(ergo_real stepLength); 82 void use_diis_to_get_new_fock_matrix(); 83 void clear_diis_list(); 84 void clear_error_matrices(); 85 void save_current_fock_as_fprev(); 86 void get_new_density_matrix(); 87 void write_density_to_file(); 88 void save_final_potential(); 89 void add_random_disturbance_to_starting_guess(); 90 void output_expected_values_pos_operator(); 91 void get_expected_values_pos_operator(generalVector &eigVec, const char *vector_name); 92 void output_density_images(); 93 void output_density_images_orbital(generalVector &eigVec, const std::string &filename_id); 94 void write_diag_dens_to_file(); 95 void report_final_results(); 96 void save_density_as_prevdens(); 97 void update_subspace_diff(); 98 void disturb_fock_matrix(ergo_real subspaceError); 99 void disturb_dens_matrix(ergo_real subspaceError); 100 void do_spin_flip(int atomCount); 101 void disturb_dens_matrix_exact(ergo_real subspaceError); 102 void save_full_matrices_for_matlab(); 103 void report_density_difference(); 104 void create_mtx_files_F(int const scfIter); 105 void create_mtx_files_D(int const scfIter); 106 void create_homo_eigvec_file() const; 107 void create_lumo_eigvec_file() const; 108 void create_eigenvectors_files() const; 109 void create_eigenvalues_files() const; 110 void create_eigvec_file(const generalVector &eigVec, 111 const char *vector_name, 112 const char *filename_id) const; 113 void create_gabedit_file() const; 114 void create_gabedit_file_2() const; 115 void compute_dipole_moment(); 116 void do_mulliken_pop_stuff(); 117 void compute_gradient_fixeddens(); 118 119 void get_non_ort_err_mat_normalized_in_ort_basis(symmMatrix & randomMatrix, int transform_with_S_also); 120 void transform_with_S(symmMatrix & A); 121 void transform_with_invChol(symmMatrix & A); 122 123 void disturb_dens_matrix_exact_try(const symmMatrix & randomMatrix, 124 const symmMatrix & orgDensMatrix, 125 ergo_real disturbanceFactor, 126 ergo_real & resultSinTheta, 127 symmMatrix & resultDensMatrix); 128 129 symmMatrix densityMatrix; 130 symmMatrix densityMatrix_core; 131 symmMatrix twoel_matrix_core; 132 symmMatrix FockMatrix; 133 symmMatrix Fprev; 134 symmMatrix Dprev; 135 symmMatrix F_ort_prev; // Used by purification 136 symmMatrix D_ort_prev; // Used for computing eigenvectors 137 symmMatrix bestFockMatrixSoFar; 138 symmMatrix bestFockMatrixSoFar2; 139 normalMatrix ErrorMatrix; 140 // The following three matrices are only used when doing sparsity investigation, otherwise they are empty 141 symmMatrix J_matrix; 142 symmMatrix K_matrix; 143 symmMatrix Fxc_matrix; 144 145 std::vector<generalVector> eigVecOCC; 146 std::vector<generalVector> eigVecUNOCC; 147 std::vector<ergo_real> eigValOCC; 148 std::vector<ergo_real> eigValUNOCC; 149 150 intervalType homoInterval_F_ort_prev; 151 intervalType lumoInterval_F_ort_prev; 152 intervalType homoInterval_Fprev; 153 intervalType lumoInterval_Fprev; 154 155 }; 156 157 158 159 160 161 #endif 162