Repository navigation
Conversation
…out_app_flag=2
The band output did not honor out_app_flag=2: the filename never received
a g{step} suffix and always wrote into global_out_dir, so multi-step runs
(MD/relax) would overwrite bands1.txt / bands2.txt and only keep the last
step.
Changes:
- Add global_band_dir to System_para, mapped to OUT/<suffix>/BANDS/ in mode 2
and falling back to global_out_dir otherwise; includes MPI broadcast.
- write_bands: use global_band_dir as the output directory, add g{istep+1}
suffix when out_app_flag==2, and lazily ensure the BANDS/ directory exists.
- Tests: sync io_sys_var_test directory assertions and test_write_bands
TestParameters with the new global_band_dir.
Verified: MODULE_IO_write_bands (10/10), MODULE_IO_system_variable_test pass;
esolver builds cleanly; governance check has no new blockers.
Replace the legacy "RELAX STEP" keyword and pre-existing inconsistent "Ionic Step" (with space) occurrences with "Ionic_Step" (underscore) to match the established convention already used by write_cube.cpp and related integration-test fixtures. Production code: - source_relax/relax_stru_io.cpp: STRU file provenance header - source_io/module_output/print_info.cpp: stdout/ofs_running run logs - source_io/module_hs/vxc_op_tools.cpp: eband decomposition energy header - source_pw/module_pwdft/dftu_base_io.cpp: DFTU occ_mat provenance header - source_io/module_dm/write_dmk.cpp: DM(k) frame header (historical) - source_io/module_dm/write_dmr.cpp: DM(R) CSR frame header (historical) - source_io/module_hs/hsr_writer.cpp: H(R)/S(R) CSR frame header (historical) - source_io/module_mulliken/output_mulliken.cpp: Mulliken output frame header (historical) Tests: - source_relax/unittests/test_relax_stru_io.cpp - source_io/unittests/test_print_info.cpp - source_io/module_dm/test/write_dmk_test.cpp - source_io/module_dm/test/test_write_dmr.cpp - source_io/module_hs/unittests/test_hsr_writer.cpp Comments / doc strings: - source_base/module_out/csr_reader.h: CSR format example - source_io/module_parameter/read_inp_out.cpp: out_stru parameter description Verification: - make -j 30 -> 100% - ctest -R "(RELAX_relax_stru_io|IO_print_info|IO_vxc_op_tools|PW_dftu_base| IO_mulliken|IO_write_dmk|IO_write_dmr|IO_hsr_writer)" -> 10/10 PASSED - grep -rn "RELAX STEP" / "Ionic Step " -> zero matches in source tree
Production code:
- source_io/module_wf/write_wfc_nao.cpp: wf{ki}s{spin}_nao.txt provenance header
- source_io/module_energy/write_bands.cpp: band eigenvalue provenance header
Tests:
- source_io/unittests/test_write_wfc_nao.cpp
- source_io/unittests/test_read_wfc_nao.cpp
- source_io/unittests/test_write_bands.cpp
Verification:
- make -j 30 -> 100%
- ctest -R "(IO_write_wfc_nao|IO_read_wfc_nao|IO_write_bands|
RELAX_relax_stru_io|IO_print_info)" -> 8/8 PASSED
- grep -rn "RELAX STEP\|Ionic Step \|IONIC STEP" -> zero matches
Three source output files wrote "# ionic step" (or "X # ionic step") in their per-ionic-step header comments, while STRU and cube outputs already use "Ionic_Step". Rename to the unified keyword across: - cal_dos.cpp -> "X # Ionic_Step" (doss*.txt / pdoss*.txt) - write_eig_occ.cpp -> "X # Ionic_Step" (eig_occ.txt) - hs_dense_io.cpp -> "# Ionic_Step X" (HS dense matrix) Sync test assertions and INPUT parameter description accordingly. Also refines the INPUT file under examples/17_relax/04_relax_with_output_lcao with end-of-line filename comments for each enabled out_* parameter.
The prior commit 4038796 unified "# ionic step" to "# Ionic_Step" in hs_dense_io.cpp but missed test_hs_dense_io.cpp, causing TextHeaderContains StepAndDimension and TextHeaderStepTwo to fail. Sync the EXPECT_NE find() strings and a nearby comment. Verification: MODULE_IO_hs_dense_io_test -> 11/11 PASSED.
Three writers produced per-frame headers as "STEP: N" or "IONIC_STEP: N": - pos_op_csr.cpp (rr_nao.csr, rx_nao.csr, ...) - hs_sparse_io.cpp (hrs*.csr, srg*.csr, trs*.csr, ...) - dhs_sparse_writer.cpp (dhrx*.csr, dsrx*.csr, ...) - overlap.cpp (S_async(R) overlap) Rename to "Ionic_Step N" (keyword-first, no colon) to match STRU cube, doss, eig_occ, and HS dense-matrix headers unified in the previous commit. Sync test assertions, fixture SR.csr, and comments accordingly.
PDOS text output (write_pdos_text.cpp) used "# istep:" as its per-step header keyword while all other outputs had already been unified to "Ionic_Step". This was the last remaining non-Ionic_Step keyword in production output. Production code: - source_io/module_dos/write_pdos_text.cpp Tests: - source_io/module_dos/unittests/test_write_pdos_text.cpp (5 assertions) Docs: - docs/advanced/elec_properties/dos.md (PDOS format example and description) Verification: - make -j 30 -> 100% - MODULE_DOS_write_pdos_text -> 5/5 PASSED
hs_dense_io.cpp writes "# Ionic_Step N" since the keyword unification, but the hk/sk/vxc/dH reference files still contained "# ionic step". CompareFile.py compares comment lines token by token, so those matrix comparisons would fail. Update 31 references under tests/; value data is unchanged.
out_mat_r writes a single rr_nao.txt (or MAT/rrg{step}_nao.txt when
out_app_flag = 2) rather than separate rxrs/ryrs/rzrs CSR files. Update
the INPUT description, the position-matrix guide, and the example INPUT
comment, and align the documented frame header with the emitted
Ionic_Step keyword.
Tensor quantities (sigma, vsigma, v2rho2, v2rhosigma, v2sigma2, v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3, v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4) previously used _s1/_s2/_s3 suffixes that collide with the real spin-index convention used by rho and vrho. Replace them with explicit Libxc-channel index tuples (_00, _01, _11 for 3-channel tensors, etc.). Scalar quantities (exc, amag) no longer carry a redundant _s1 suffix. Rho and vrho keep _sN since those map to actual spin indices. A set of small helper lambdas generates the suffix lists so the channel ordering stays consistent with Libxc throughout.
Follow the repository NAO sparse-matrix naming convention: one-based
spin index, "_nao.csr" suffix, and the g{step} suffix plus append
behavior driven by out_app_flag in mode 2. Pass the ionic step and
out_app_flag explicitly into write_Vxc_R instead of hard-coding
istep = -1. Update the out_mat_xc2 help text, the example INPUT
comment, and the scf_out_hxc reference fixture (including its
Ionic_Step header).
ABACUS-PR-BOT
left a comment
There was a problem hiding this comment.
The output changes introduce mismatched derivative labels, a CSR step-reader regression, stale Vxc records on reruns, and unmigrated integration headers. The global-dependency budget and three non-blocking documentation/test items also need attention. Static source and API-contract review of 63431111; no builds or tests were run.
The earlier commit 91465ba updated 31 .txt.ref files under tests/ for the Ionic_Step unification, but left .csr.ref, rr_nao.txt.ref, mulliken.txt.ref and cube.ref fixtures still carrying the legacy "--- Ionic Step N ---", "STEP: N" or "IONIC_STEP: N" headers. CompareFile.py does a token-by-token compare and those mismatches cause the integrating tests (md_out_hk_syns, scf_out_hk_spin2, scf_out_mul, scf_out_mul_spin2, ...) to fail. Update 41 remaining reference files under tests/02_NAO_Gamma/ and tests/03_NAO_multik/ to the new unified "Ionic_Step N" keyword. Data values are untouched.
The eig_occ.txt per-ionic-step header was unified from "X # ionic
step" to "X # Ionic_Step", but the ASE reader still counted frames
with endswith('# ionic step'), yielding nframe = 0 and failing the
assertion len(ik) == nframe * nspin * nk in read_band_from_eig_occ.
Match the header with a case-insensitive regex that accepts both the
old and the new spelling, and sync the nspin4-gamma-eigocc fixture to
the current format.
The out_band BANDS/ change read PARAM.globalv.global_band_dir inside write_bands, which pushed the PR over the global dependency budget (added=4, removed=3, net_delta=1) and blocked CI. Resolve the directory once in ESolver_KS::after_scf and pass it as an explicit argument, following the existing write_eig_file / output_mat_sparse convention. This keeps the band writer free of PARAM and brings the PR-wide delta to zero. Verified: MODULE_IO_write_bands 2/2 passed; abacus_basic_para target builds; governance diff counting gives net_delta=0.
ABACUS-PR-BOT
left a comment
There was a problem hiding this comment.
The reader now accepts both step-header spellings. The suggestion below covers the legacy format. Static incremental review; builds and tests were not run.
The non-MPI-specific tests in test_hsr_writer.cpp performed file I/O on all MPI ranks simultaneously, causing file corruption and race conditions when the test binary was launched with mpirun -np 2. - For the 7 tests that call the non-collective write_hcontainer_csr / write_hcontainer_csr_binary directly, add an early return on non-zero ranks so only rank 0 writes/reads/removes the files. - For WriteHsrTextCsrCarriesPerSpinFermiFromEfermi, keep the collective write_hsr call (which internally uses gatherParallels) on all ranks, but guard the file read-back, assertions, and cleanup to rank 0 only. Verified: single-process (21 passed, 1 skipped) and mpirun -np 2 (22 passed on both ranks), plus ctest serial+parallel both pass.
The MO-basis Vxc matrix written by out_mat_xc reused the "vxc" property,
which resolved to the same vxck{ik}s{spin}_nao.txt filename as the
NAO-basis matrix from out_mat_vxck; with out_app_flag 0/1 the later
writer silently overwrote the former. Give the MO-basis matrix its own
"vxcmo" property and pass the real ionic step and out_app_flag into
write_Vxc instead of locally shadowed constants, which restores the
one-based Ionic_Step header and the mode-2 g{step} suffix. Update the
two integration fixtures and props_mat.sh accordingly.
write_Vxc_R is called from ctrl_runner_lcao, which runs once at the end
of the whole calculation, so out_app_flag=2 only ever produced a single
vxcrs{spin}g{N}_nao.csr file. Drop the per-step suffix and always
truncate, matching the documented vxcrs{spin}_nao.csr name, and remove
the now unused out_app_flag parameter.
write_h_term looped both spin channels while write_hk_common enumerated only the spin-up k indices, so Vnl(k)/Vl(k)/Vh(k) were written twice into s1 files, and Vxc(k), which is spin dependent, placed both channels in the same s1 file. Enumerate the local k points of each spin through K_Vectors::isk as write_hsk does, pass nspin=1 to filename_output for spin-independent terms so they carry no spin suffix, and apply the same enumeration to the EXX writer and to T(k).
Emit the column header only once per file and stamp each frame with "# Ionic_Step <1-based step>" so the angular-momentum matrices match the step labelling of the other matrix outputs. Appending frames no longer repeats the full header.
Mode 0 previously kept every written frame and mode 2 ignored the step
number. Open the file per the selected mode: overwrite for mode 0, append
after the first step for mode 1, and write mullikeng{step}.txt in mode 2.
write_eig_file always appended after the first step and ignored the ionic
output frequency, so mode 0 kept every frame and mode 2 had no step suffix.
Gate the write by out_freq_ion and open the file per out_app_flag: overwrite
in mode 0, append after the first step in mode 1, and write eig_occg{step}.txt
in mode 2.
out_band was dumped on every ionic step regardless of out_freq_ion, so a run with out_freq_ion = 2 produced five band frames while the other step-scoped outputs produced three. Gate write_bands with the same frequency used by eig_occ.txt; a non-positive frequency still writes every step.
output_SR wrote a compact "Matrix Dimension" header while write_hsr wrote the self-describing CSR header for the same sr_nao.csr file name. Pass the unit cell explicitly and enable csr_format so both paths emit one layout; the binary record path is unchanged.
Every R-space writer assembled its own "<prefix>[s<spin>][g<step>]_nao" name, which let the S(R) path drift: output_SR ignored out_app_flag=2 and always wrote sr_nao.csr into the run directory with step 0. Add make_sparse_R_filename in the shared detail header and route H(R), S(R), DM(R), dH/dR, r(R), L(R), T(R) and Vxc(R) through it. output_SR now takes the ionic step and writes into global_matrix_dir with the mode-2 step suffix; existing names are unchanged.
save_sparse now writes only R blocks with elements above the threshold, but the out_mat_t and out_mat_r descriptions (and the r(R) format note) still promised one block per candidate R vector. Describe the header count and block list as the non-empty R set actually written.
prepare_exx_nscf assumed a flat directory with fixed file names, so an
SCF run with out_app_flag=2 (eig_occg{step}.txt in the output root and
wavefunctions under PSI/) could not feed the hybrid NSCF. Resolve the
latest written ionic/electronic step, preferring the fixed name so that
modes 0 and 1 keep their existing paths.
State that source files need no renaming: fixed names win, and otherwise
the latest g{step}/e{iter} snapshot is read from the output root and its
PSI/ subdirectory.
Remove the RT-TDDFT-only out_freq_td branches from every writer; in RT-TDDFT istep is already the cumulative electronic step, so the same frequency works. Keep out_freq_td as a deprecated input alias that is forwarded to out_freq_ion when the canonical key is not set, and ignore it outside RT-TDDFT.
The CSR angular-momentum writer only fills the scalar real-harmonic block, so a spinor basis would produce a silently incomplete L(R). Fail in ReadInput instead of aborting after SCF, document the reason, and keep the writer guard as a defensive check.
Move the duplicated CSR description banner to the lower ModuleIO layer so Output_HContainer and the R-space sparse writers emit byte-identical text without a source_hamilt -> source_io dependency.
The text dH/dR and r(R) writers must keep a zero block for every R counted in their shared header, but a globally empty component needs no MPI collective. Write the zero block directly on the owning rank so empty components no longer pay one allreduce per row, while output stays byte-identical.
The local istep_mat=-1 bypassed the zero-based to one-based conversion in save_mat, producing "# Ionic_Step 0" in vxc matrix headers. Use the istep parameter directly so the header prints step 1 as intended.
…at_tk The dense text body writer asserts a positive precision, but the three INPUT keywords that feed it accepted 0 or negative values and tripped the assertion during text output. Validate the precision during input parsing in prepare_input, where the error string is broadcast to every rank before aborting, and document the positive-integer requirement for each keyword. Cover the boundary with input-error cases for out_hsk/out_dmk/out_mat_tk.
ABACUS-PR-BOT
left a comment
There was a problem hiding this comment.
At cdf5bcb0, get_s output, RT-TDDFT cadence/input validation, and restart-source consistency need the corrections below and in the existing threads.
Static incremental review since d46e01e6 against fcd57f6d; no builds or runtime tests were run, and CI was not verified. The merge-tree check against f05ff9f2 reports a conflict in source/source_md/unittests/CMakeLists.txt; preserve both sets of test registrations when resolving it.
… 2026-11-05-a Resolve add/add conflict in source/source_md/unittests/CMakeLists.txt by keeping both sides' tests: upstream's migrated MD test targets (lj/snap/dp/nep/fire/verlet/nhc/msst/lgv) and the local MODULE_MD_final_step target for run_md loop predicates.
…ectory
The write_Vxc_LIP caller passes global_mat_dir, so with basis_type =
lcao_in_pw the fixed-name matrices and eband_vxc*.txt files go to the
MAT directory (OUT.${suffix}/MAT/ when out_app_flag = 2), not the root
output directory. Clarify the mode-2 behavior and give concrete file
names for Gamma-only and multi-k cases.
…test The TextAppendTwoStepsAndFirstStepTruncates test previously deleted the file before writing, so it never exercised replacing a stale record. It also only checked step headers, not the matrix values. Seed a stale frame first, then write a fresh-run step 0 (truncating) and step 1 (appending). Assert exactly two frames remain, their upper- triangle payloads match the new matrices, and no stale values survive.
With calculation=get_s and out_app_flag=2, output_SR opens a .csr file under global_matrix_dir (MAT/) before any ensure_directory call ran, so a fresh output directory made the open fail. Create the directory once before output_SR and drop the now-redundant calls in the out_mat_r and out_mat_ds branches.
read_dmk only checked nkstot and the k-point index, so a reordered or
shifted k-mesh of the same size was silently accepted; the init_chg=dm
fallback then folded the stored DM(k) with the current KPT phases and
produced a wrong density. The reader now parses header[6] (kvec_d) and
rejects the file unless the direct coordinates match the running mesh
modulo a reciprocal lattice vector (integer shifts leave e^{ik·R}
unchanged). A same-count mismatch test covers swapped, shifted and
wrapped meshes.
Rank 0 now probes the DMR CSR files and broadcasts the result to all ranks, ensuring every rank selects the same communication path (DMR distribution vs DM(k) broadcast). Previously each rank decided independently, which could deadlock when file visibility differed across ranks.
Hardcoded /tmp paths ignore the configured scratch directory, and two failed writes could previously compare as equal empty outputs. Build the paths from testing::TempDir() per rule 17 and assert both output and readback streams open before comparing contents.
Rule 5 prohibits adding default arguments to existing interfaces. Drop the default "pw" from write_input/reject_input in the input-domain test fixture and provide an explicit one-argument overload that forwards "pw", so the 24 existing PW call sites stay unchanged while the LCAO case keeps its basis explicit. Verified: OMP_NUM_THREADS=1 ./MODULE_IO_input_domain_reader, 19/19 pass.
Change the dense dH/dk filename to put the 1-based k-point index right after the prefix and use _ia for the atom index: dhk1x_ia1_nao.txt replaces dhkx_iat1_ik0_nao.txt. The _nao suffix is kept. Update the unit test and the scf_out_dh / scf_out_dh_t reference files and result.ref keys to match.
Check strtod range errors and finite components so malformed restart matrices cannot propagate infinity or NaN into the density.
The DM(k) text files produced by write_dmk carry D(i,j) = sum_n w_n conj(c_n,i) c_n,j because dm_from_psi builds DM = conj(P) (the physical one-body density matrix P with the complex conjugate on the first band index). This convention was only implicit in a consumer-side note at source/source_io/module_mulliken/output_mulliken.cpp ~L37 (added in PR deepmodeling#8250), so restart readers and external post-processing tools could silently mix conj-first and conj-last interpretations. - Emit a '#' comment line inside the 11-line header of every DM(k) file stating the exact element convention. Placing it inside the header block lets read_dmk's read_data_line skip it transparently; put it after the UnitCell block would break the matrix-body stream extractor which does not skip comment lines. - Document the same convention in write_dmk's Doxygen @details, including the relation to the physical density matrix sum_n w_n c_n,i conj(c_n,j). - Add a unit test HeaderStatesConjFirstConvention that asserts the header comment is present and that a non-symmetric complex probe round-trips through write_dmk/read_dmk without losing off-diagonal imaginary signs.
…format upgrade The hs_sparse_io writer was upgraded in c1ff9a6 ("align tr_nao.csr with the self-describing CSR layout", 2026-11-09) to emit the header block with #-comment annotation, lattice info, and CSR format banner. The commit updated two integration-test refs but did not touch get_s/sr_nao.csr.ref, which was still in the legacy "Matrix Dimension of S(R)" / "Matrix number of S(R)" format. A follow-up update at 1500cec ("Align Vxc(R) CSR output with the H(R) CSR layout") then changed the R count of the two tr_nao.csr.ref files to values that do not match the case INPUT (125 and 9 vs the actual 9 and 1, respectively). Both gaps are fixed here by running the three cases under the current writer and capturing what it emits: - get_s/sr_nao.csr.ref: legacy -> new self-describing header, R count 3 (c1ff9a6 did not update this file at all). - nscf_out_hsr_tr_rr/tr_nao.csr.ref: R count 125 -> 9 (matches c1ff9a6's correct value; 1500cec had changed it by hand). - scf_out_dh_t/tr_nao.csr.ref: R count 27 -> 1 (the case INPUT emits one R block; previous ref was R=27 from c1ff9a6, already a case/INPUT mismatch). Also remove the untracked KPT file left behind under tests/02_NAO_Gamma/ by a local run. No INPUT changes are present in this commit — the refs now reflect what the cases actually compute.
…rdinates as DM UcellIO::read_ucell used to be a void line skipper: when the per-type atom-count line in a DMK file was malformed (non-numeric, empty), the std::istringstream loop yielded total_natom == 0, so the function only consumed the "Direct" marker and left the coordinate rows on the stream. A subsequent small-matrix body read (e.g. nlocal = 2 gamma) would then happily consume those coordinate numbers and hand back a bogus density matrix. The init_chg = dm restart path trusts read_dmk's return value, so a silently wrong density would seed the next SCF. - Change UcellIO::read_ucell signature from void to bool. - Every getline now checks the stream state; the atom-count line must yield at least one non-negative integer summing to a positive total, otherwise the block is indeterminate and we bail out. - read_dmk handles the new return value: failure sets read_success, prints a diagnostic, and breaks out of the rank0 body so the existing bcast_bool cooperative-failure path propagates the error. - Add a handwritten unit test ReadDMKRejectsMalformedAtomCount that rewrites the per-type count line to a non-numeric token and asserts read_dmk returns false without touching the caller buffer. Test: DMKTest.* 24/24 pass (1 new, 23 existing no regression).
… 2026-11-05-a Conflicts resolved: - source/source_io/CMakeLists.txt: merged both sides' object lists, keeping parse_args.cpp + upstream's new parse_command_line.cpp + local libxc_r_suffix.cpp - source/source_md/unittests/test_run_md.cpp: kept upstream's consolidate (deepmodeling#8322) RunMDTest/RunMDCadenceTest suite and appended local RunMdFinalStepTest
The old description compressed scalar, spin-resolved and tensor outputs into one optional-suffix pattern, so users could not derive file names such as xc_v2rhosigma_0_00.cube. List the three channel forms explicitly and align the examples with libxc_r_channel_suffixes.
ABACUS-PR-BOT
left a comment
There was a problem hiding this comment.
The merged MD test target is missing required link dependencies. Changed DMK findings and source-level fixes are updated in the original threads. This review used static source and reference-data analysis; no builds, tests or MPI/CI checks were run.
| addtest( | ||
| TARGET MODULE_MD_final_step | ||
| SOURCES test_run_md.cpp) |
There was a problem hiding this comment.
[P1] After the merge, test_run_md.cpp also constructs cell objects and calls the non-inline Run_MD::prepare_mdcell, but this target still compiles it alone. AddTest supplies only GTest and the numerical runtime here, leaving the required ABACUS implementations unlinked. Please remove this redundant target in favor of MODULE_MD_run, or give the header-only predicate tests a separate source.
| MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); | ||
| MPI_Comm_size(MPI_COMM_WORLD, &world_size); |
There was a problem hiding this comment.
Non-blocking: please route the new rank/size, barrier and reduction calls through the project parallel helpers, and encapsulate the split/free lifecycle or document a narrow exception. The added barrier in test_hs_dense_io.cpp has the same rule-9 issue; existing MPI calls are outside this request.
| } | ||
| fk += "_nao.txt"; | ||
| const bool append_fk = (out_app_flag == 1) && (params.istep > 0); | ||
| std::string fk = kprefix + std::to_string(params.kv->ik2iktot[ik] + 1) + tag; |
There was a problem hiding this comment.
Non-blocking: please update out_mat_dh help and write_dh.h to match this filename change. The writer now produces names such as dhk1z_ia2_nao.txt, while the help still promises dhk[xyz]_iat{I} with an optional _ik suffix, so users following it will look for nonexistent files.
AsTonyshment
left a comment
There was a problem hiding this comment.
Still a few minor issues to address before merging.
| { | ||
| const std::string filename = ModuleIO::filename_output(readin_dir, "wf", "pw", iq, | ||
| source_points->ik2iktot, inp.nspin, nks, 2, false, false, -1); | ||
| const std::string filename = resolve_wfc(iq, source_points->ik2iktot, nks); |
There was a problem hiding this comment.
I think this has been pointed out by the PR bot earlier. WFC and occupation files independently select their latest snapshots, potentially mixing different ionic/electronic steps and producing an incorrect EXX operator. We should somehow ensure all source files belong to the same snapshot.
| // A per-step file (mode 2) must describe the step its name | ||
| // announces, otherwise the restart would silently mix steps. | ||
| if (out_app_flag == 2 && frame_step >= 0 && frame_step != istep + 1) |
There was a problem hiding this comment.
Mode 0 does not check consistency of Ionic_Step across k/spin files. An interrupted write can therefore mix density matrices from different steps, producing an incorrect restart density. Maybe we should validate their common step ID.
| // final step is independent of SCF convergence (an unconverged final | ||
| // step is still useful), and it is not duplicated when it happens to | ||
| // fall on the cadence because this function writes at most once. | ||
| if (istep % inp.out_freq_ion == 0 || last_ion_step) |
There was a problem hiding this comment.
I think this has also been pointed out by the PR bot earlier. In RT-TDDFT, last_ion_step remains true for every electronic substep of the final ionic step, bypassing out_freq_ion. Maybe restrict the final-frame override to the last electronic substep?
For example, with md_nstep=1, estep_per_md=5, and out_freq_ion=4, all 6 electronic steps are written instead of only steps 1, 5, and 6 (one-based).
Summary
This PR consolidates a set of IO-output naming clean-ups that have grown
inconsistent across different writers. Three coordinated changes:
1. Unify ionic-step header keyword to
Ionic_Step NOutput files written during geometry relaxations / MD previously used a
mix of header markers —
RELAX STEP N,STEP: N,IONIC STEP N,# istep:— across different writers. All text-based per-step outputsnow use the single form
# Ionic_Step N(one-based), matching theexisting STRU-frame convention and the project-wide rule recorded in
AGENTS.md.
Files updated:
source_io/module_hs/*(HS/H(R)/S(R) dense + sparse writers)source_io/module_dos/write_pdos_text.cppsource_io/module_wfc/*(WFC / band header lines)Related integration fixtures under
tests/02_NAO_Gamma/**/*.ref2. Disambiguate Libxc cube channel suffixes from real spin indices
write_libxc_r.cpppreviously tagged every cube channel with_sN,which collided with the real-spin convention used by
rho/vrho(
s1= spin-up,s2= spin-down). Tensor quantities (sigma,vsigma,v2rho2,v2rhosigma,v2sigma2,v3rho3, …v4sigma4)now carry explicit Libxc channel-index tuples (
_00,_01,_11, …)and scalar quantities (
exc,amag) drop the redundant_s1suffix.rho_s1.cube,vrho_s2.cube_sNis meaningful)exc_s1.cube,amag_s1.cubeexc.cube,amag.cubesigma_s1/s2/s3.cubesigma_00/01/11.cubev2rhosigma_s1..s6.cubev2rhosigma_00_0 / 00_1 / … .cubev3sigma3_s1..s10.cubev3sigma3_00_00_00 / … .cubeA small set of helper lambdas generates the suffix lists, so the
Libxc channel ordering stays consistent with
libxc_tools.cpp(
(00), (01), (11)for 3-channel tensors, symmetric-combination orderfor higher ranks).
3. Rename Vxc(R) sparse CSR fixture to canonical form
source_io/module_hs/vxc_op_r.cppwas writing the Vxc(R) sparse matrixas
Vxc_R_spin0.refin test fixtures. The file is now produced underthe canonical LCAO-matrix naming
vxcrs{spin}_nao.csr, aligned withhsr_writer/dsr_writerconventions. The fixture undertests/02_NAO_Gamma/scf_out_hxc/is renamed and its header assertionupdated accordingly.
Verification
make -j$(nproc): full build passes, zero errorssource/source_io/module_chgpot/write_libxc_r.cppcompiles cleanly under__LIBXCIntegration references under
tests/02_NAO_Gamma/,tests/03_NAO_multik/,and
tests/08_RI/have been updated to match the new header stringsMigration note for downstream users
Any post-processing scripts that parse the per-step header from
HS/H(R)/DOS/PDOS/WFC output files should look for
Ionic_Step Ninstead of
STEP: N,RELAX STEP N,IONIC STEP N, oristep:.Cube-filename consumers should switch from the
_sNsuffix pattern tothe new explicit index tuple for tensor quantities; real-spin files
(
rho_s1,vrho_s2) are unaffected.