Skip to content

feat(dftu): add AMF and fixed-alpha mixing for the Full projector - #8359

Open
rimujiangshu wants to merge 6 commits into
deepmodeling:developfrom
rimujiangshu:codex/dftu-full-amf-mixed-8281
Open

rimujiangshu wants to merge 6 commits into
deepmodeling:developfrom
rimujiangshu:codex/dftu-full-amf-mixed-8281

Conversation

@rimujiangshu

@rimujiangshu rimujiangshu commented Nov 21, 2026 •

Copy link
Copy Markdown

Linked Issue

Related to #8281.

What's changed?

Add AMF and fixed-alpha FLL/AMF interpolation to the existing Full DFT+U projector (dft_plus_u=1, controlled by onsite_radius), while preserving FLL as the default.

  • Add dftu_dc = fll | amf | mixed.
  • Require an explicit, finite dftu_alpha in [0,1] for mixed.
  • Use alpha=0 for AMF and alpha=1 for FLL.
  • Apply interpolation to the local correction functional and its corresponding potential at the same projected occupation.
  • Reuse the existing Full occupation builder, Hamiltonian assembly and update timing.

Here, Full refers to the existing radius-adjustable localized projection with simplified U_eff=U-J. This PR does not introduce an anisotropic U/J functional, another projector, Dual modifications or SOC support.

Functional and compatibility

For each atom and spin channel, with N = Tr(n) and M = 2l+1:

E_alpha = U_eff/2 * [alpha*N + (1-alpha)*N^2/M - Tr(n^2)]
V_alpha = U_eff * [(alpha/2 + (1-alpha)*N/M)*I - n]

AMF uses the orbital average within each spin channel, without additional normalization of the existing projected occupation. The band-energy correction remains E_alpha - ReTr(V_alpha*n), evaluated at the same occupation as the potential.

For nspin=1, the existing per-spin occupation convention is retained: the shell energy is doubled, but the potential is not. For nspin=2, each spin-channel contribution is accumulated once.

Omitting the new parameters or explicitly selecting dftu_dc fll retains the existing FLL potential and energy implementation. Additional AMF/mixed scope guards do not restrict legacy FLL requests.

Example additions to a valid Full DFT+U input:

dftu_dc     mixed
dftu_alpha  0.5

The new modes support double-precision CPU/LCAO, explicit PBE, collinear fixed-structure KS SCF, one k pool, one band group, atomic cold starts and symmetry=0/-1. Unsupported combinations, including SOC, force/stress, restart/occupation initialization, occupation/DMR mixing, Yukawa U, U-ramping, EXX and guarded matrix exports, are rejected explicitly. These guards also apply to mixed endpoints.

Unit Tests and/or Case Tests for my changes

Results below cover the selected tests and stated SCF configuration, using the frozen candidate based on upstream f5315651166ea265ba673996e3c9efeb5e4cd9b0.

Check Result
Selected registered DFT+U/INPUT CTest suite 32/32 passed; zero failures and zero skipped tests.
Default DC settings vs explicit FLL Passed; printed total energy and band gap agree. The default also agrees with upstream on the tested configuration.
AMF vs mixed with alpha=0 Passed; printed total energy and band gap agree.
FLL vs mixed with alpha=1 Passed; printed total energy and band gap agree.

The CTest selection includes energy-potential finite differences with trace-changing and off-diagonal perturbations, spin-factor and production-operator checks, and INPUT round-trip/MPI parameter tests.

SCF comparisons used CrI3, nspin=2, a 2x2x1 k mesh, U_eff=2 eV, 100 Ry, genelpa, scf_thr=1e-9 and at most 500 iterations. Runs used four MPI ranks on distinct physical cores with single-threaded math libraries. Energy and gap comparison thresholds were 1e-7 eV/cell and 1e-6 eV, respectively. Reported equality refers to the recorded output precision.

Recorded command forms, with paths and the selected test expression represented by variables:

ctest --test-dir "$BUILD_MPI" -V --timeout 240 -j 1 -R "$DFTU_IO_TEST_REGEX" --output-junit "$JUNIT"
"$CHECKED_MPI" -n 4 "$BASELINE_MPI"
"$CHECKED_MPI" -n 4 "$CANDIDATE_MPI"

