Feature: velocity matrix correction for meta-gga xc functionals#7391
Open
Flying-dragon-boxing wants to merge 5 commits into
Open
Feature: velocity matrix correction for meta-gga xc functionals#7391Flying-dragon-boxing wants to merge 5 commits into
Flying-dragon-boxing wants to merge 5 commits into
Conversation
This reverts commit bed1ff6.
There was a problem hiding this comment.
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) intohamilt::Velocityfrom PW and SDFT conductivity drivers. - Implement a meta-GGA velocity correction term in
Velocity::act()using real/reciprocal transforms andmeta_pw_op. - Refactor EXX inner-loop
set_psi()placement inESolver_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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See the title for details.