Repository navigation
Conversation
ABACUS-PR-BOT
left a comment
There was a problem hiding this comment.
Four diagnostic paths can misreport or discard SCF data: intermediate U-ramping stages, PW file-charge initialization, two-Fermi gaps, and EXX reruns. Please address these before relying on the records for analysis. Three nonblocking metadata/governance points are included.
Static review only; no builds or runtime tests were run.
| diagnostic_step.restart_count = this->p_chgmix->mixing_restart_count; | ||
| diagnostic_step.restart_scheduled_step = this->p_chgmix->mixing_restart_step; | ||
| diagnostic_step.restart_executed = this->inp_->mixing_restart > 0.0 | ||
| && iter == this->p_chgmix->mixing_restart_step && this->p_chgmix->mixing_restart_count > 0; |
There was a problem hiding this comment.
[P2] Capture the restart event before its schedule changes
During a U-ramping restart that has not reached target U, chgmixing_ks_lcao increments the restart counter and then replaces mixing_restart_step with a future step. This comparison therefore emits mixing_restart_executed=0 for a restart that just ran; the PW observer has the same issue. Please capture the executed event separately from the future schedule and cover every counter increment in a multi-stage ramp.
| diagnostic_step.mixing_restart = this->inp_->mixing_restart; | ||
| diagnostic_step.uramping_eV = this->dftu_->get_uramping() * ModuleBase::Ry_to_eV; | ||
| diagnostic_step.u_converged = this->dftu_->u_converged(); | ||
| const bool input_ready = iter > 1 || istep > 0 || this->dftu_->is_occmat_ready(); |
There was a problem hiding this comment.
[P2] Distinguish a loaded occupation seed from an applied input
With init_chg=file and default init_occ_mat=0, init_base loads occupations and sets readiness, but iter_init_dftu_pw skips Hubbard-potential construction on the first SCF step. This expression nevertheless reports the loaded matrix as n_in, while the applied onsite potential and source correction are still zero. Please derive input availability from the actual potential-construction path and cover this first-step case; the inherited production behavior is separate from the new diagnostic mislabeling.
| diagnostic_step.restart_executed = this->inp_->mixing_restart > 0.0 | ||
| && iter == this->p_chgmix->mixing_restart_step && this->p_chgmix->mixing_restart_count > 0; | ||
| diagnostic_step.converged = conv_esolver; | ||
| diagnostic_step.gap_eV = this->pelec->bandgap * ModuleBase::Ry_to_eV; |
There was a problem hiding this comment.
[P2] Handle the two-Fermi gap fields explicitly
With nonzero nupdown, base iter_finish calls cal_bandgap_updw(), which updates only bandgap_up and bandgap_dw; bandgap remains its initial zero. Both PW and LCAO observers emit that zero as logged_E_gap_k_eV, although native output logs the two spin gaps. Please emit the spin gaps separately or mark the scalar gap unavailable, and add a regression for this mode.
| } | ||
| const std::string path = step.output_dir + "scf_diagnostics.jsonl"; | ||
| const bool first = step.ionic_step == 1 && step.iteration == 1; | ||
| const std::ios::openmode mode = first ? std::ios::trunc : std::ios::app; |
There was a problem hiding this comment.
[P2] Preserve records across repeated SCF passes
A PW separate-EXX loop can reset iter to 1 while keeping the same ionic step, so this condition truncates all preceding diagnostic records at the first geometry. Later geometries instead append repeated iteration numbers without a pass identifier. Please initialize the file once per calculation and distinguish SCF passes, or explicitly reject that diagnostic combination; also account for EXX revoking the provisional convergence flag captured by the observer.
| item.type = "Real"; | ||
| item.description = "Once uramping > 0.15 eV. DFT+U calculations will start SCF with U = 0 eV, namely normal LDA/PBE calculations. Once SCF restarts when drho<mixing_restart, U value will increase by uramping eV. SCF will repeat above calcuations until U values reach target defined in hubbard_u. As for uramping=1.0 eV, the recommendations of mixing_restart is around 5e-4."; | ||
| item.default_value = "-1.0."; | ||
| item.description = "For any positive uramping increment (eV), DFT+U calculations will start SCF with U = 0 eV, namely normal LDA/PBE calculations. Once SCF restarts when drho<mixing_restart, U value will increase by uramping eV. SCF will repeat above calcuations until U values reach target defined in hubbard_u. As for uramping=1.0 eV, the recommendations of mixing_restart is around 5e-4."; |
There was a problem hiding this comment.
Non-blocking: Please expose the newly enforced constraints in the source Input_Item metadata: uramping requires mixing_restart>scf_thr and excludes Yukawa, while mixing_dmr requires LCAO and scf_thr_type=2 as well as a positive restart threshold. The current parameter help advertises weaker conditions than the new check callbacks. Update the source metadata without committing generated YAML/Markdown.
| { | ||
| return {}; | ||
| } | ||
| return std::vector<double>(this->raw_.begin() + offset, this->raw_.begin() + offset + size); |
There was a problem hiding this comment.
Non-blocking: Current AGENTS rule 14 requires named locals for computed call arguments. Please name these iterator endpoints, and the new spin + 1 and pointer-endpoint arguments in the observers, before passing them to their calls.
| } | ||
| if (first) | ||
| { | ||
| running_log << "Write SCF diagnostic records to file: " << path << '\n'; |
There was a problem hiding this comment.
Non-blocking: Please log the absolute output path for this creation/overwrite notice, as required by AGENTS rule 16. global_out_dir is normally OUT.<suffix>/, so concatenating it here leaves a relative path; the existing absolute_path_for_log helper can format the notice without changing the file location.
Problem and behavior
LCAO onsite DFT+U accepted
mixing_dftuwithout applying occupation mixing to the Hubbard Hamiltonian. PW occupation and LCAO DMR histories could outlive a charge-mixer restart, or reuse coefficients when charge mixing was skipped. The existing local per-electronic-step observer rejected either mixing option, preventing analysis of these workflows.This draft connects LCAO onsite linear occupation mixing, synchronizes PW occupation/DMR histories with charge mixing, and exercises each mixing option separately with U-ramping. It includes the original opt-in PW/LCAO diagnostics and extends them to schema 4: actual Hubbard input, current raw output, input-construction occupation mixing snapshots, current post-DMR projection, actual U, restart information, channel residuals, magnetism and source energy. Snapshot timing and the Hubbard band-energy correction convention are documented explicitly.
Scope is
dft_plus_u=1. Simultaneousmixing_dmrandmixing_dftuis rejected; PW DMR mixing is not implemented. Legacy LCAO DFT+U is outside this work. Diagnostics currently support collinear double precision; LCAO diagnostics require symmetry disabled. GPU/SOC diagnostic output and broad material convergence claims are outside the verified scope.Implementation and INPUT changes
OccMatMixerandmixing_beta; its first unseeded projection passes through. File occupations seed the previous physical input, andinit_occ_mat=2remains fixed.mixing_restart, and requires LCAO, real-space convergence (scf_thr_type=2) and a positive restart threshold.urampingincrement enables ramping (previously increments below 0.01 Ry were effectively ignored). Zero/negative values disable it. Requiremixing_restart>scf_thr; reject Yukawa+ramping. Clamp the final increment and retain the target-U convergence guard in PW-only compilation.ABACUS_SCF_DIAGNOSTICS=1writes one flushed JSON record per completed step. Missing matrices remain null. The observer never feeds its copies back into SCF.Validation
Verified again after merging upstream
a56706f(v3.11.0-beta14), headd4ca3dc. The merge preserves the two formatting-conflict resolutions and all feature checks below.Local CPU build: Intel 2024 compiler, MPI, MKL, ELPA; LCAO enabled, LibRI/LibXC disabled;
OMP_NUM_THREADS=1for runtime checks.Commands/checks completed:
cmake --build build --target abacus_basic_para -j4: full build passed.ctest --test-dir build --output-on-failure -R '^(MODULE_ESTATE_occ_mixer|MODULE_CHARGE_mix|MODULE_CHARGE_dmr|MODULE_CHARGE_drho|MODULE_ESTATE_scf_diagnostics|MODULE_PW_dftu_base_test)$': 6/6 suites passed in the normal local MPI environment. A restricted-environment MPI initialization failure was rerun outside that environment; no test expectations were relaxed.tests/17_DS_DFTU,bash ../integrate/Autotest.sh -a "$ABACUS" -n 2 -o 1 -j 2 -f CASES_DFTU_MIXING.txt -g, then the same command without-g: ten fixed-input Si p-shell cases all converged; both energy comparisons per case passed. The ten cases are also listed inCASES_CPU.txt.check_dftu_scf_diagnostics.pychecks over all ten runs, requiring actual ramp/DMR/occupation events where requested: passed. Checks cover finite Hermitian matrices, consecutive steps, correct input/output handoff, LCAO linear mixing and the source Hubbard energy identity../build/abacus_basic_para --version,-h mixing_dftu,-h mixing_dmr,-h uramping,--check-input, YAML parameter dump and documentation generation: passed. Unsupported simultaneous mixers, PW DMR, and an invalid ramp threshold fail early.-U__LCAO: passed. A separate full PW-only link and GPU runtime tests were not performed.cmake-format --check;git diff --checkpasses; governance has no blockers.These tests establish update semantics, not universal convergence improvement. An additional Fe stress trajectory reached its 120-step limit despite correct U and matrix handoffs; its nonconvergence is not represented as a passing material-convergence result.
Governance notes
No separate issue: this is a user-requested repair and diagnostic-development draft. Core impact is limited to SCF orchestration, charge/auxiliary history lifecycle, onsite Hubbard occupations, and observational estate output. The new diagnostic test lives with its estate source.
Global dependency budget is unchanged (six added and six removed references); existing solver globals supply the output stream, output directory and writer rank, without adding global control in numerical kernels. Added headers provide value types used directly by their interfaces (
vector,string,ostream, diagnostic record structs). No governance exception is requested.The existing local diagnostic-only checkout and both pinned production binaries were preserved and independently verified against their initial SHA256 values.