DFTU_IO_TEST_REGEX selects the 32 registered tests above. CHECKED_MPI is the validation harness's binding-checked launcher. Each SCF configuration was run in a separate case directory.

Implementation notes

  • Extend the existing LCAO factory and DFTU_onsite operator with explicit immutable DC configuration.
  • Add a local DC helper while retaining the existing FLL branch.
  • Add INPUT metadata, validation, MPI synchronization and round-trip-safe alpha serialization.
  • Update user documentation and register the added production/test sources without introducing new dependencies.
  • Governance exceptions requested: none.

Upstream merge validation (2026-11-21)

Merged develop at 153ad6290f95578d6ef97a719939b63d76ad4e99, preserving the original feature commit.

  • Resolve the INPUT test-registration conflict by retaining both sides, including all six DC MPI cases and the upstream output-precision cases.
  • Place the added INPUT test in flat unittests/, retaining its serial compilation scope and assertions.
  • Adapt AMF/mixed export guards to upstream's canonical output names and compatibility aliases; cover the new names in the existing policy test. The early FLL return remains unchanged.
  • The Full DC functional and legacy FLL potential/energy branch are unchanged. Retain upstream parallel-layout API updates.

Fresh verification in the project's CPU abacus-gnu image (GCC 11.4.0, Open MPI 4.1.2; OMP_NUM_THREADS=1, OPENBLAS_NUM_THREADS=1):

  • 38/38 registered CTests passed, zero failed or skipped: the original 32 selected DFT+U/INPUT tests plus six retained upstream output/helper tests. MPI INPUT tests use four ranks.
  • hamilt_lcao and abacus_input_yaml built successfully.
  • git diff --check upstream/develop passed; governance has no blockers. The four standard-header include advisories are required by the declared string/vector/complex types and owned configuration members.
cmake --build "$BUILD_MPI" --target "${DFTU_IO_TARGETS[@]}" -j2
ctest --test-dir "$BUILD_MPI" -V --timeout 240 -j1 \
  -R "$MERGE_TEST_REGEX" --output-junit "$JUNIT"
cmake --build "$BUILD_MPI" --target hamilt_lcao abacus_input_yaml -j2
python3 tools/03_code_analysis/agent_governance_check.py \
  --base upstream/develop --head HEAD --format text

DFTU_IO_TARGETS builds the selected DFT+U/INPUT executables. MERGE_TEST_REGEX extends the original 32-test selection with MODULE_IO_libxc_r_suffix, MODULE_IO_frame_append, MODULE_IO_provenance_header, and the three MODULE_IO_input_error_mpi_out_*_zero_precision cases.

No SCF calculations were rerun for this merge; the SCF comparisons above remain attributed to the frozen candidate and configuration stated there.

Review follow-up: INPUT failure handling and phase coverage

Implemented in 0f2cb7c0225faccd75d30f36abac6376fd8f1922 (tested tree
4586b5c98a5f6c686814a82e41edbf31aeb5756b).

Fresh local CPU validation: 42/42 registered CTests passed, zero failures
and zero skips, including the four new four-rank INPUT cases. The conjugate-k
test passed with 1 rank through CTest and separately with 2 and 4 MPI ranks.
hamilt_lcao and abacus_input_yaml built, and the generated alpha metadata
contains the [0,1] value rule. Toolchain: GCC 11.4.0, Open MPI 4.1.2, official
abacus-gnu image digest
sha256:ee3101aea0e50813e2e408cb857e29ca9ea774da5a9b8c8d65b87cb7dd77799d,
with single-threaded math/runtime settings. These are local results, not a
claim that the new GitHub CI or scientific SCF regressions have completed.
No SCF was rerun for this review fix; the earlier SCF evidence remains tied to
the exact historical revision below.

The alpha reader now registers value>=0 and value<=1 with the existing scalar
domain validator. Invalid values are rejected before the rank-zero reader
callback, so the diagnostic follows the existing input_error broadcast and
normal INPUT shutdown path. The direct parser's defensive checks remain.
There is no change to accepted values, DC defaults, the FLL implementation,
the functional, or numerical tolerances.

Four new registered reader cases use four MPI ranks each: alpha -0.1, 1.1,
nan and 0.5junk. They require exit code 1, the parameter/input-file/manual
diagnostic and all four reader shutdown markers, not merely a nonzero exit.
They extend the existing INPUT unit-test harness because a numerical Autotest
reference does not check per-rank failure-path shutdown.

DFTUTest.FullDcConjugateKDensityAndHamiltonian adds conjugate k points
(+/-0.23,0,0), R=0,+/-1 atom blocks and complex Hermitian DMK with k weights
and spin degeneracy included. It connects production DMK-to-DMR, Full
occupation contraction/reduction, DC potential/energy, H(R) assembly and H(k)
folding. It compares against an independent direct k-space projector
contraction for alpha=0,0.35,1 and checks the density-Hamiltonian trace and
reset/rebuild behavior. Neighbors and overlaps are explicit fixtures: this is
not a test of neighbor search, radial integrals or a new SCF benchmark.
Existing operator-construction/dispatch and default-FLL tests are retained.

The Hermiticity residual is now a named local before std::abs, with the same
arithmetic and rejection tolerance.

No documentation update required for the manual INPUT reference: [0,1] was
already the documented contract. The new domain rule updates the registered
metadata used to generate the reference; generated YAML/Markdown artifacts
are not committed.

Exact historical verification identities and selections

The earlier SCF comparisons and 32 CTests used the frozen source tree
ee8ef1e9099bc81ae39eb0cc74665c0fc5b02ca2, subsequently published unchanged as
feature commit 3e3bcf2eec187e60341f80e13bf081baaf34f687, on upstream base
f5315651166ea265ba673996e3c9efeb5e4cd9b0. The frozen tree was tested before
that publication commit was created; this is a verified source-tree identity,
not a claim that the later Git commit ID was embedded in the old executable.
The tested patch SHA256 is
dbf805932c85d324230ce3e72d71017cff5e05af9ff91a034a5b0eda8c0fb048.

The separate 38-test merge validation used
bf34603d1a1487a6de8faf25bde4e3a43c6d404b, tree
7715f58253d6af8c7e40227fe899177cf4da9068, merged with upstream
153ad6290f95578d6ef97a719939b63d76ad4e99. It did not rerun SCF.

The following explicit target lists and anchored regexes resolve the variables
used above. The grouped 32-test regex selects exactly the recorded 32 names;
the six added merge tests are listed separately. Counts refer to registered
CTest entries, not the number of internal assertions or MPI ranks.

# Feature revision: 3e3bcf2eec187e60341f80e13bf081baaf34f687
FEATURE_TEST_TARGETS=(
  MODULE_DFTU_pots MODULE_DFTU_energy MODULE_DFTU_op_legacy
  MODULE_DFTU_for_r MODULE_DFTU_str_r MODULE_DFTU_folding MODULE_DFTU_fs_r
  MODULE_DFTU_fs_reduce MODULE_DFTU_fs_k MODULE_DFTU_fs_accum
  MODULE_DFTU_op MODULE_DFTU_ijr MODULE_DFTU_base_io MODULE_DFTU_full_dc
  MODULE_IO_read_item_serial MODULE_IO_input_domain_reader
  MODULE_IO_dftu_dc_check MODULE_IO_read_inp_exx_dftu MODULE_IO_input_error_mpi
)
DFTU_IO_TEST_REGEX='^(MODULE_DFTU_(pots|energy|op_legacy|for_r|str_r|folding|fs_r|fs_reduce|fs_k|fs_accum|op|ijr|base_io|full_dc)|MODULE_IO_(read_item_serial|input_domain_reader|dftu_dc_check|read_inp_exx_dftu|input_error_mpi_(missing_file|missing_header|unknown_parameter|duplicate_parameter|duplicate_string_eof|invalid_value|invalid_dependency|valid|dftu_default|dftu_fll|dftu_amf|dftu_mixed0|dftu_mixed05|dftu_mixed1)))$'

# Merge revision: bf34603d1a1487a6de8faf25bde4e3a43c6d404b
DFTU_IO_TARGETS=("${FEATURE_TEST_TARGETS[@]}"
  MODULE_IO_libxc_r_suffix MODULE_IO_frame_append MODULE_IO_provenance_header
)
MERGE_TEST_REGEX='^(MODULE_DFTU_(pots|energy|op_legacy|for_r|str_r|folding|fs_r|fs_reduce|fs_k|fs_accum|op|ijr|base_io|full_dc)|MODULE_IO_(read_item_serial|input_domain_reader|dftu_dc_check|read_inp_exx_dftu|libxc_r_suffix|frame_append|provenance_header|input_error_mpi_(missing_file|missing_header|unknown_parameter|duplicate_parameter|duplicate_string_eof|invalid_value|invalid_dependency|valid|dftu_default|dftu_fll|dftu_amf|dftu_mixed0|dftu_mixed05|dftu_mixed1|out_dmk_zero_precision|out_hsk_zero_precision|out_mat_tk_zero_precision)))$'

export OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1
cmake --build "$BUILD_MPI" --target "${DFTU_IO_TARGETS[@]}" -j2
ctest --test-dir "$BUILD_MPI" -V --timeout 240 -j1 \
  -R "$MERGE_TEST_REGEX" --output-junit "$JUNIT"

On the feature revision, build "${FEATURE_TEST_TARGETS[@]}" instead and
select "$DFTU_IO_TEST_REGEX". The historical SCF executable target was
abacus_std_para, built separately/in the same build command as those test
targets. The command above is the merge unit-test selection, not an SCF run.

The four new failure-path cases extend the 38-test selection with:

MODULE_IO_input_error_mpi_dftu_alpha_below_zero
MODULE_IO_input_error_mpi_dftu_alpha_above_one
MODULE_IO_input_error_mpi_dftu_alpha_nonfinite
MODULE_IO_input_error_mpi_dftu_alpha_trailing

Their existing per-test timeout is 45 seconds (MPI subprocess: 30 seconds).
No references or convergence thresholds were loosened and no private run logs
or calculation inputs are included in the commit.

The review-fix selection and additional MPI phase checks can be run as:

REVIEW_TEST_REGEX="${MERGE_TEST_REGEX}|^MODULE_IO_input_error_mpi_dftu_alpha_(below_zero|above_one|nonfinite|trailing)$"
ctest --test-dir "$BUILD_MPI" -V --timeout 240 -j1 \
  -R "$REVIEW_TEST_REGEX" --output-junit "$JUNIT"
for ranks in 2 4; do
  mpirun -n "$ranks" \
    "$BUILD_MPI/source/source_lcao/module_dftu/unittests/MODULE_DFTU_op" \
    --gtest_filter=DFTUTest.FullDcConjugateKDensityAndHamiltonian
done

Related to deepmodeling#8281. Preserve the existing default FLL path and add focused Full-projector DC, input, operator tests and documentation.
Keep both INPUT test registrations, follow the flat unit-test layout, and adapt AMF/mixed export guards to renamed upstream parameters without restricting legacy FLL. Verified 38 registered CTests and hamilt_lcao/abacus_input_yaml builds.

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One INPUT failure-path defect and three nonblocking suggestions remain. This was a static source and algebra review; no builds, numerical/MPI runs or CI diagnostics were performed, and the reported validation remains author-reported.

Non-blocking: Please add the exact feature SHA used for the earlier SCF comparisons and the values of DFTU_IO_TARGETS, DFTU_IO_TEST_REGEX and MERGE_TEST_REGEX (or explicit target/test lists). The upstream base SHA and command forms alone do not identify the tested feature revision or reproduce the reported 32/38-test selection.

item.description = "Explicit finite weight in [0,1] for dftu_dc=mixed. Zero gives AMF and one gives FLL. Not accepted for other DC modes. This weight is fixed, not determined self-consistently.";
item.domain.scalar();
item.read_value = [](const Input_Item& item, Parameter& para) {
para.input.dftu_alpha = parse_dftu_alpha(item.str_values.at(0));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Finite out-of-range values such as dftu_alpha 1.1 pass this scalar domain and then throw uncaught from parse_dftu_alpha during rank-zero prepare_input(), before input_error is broadcast. This bypasses the normal INPUT diagnostic path while the other ranks wait in that broadcast. Please register the [0,1] domain constraint (or return the range error through prepare_input) and add a four-rank invalid-alpha reader case.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 0f2cb7c. The scalar domain now registers value>=0 and value<=1 before the rank-zero read_value callback. Added four-rank reader cases for -0.1, 1.1, nan and 0.5junk; all require exit 1, the INPUT diagnostic and all four shutdown markers. The original 1.1 failure was reproduced as exit 134 before the fix. All four cases and the full selected 42-test suite pass locally; accepted input values/default FLL are unchanged.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Source review at 0f2cb7c0 confirms that the range error is addressed: [0,1] validation now returns a diagnostic before read_value, allowing the existing input_error broadcast to handle it. The four new reader cases require exit code 1 and all four shutdown markers. This was a static review; I have not independently verified the reported test or CI results.

{
SCOPED_TRACE(modes[mode]);
SCOPED_TRACE(weights[mode]);
module_dm::DensityMatrix<TK, double> dm(paraV, nspin, nspin);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking: This constructor creates one Gamma point per spin, and the DMK entries below are real, so the complex-density test does not exercise nontrivial multi-k phases. Add a small conjugate ±k case with nonzero R and complex Hermitian DMK, comparing the projected occupation, Hamiltonian contribution and energy against an independent contraction.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added in 0f2cb7c as DFTUTest.FullDcConjugateKDensityAndHamiltonian: conjugate +/-0.23 k points, nonzero +/-1 R blocks and complex Hermitian DMK, feeding the production DMK-to-DMR, occupation/reduction, Full DC, H(R) and H(k) routines. Occupation, potential/energy, every local H(k) entry and the density-Hamiltonian trace are checked against an independent direct k-space contraction for alpha=0/0.35/1, including reset/rebuild. Passes with 1, 2 and 4 MPI ranks. Neighbors/overlaps are explicit fixtures, not a claim of radial-integral/neighbor-search or SCF coverage; existing operator dispatch tests remain.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The new conjugate ±k fixture addresses the phase-coverage request. Non-blocking: Please register a four-rank CTest entry filtered to DFTUTest.FullDcConjugateKDensityAndHamiltonian, with PROCESSORS 4, a timeout and OMP_NUM_THREADS=1. AddTest launches the binary directly, so normal CTest still uses one rank; an MPI entry would preserve the cross-owner regression in routine testing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Implemented in f40582a. The only change is nine lines in source/source_lcao/module_dftu/unittests/CMakeLists.txt.

MODULE_DFTU_op_conjugate_k_mpi4 now launches the existing MODULE_DFTU_op executable through the configured MPI launcher with four ranks, forwarding MPIEXEC_NUMPROC_FLAG, MPIEXEC_PREFLAGS and MPIEXEC_POSTFLAGS, and filtering to DFTUTest.FullDcConjugateKDensityAndHamiltonian. It sets PROCESSORS 4, TIMEOUT 120, and OMP_NUM_THREADS=1, inside the existing MPI/LCAO guards. No production sources, default FLL behavior, test assertions or tolerances were changed.

Built MODULE_DFTU_op and MODULE_DFTU_full_dc on an allocated CPU compute node, then ran:

ctest --test-dir build -V -j 4 --no-tests=error \
  -R '^(MODULE_DFTU_full_dc|MODULE_DFTU_op|MODULE_DFTU_op_conjugate_k_mpi4)$'

Result: 3/3 registered CTests passed, with no failures or skips. The full verbose log confirms four distinct MPI ranks and four successful executions of the filtered test. The post-test log checker initially encountered CTest's 1024-byte JUnit output truncation; the complete log was checked instead, without rerunning or changing the tests. No SCF calculation was run. This is focused compute-node validation, not a claim that the newly triggered upstream CI has already completed.

const T nij = occupation[i * dimension + j];
const T nji = occupation[j * dimension + i];
if (!std::isfinite(std::real(nij)) || !std::isfinite(std::imag(nij))
|| std::abs(nij - std::conj(nji)) > 1.0e-10)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Non-blocking: Please assign nij - std::conj(nji) to a named local before passing it to std::abs. Current root AGENTS.md rule 14 requires computed arguments to be named, and the residual would then be directly inspectable when an occupation is rejected.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated in 0f2cb7c: the computed difference is stored in hermiticity_residual before std::abs. The formula and 1e-10 Hermiticity threshold are unchanged. The focused Full DC tests and selected 42-test suite pass locally.

@rimujiangshu

Copy link
Copy Markdown
Author

Follow-up to the review: all four points have been addressed for commit 0f2cb7c0225faccd75d30f36abac6376fd8f1922.

  1. INPUT failure handling: registered the alpha range with the existing domain validator and added four-rank cases for -0.1, 1.1, nan and 0.5junk, checking the normal diagnostic and shutdown path. Individual reply.
  2. Nontrivial complex k phases: added the conjugate +/-k test with nonzero R and complex Hermitian DMK, comparing occupation, potential/energy and H(k) against an independent contraction. It passes with 1, 2 and 4 MPI ranks. Individual reply and coverage boundaries.
  3. Named Hermiticity residual: introduced hermiticity_residual without changing the arithmetic or tolerance. Individual reply.
  4. Exact historical verification identity and selections: the PR description now includes the frozen source tree ee8ef1e9099bc81ae39eb0cc74665c0fc5b02ca2, subsequently published unchanged as feature commit 3e3bcf2eec187e60341f80e13bf081baaf34f687, and the separate merge-validation commit bf34603d1a1487a6de8faf25bde4e3a43c6d404b. It also gives explicit target lists and the values of DFTU_IO_TARGETS, DFTU_IO_TEST_REGEX and MERGE_TEST_REGEX, checked against the recorded 32/38-test selections. The historical tests predate the feature publication commit; this is a source-tree identity, not a claim that the old executable embedded that later SHA.

The review fix passed 42/42 selected local CTests, with zero failures or skips. The upstream CI round for the current commit has also passed, including ASE: both previously failing Si tests (test_calculator_results and test_restart) are included in the core suite's 22/22 result with no skips. No SCF benchmark was rerun for this review fix, and no defaults, references or numerical thresholds were relaxed.

Could a maintainer please re-review the updated commit and confirm whether the three inline threads can be resolved? They remain open for review; the replies are not a claim of reviewer approval.

@mohanchen mohanchen added DFT+U Issues related to DFT plus U function Refactor Refactor ABACUS codes labels Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would suggest not adding DFTU-related check in module_parameter, otherwise the module will become huge if every parameter is checked in this way (more source files will be added). Adding the checks in DFT+U module may be another choice?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. Moved dftu_dc_check.{h,cpp} to source/source_lcao/module_dftu under DFTU_LCAO in a86d6c1. module_parameter now only calls the check at the existing INPUT stage, after resets. The validation conditions, diagnostics and default FLL behavior are unchanged.

The dependency-light checker remains compiled through the unconditional io_input object target, so disabling LCAO does not remove INPUT validation or require linking the LCAO operator library. The serial-reader and legacy Makefile source references were updated as well.

Verified on a CPU compute node: 25 selected INPUT CTests passed, including the four-rank default/explicit FLL, AMF, mixed endpoints and invalid-alpha reader cases. In addition, the four serial INPUT test targets passed with LCAO disabled, and again with both MPI and LCAO disabled; abacus_input_yaml built and ran in all three configurations. No INPUT metadata/documentation change is needed because there is no user-facing behavior change. No SCF was run.


namespace DFTU_LCAO
{
struct FullDcEnergy

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it would be simpler if we don't use the struct, and put the two variables to related classes?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks. Removed FullDcEnergy in 93ab9d4. The helper now returns the interaction energy as a double and supplies the band correction through an explicit output reference. The Full operator continues to accumulate that correction in its existing u_energy/set_energy path; no additional persistent energy members are needed. The interaction value remains available to the derivative and energy-ledger tests without adding unused class state.

The numerical expressions, operation order, potential layout and legacy FLL branch are unchanged. All callers and tests were adapted; the tests also check that invalid inputs leave both output arguments unchanged and that zero-U/repeated calls do not retain an old correction. Existing references and tolerances were not relaxed.

Verified this exact revision on a CPU compute node: production dftu and hamilt_lcao targets built; 43 selected CTests passed with no failures/skips, including MODULE_DFTU_op_conjugate_k_mpi4 (all four ranks passed). The selection was:

ctest --test-dir build -V -j 4 --no-tests=error -R '^(MODULE_DFTU_(pots|energy|op_legacy|for_r|str_r|folding|fs_r|fs_reduce|fs_k|fs_accum|op|ijr|base_io|full_dc|op_conjugate_k_mpi4)|MODULE_IO_(read_item_serial|input_domain_reader|dftu_dc_check|read_inp_exx_dftu|libxc_r_suffix|frame_append|provenance_header|input_error_mpi_.*))$'

OMP_NUM_THREADS=1 was used. No SCF or installation was performed. These are internal-interface changes, so the existing user documentation remains applicable. Both discussions are left open for your confirmation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DFT+U Issues related to DFT plus U function Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants