Repository navigation
feat(dfpt): v_sc Broyden mixing for the response SCF (default), plus rho_broyden, rho_kerker, v_sc_plain #8214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Zanthoxylum
wants to merge
14
commits into
deepmodeling:develop
Choose a base branch
from
Zanthoxylum:dfpt-mix
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+625
−62
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7d9805a
feat(dfpt): promote the response mixing scheme to INPUT parameters
Zanthoxylum 3fed63c
feat(dfpt): Broyden mixing for the response SCF (dfpt_mix_type = broy…
Zanthoxylum eba2ba5
feat(dfpt): v_sc mixing route for the response SCF (dfpt_mix_type = v…
Zanthoxylum 4dc56de
test(dfpt): disable Broyden mock test pending interface fix
Zanthoxylum ce35b98
fix(dfpt): accept broyden and v_sc in the DFPT_Rho init validation an…
Zanthoxylum 8c8f8f0
fix(dfpt): provide the mix callback for Broyden push_data
Zanthoxylum 7753433
fix(dfpt): reset the Broyden mixer's address binding between displace…
Zanthoxylum 629a1e9
refactor(dfpt): rename mixing methods to {variable}_{algorithm} forma…
Zanthoxylum 14c1890
feat(dfpt): set v_sc_broyden as the default mixing scheme
Zanthoxylum 1a2f421
fix(dfpt): address review findings on the mixing PR
Zanthoxylum 07276d1
test(dfpt): correct the plain-mixing contraction note in the Broyden …
Zanthoxylum 17bfa50
fix(dfpt): address the human-review nits on the E-field loop and init
Zanthoxylum 81c95ee
feat(dfpt): give the E-field solve the density-space Broyden mixer un…
Zanthoxylum 74f0171
Merge branch 'develop' into dfpt-mix
Zanthoxylum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,12 +13,15 @@ | |
|
|
||
| #include "dfpt_pw_data.h" | ||
| #include "source_base/timer.h" | ||
| #include "source_base/tool_quit.h" | ||
| #include "source_base/tool_title.h" | ||
|
|
||
| #include <cmath> | ||
| #include <complex> | ||
| #include <cstdlib> | ||
| #include <iomanip> | ||
| #include <iostream> | ||
| #include <sstream> | ||
| #include <vector> | ||
|
|
||
| namespace ModuleDFPT | ||
|
|
@@ -312,6 +315,8 @@ void DFPT_PW::Impl::solve_efield_resp(int q_idx) | |
| rho_.reset_mixing(q_idx); | ||
| data_.set_drho_g(q_idx, 0, std::vector<std::complex<double>>(npw, std::complex<double>(0.0, 0.0))); | ||
| bool converged = false; | ||
| int n_iter_done = 0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking: |
||
| double residual_last = 0.0; | ||
| for (int iter = 0; iter < max_iter_ && !converged; ++iter) | ||
| { | ||
| // screened response potential of the mixed input density | ||
|
|
@@ -338,13 +343,26 @@ void DFPT_PW::Impl::solve_efield_resp(int q_idx) | |
| rho_.compute_drho(gs_psi_, wg_, q_idx, data_); | ||
| rho_.mix_drho(q_idx, data_); | ||
| const double residual = rho_.get_residual(q_idx, data_); | ||
| residual_last = residual; | ||
| converged = (residual < conv_thr_); | ||
| ++n_iter_done; | ||
| if (converged) | ||
| { | ||
| std::cout << "DFPT efield dir=" << a << " converged, residual=" << residual << " (iter=" << iter << ")" | ||
| << std::endl; | ||
| } | ||
| } | ||
| if (!converged) | ||
| { | ||
| // same explicit non-convergence report as solve_displacement: | ||
| // a silently truncated E-field solve corrupts Z* / LO-TO | ||
| std::ostringstream oss; | ||
| oss << "the E-field response (dir " << static_cast<char>('x' + a) | ||
| << ") did not converge within dfpt_max_iter=" << max_iter_ << ": final residual " << std::scientific | ||
| << std::setprecision(3) << residual_last << " vs threshold " << std::setprecision(1) << conv_thr_ | ||
| << std::defaultfloat << ". Z* / LO-TO splitting from this solve is unreliable"; | ||
| ModuleBase::WARNING("DFPT_PW::solve_efield_resp", oss.str()); | ||
| } | ||
| stash_dpsi_efield(q_idx, a, nk, nbands); | ||
| } | ||
| ModuleBase::timer::end("DFPT_PW", "solve_efield_resp"); | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking: Consider declaring the positive-a2 and ndim>=1 bounds with
domain.set_rule, and the five mode values withdomain.set_choices. Numeric scalar parsing is already validated by theread_syncmacros; the range/choice checks currently remain in root-onlycheck_valueafter broadcasts. Declared domains would expose these constraints in help and route rejection through the shared input-error path. This can be a follow-up.