25#ifndef __CHECK_WAVE_FUNCTIONS_HPP__
26#define __CHECK_WAVE_FUNCTIONS_HPP__
33template <
typename T,
typename F>
34void check_wave_functions(Hamiltonian_k<real_type<T>>
const& Hk__, wf::Wave_functions<T>& psi__, wf::spin_range sr__,
35 wf::band_range br__,
double* eval__)
37 wf::Wave_functions<T> hpsi(psi__.gkvec_sptr(), psi__.num_md(), wf::num_bands(br__.size()), sddk::memory_t::host);
38 wf::Wave_functions<T> spsi(psi__.gkvec_sptr(), psi__.num_md(), wf::num_bands(br__.size()), sddk::memory_t::host);
40 la::dmatrix<F> ovlp(br__.size(), br__.size());
43 Hk__.template apply_h_s<F>(sr__, br__, psi__, &hpsi, &spsi);
45 wf::inner(Hk__.H0().ctx().spla_context(), sddk::memory_t::host, sr__, psi__, br__, spsi, br__, ovlp, 0, 0);
47 auto diff = check_identity(ovlp, br__.size());
49 std::cout <<
"[check_wave_functions] Error! Wave-functions are not orthonormal, difference : " << diff << std::endl;
51 std::cout <<
"[check_wave_functions] Ok! Wave-functions are orthonormal" << std::endl;
54 for (
int ib = 0; ib < br__.size(); ib++) {
56 for (
auto s = sr__.begin(); s != sr__.end(); s++) {
57 auto s1 = hpsi.actual_spin_index(s);
58 for (
int ig = 0; ig < psi__.gkvec().count(); ig++) {
60 auto z = hpsi.pw_coeffs(ig, s1, wf::band_index(ib)) -
61 spsi.pw_coeffs(ig, s1, wf::band_index(ib)) *
static_cast<real_type<T>
>(eval__[ib]);
64 psi__.gkvec().comm().allreduce(&l2norm, 1);
65 l2norm = std::sqrt(l2norm);
66 std::cout <<
"[check_wave_functions] band : " << ib <<
", residual l2norm : " << l2norm << std::endl;
Contains declaration and definition of sirius::Hamiltonian class.
std::enable_if_t< std::is_same< T, real_type< F > >::value, void > inner(::spla::Context &spla_ctx__, sddk::memory_t mem__, spin_range spins__, W const &wf_i__, band_range br_i__, Wave_functions< T > const &wf_j__, band_range br_j__, la::dmatrix< F > &result__, int irow0__, int jcol0__)
Compute inner product between the two sets of wave-functions.
Namespace of the SIRIUS library.
auto conj(double x__)
Return complex conjugate of a number. For a real value this is the number itself.
Contains declaration and implementation of Wave_functions class.