Skip to content

Commit 0317913

Browse files
authored
Docs: move doxygen to headers for DiagoDavid class and add some new (#5736)
* Docs: move doxygen to .h for DiagoDavid class and add some new * Docs: class DiagoDavid
1 parent c1cb6ac commit 0317913

File tree

2 files changed

+150
-134
lines changed

2 files changed

+150
-134
lines changed

source/module_hsolver/diago_david.cpp

Lines changed: 8 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,6 @@
1414
using namespace hsolver;
1515

1616

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-
*/
3417
template <typename T, typename Device>
3518
DiagoDavid<T, Device>::DiagoDavid(const Real* precondition_in,
3619
const int nband_in,
@@ -121,13 +104,6 @@ DiagoDavid<T, Device>::DiagoDavid(const Real* precondition_in,
121104
#endif
122105
}
123106

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-
*/
131107
template <typename T, typename Device>
132108
DiagoDavid<T, Device>::~DiagoDavid()
133109
{
@@ -343,21 +319,7 @@ int DiagoDavid<T, Device>::diag_once(const HPsiFunc& hpsi_func,
343319
return dav_iter;
344320
}
345321

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+
361323
template <typename T, typename Device>
362324
void DiagoDavid<T, Device>::cal_grad(const HPsiFunc& hpsi_func,
363325
const SPsiFunc& spsi_func,
@@ -614,18 +576,7 @@ void DiagoDavid<T, Device>::cal_grad(const HPsiFunc& hpsi_func,
614576
return;
615577
}
616578

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+
629580
template <typename T, typename Device>
630581
void DiagoDavid<T, Device>::cal_elem(const int& dim,
631582
int& nbase, // current dimension of the reduced basis
@@ -780,23 +731,7 @@ void DiagoDavid<T, Device>::diag_zhegvx(const int& nbase,
780731
return;
781732
}
782733

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+
800735
template <typename T, typename Device>
801736
void DiagoDavid<T, Device>::refresh(const int& dim,
802737
const int& nband,
@@ -937,19 +872,7 @@ void DiagoDavid<T, Device>::refresh(const int& dim,
937872
return;
938873
}
939874

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+
953876
template <typename T, typename Device>
954877
void DiagoDavid<T, Device>::SchmidtOrth(const int& dim,
955878
const int nband,
@@ -1078,21 +1001,13 @@ void DiagoDavid<T, Device>::SchmidtOrth(const int& dim,
10781001
return;
10791002
}
10801003

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+
10901005
template <typename T, typename Device>
10911006
void DiagoDavid<T, Device>::planSchmidtOrth(const int nband, std::vector<int>& pre_matrix_mm_m, std::vector<int>& pre_matrix_mv_m)
10921007
{
10931008
if (nband <= 0) {
10941009
return;
1095-
}
1010+
}
10961011
std::fill(pre_matrix_mm_m.begin(), pre_matrix_mm_m.end(), 0);
10971012
std::fill(pre_matrix_mv_m.begin(), pre_matrix_mv_m.end(), 0);
10981013
int last_matrix_size = nband;
@@ -1150,27 +1065,7 @@ void DiagoDavid<T, Device>::planSchmidtOrth(const int nband, std::vector<int>& p
11501065
}
11511066
}
11521067

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+
11741069
template <typename T, typename Device>
11751070
int DiagoDavid<T, Device>::diag(const HPsiFunc& hpsi_func,
11761071
const SPsiFunc& spsi_func,
@@ -1201,26 +1096,7 @@ int DiagoDavid<T, Device>::diag(const HPsiFunc& hpsi_func,
12011096
return sum_dav_iter;
12021097
}
12031098

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+
12241100
template <typename T, typename Device>
12251101
inline bool DiagoDavid<T, Device>::check_block_conv(const int& ntry,
12261102
const int& notconv,

0 commit comments

Comments
 (0)