Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ OBJS_LCAO=DM_gamma.o\
norm_psi.o\
propagator.o\
td_velocity.o\
td_current.o\
snap_psibeta_half_tddft.o\
upsi.o\
FORCE_STRESS.o\
Expand Down
7 changes: 2 additions & 5 deletions source/module_esolver/esolver_ks_lcao_tddft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,17 +401,14 @@ void ESolver_KS_LCAO_TDDFT::after_scf(const int istep) {
}
if (TD_Velocity::out_current == true)
{
elecstate::DensityMatrix<std::complex<double>, double>* tmp_DM
= dynamic_cast<elecstate::ElecStateLCAO<std::complex<double>>*>(this->pelec)->get_DM();
hamilt::HamiltLCAO<std::complex<double>, double>* p_ham_lcao = dynamic_cast<hamilt::HamiltLCAO<std::complex<double>, double>*>(this->p_hamilt);
elecstate::DensityMatrix<std::complex<double>, double>* tmp_DM = dynamic_cast<elecstate::ElecStateLCAO<std::complex<double>>*>(this->pelec)->get_DM();
ModuleIO::write_current(istep,
this->psi,
pelec,
kv,
two_center_bundle_.overlap_orb.get(),
tmp_DM->get_paraV_pointer(),
this->RA,
p_ham_lcao->getSR()); // mohan add 2024-04-02
this->RA); // mohan add 2024-04-02
}
ESolver_KS_LCAO<std::complex<double>, double>::after_scf(istep);
}
Expand Down
3 changes: 1 addition & 2 deletions source/module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,10 @@ HamiltLCAO<TK, TR>::HamiltLCAO(Gint_Gamma* GG_in,
// TDDFT_velocity_gague
if (TD_Velocity::tddft_velocity)
{
elecstate::H_TDDFT_pw::update_At();
if(!TD_Velocity::init_vecpot_file) elecstate::H_TDDFT_pw::update_At();
Operator<TK>* td_ekinetic = new TDEkinetic<OperatorLCAO<TK, TR>>(LM_in,
this->hR,
&(this->getHk(LM_in)),
this->sR,
kv,
&GlobalC::ucell,
&GlobalC::GridD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ template <typename TK, typename TR>
TDEkinetic<OperatorLCAO<TK, TR>>::TDEkinetic(LCAO_Matrix* LM_in,
hamilt::HContainer<TR>* hR_in,
std::vector<TK>* hK_in,
hamilt::HContainer<TR>* SR_in,
const K_Vectors* kv_in,
const UnitCell* ucell_in,
Grid_Driver* GridD_in,
const Parallel_Orbitals* paraV,
const TwoCenterIntegrator* intor)
: SR(SR_in), kv(kv_in), OperatorLCAO<TK, TR>(LM_in, kv_in->kvec_d, hR_in, hK_in), intor_(intor)
: kv(kv_in), OperatorLCAO<TK, TR>(LM_in, kv_in->kvec_d, hR_in, hK_in), intor_(intor)
{
this->LM = LM_in;
this->ucell = ucell_in;
Expand All @@ -44,18 +43,18 @@ TDEkinetic<OperatorLCAO<TK, TR>>::~TDEkinetic()
}
// term A^2*S
template <typename TK, typename TR>
void TDEkinetic<OperatorLCAO<TK, TR>>::td_ekinetic_scalar(std::complex<double>* Hloc, TR* Sloc, int nnr)
void TDEkinetic<OperatorLCAO<TK, TR>>::td_ekinetic_scalar(std::complex<double>* Hloc, TR overlap, int nnr)
{
return;
}
// term A^2*S
template <>
void TDEkinetic<OperatorLCAO<std::complex<double>, double>>::td_ekinetic_scalar(std::complex<double>* Hloc,
double* Sloc,
double overlap,
int nnr)
{
// the correction term A^2/2 , 4.0 due to the unit transformation
std::complex<double> tmp = {cart_At.norm2() * Sloc[nnr] / 4.0, 0};
std::complex<double> tmp = {cart_At.norm2() * overlap, 0};
Hloc[nnr] += tmp;
return;
}
Expand All @@ -69,7 +68,7 @@ void TDEkinetic<OperatorLCAO<TK, TR>>::td_ekinetic_grad(std::complex<double>* Hl
//∇ refer to the integral ∫𝜙(𝑟)𝜕/𝜕𝑟𝜙(𝑟−𝑅)𝑑𝑟,but abacus only provide the integral of ∫𝜙(𝑟)𝜕/𝜕R𝜙(𝑟−𝑅)𝑑𝑟. An extra
//minus must be counted in. The final term is iA dot ∇R
std::complex<double> tmp = {0, grad_overlap * cart_At};
Hloc[nnr] += tmp;
Hloc[nnr] += tmp * 2.0;
return;
}

Expand Down Expand Up @@ -102,22 +101,20 @@ void TDEkinetic<OperatorLCAO<TK, TR>>::calculate_HR()
ModuleBase::Vector3<double> dtau = this->ucell->cal_dtau(iat1, iat2, R_index2);

hamilt::BaseMatrix<std::complex<double>>* tmp = this->hR_tmp->find_matrix(iat1, iat2, R_index2);
hamilt::BaseMatrix<TR>* tmps = this->SR->find_matrix(iat1, iat2, R_index2);
if (tmp != nullptr)
{
if (TD_Velocity::out_current)
{
std::complex<double>* tmp_c[3] = {nullptr, nullptr, nullptr};
for (int i = 0; i < 3; i++)
{
tmp_c[i]
= td_velocity.get_current_term_pointer(i)->find_matrix(iat1, iat2, R_index2)->get_pointer();
tmp_c[i] = td_velocity.get_current_term_pointer(i)->find_matrix(iat1, iat2, R_index2)->get_pointer();
}
this->cal_HR_IJR(iat1, iat2, paraV, dtau, tmp->get_pointer(), tmp_c, tmps->get_pointer());
this->cal_HR_IJR(iat1, iat2, paraV, dtau, tmp->get_pointer(), tmp_c);
}
else
{
this->cal_HR_IJR(iat1, iat2, paraV, dtau, tmp->get_pointer(), nullptr, tmps->get_pointer());
this->cal_HR_IJR(iat1, iat2, paraV, dtau, tmp->get_pointer(), nullptr);
}
}
else
Expand All @@ -135,8 +132,7 @@ void TDEkinetic<OperatorLCAO<TK, TR>>::cal_HR_IJR(const int& iat1,
const Parallel_Orbitals* paraV,
const ModuleBase::Vector3<double>& dtau,
std::complex<double>* data_pointer,
std::complex<double>** data_pointer_c,
TR* s_pointer)
std::complex<double>** data_pointer_c)
{
const LCAO_Orbitals& orb = LCAO_Orbitals::get_const_instance();
// ---------------------------------------------
Expand Down Expand Up @@ -171,6 +167,7 @@ void TDEkinetic<OperatorLCAO<TK, TR>>::cal_HR_IJR(const int& iat1,
// calculate the Ekinetic matrix for each pair of orbitals
// ---------------------------------------------
double grad[3] = {0, 0, 0};
double overlap = 0;
auto row_indexes = paraV->get_indexes_row(iat1);
auto col_indexes = paraV->get_indexes_col(iat2);
const int step_trace = col_indexes.size() + 1;
Expand All @@ -195,17 +192,16 @@ void TDEkinetic<OperatorLCAO<TK, TR>>::cal_HR_IJR(const int& iat1,
int M2 = (m2 % 2 == 0) ? -m2 / 2 : (m2 + 1) / 2;

// calculate <psi|∇R|psi>, which equals to -<psi|∇r|psi>.
intor_->calculate(T1, L1, N1, M1, T2, L2, N2, M2, dtau * this->ucell->lat0, nullptr, grad);
intor_->calculate(T1, L1, N1, M1, T2, L2, N2, M2, dtau * this->ucell->lat0, &overlap, grad);
ModuleBase::Vector3<double> grad_overlap(grad[0], grad[1], grad[2]);

for (int ipol = 0; ipol < npol; ipol++)
{
// key change
td_ekinetic_scalar(data_pointer, s_pointer, ipol * step_trace);
td_ekinetic_scalar(data_pointer, overlap, ipol * step_trace);
td_ekinetic_grad(data_pointer, ipol * step_trace, grad_overlap);
}
data_pointer += npol;
s_pointer += npol;
// current grad part
if (data_pointer_c != nullptr)
{
Expand All @@ -216,13 +212,14 @@ void TDEkinetic<OperatorLCAO<TK, TR>>::cal_HR_IJR(const int& iat1,
// part of Momentum operator, -i∇r,used to calculate the current
// here is actually i∇R
data_pointer_c[dir][ipol * step_trace] += std::complex<double>(0, grad_overlap[dir]);
// part of Momentum operator, eA,used to calculate the current
data_pointer_c[dir][ipol * step_trace] += std::complex<double>(overlap * cart_At[dir], 0);
}
data_pointer_c[dir] += npol;
}
}
}
data_pointer += (npol - 1) * col_indexes.size();
s_pointer += (npol - 1) * col_indexes.size();
if (data_pointer_c != nullptr)
{
for (int dir = 0; dir < 3; dir++)
Expand All @@ -236,7 +233,7 @@ void TDEkinetic<OperatorLCAO<TK, TR>>::init_td(void)
{
TD_Velocity::td_vel_op = &td_velocity;
// calculate At in cartesian coorinates.
td_velocity.cal_cart_At(this->ucell->a1, this->ucell->a2, this->ucell->a3, elecstate::H_TDDFT_pw::At);
td_velocity.cal_cart_At(elecstate::H_TDDFT_pw::At);
this->cart_At = td_velocity.cart_At;
std::cout << "cart_At: " << cart_At[0] << " " << cart_At[1] << " " << cart_At[2] << std::endl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class TDEkinetic<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
TDEkinetic<OperatorLCAO<TK, TR>>(LCAO_Matrix* LM_in,
hamilt::HContainer<TR>* hR_in,
std::vector<TK>* hK_in,
hamilt::HContainer<TR>* SR_in,
const K_Vectors* kv_in,
const UnitCell* ucell_in,
Grid_Driver* GridD_in,
Expand Down Expand Up @@ -70,8 +69,7 @@ class TDEkinetic<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>
const Parallel_Orbitals* paraV,
const ModuleBase::Vector3<double>& dtau,
std::complex<double>* data_pointer,
std::complex<double>** data_pointer_c,
TR* s_pointer);
std::complex<double>** data_pointer_c);

/**
* @brief calculate the ekinetic matrix correction term in tddft with specific <I,J,R> atom-pairs
Expand All @@ -94,7 +92,7 @@ class TDEkinetic<OperatorLCAO<TK, TR>> : public OperatorLCAO<TK, TR>

const K_Vectors* kv;
/// @brief correction term iA⋅∇
void td_ekinetic_scalar(std::complex<double>* Hloc, TR* Sloc, int nnr);
void td_ekinetic_scalar(std::complex<double>* Hloc, TR Sloc, int nnr);
/// @brief correction term A^2*S
void td_ekinetic_grad(std::complex<double>* Hloc, int nnr, ModuleBase::Vector3<double> grad_overlap);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void hamilt::TDNonlocal<hamilt::OperatorLCAO<TK, TR>>::calculate_HR()
atom1->iw2n[iw1],
tau0 * this->ucell->lat0,
T0,
cart_At / 2.0,
cart_At,
TD_Velocity::out_current);
for (int dir = 0; dir < nlm_dim; dir++)
{
Expand Down Expand Up @@ -412,7 +412,7 @@ void hamilt::TDNonlocal<hamilt::OperatorLCAO<TK, TR>>::contributeHR()
static_cast<OperatorLCAO<TK, TR>*>(this->next_sub_op)->set_HR_fixed(this->hR_tmp);
}
// calculate the values in hR_tmp
this->calculate_HR();
//this->calculate_HR();
this->hR_tmp_done = true;
}
ModuleBase::timer::tick("TDNonlocal", "contributeHR");
Expand Down
1 change: 1 addition & 0 deletions source/module_hamilt_lcao/module_tddft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if(ENABLE_LCAO)
propagator.cpp
upsi.cpp
td_velocity.cpp
td_current.cpp
snap_psibeta_half_tddft.cpp
)

Expand Down
Loading