Skip to content

Feature: velocity matrix correction for meta-gga xc functionals#7391

Open
Flying-dragon-boxing wants to merge 5 commits into
deepmodeling:developfrom
Flying-dragon-boxing:260302-MGGA
Open

Feature: velocity matrix correction for meta-gga xc functionals#7391
Flying-dragon-boxing wants to merge 5 commits into
deepmodeling:developfrom
Flying-dragon-boxing:260302-MGGA

Conversation

@Flying-dragon-boxing
Copy link
Copy Markdown
Collaborator

See the title for details.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the PW velocity operator used by conductivity calculations to include a meta-GGA (v_\tau)-dependent commutator contribution, enabling a corrected “velocity matrix” when meta-GGA XC functionals are selected.

Changes:

  • Thread meta-GGA (v_\tau) (from Potential::vofk_smooth) into hamilt::Velocity from PW and SDFT conductivity drivers.
  • Implement a meta-GGA velocity correction term in Velocity::act() using real/reciprocal transforms and meta_pw_op.
  • Refactor EXX inner-loop set_psi() placement in ESolver_KS_PW::iter_finish() to avoid redundant calls.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
source/source_pw/module_stodft/sto_elecond.cpp Passes vofk_smooth data (as (v_\tau)) into Velocity for STO conductivity.
source/source_pw/module_pwdft/op_pw_vel.h Extends Velocity API/state to accept/store (v_\tau) and work buffers.
source/source_pw/module_pwdft/op_pw_vel.cpp Implements meta-GGA commutator-based velocity correction and allocates new workspaces.
source/source_pw/module_pwdft/elecond.cpp Passes vofk_smooth data (as (v_\tau)) into Velocity for KG conductivity.
source/source_esolver/esolver_ks_pw.cpp Adjusts EXX set_psi() call timing in the separate-loop path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

int vtau_row_ = 0; ///< number of spin channels stored in vtau_
std::complex<FPTYPE>* porter1_ = nullptr; ///< workspace on real grid
std::complex<FPTYPE>* porter2_ = nullptr; ///< workspace on real grid / recip grid
base_device::DEVICE_CPU* ctx = {};
// ---------------------------------------------
if (this->vtau_ != nullptr && this->vtau_col_ > 0 && XC_Functional::get_func_type() == 3)
{
const int current_spin = (this->vtau_row_ > 1 && psi_in->get_npol() == 2) ? this->isk[this->ik] : 0;
Comment on lines 34 to +40
if (this->nonlocal)
{
this->ppcell->initgradq_vnl(*this->ucell);
}
// workspace for meta-GGA correction (size follows wfcpw grids)
resmem_complex_op()(porter1_, this->wfcpw->nmaxgr);
resmem_complex_op()(porter2_, this->wfcpw->nmaxgr);
Comment on lines +146 to +150
// term1: ∂_id (v_tau * psi)
this->wfcpw->recip_to_real(this->ctx, bandpsi, this->porter1_, this->ik);
ModuleBase::vector_mul_vector_op<Complex, Device>()(this->vtau_col_, this->porter1_, this->porter1_, vtau_spin);
this->wfcpw->real_to_recip(this->ctx, this->porter1_, this->porter1_, this->ik);
meta_pw_op<Real, Device>()(this->ctx,
// fix to the velocity path by adding the missing 1/2 here:
// V_tau = -(1/2) ∇·(v_tau ∇), so
// [V_tau, r]_j = -(1/2) [ ∂_j(v_tau ψ) + v_tau ∂_j ψ ].
// The contribution to velocity is -i times the bracket.
@mohanchen mohanchen added Features Needed The features are indeed needed, and developers should have sophisticated knowledge Refactor Refactor ABACUS codes labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Features Needed The features are indeed needed, and developers should have sophisticated knowledge Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants