|
| using | Real = typename GetTypeReal< T >::type |
| |
| using | ct_Device = typename ct::PsiToContainer< Device >::type |
| |
| using | setmem_var_op = ct::kernels::set_memory< Real, ct_Device > |
| |
| using | resmem_var_op = ct::kernels::resize_memory< Real, ct_Device > |
| |
| using | delmem_var_op = ct::kernels::delete_memory< Real, ct_Device > |
| |
| using | syncmem_var_h2d_op = ct::kernels::synchronize_memory< Real, ct_Device, ct::DEVICE_CPU > |
| |
| using | syncmem_var_d2h_op = ct::kernels::synchronize_memory< Real, ct::DEVICE_CPU, ct_Device > |
| |
| using | setmem_complex_op = ct::kernels::set_memory< T, ct_Device > |
| |
| using | delmem_complex_op = ct::kernels::delete_memory< T, ct_Device > |
| |
| using | resmem_complex_op = ct::kernels::resize_memory< T, ct_Device > |
| |
| using | syncmem_complex_op = ct::kernels::synchronize_memory< T, ct_Device, ct_Device > |
| |
| using | gemm_op = ModuleBase::gemm_op< T, Device > |
| |
|
| void | calc_prec () |
| | Update the precondition array.
|
| |
| void | calc_hpsi_with_block (const HPsiFunc &hpsi_func, T *psi_in, ct::Tensor &hpsi_out) |
| | Apply the H operator to psi and obtain the hpsi matrix.
|
| |
| void | diag_hsub (const ct::Tensor &psi_in, const ct::Tensor &hpsi_in, ct::Tensor &hsub_out, ct::Tensor &eigenvalue_out) |
| | Diagonalization of the subspace matrix.
|
| |
| void | rotate_wf (const ct::Tensor &hsub_in, ct::Tensor &psi_out, ct::Tensor &workspace_in) |
| | Inplace matrix multiplication to obtain the initial guessed wavefunction.
|
| |
| void | calc_grad_with_block (const ct::Tensor &prec_in, ct::Tensor &err_out, ct::Tensor &beta_out, ct::Tensor &psi_in, ct::Tensor &hpsi_in, ct::Tensor &grad_out, ct::Tensor &grad_old_out) |
| | Calculate the gradient for all bands used in CG method.
|
| |
| void | calc_hsub_with_block (const HPsiFunc &hpsi_func, T *psi_in, ct::Tensor &psi_out, ct::Tensor &hpsi_out, ct::Tensor &hsub_out, ct::Tensor &workspace_in, ct::Tensor &eigenvalue_out) |
| | Apply the Hamiltonian operator to psi and obtain the hpsi matrix.
|
| |
| void | calc_hsub_with_block_exit (ct::Tensor &psi_out, ct::Tensor &hpsi_out, ct::Tensor &hsub_out, ct::Tensor &workspace_in, ct::Tensor &eigenvalue_out) |
| | Apply the Hamiltonian operator to psi and obtain the hpsi matrix.
|
| |
| void | orth_projection (const ct::Tensor &psi_in, ct::Tensor &hsub_in, ct::Tensor &grad_out) |
| | Orthogonalize column vectors in grad to column vectors in psi.
|
| |
| void | line_minimize (ct::Tensor &grad_in, ct::Tensor &hgrad_in, ct::Tensor &psi_out, ct::Tensor &hpsi_out) |
| | Optimize psi as well as the hpsi.
|
| |
| void | orth_cholesky (ct::Tensor &workspace_in, ct::Tensor &psi_out, ct::Tensor &hpsi_out, ct::Tensor &hsub_out) |
| | Orthogonalize and normalize the column vectors in psi_out using Cholesky decomposition.
|
| |
| bool | test_error (const ct::Tensor &err_in, const std::vector< double > ðr_band) |
| | Checks if the error satisfies the given threshold.
|
| |
template<typename
T = std::complex<double>, typename Device = base_device::DEVICE_CPU>
class hsolver::DiagoBPCG< T, Device >
A class for diagonalization using the Blocked-PCG method.
- Template Parameters
-
| T | The floating-point type used for calculations. |
| Device | The device used for calculations (e.g., cpu or gpu). |
template<typename
T , typename Device >
Calculate the gradient for all bands used in CG method.
prec_in[dim: n_basis_max, column major], err_out[dim: n_band, column major], beta_out[dim: n_band, column major], psi_in[dim: n_basis x n_band, column major, lda = n_basis_max], hpsi_in[dim: n_basis x n_band, column major, lda = n_basis_max], grad_out[dim: n_basis x n_band, column major, lda = n_basis_max], grad_old_out[dim: n_basis x n_band, column major, lda = n_basis_max],
- Parameters
-
| prec_in | Input preconditioner. |
| err_out | Output error state value. If it is smaller than a given threshold, exit the iteration. |
| beta_out | Output beta coefficient. |
| psi_in | Input wavefunction matrix. |
| hpsi_in | Product of psi_in and Hamiltonian. |
| grad_out | Output gradient matrix. |
| grad_old_out | Previous gradient matrix. |
- Note
- The steps involved in optimization are:
- normalize psi
- calculate the epsilo
- calculate the gradient by hpsi - epsilo * psi
- gradient mix with the previous gradient
- Do precondition
template<typename
T , typename Device >
Apply the H operator to psi and obtain the hpsi matrix.
This function calculates the matrix product of the Hamiltonian operator (H) and the input wavefunction (psi). The resulting matrix is stored in the output array hpsi_out.
- Note
- hpsi = H|psi>;
psi_in[dim: n_basis x n_band, column major, lda = n_basis_max], hpsi_out[dim: n_basis x n_band, column major, lda = n_basis_max].
- Parameters
-
| hpsi_func | A function computing the product of the Hamiltonian matrix H and a wavefunction blockvector X. |
| psi_in | The input wavefunction psi. |
| hpsi_out | Pointer to the array where the resulting hpsi matrix will be stored. |
template<typename
T , typename Device >
Apply the Hamiltonian operator to psi and obtain the hpsi matrix.
psi_out[dim: n_basis x n_band, column major, lda = n_basis_max], hpsi_out[dim: n_basis x n_band, column major, lda = n_basis_max], hsub_out[dim: n_band x n_band, column major, lda = n_band], eigenvalue_out[dim: n_basis_max, column major].
- Parameters
-
| hpsi_func | A function computing the product of matrix H and wavefunction blockvector X. |
| psi_in | Input wavefunction pointer. |
| psi_out | Output wavefunction. |
| hpsi_out | Product of psi_out and Hamiltonian. |
| hsub_out | Subspace matrix output. |
| eigenvalue_out | Computed eigen. |
template<typename
T , typename Device >
Apply the Hamiltonian operator to psi and obtain the hpsi matrix.
psi_out[dim: n_basis x n_band, column major, lda = n_basis_max], hpsi_out[dim: n_basis x n_band, column major, lda = n_basis_max], hsub_out[dim: n_band x n_band, column major, lda = n_band], eigenvalue_out[dim: n_basis_max, column major].
- Parameters
-
| hamilt_in | Pointer to the Hamiltonian object. |
| psi_in | Input wavefunction. |
| psi_out | Output wavefunction. |
| hpsi_out | Product of psi_out and Hamiltonian. |
| hsub_out | Subspace matrix output. |
| eigenvalue_out | Computed eigen. |
template<typename
T , typename Device >
Diagonalization of the subspace matrix.
All the matrix used in this function are stored and used as the column major. psi_in[dim: n_basis x n_band, column major, lda = n_basis_max], hpsi_in[dim: n_basis x n_band, column major, lda = n_basis_max], hpsi_out[dim: n_basis x n_band, column major, lda = n_basis_max], eigenvalue_out[dim: n_basis_max, column major].
- Parameters
-
| psi_in | Input wavefunction matrix with [dim: n_basis x n_band, column major]. |
| hpsi_in | H|psi> matrix with [dim: n_basis x n_band, column major]. |
| hsub_out | Output Hamiltonian subtracted matrix with [dim: n_band x n_band, column major] |
| eigenvalue_out | Computed eigen array with [dim: n_band] |
template<typename
T , typename Device >
Inplace matrix multiplication to obtain the initial guessed wavefunction.
hsub_in[dim: n_band x n_band, column major, lda = n_band], workspace_in[dim: n_basis x n_band, column major, lda = n_basis_max], psi_out[dim: n_basis x n_band, column major, lda = n_basis_max],
- Parameters
-
| hsub_in | Subspace matrix input, dim [n_basis, n_band] with column major. |
| psi_out | output wavefunction matrix with dim [n_basis, n_band], column major. |