|
14 | 14 | using namespace hsolver; |
15 | 15 |
|
16 | 16 |
|
17 | | -/** |
18 | | - * @brief Constructor for the DiagoDavid class. |
19 | | - * |
20 | | - * @param[in] precondition_in Pointer to the preconditioning matrix. |
21 | | - * @param[in] nband_in Number of eigenpairs required(i.e. bands). |
22 | | - * @param[in] dim_in Dimension of the matrix. |
23 | | - * @param[in] david_ndim_in Dimension of the reduced basis set of Davidson. |
24 | | - * `david_ndim_in` * `nband_in` is the maximum allowed size of |
25 | | - * the reduced basis set before \b restart of Davidson. |
26 | | - * @param[in] use_paw_in Flag indicating whether to use PAW. |
27 | | - * @param[in] diag_comm_in Communication information for diagonalization. |
28 | | - * |
29 | | - * @tparam T The data type of the matrices and arrays. |
30 | | - * @tparam Device The device type (base_device::DEVICE_CPU or DEVICE_GPU). |
31 | | - * |
32 | | - * @note Auxiliary memory is allocated in the constructor and deallocated in the destructor. |
33 | | - */ |
34 | 17 | template <typename T, typename Device> |
35 | 18 | DiagoDavid<T, Device>::DiagoDavid(const Real* precondition_in, |
36 | 19 | const int nband_in, |
@@ -121,13 +104,6 @@ DiagoDavid<T, Device>::DiagoDavid(const Real* precondition_in, |
121 | 104 | #endif |
122 | 105 | } |
123 | 106 |
|
124 | | -/** |
125 | | - * @brief Destructor for the DiagoDavid class. |
126 | | - * |
127 | | - * This destructor releases the dynamically allocated memory used by the class members. |
128 | | - * It deletes the basis, hpsi, spsi, hcc, scc, vcc, lagrange_matrix, and eigenvalue arrays. |
129 | | - * |
130 | | - */ |
131 | 107 | template <typename T, typename Device> |
132 | 108 | DiagoDavid<T, Device>::~DiagoDavid() |
133 | 109 | { |
@@ -343,21 +319,7 @@ int DiagoDavid<T, Device>::diag_once(const HPsiFunc& hpsi_func, |
343 | 319 | return dav_iter; |
344 | 320 | } |
345 | 321 |
|
346 | | -/** |
347 | | - * Calculates the preconditioned gradient of the eigenvectors in Davidson method. |
348 | | - * |
349 | | - * @param hpsi_func The function to calculate the matrix-blockvector product H * psi. |
350 | | - * @param spsi_func The function to calculate the matrix-blockvector product overlap S * psi. |
351 | | - * @param dim The dimension of the blockvector. |
352 | | - * @param nbase The current dimension of the reduced basis. |
353 | | - * @param nbase_x The maximum dimension of the reduced basis set. |
354 | | - * @param notconv The number of unconverged eigenpairs. |
355 | | - * @param hpsi The output array for the Hamiltonian H times blockvector psi. |
356 | | - * @param spsi The output array for the overlap matrix S times blockvector psi. |
357 | | - * @param vcc The input array for the eigenvector coefficients. |
358 | | - * @param unconv The array of indices for the unconverged eigenpairs. |
359 | | - * @param eigenvalue The array of eigenvalues. |
360 | | - */ |
| 322 | + |
361 | 323 | template <typename T, typename Device> |
362 | 324 | void DiagoDavid<T, Device>::cal_grad(const HPsiFunc& hpsi_func, |
363 | 325 | const SPsiFunc& spsi_func, |
@@ -614,18 +576,7 @@ void DiagoDavid<T, Device>::cal_grad(const HPsiFunc& hpsi_func, |
614 | 576 | return; |
615 | 577 | } |
616 | 578 |
|
617 | | -/** |
618 | | - * Calculates the elements of the diagonalization matrix for the DiagoDavid class. |
619 | | - * |
620 | | - * @param dim The dimension of the problem. |
621 | | - * @param nbase The current dimension of the reduced basis. |
622 | | - * @param nbase_x The maximum dimension of the reduced basis set. |
623 | | - * @param notconv The number of newly added basis vectors. |
624 | | - * @param hpsi The output array for the Hamiltonian H times blockvector psi. |
625 | | - * @param spsi The output array for the overlap matrix S times blockvector psi. |
626 | | - * @param hcc Pointer to the array where the calculated Hamiltonian matrix elements will be stored. |
627 | | - * @param scc Pointer to the array where the calculated overlap matrix elements will be stored. |
628 | | - */ |
| 579 | + |
629 | 580 | template <typename T, typename Device> |
630 | 581 | void DiagoDavid<T, Device>::cal_elem(const int& dim, |
631 | 582 | int& nbase, // current dimension of the reduced basis |
@@ -780,23 +731,7 @@ void DiagoDavid<T, Device>::diag_zhegvx(const int& nbase, |
780 | 731 | return; |
781 | 732 | } |
782 | 733 |
|
783 | | -/** |
784 | | - * Refreshes the diagonalization solver by updating the basis and the reduced Hamiltonian. |
785 | | - * |
786 | | - * @param dim The dimension of the problem. |
787 | | - * @param nband The number of bands. |
788 | | - * @param nbase The number of basis states. |
789 | | - * @param nbase_x The maximum dimension of the reduced basis set. |
790 | | - * @param eigenvalue_in Pointer to the array of eigenvalues. |
791 | | - * @param psi_in Pointer to the array of wavefunctions. |
792 | | - * @param ld_psi The leading dimension of the wavefunction array. |
793 | | - * @param hpsi Pointer to the output array for the updated basis set. |
794 | | - * @param spsi Pointer to the output array for the updated basis set (nband-th column). |
795 | | - * @param hcc Pointer to the output array for the updated reduced Hamiltonian. |
796 | | - * @param scc Pointer to the output array for the updated overlap matrix. |
797 | | - * @param vcc Pointer to the output array for the updated eigenvector matrix. |
798 | | - * |
799 | | - */ |
| 734 | + |
800 | 735 | template <typename T, typename Device> |
801 | 736 | void DiagoDavid<T, Device>::refresh(const int& dim, |
802 | 737 | const int& nband, |
@@ -937,19 +872,7 @@ void DiagoDavid<T, Device>::refresh(const int& dim, |
937 | 872 | return; |
938 | 873 | } |
939 | 874 |
|
940 | | -/** |
941 | | - * SchmidtOrth function performs orthogonalization of the starting eigenfunction to those already calculated. |
942 | | - * It takes the dimension of the basis, number of bands, index of the current band, starting eigenfunction psi_m, |
943 | | - * lagrange_m array, mm_size, and mv_size as input parameters. |
944 | | - * |
945 | | - * @param dim The dimension of the basis. |
946 | | - * @param nband The number of bands. |
947 | | - * @param m The index of the current band. |
948 | | - * @param spsi Pointer to the starting eigenfunction psi_m. |
949 | | - * @param lagrange_m Pointer to the lagrange_m array. |
950 | | - * @param mm_size The size of the square matrix for future lagranges. |
951 | | - * @param mv_size The size of the lagrange_m array. |
952 | | - */ |
| 875 | + |
953 | 876 | template <typename T, typename Device> |
954 | 877 | void DiagoDavid<T, Device>::SchmidtOrth(const int& dim, |
955 | 878 | const int nband, |
@@ -1078,21 +1001,13 @@ void DiagoDavid<T, Device>::SchmidtOrth(const int& dim, |
1078 | 1001 | return; |
1079 | 1002 | } |
1080 | 1003 |
|
1081 | | -/** |
1082 | | - * @brief Plans the Schmidt orthogonalization for a given number of bands. |
1083 | | - * |
1084 | | - * @tparam T The type of the elements in the vectors. |
1085 | | - * @tparam Device The device on which the computation will be performed. |
1086 | | - * @param nband The number of bands. |
1087 | | - * @param pre_matrix_mm_m The vector to store the matrix sizes. |
1088 | | - * @param pre_matrix_mv_m The vector to store the number of matrix-vector multiplications. |
1089 | | - */ |
| 1004 | + |
1090 | 1005 | template <typename T, typename Device> |
1091 | 1006 | void DiagoDavid<T, Device>::planSchmidtOrth(const int nband, std::vector<int>& pre_matrix_mm_m, std::vector<int>& pre_matrix_mv_m) |
1092 | 1007 | { |
1093 | 1008 | if (nband <= 0) { |
1094 | 1009 | return; |
1095 | | -} |
| 1010 | + } |
1096 | 1011 | std::fill(pre_matrix_mm_m.begin(), pre_matrix_mm_m.end(), 0); |
1097 | 1012 | std::fill(pre_matrix_mv_m.begin(), pre_matrix_mv_m.end(), 0); |
1098 | 1013 | int last_matrix_size = nband; |
@@ -1150,27 +1065,7 @@ void DiagoDavid<T, Device>::planSchmidtOrth(const int nband, std::vector<int>& p |
1150 | 1065 | } |
1151 | 1066 | } |
1152 | 1067 |
|
1153 | | -/** |
1154 | | - * @brief Performs iterative diagonalization using the David algorithm. |
1155 | | - * |
1156 | | - * @warning Please see docs of `HPsiFunc` for more information about the hpsi mat-vec interface. |
1157 | | - * |
1158 | | - * @tparam T The type of the elements in the matrix. |
1159 | | - * @tparam Device The device type (CPU or GPU). |
1160 | | - * @param hpsi_func The function object that computes the matrix-blockvector product H * psi. |
1161 | | - * @param spsi_func The function object that computes the matrix-blockvector product overlap S * psi. |
1162 | | - * @param ld_psi The leading dimension of the psi_in array. |
1163 | | - * @param psi_in The input wavefunction. |
1164 | | - * @param eigenvalue_in The array to store the eigenvalues. |
1165 | | - * @param david_diag_thr The convergence threshold for the diagonalization. |
1166 | | - * @param david_maxiter The maximum number of iterations for the diagonalization. |
1167 | | - * @param ntry_max The maximum number of attempts for the diagonalization restart. |
1168 | | - * @param notconv_max The maximum number of bands unconverged allowed. |
1169 | | - * @return The total number of iterations performed during the diagonalization. |
1170 | | - * |
1171 | | - * @note ntry_max is an empirical parameter that should be specified in external routine, default 5 |
1172 | | - * notconv_max is determined by the accuracy required for the calculation, default 0 |
1173 | | - */ |
| 1068 | + |
1174 | 1069 | template <typename T, typename Device> |
1175 | 1070 | int DiagoDavid<T, Device>::diag(const HPsiFunc& hpsi_func, |
1176 | 1071 | const SPsiFunc& spsi_func, |
@@ -1201,26 +1096,7 @@ int DiagoDavid<T, Device>::diag(const HPsiFunc& hpsi_func, |
1201 | 1096 | return sum_dav_iter; |
1202 | 1097 | } |
1203 | 1098 |
|
1204 | | -/** |
1205 | | - * @brief Check the convergence of block eigenvectors in the Davidson iteration. |
1206 | | - * |
1207 | | - * This function determines whether the block eigenvectors have reached convergence |
1208 | | - * during the iterative diagonalization process. Convergence is judged based on |
1209 | | - * the number of eigenvectors that have not converged and the maximum allowed |
1210 | | - * number of such eigenvectors. |
1211 | | - * |
1212 | | - * @tparam T The data type for the eigenvalues and eigenvectors (e.g., float, double). |
1213 | | - * @tparam Device The device type (e.g., base_device::DEVICE_CPU). |
1214 | | - * @param ntry The current number of tries for diagonalization. |
1215 | | - * @param notconv The current number of eigenvectors that have not converged. |
1216 | | - * @param ntry_max The maximum allowed number of tries for diagonalization. |
1217 | | - * @param notconv_max The maximum allowed number of eigenvectors that can fail to converge. |
1218 | | - * @return true if the eigenvectors are considered converged or the maximum number |
1219 | | - * of tries has been reached, false otherwise. |
1220 | | - * |
1221 | | - * @note Exits the diagonalization loop if either the convergence criteria |
1222 | | - * are met or the maximum number of tries is exceeded. |
1223 | | - */ |
| 1099 | + |
1224 | 1100 | template <typename T, typename Device> |
1225 | 1101 | inline bool DiagoDavid<T, Device>::check_block_conv(const int& ntry, |
1226 | 1102 | const int& notconv, |
|
0 commit comments