Add unified H/S matrix output options and gamma-only H(R)/S(R) output - #7707
Merged
Conversation
Collaborator
Author
|
The motivation for modifying the input parameters is that users find it difficult to understand them based on their names alone: out_mat_hs represents H(k)/S(k); |
mohanchen
reviewed
Jul 30, 2026
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.
Summary
This PR contains five focused changes:
nspin = 1,2, and4, including spin-independent overlap files and ionic-step suffixes.R = (0, 0, 0)block, with an explicit folded-representation comment in text CSR output.out_hskandout_hsrformat controls. Values are0for disabled,1for text,2for reserved binary output, and3for NPZ (out_hsronly).out_mat_hs,out_mat_hs2, andout_hsr_npzremain compatible aliases; explicit new options take precedence regardless of INPUT order.sr_nao, adopting one-based NAO names for H/S NPZ files, correctingget_s, and documenting H(k)/S(k) as reciprocal-space matrices and H(R)/S(R) as real-space matrices indexed by the Bravais lattice vector R.The INPUT help,
parameters.yaml, generatedinput-main.md, H/S matrix guide, migration guide, TB2J/DeepH interface documentation, examples, reference files, and integration checks are synchronized with the output contract below.Matrix output filenames
H(k)/S(k) text output:
nspin = 1:hk_nao.txt,sk_nao.txtnspin = 2:hks1_nao.txt,hks2_nao.txt,sk_nao.txtnspin = 1:hk${k}_nao.txt,sk${k}_nao.txtnspin = 2:hk${k}s1_nao.txt,hk${k}s2_nao.txt,sk${k}_nao.txtnspin = 4:hk${k}s4_nao.txt,sk${k}_nao.txtHere
${k}is the one-based k-point index. Whenout_app_flagis false,g${step}is inserted before_nao, where${step}is the one-based ionic-step index.H(R)/S(R) text CSR output:
nspin = 1:hrs1_nao.csr,sr_nao.csrnspin = 2:hrs1_nao.csr,hrs2_nao.csr,sr_nao.csrnspin = 4:hrs1_nao.csr,sr_nao.csrsrg${step}_nao.csr; append/regular output usessr_nao.csrcalculation get_swritesOUT.${suffix}/sr_nao.csrH(R)/S(R) NPZ output:
hrs1_nao.npz;nspin = 2additionally writeshrs2_nao.npzsr_nao.npzout_hsr 3, legacyout_hsr_npz 1, and independent H-onlyout_hr_npz 1output_HR0.npz,output_HR1.npz, andoutput_SR.npzcopies are not generatedBehavior
R = (0, 0, 0)is present.nspin = 4remains unsupported. Existing gamma-only restrictions forout_hr_npz,out_mat_r,out_mat_t, and DM(R) NPZ remain unchanged.Tests
ENABLE_CNPY=ONbuild trees:cmake --build build_repro_hs2 --target abacus_basic_para MODULE_IO_read_item_serial MODULE_IO_read_input_serial MODULE_IO_input_help_test MODULE_IO_write_hs_r_compat_test -j2cmake --build build_repro_hs2_cnpy --target abacus_basic_para MODULE_IO_read_item_serial MODULE_IO_read_input_serial MODULE_IO_input_help_test MODULE_IO_write_hs_r_compat_test -j2ctest --test-dir build_repro_hs2 --output-on-failure -R '^(MODULE_IO_read_item_serial|MODULE_IO_read_input_serial|MODULE_IO_input_help_test|MODULE_IO_write_hs_r_compat_test)$'ctest --test-dir build_repro_hs2_cnpy --output-on-failure -R '^(MODULE_IO_read_item_serial|MODULE_IO_read_input_serial|MODULE_IO_input_help_test|MODULE_IO_write_hs_r_compat_test)$'OMP_NUM_THREADS=1 ../integrate/Autotest.sh -a /home/goodchong/abacus-develop/build_repro_hs2/abacus_basic_para -n 2 -o 1 -r '^scf_out_hk_spin2$'passed 11 checks.OMP_NUM_THREADS=1 ../integrate/Autotest.sh -a /home/goodchong/abacus-develop/build_repro_hs2/abacus_basic_para -n 2 -o 1 -r '^(scf_out_hsr|scf_out_hsr_spin4|nscf_out_hsr_tr_rr|get_s)$'passed 16 checks.OMP_NUM_THREADS=1 ../integrate/Autotest.sh -a /home/goodchong/abacus-develop/build_repro_hs2_cnpy/abacus_basic_para -n 2 -o 1 -f CASES_CNPY.txt -r '^(scf_out_hsr_npz|scf_out_hr_npz)$'passed 7 checks. After deleting previous generated NPZ files, the new NAO names were present and the legacy NPZ names were absent.out_hsr 3produced non-emptyhrs1_nao.npz,hrs2_nao.npz, andsr_nao.npz. Each file contained three matrix keys, all ending in_0_0_0.build_repro_hs2/abacus_basic_para --generate-parameters-yaml > /tmp/abacus-parameters-review.yaml,python3 docs/generate_input_main.py /tmp/abacus-parameters-review.yaml --output /tmp/abacus-input-main-review.md, andcmpagainst both checked-in generated files passed.python3 tools/03_code_analysis/agent_governance_check.py --base 39c688ea76d417d2b471189a3c3b99e9fb4f855b --head HEAD --format textcompleted with four migration-neutral warnings and an overall global-dependency delta of-2.git diff --check 39c688ea76d417d2b471189a3c3b99e9fb4f855b HEADpassed.