25#ifndef __HAMILTONIAN_HPP__
26#define __HAMILTONIAN_HPP__
41class Simulation_context;
55class Gaunt_coefficients;
90 std::unique_ptr<D_operator<T>>
d_op_;
93 std::unique_ptr<Q_operator<T>>
q_op_;
95 std::vector<sddk::mdarray<std::complex<T>, 2>> hmt_;
124 Local_operator<T>& local_op()
const
129 inline Q_operator<T>& Q()
const
134 inline D_operator<T>& D()
const
139 auto const& hmt(
int ia__)
const
153 template <spin_block_t sblock>
154 void apply_hmt_to_apw(Atom
const& atom__,
int ngv__, sddk::mdarray<std::complex<T>, 2>& alm__,
155 sddk::mdarray<std::complex<T>, 2>& halm__)
const;
159 sddk::mdarray<std::complex<T>, 2>& alm__)
const;
162 void apply_bmt(wf::Wave_functions<T>& psi__, std::vector<wf::Wave_functions<T>>& bpsi__)
const;
170 void apply_so_correction(wf::Wave_functions<T>& psi__, std::vector<wf::Wave_functions<T>>& hpsi__)
const;
182 std::shared_ptr<U_operator<T>>
u_op_;
202 template <
typename F,
int what>
343 void apply_fv_h_o(
bool apw_only__,
bool phi_is_lo__, wf::band_range b__, wf::Wave_functions<T>& phi__,
344 wf::Wave_functions<T>* hphi__, wf::Wave_functions<T>* ophi__)
const;
413 void set_fv_h_o(la::dmatrix<std::complex<T>>& h__, la::dmatrix<std::complex<T>>& o__)
const;
416 void set_fv_h_o_it(la::dmatrix<std::complex<T>>& h__, la::dmatrix<std::complex<T>>& o__)
const;
419 void set_fv_h_o_lo_lo(la::dmatrix<std::complex<T>>& h__, la::dmatrix<std::complex<T>>& o__)
const;
422 void set_fv_h_o_apw_lo(Atom
const& atom,
int ia, sddk::mdarray<std::complex<T>, 2>& alm_row,
423 sddk::mdarray<std::complex<T>, 2>& alm_col, sddk::mdarray<std::complex<T>, 2>& h,
424 sddk::mdarray<std::complex<T>, 2>& o)
const;
437 template <
typename F>
438 std::enable_if_t<std::is_same<T, real_type<F>>::value,
void>
442 PROFILE(
"sirius::Hamiltonian_k::apply_h_s");
444 auto pcs = env::print_checksum();
446 if (hphi__ !=
nullptr) {
448 H0().local_op().apply_h(
reinterpret_cast<fft::spfft_transform_type<T>&
>(kp_.spfft_transform()),
449 kp_.gkvec_fft_sptr(), spins__, phi__, *hphi__, br__);
452 auto mem = H0().ctx().processing_unit_memory_t();
455 auto cs = phi__.checksum(mem, br__);
456 print_checksum(
"phi", cs, RTE_OUT(H0().ctx().out()));
458 auto cs = hphi__->checksum(mem, br__);
459 print_checksum(
"hloc_phi", cs, RTE_OUT(H0().ctx().out()));
464 if (sphi__ !=
nullptr) {
465 for (
auto s = spins__.begin(); s!= spins__.end(); s++) {
467 wf::copy(mem, phi__, sp, br__, *sphi__, sp, br__);
472 if (H0().ctx().unit_cell().max_mt_basis_size()) {
473 auto bp_generator = kp_.beta_projectors().make_generator();
474 auto beta_coeffs = bp_generator.prepare();
475 apply_non_local_D_Q<T, F>(mem, spins__, br__, bp_generator, beta_coeffs, phi__, &H0().D(), hphi__, &H0().Q(), sphi__);
479 if (H0().ctx().hubbard_correction() && !H0().ctx().gamma_point() && hphi__) {
486 auto cs = hphi__->checksum(mem, br__);
487 print_checksum(
"hphi", cs, RTE_OUT(H0().ctx().out()));
490 auto cs = sphi__->checksum(mem, br__);
491 print_checksum(
"hsphi", cs, RTE_OUT(H0().ctx().out()));
496 template <
typename F>
497 std::enable_if_t<!std::is_same<T, real_type<F>>::value,
void>
501 RTE_THROW(
"implementat this");
514 template <
typename F>
515 std::enable_if_t<std::is_same<T, real_type<F>>::value,
void>
517 auto mem = H0().ctx().processing_unit_memory_t();
518 auto bp_gen = kp_.beta_projectors().make_generator();
519 auto bp_coeffs = bp_gen.prepare();
520 apply_S_operator<T, F>(mem, spin__, br__,
521 bp_gen, bp_coeffs, phi__, &H0().Q(), sphi__);
Represent the k-point independent part of Hamiltonian.
Unit_cell & unit_cell_
Alias for unit cell.
Hamiltonian_k< T > operator()(K_point< T > &kp__) const
Return a Hamiltonian for the given k-point.
std::unique_ptr< Q_operator< T > > q_op_
Q operator (non-local part of S-operator).
void apply_hmt_to_apw(Atom const &atom__, int ngv__, sddk::mdarray< std::complex< T >, 2 > &alm__, sddk::mdarray< std::complex< T >, 2 > &halm__) const
Apply the muffin-tin part of the Hamiltonian to the apw basis functions of an atom.
void apply_so_correction(wf::Wave_functions< T > &psi__, std::vector< wf::Wave_functions< T > > &hpsi__) const
Apply SO correction to the first-variational LAPW wave-functions.
std::unique_ptr< D_operator< T > > d_op_
D operator (non-local part of Hamiltonian).
Potential * potential_
Alias for the potential.
Hamiltonian0(Hamiltonian0< T > &&src)=default
Default move constructor.
void add_o1mt_to_apw(Atom const &atom__, int num_gkvec__, sddk::mdarray< std::complex< T >, 2 > &alm__) const
Add correction to LAPW overlap arising in the infinite-order relativistic approximation (IORA).
Simulation_context & ctx_
Simulation context.
void apply_bmt(wf::Wave_functions< T > &psi__, std::vector< wf::Wave_functions< T > > &bpsi__) const
Apply muffin-tin part of magnetic filed to the wave-functions.
std::unique_ptr< Local_operator< T > > local_op_
Local part of the Hamiltonian operator.
Representation of Kohn-Sham Hamiltonian.
Hamiltonian_k< T > & operator=(Hamiltonian_k< T > const &src__)=delete
Assignment operator is forbidden.
std::enable_if_t< std::is_same< T, real_type< F > >::value, void > apply_h_s(wf::spin_range spins__, wf::band_range br__, wf::Wave_functions< T > const &phi__, wf::Wave_functions< T > *hphi__, wf::Wave_functions< T > *sphi__) const
Apply pseudopotential H and S operators to the wavefunctions.
void set_fv_h_o_lo_lo(la::dmatrix< std::complex< T > > &h__, la::dmatrix< std::complex< T > > &o__) const
Setup lo-lo block of Hamiltonian and overlap matrices.
void apply_b(wf::Wave_functions< T > &psi__, std::vector< wf::Wave_functions< T > > &bpsi__) const
Apply magnetic field to first-variational LAPW wave-functions.
void set_fv_h_o(la::dmatrix< std::complex< T > > &h__, la::dmatrix< std::complex< T > > &o__) const
Setup the Hamiltonian and overlap matrices in APW+lo basis.
void set_fv_h_o_it(la::dmatrix< std::complex< T > > &h__, la::dmatrix< std::complex< T > > &o__) const
Add interstitial contribution to apw-apw block of Hamiltonian and overlap.
void apply_fv_h_o(bool apw_only__, bool phi_is_lo__, wf::band_range b__, wf::Wave_functions< T > &phi__, wf::Wave_functions< T > *hphi__, wf::Wave_functions< T > *ophi__) const
Apply first-variational LAPW Hamiltonian and overlap matrices.
std::shared_ptr< U_operator< T > > u_op_
Hubbard correction.
void set_fv_h_o_apw_lo(Atom const &atom, int ia, sddk::mdarray< std::complex< T >, 2 > &alm_row, sddk::mdarray< std::complex< T >, 2 > &alm_col, sddk::mdarray< std::complex< T >, 2 > &h, sddk::mdarray< std::complex< T >, 2 > &o) const
Setup apw-lo and lo-apw blocks of LAPW Hamiltonian and overlap matrices.
Hamiltonian0< T > const & H0_
K-point independent part of Hamiltonian.
Hamiltonian_k(Hamiltonian_k< T > const &src__)=delete
Copy constructor is forbidden.
std::enable_if_t< std::is_same< T, real_type< F > >::value, void > apply_s(wf::spin_range spin__, wf::band_range br__, wf::Wave_functions< T > const &phi__, wf::Wave_functions< T > &sphi__) const
apply S operator
K-point related variables and methods.
auto const & hubbard_wave_functions_S() const
Return the actual hubbard wave functions used in the calculations.
Generate effective potential from charge density and magnetization.
Simulation context is a set of parameters and objects describing a single simulation.
Representation of a unit cell.
auto actual_spin_index(spin_index s__) const
Return the actual spin index of the wave-functions.
Wave-functions representation.
Describe a range of bands.
Describe a range of spins.
Contains definition and implementation of distributed matrix class.
Contains helper functions for the interface with SpFFT library.
Declaration of sirius::Local_operator class.
Memory management functions and classes.
void copy(sddk::memory_t mem__, Wave_functions< T > const &in__, wf::spin_index s_in__, wf::band_range br_in__, Wave_functions< F > &out__, wf::spin_index s_out__, wf::band_range br_out__)
Copy wave-functions.
Namespace of the SIRIUS library.
void apply_U_operator(Simulation_context &ctx__, wf::spin_range spins__, wf::band_range br__, wf::Wave_functions< T > const &hub_wf__, wf::Wave_functions< T > const &phi__, U_operator< T > const &um__, wf::Wave_functions< T > &hphi__)
Contains declaration of sirius::Non_local_operator class.
Contains typedefs, enums and simple descriptors.
Contains declaration and implementation of Wave_functions class.