Skip to content

fix(input): preserve explicit magnetic mixing parameters - #8185

Merged
mohanchen merged 1 commit into
deepmodeling:developfrom
Stardust0831:fix/input-preserve-magnetic-mixing
Oct 21, 2026
Merged

mohanchen merged 1 commit into
deepmodeling:developfrom
Stardust0831:fix/input-preserve-magnetic-mixing

Conversation

@Stardust0831

@Stardust0831 Stardust0831 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Preserve the user's explicitly specified, valid magnetic mixing parameters instead of silently resetting them. For nspin=2/4, omitting mixing_beta currently changes an explicit mixing_beta_mag=0.2 and mixing_gg0_mag=0.7 to 1.6 and 0.0. This PR retains 0.2/0.7 while resolving the omitted charge-mixing default.

#7719 tracks INPUT finalization that silently changes user-specified parameters and can make an explicit value behave differently from the equivalent default. Its central requirement is to preserve valid explicit input and replace silent correction of invalid or contradictory input with a clear error: name the offending parameters and values, explain the conflict, and provide legal values/corrective guidance and the relevant manual link. Intentional defaults for omitted parameters remain useful; they must not overwrite the user's explicit choices.

This small PR handles the preservation side of that contract: these magnetic values are valid, so they must be kept. It does not introduce a new invalid-value rule. Explicit negative mixing values and unset-sentinel handling will be addressed by a subsequent unified parameter-validity validation stage tracked in #7719; that work is outside this PR.

Linked Issue

Part of #7719. Independent of the other reset-cleanup PRs.

Unit Tests and/or Case Tests for my changes

Commands run with the GNU 13.4 conda toolchain on PATH, LD_LIBRARY_PATH=/home/stardust/miniconda3/envs/phono3py/lib, and OMP_NUM_THREADS=1:

cmake --build /tmp/abacus-7719-small-pr-build --target MODULE_IO_read_item_serial MODULE_IO_availability abacus_pw_omp -j8
ctest --test-dir /tmp/abacus-7719-small-pr-build --output-on-failure -R '^MODULE_IO_(read_item_serial|availability)$'
/tmp/abacus-7719-small-pr-build/abacus_pw_omp --version
/tmp/abacus-7719-small-pr-build/abacus_pw_omp -h mixing_beta_mag
/tmp/abacus-7719-small-pr-build/abacus_pw_omp -h mixing_gg0_mag
/tmp/abacus-7719-small-pr-build/abacus_pw_omp --check-input
/tmp/abacus-7719-small-pr-build/abacus_pw_omp --generate-parameters-yaml > /tmp/abacus-7719-mixing-parameters.yaml
python3 docs/generate_input_main.py /tmp/abacus-7719-mixing-parameters.yaml --output /tmp/abacus-7719-mixing-input-main.md --verbose

Build and both CTest targets passed. Before applying the fix, the new PreserveExplicitMagneticMixing regression failed for both overwritten values at nspin=2/4; the default-value regression already passed. After the fix, the full reader tests preserve 0.2/0.7 with omitted or explicit mixing_beta, including nspin=1 controls. Omitted magnetic parameters still resolve to 1.6/0 for nspin=2/4.

--check-input passed in all nine case directories (nspin=1/2/4, default input or custom magnetic parameters with implicit/explicit mixing_beta). Exact retained values are asserted by the reader unit tests. Version is v3.11.0-beta11; both help pages and generated documentation contain the new guidance (579 parameters, 37 categories). An initial CTest invocation without the toolchain PATH failed to locate ctest; the corrected invocation above passed. MPI/GPU and numerical LCAO runs were not performed; local validation uses the CPU/OpenMP build with MPI/LCAO backends disabled.

What's changed?

  • Delete four cross-field assignments in the mixing_beta default hook. Magnetic defaults remain in their own existing initializer/hook.
  • Document preservation of explicit values in the mixing_beta_mag and mixing_gg0_mag metadata.
  • Add full-reader regressions and update the old hook-level expectations. Negative-value/sentinel validation is outside this small PR.

Governance Notes

  • INPUT/docs changes: magnetic mixing values are preserved when mixing_beta is omitted. No documentation update required outside the Input_Item registrations; generated YAML/Markdown are build artifacts.
  • Core module impact: shared INPUT default resolution only. No charge-mixing numerical algorithm or solver changes, and no new global dependencies.
  • Verification: git diff --cached --check and python3 tools/03_code_analysis/agent_governance_check.py --staged --event-path /mnt/g/work/agent/abacus/issue-7719-pr-notes/mixing-event.json --format text passed. Whole-file quality scores remain 0/0 (baseline 0/0), reflecting existing large-file debt; the test additions increase test-file length.
  • Exceptions requested: none.

@Stardust0831 Stardust0831 added the Input&Output Suitable for coders without knowing too many DFT details label Oct 20, 2026
@Stardust0831
Stardust0831 marked this pull request as ready for review October 20, 2026 13:26
@mohanchen mohanchen added the Refactor Refactor ABACUS codes label Oct 21, 2026
@mohanchen

Copy link
Copy Markdown
Collaborator

Thanks for the fix.

@mohanchen
mohanchen merged commit 6c9049d into deepmodeling:develop Oct 21, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Input&Output Suitable for coders without knowing too many DFT details Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants