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 puri_info.h 31 32 @brief File containing classes IterationInfo and PuriInfo. 33 IterationInfo is a class with the information stored for each iteration of the recursive expansion. 34 PuriInfo is a class containing general information about the recursive expansion. 35 36 @author Anastasia Kruchinina <em>responsible</em> 37 @sa puri_info.cc 38 */ 39 40 41 42 #ifndef PURI_INFO_HEADER 43 #define PURI_INFO_HEADER 44 45 #include "output.h" 46 #include "matrix_typedefs.h" // definitions of matrix types and interval type 47 #include "realtype.h" // definitions of types 48 49 //#define CHECK_IF_STOPPED_TOO_LATE_OR_TOO_EARLY 50 51 52 class IterationInfo{ 53 public: 54 typedef ergo_real real; 55 56 int it; //iteration number 57 real threshold_X; 58 double Xsquare_time; 59 double trunc_time; 60 double purify_time; 61 double total_time; 62 double stopping_criterion_time; 63 double eucl_diff_time; 64 double trace_diff_time ; 65 double mixed_diff_time; 66 double frob_diff_time; 67 double nnz_time; 68 double inf_diff_time; 69 double orbital_homo_time; 70 double orbital_lumo_time; 71 double DX_mult_homo_time; 72 double DX_mult_lumo_time; 73 double homo_eig_solver_time; 74 double lumo_eig_solver_time; 75 real XmX2_trace; 76 real XmX2_fro_norm; 77 real XmX2_infty_norm; 78 real XmX2_mixed_norm; 79 real XmX2_eucl; 80 real order; 81 int poly; 82 real gap; // estimated gap 83 real NNZ_X; 84 real NNZ_X2; 85 // bounds for homo and lumo during iterations 86 // [lumo_low, lumo_upp] and [1-homo_upp, 1-homo_low] 87 real homo_bound_low; 88 real homo_bound_upp; 89 real lumo_bound_low; 90 real lumo_bound_upp; 91 92 real commutation_error; 93 94 real alpha; // for SP2 accelerated 95 96 real constantC; 97 98 IterationInfo()99 IterationInfo(): 100 it(-1), 101 threshold_X(0), 102 Xsquare_time(0), 103 trunc_time(0), 104 purify_time(0), 105 total_time(0), 106 stopping_criterion_time(0), 107 eucl_diff_time(0), 108 trace_diff_time(0), 109 mixed_diff_time(0), 110 frob_diff_time(0), 111 nnz_time(0), 112 inf_diff_time(0), 113 orbital_homo_time(0), 114 orbital_lumo_time(0), 115 DX_mult_homo_time(0), 116 DX_mult_lumo_time(0), 117 homo_eig_solver_time(0), 118 lumo_eig_solver_time(0), 119 XmX2_trace(-1), 120 XmX2_fro_norm(-1), 121 XmX2_mixed_norm(-1), 122 XmX2_eucl(-1), 123 order(0), 124 poly(-1), 125 gap(-1), 126 NNZ_X(0), 127 NNZ_X2(0), 128 homo_bound_low(0), 129 homo_bound_upp(0), 130 lumo_bound_low(0), 131 lumo_bound_upp(0), 132 commutation_error(0), 133 alpha(0), 134 constantC(0) 135 {}; 136 137 138 }; 139 140 141 class PuriInfo{ 142 public: 143 typedef ergo_real real; 144 PuriInfo()145 PuriInfo() : 146 method(0), 147 stopping_criterion(0), 148 total_it(0), 149 converged(0), 150 error_subspace(0), 151 accumulated_error_subspace(0), 152 accumulated_time_calls_for_eigenvec_functions(0), 153 compute_eigenvectors_in_this_SCF_cycle(false), 154 homo_eigenvector_is_computed(false), 155 lumo_eigenvector_is_computed(false), 156 homo_eigenvector_is_computed_in_iter(-1), 157 lumo_eigenvector_is_computed_in_iter(-1), 158 homo_eigensolver_iter(-1), 159 lumo_eigensolver_iter(-1), 160 homo_eigensolver_time(-1), 161 lumo_eigensolver_time(-1), 162 debug_output(0) 163 {}; 164 165 166 void print_collected_info(); 167 void print_collected_info_printf(); 168 169 real get_total_Xsquare_time(); 170 real get_total_Xtrunc_time(); 171 real get_total_purify_time(); 172 real get_total_stopping_criterion_time(); 173 real get_total_trace_diff_time(); 174 real get_total_frob_diff_time(); 175 real get_total_mixed_diff_time(); 176 real get_total_eucl_diff_time(); 177 real get_total_inf_diff_time(); 178 real get_total_nnz_time(); 179 180 void get_poly_seq(std::vector<int> &norms); 181 void get_vec_frob_norms(std::vector<real> &norms); 182 void get_vec_infty_norms(std::vector<real> &norms); 183 void get_vec_mixed_norms(std::vector<real> &norms); 184 void get_vec_traces(std::vector<real> & traces); 185 186 void get_spectrum_bounds(real &lower_spectrum_bound_, real &upper_spectrum_bound_) const; 187 void set_spectrum_bounds(const real lower_spectrum_bound_, const real upper_spectrum_bound_); 188 189 int method; // 1 for SP2, 2 for SP2 accelerated 190 191 int stopping_criterion; // 1 if new, 0 if not 192 real norm_F_Fprev; 193 real total_time; 194 int total_it; 195 real time_spectrum_bounds; 196 int estim_total_it; 197 int additional_iterations; 198 199 int converged; // 1 if converged, 0 otherwise 200 201 real error_subspace; // expected maximum error in subspace 202 real accumulated_error_subspace; // accumulated error in subspace 203 204 real accumulated_time_calls_for_eigenvec_functions; 205 206 real homo_estim_upp_F; 207 real homo_estim_low_F; 208 real lumo_estim_upp_F; 209 real lumo_estim_low_F; 210 211 bool compute_eigenvectors_in_this_SCF_cycle; 212 bool homo_eigenvector_is_computed; 213 bool lumo_eigenvector_is_computed; 214 int homo_eigenvector_is_computed_in_iter; 215 int lumo_eigenvector_is_computed_in_iter; 216 int homo_eigensolver_iter; 217 int lumo_eigensolver_iter; 218 double homo_eigensolver_time; 219 double lumo_eigensolver_time; 220 real eigValHOMO; 221 real eigValLUMO; 222 223 std::vector<IterationInfo> Iterations; 224 int debug_output; 225 226 real upper_spectrum_bound; 227 real lower_spectrum_bound; 228 229 }; 230 231 #endif 232