Skip to content

feat(librpa): strict 2D/3D Coulomb kernels and 2D reader-v1 producer outputs - #8176

Open
AroundPeking wants to merge 87 commits into
deepmodeling:developfrom
AroundPeking:abacus-librpa-strict2d-oct17
Open

AroundPeking wants to merge 87 commits into
deepmodeling:developfrom
AroundPeking:abacus-librpa-strict2d-oct17

Conversation

@AroundPeking

Copy link
Copy Markdown

Problem

  • After the module_rpa split (Title: refactor(rpa): move LibRPA producer into module_rpa #8154), develop still lacks strict-2D support: the Ewald short-range tail machinery, direct 2D mixed-Fourier / 3D reciprocal Coulomb kernels, the strict-2D head normalization, and the 2D reader-v1 producer outputs needed by LibRPA's 2D (slab) GW/RPA pipeline.
  • Two latent defects surface once this machinery runs test geometries: the Ewald tail completeness check bounds the projected Gaussian tensor by the raw gaussianized-aux radius sum instead of the RI pipeline's integral support, so rpa_scf_gamma's guard shell always fails coverage in warn mode; and Symmetry_rotation_k::wigner_d overflows int factorials for l>=5, producing NaN rotation matrices.

Change

  • module_ri: port the strict-2D/3D kernels, Ewald tail planner/checker, Gaussian 2D integrals, MPI shell-key distribution, and LRI_CV extensions (adapted to develop's p_info_ri/timer conventions); restore the empty-abfs construction branch in Exx_LRI::init_spencer; bound the tail check's Gaussian support by min(cal_V_Rcut); evaluate wigner_d factorials in double.
  • module_rpa: port the strict-2D head sidecar and direct-Coulomb output wiring into output_ewald_coulomb with v1 naming, plus the LibRPA io writers (head / structure symmetry / BZ sampling) and ABFS preorthogonalization.
  • Input parameters and Exx_Info_RI / XC functional fields for all of the above, with read_input unit tests.
  • Tests: new 61_librpa_2d_reader_v1 producer contract (including the head sidecar) with single-rank-layout references; regenerated Ewald far-field coulomb_mat references for rpa_scf_gamma / rpa_scf_shrink_multik (energies unchanged to 4e-13 eV); unit tests for the kernels, tail utilities, io writers, and symmetry rotation.

Validation

  • ctest -R "MODULE_RI|MODULE_RPA|read_input|op_exx" — 24/24 pass, including the
    direct 2D/3D Coulomb kernels, the Ewald tail planner and utilities, the Gaussian
    2D integrals, the reader-v1 io writers, and the symmetry rotation tests.
  • 08_RI integration suite (4 MPI ranks): rpa_scf_gamma and rpa_scf_shrink_multik
    pass with the regenerated Ewald far-field references; bse_lr_multik,
    rt_tddft_pbe0_gamma, and the LibRPA producer contract (cases 60/61/64, including
    the strict-2D head sidecar) pass. The hse / lr_tddft / lr_relax failures seen
    locally are LibXC-dependent cases under an ENABLE_LIBXC=OFF build; CI builds
    with LibXC enabled.

…strict-2D RI-EXX

Add the strict-2D/3D Ewald Coulomb controls (ewald dimension, lambda, tail
check mode with tolerances and adaptive expansion limits, direct
mixed-Fourier 2D and reciprocal 3D Coulomb output selection with quadrature
orders, RPA ABFS preorthogonalization, EXX V-matrix screening thresholds)
to the input parameters, wire them through the EXX reading path, and extend
Exx_Info_RI and the XC functional type so downstream RI modules can consume
them. read_input unit tests cover the new keywords.
…metry wiring

Port the strict-2D RI-EXX machinery: direct mixed-Fourier 2D and reciprocal
3D bare-Coulomb kernels, the Ewald short-range tail planner with its
completeness check, Gaussian auxiliary-basis 2D integrals, MPI shell-key
distribution, and the extended LRI_CV pipeline, adapted to develop's
p_info_ri and timer conventions. Restore the empty-abfs construction
branch in Exx_LRI::init_spencer that the signature unification dropped.
The tail completeness check now bounds the projected Gaussian tensor by
the RI integral pipeline's own support min(cal_V_Rcut) instead of the raw
gaussianized-aux radius sum, which demanded identically-zero blocks and
failed coverage in warn mode. Evaluate wigner_d factorials in double so
high-L (l>=5) rotation matrices no longer overflow int and produce NaN.
Wire the EXX LCAO operator, LR-TDDFT esolver, RDMFT, and center2orbital
paths to the extended interfaces, and add unit tests for the kernels,
tail utilities, and symmetry rotation.
…s in module_rpa

Port the master_ghj output wiring that the module_rpa split dropped: the
strict-2D Coulomb head normalization sidecar written next to the reader-v1
Ewald outputs, the direct mixed-Fourier 2D / reciprocal 3D Coulomb output
block with its reader-v1 basis export, and the LibRPA io writers (2D head,
structure symmetry, BZ sampling) plus RPA ABFS preorthogonalization, all
using develop's v1 output naming. Unit tests cover the new io writers.
…cker kinds

Add tests/08_RI/61_librpa_2d_reader_v1 exercising the strict-2D Ewald
reader-v1 producer contract including the Coulomb head sidecar, with
references generated at the producer's single-rank layout, and register it
in the LibRPA producer case list. Extend check_librpa_producer.py with the
strict_2d_head kind and its self-test. Regenerate the Ewald far-field
coulomb_mat references of rpa_scf_gamma and rpa_scf_shrink_multik for the
ported tail machinery (energies unchanged to 4e-13 eV).
…il sources

Comment the construction the ported kernels implement: the positive Gram
quadrature of the direct mixed-Fourier route (the tan-mapped kz rule and
the Massidda-constrained Gamma plane), the analytic 2D Gaussian
compensation integrals, the Ewald tail planner decision table, the
Gaussian decay exponent search, and the strict-2D head normalization.
The new sources carried essentially no comments, repeating the review
finding from the reader-v1 producer PR.

Also drop the INTERFACE OpenMP link added to the device object library
during the port: this PR's OpenMP usage lives in the module_ri targets,
and develop links the same device objects without publishing OpenMP, so
the hunk was unrelated to this PR's scope.
The new operator_exx_nscf_cell_nearest test target referenced
lcao_set_mat2d.cpp with one ../ level too many, which only surfaces
when ENABLE_LIBRI=ON (the CI test configuration), breaking CMake
generate. Two new headers used #pragma once, which the repository
governance checker rejects; use traditional include guards, matching
the guard style of the neighboring headers.
…rmat

The operator cell-nearest test target never compiled under GNU CI
toolchain before: its AddTest source list missed the translation
units providing ModuleIO::save_sparse and hamilt::transferSerial2Parallels,
and ri OBJECT-library members were duplicated on the link line.

- complete the source list (hs_sparse_io, lat_r_csr, hcontainer
  transfer sources, center2orb, orb_read, elem_basis_idx_orb,
  restart) and link the ri object library instead of re-listing
  its members
- drop tmp_mocks entries now provided by the real translation units
- write the CSR fixtures in the sparse-file format the develop
  csrFileReader parses (SR.csr-style header with lattice block)
- relax the high-L Gamma closed-form check from 2e-11 to 1e-9
  relative: the degree-14 Hermite reference agrees with the kernel
  to a constant 2.09e-11 relative on glibc, so the old bound was
  knife-edge across libms
…x restart CSR

The symmetry entry derived case metadata positionally, which broke when
the strict-2D case joined the producer list: the generic 3D meshes
tripped the nkz = 1 guard of the 2D Ewald path, and the nspin pairing
appended nupdown to an unpolarized case. Derive the mesh variants and
nspin from each case's INPUT instead, and iterate every listed case so
the nspin = 2 coverage is kept.

write_Hexxs_csr emitted the bare save_sparse layout, which
read_Hexxs_csr cannot parse back. Emit the sparse-file layout shared
with the DM(R) restart files (header, lattice block, CSR blocks per R)
and pin the contract with a read-back unit test. List ucell_io.cpp in
the two test targets that now reference UcellIO::write_ucell.
mohanchen and others added 2 commits October 20, 2026 11:08
- resolve_runtime_xc_type now takes the input functional explicitly;
  the Exx_LRI_Interface call sites pass PARAM.inp.dft_functional from
  their own scope, so module_xc no longer includes parameter.h
- align the Exx_Info_RI member declarations with the surrounding
  4-space struct indentation

@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.

Static review of acbe254 against ffc4d0d. No build or runtime tests were run; CI diagnostics were unavailable. The inline findings are source/analytic conclusions. Finite-mesh Gamma equivalence, compensation-tail error bounds, and sparse-restart/symmetry edge cases remain unresolved; this is not full numerical acceptance.

Comment thread source/source_lcao/module_ri/exx_lri.h Resolved
Comment thread source/source_lcao/module_ri/exx_lri.h Resolved
Comment thread source/source_lcao/module_rpa/rpa_lri.h Resolved
…, and review fixes

- Extend Parallel_Reduce/Parallel_Common with sub-communicator overloads
  (reduce_all/max/min, reduce_max_loc, gather_int_all, bcast from an
  arbitrary root, my_rank/nproc/barrier) plus MPI_Type<unsigned long long>,
  and route the new tail reductions, direct-output drivers, eigenvector
  guards and raw-overlap writer through them instead of raw MPI calls.
- Remove the unused symmetry_rotation_/use_spacegroup_symmetry_ members of
  RPA_LRI together with the now-unneeded symmetry-header dependency.
- Construct the cut/full-coulomb Exx_LRI helpers with an explicit
  ExxLriRuntime at the remaining callers and drop the factory-delegating
  single-argument constructor.
- Rename abf_rotation_test.cpp and nspin4_restore_test.cpp to the
  test_<module_name>.cpp convention and update the CMake entries.
- Complete the INPUT metadata of the new registrations: strict-2D slab,
  k-mesh and force restrictions; tail-mode warn abort conditions on
  incomplete coverage or a failed Hermitian check; direct quadrature
  convergence notes; missing guard-shell tolerance descriptions.
- Fix the dangling default argument on cal_ewald_coulomb, un-nest the
  ExxLriDetail void_t block that shadowed the enclosing namespace, and
  qualify RpaAbfsPreorthReport at the production call site in rpa_lri.cpp.
…d close gamma-dipole test link

Removing the factory-delegating single-argument Exx_LRI constructor
missed three call sites, so every ENABLE_LIBRI configuration failed to
compile: the LR workspace in exx_workspace.cpp and both esolver_lr_init
constructions. The workspace now copies the owning solver's runtime, and
the esolver sites call make_exx_lri_runtime() like the interface, RDMFT
and RPA paths.

The new gamma-dipole unit test linked cell without the libraries its
members depend on; add neighbor_search, domain_decomposition and
neighbor so the mdcell_reader, record_adj and domain_decomposition
symbols resolve.
@mohanchen

mohanchen commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

If you have fixed specific issues, please reply to each comment. @AroundPeking

@AroundPeking

Copy link
Copy Markdown
Author

Thanks for the detailed review. All inline comments have been addressed and replied to individually:

  • The LibRI C++14 compatibility (void_t), the reader-v1 output path, the preorthogonalization wiring, the z-image removal in the strict-2D real-space sum, the dual-lattice Massidda bound, the scaled-erfc evaluation, the direct-3D Carrier q-mesh population, the removed interface defaults, the test renames, and the MPI wrapper routing all landed in de29636.
  • The deterministic Eexx initializer, the explicit ExxLriRuntime construction sites, and the gamma-dipole test link closure landed in d691c13.
  • The INPUT registration metadata (strict-2D slab/k-mesh/force restrictions, tail-mode warn abort conditions, direct-quadrature convergence notes) is complete; docs/parameters.yaml and input-main.md regenerate through the CI documentation pipeline after merge.

CI is green on d691c13 (16/16 checks).

AroundPeking and others added 2 commits October 21, 2026 10:00
…rict2d-oct17

# Conflicts:
#	source/source_lcao/module_operator_lcao/test/CMakeLists.txt
#	source/source_lcao/module_ri/CMakeLists.txt
#	source/source_lcao/module_ri/module_exx_symmetry/test/CMakeLists.txt
#	source/source_lcao/module_rpa/CMakeLists.txt
#	source/source_lcao/module_rpa/module_librpa_io/unittests/CMakeLists.txt
#	source/source_lcao/module_rpa/unittests/CMakeLists.txt
…rict2d-oct17

# Conflicts:
#	source/source_io/test/CMakeLists.txt
#	source/source_lcao/module_operator_lcao/test/CMakeLists.txt
#	source/source_lcao/module_ri/unittests/CMakeLists.txt
…tools

validation_tools only compares produced files against stored references.
The 2D producer contract is exercised end-to-end by
tests/08_RI/61_librpa_2d_reader_v1 (manifest-driven comparison against
producer_reference) and by the module_librpa_io unit tests, so the
mock-data unit test file is removed from this folder.
The merge resolution took the upstream version of source_io/test/CMakeLists.txt
wholesale, which dropped the ucell_io.cpp entry that the Hexx restart
round-trip test needs for ModuleIO::UcellIO::write_ucell.
@mohanchen mohanchen added Features Needed The features are indeed needed, and developers should have sophisticated knowledge Refactor Refactor ABACUS codes labels Oct 23, 2026

@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.

Incremental static review of 84d0923 against 370ba68. Source inspection confirms the earlier numerical fixes and most cleanup; residual source-rule items and bounded follow-ups are tracked in their existing threads. The new inline comments cover test repeatability and declaration style. No build, ABACUS/CTest run, or documentation generation was performed; CI diagnostics were unavailable. Earlier finite-mesh Gamma, compensation-tail and sparse-restart/symmetry verification limits remain open.

Comment thread source/source_base/parallel_reduce.cpp Resolved
…iene

- Route the remaining sub-communicator collectives in exx_lri.hpp and the
  raw-overlap writer through Parallel_Common/Parallel_Reduce, adding a
  gatherv_int_all wrapper, and split the reduce_max_loc locals.
- Drop the default threshold on read_Cs_ao_all and pass 0.0 explicitly at
  the LR/BSE call sites.
- Make the direct-output test own a mkdtemp directory with RAII cleanup so
  repeated CTest runs stay independent, and add erfcx-crossover and
  large-separation regressions for the scaled-erfc helpers.
- State the active-only scope of rpa_abfs_preorth under shrink in the INPUT
  description and cover it in the preorth unit test.
- Relocate the producer-checker rejection cases out of validation_tools into
  tests/integrate/producer_contract and register them with CTest.
Link errors first: MODULE_LCAO_op_exx_nscf_nearest_test compiles
op_exx_lcao.cpp, whose contributeHR calls XC_Functional (three symbols) and
TD_info::initialize_phase_hybrid. Neither lives in the libraries this
target lists, so the link failed. Compile xc_functional.cpp and
module_rt/td_info.cpp into the target, the same way module_lr's tests pull
in xc_functional.cpp.

MODULE_IO_read_item_serial lost its serial configuration when it moved out
of test_serial/: that directory disabled __MPI for everything in it, while
unittests/ does not. The test therefore saw __MPI while io_input_serial was
still compiled without it, and Item_test2 reached the serial ScaLAPACK
validator outside EXPECT_EXIT. AddTest only had KEEP_FEATURE_DEFINITIONS, so
add the symmetric DROP_FEATURE_DEFINITIONS: the target drops __MPI and
matches the library it exercises. Sibling targets keep __MPI.

Review findings:

- P1 unfolded RI setup: set_Vs was skipped for unfold_hybrid_images and
  Cs was registered before the image period was chosen, so a td_stype=2
  hybrid run installed neither map. Move the period selection ahead of the
  Cs registration and install Vs inside it, as the base does.
- cal_dCV was computed but unused: derivative construction and
  registration now use it, so an unfolded run with cal_force no longer
  builds and stores dV/dC tensors nobody consumes.

@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.

In 57a04ec8, unfolded RI tensor registration and the derivative bypass are repaired in source. The NSCF test link and MPI-disabled INPUT-test registration still need corrections, detailed in the existing threads. Static incremental review only: no configure, build, tests or numerical runs were performed; CI diagnostics were unavailable.

MODULE_LCAO_op_exx_nscf_nearest_test linked the whole `ri` object library.
That was harmless while Exx_LRI_Interface was header-only, but develop moved
its implementation into exx_lri_interface.cpp, so the library now also
carries that translation unit. Linking it dragged in
ElecState::set_exx, Symmetry_rotation_k::restore_dm and the interface's own
members, none of which this focused fixture links.

Drop `ri` from LIBS and compile ri_2d_comm.cpp directly: op_exx_lcao.cpp
only needs add_HexxR and dm_container_to_Ds from module_ri, and both live in
that file. The fixture keeps its existing coverage of the Hexx restart
round trip without inheriting the rest of the RI stack.
Two follow-ups from review:

- F14: compiling xc_functional.cpp and td_info.cpp into this fixture
  duplicated symbols test_tmp_mocks.cpp already defines
  (XC_Functional::func_type, XC_Functional::set_xc_type, TD_info::endpoint_A)
  and pulled in Position_op / TDFieldManager / LibXC setup helpers. Extend
  the mock set instead: add set_xc_first_loop, both
  resolve_runtime_xc_type overloads, and a no-op
  TD_info::initialize_phase_hybrid for double and complex double.
- F16: MODULE_IO_read_item_serial sat after the `if(NOT ENABLE_MPI) return()`
  in the unittests directory, so an MPI-disabled build registered no
  INPUT-item suite at all. Register it before the guard; io_input_serial
  comes from test_serial/, which is added unconditionally.

Verified both configurations: with ENABLE_MPI=OFF the target is registered;
with ENABLE_MPI=ON it drops __MPI while sibling targets keep it.

@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.

c5d0d862 repairs the serial INPUT-item test registration in source. The NSCF test still lacks EXX interface providers, detailed in its existing thread.

Static review of the three-file increment and affected callers only: no configure, build or tests were run; current-head CI results were not verified.

…ule_ri

Dropping `ri` from this fixture's LIBS fixed the stale symbols but exposed
the next layer: op_exx_lcao.cpp also calls
Exx_LRI_Interface<TK,TD>::cal_exx_elec and cal_exx_ions from
contributeHR. Those live in module_ri's exx_lri_interface.cpp, which itself
needs elecstate and module_exx_symmetry — the two libraries this focused
fixture deliberately avoids.

Provide the eight instantiations the fixture references as no-ops in
test_tmp_mocks.cpp. The fixture compiles the OperatorEXX members but never
enters contributeHR, so the stubs only satisfy the linker. Verified by
comparing `nm -u` on op_exx_lcao.o against the definitions in the mocks
object: the required set is fully covered.

@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.

6ba5dfed supplies the previously missing EXX interface methods. The shared mock additions need an EXX guard for LibRI-disabled test configurations; see the inline comment.

Static review of the two-file increment and affected consumers only. No configure, build or tests were run, and current-head CI results were not verified.

AroundPeking and others added 6 commits November 15, 2026 22:13
test_tmp_mocks.cpp is compiled by the operator, DFTU and LR fixtures as well
as the EXX one, and most of those build with ENABLE_LIBRI=OFF. The
Exx_LRI_Interface include added for the EXX fixture reaches
<RI/global/Tensor.h>, which only exists when LibRI is enabled — without the
option those builds fail with "RI/global/Tensor.h file not found".

Wrap the include, the ExxDMap alias and every new specialization in
#ifdef __EXX. __EXX tracks ENABLE_LIBRI, so the other fixtures skip the
block, and they never compile op_exx_lcao.cpp anyway, so they need none of
these stubs.

Verified both ways: with ENABLE_LIBRI=ON all 14 copies compile and the EXX
fixture keeps its stubs; with ENABLE_LIBRI=OFF all 13 copies compile, and
removing the guard reproduces the missing-header failure.
… abacus-librpa-strict2d-oct17

Two conflicts.

parallel_common.h: this branch added communicator-aware bcast/rank/size/
barrier helpers as group (3), develop added bcast_bool on an explicit
communicator as its own group (3) ahead of bcast_mpi_offset. Keep this
branch's group (3) and move develop's two declarations into group (4).

source_io/test_serial/CMakeLists.txt: develop reached the same conclusion
this branch did about MODULE_IO_read_item_serial, but kept the target in
test_serial/ (which disables __MPI for the whole directory) while pointing
at sources in unittests/. That is strictly better than the
DROP_FEATURE_DEFINITIONS __MPI this branch had added in unittests/: the
directory already disables MPI, and the target registers even without MPI.
Adopt develop's registration and drop this branch's copy.

test_read_inp_sccs.cpp also lives in unittests/ here, so its path in the
adopted registration becomes ../unittests/test_read_inp_sccs.cpp.

@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.

The direct-3D output needs safe rejection of momenta beyond its radial tables; the strict-2D sidecar also lacks a running-log confirmation. Both findings concern existing PR code, unchanged by this merge.

Static source review only; no build, test, numerical or MPI run was performed. The OpenMP trigger is source-derived, and the full scientific implementation was not re-derived.

AroundPeking and others added 13 commits November 21, 2026 21:15
… ranges

Two review points.

- The 2D Coulomb head sidecar was announced on stdout only. The repository
  file-output convention also wants the confirmation in the running log, so
  write it to both streams.
- build_coulomb_matrix called fourier_coefficients inside an OpenMP parallel
  for. That call reaches interpolate_radial, which throws when a momentum
  falls outside the auxiliary radial table; that table is sized from
  lcao_ecut / lcao_dk, so raising out_v3d_ecut can push a retained momentum
  past it. An exception cannot propagate safely out of the parallel region.
  Hoist the range check into validate_radial_range and run it over every
  regular point before the loop, so the failure surfaces on the caller's
  thread with the same message.
taesc-prep now derives the structure file from the run directory: STRU or
OUT.<suffix>/STRU_FINAL, KPT.info for the mesh, and OUT.<suffix>/symrot_R.txt
for the spatial operations. Verified against the nspin=2 and SOC producer
cases: the reconstructed geometry matches the removed stru_out.txt to 3e-10
(formatting aside), and a unit-shift-free comparison of every lattice and
position value agrees.

So this commit stops writing stru_out.txt. That also removes the reason for
the stru_out-only writers, which are deleted: out_struc and its
write_librpa_symmetry_block helper, librpa_stru_units, and rpa_lri_sym.cpp
along with their unit tests.

SOC needed one export addition. The spin_symmetry block that LibRPA reads
encodes the SU(2) representative of every operation, and for magnetic
nspin=4 runs it also carries the antiunitary elements Theta*g, which ABACUS
held only in memory. symrot_R.txt now appends

    Antiunitary operations: N
    <index> <rotation 3x3> <translation>

after the unitary block, so a reader can rebuild the full spinor set. The
trailer is only written when magnetic nspin=4 symmetry is active; existing
exports are unchanged byte for byte.

Every file the producer writes now carries the librpa_ prefix
(librpa_band_out.txt, librpa_bz_sample.txt, librpa_KS_wfc_0.dat,
librpa_velocity_matrix.txt, librpa_Cs*_*.dat, librpa_V_cut_*.dat,
librpa_V_full_*.dat, librpa_sinvS_*.dat, librpa_aux_basis*.txt,
librpa_basis_map.txt, librpa_wfc_basis.txt, librpa_KS_eigenvector.txt,
librpa_2d_coulomb_head.txt), so users can separate the LibRPA inputs from the
rest of OUT.*. Names are built through RpaLriDetail::librpa_output_path.

Tests: producer references and manifests follow the new names, the
integration validator reads symrot_R.txt instead of the removed file, and the
INPUT annotation documents both changes.
08_RI_librpa_producer_mpi still looked for Cs_1.dat, V_full_*_r1.dat and
bz_sample.txt after the producer started writing librpa_-prefixed names, so
the rank-1 output assertion failed and the file-open failure injection
created the wrong directory. The single-rank contract test needed the same
rename.

This is the last of the renaming: every producer name in tests/ now carries
the prefix (verified by a tree-wide grep for the old names).
Nothing declares kind "stru" any more, so the checker and its branch were
dead. Removing them keeps the contract vocabulary aligned with what the
producer actually writes.
… symrot format

Two CI failures, both from names I missed.

Legacy readers still looked up unprefixed names. The v0 route passes its
file prefix as an argument to out_Cs / out_coulomb_k / out_abfs_overlap
rather than building the path at the call site, so those were untouched by
the earlier rename. Prefix them too and follow through to the two
regression cases that compare those files: their reference files, their
result.ref keys and props_ml.sh's glob.

The symmetry validator assumed symrot_R.txt printed rotations as bare
integers. ABACUS writes them with std::to_string, so an integer arrives as
"-1.000000"; parse them as doubles and round with a tolerance, matching what
taesc-prep already does.
08_RI_librpa_symmetry failed on a (1,1,3) mesh with

    Operation 6 does not preserve the BvK mesh: [1, 0, -1, 1, 0, 0, 1, -1, 0]

That operation genuinely maps the mesh onto itself only for cubic meshes, so
it is not a defect. The difference is in the two files: the retired
stru_out.txt kept only the operations whose reciprocal matrix satisfies
kg[j][i] * nmp[i] / nmp[j] integral, while symrot_R.txt exports the cell's
full point group. The validator has to apply that filter before asserting, or
every non-cubic mesh looks broken.

Filter both blocks and assert on what survives, keeping the explicit
antiunitary requirement as a separate check.
08_RI_librpa_symmetry failed with

    AssertionError: symmetry=1 run did not export symrot_R.txt

and it is a regression this series introduced rather than a test defect.
The retired stru_out.txt took its operations from ucell.symm and was written
for every nspin. symrot_R.txt is written inside the exx_spacegroup_symmetry
branch, whose condition is

    nspin < 4 && ModuleSymmetry::Symmetry::symm_flag == 1

so a non-collinear cell never produced it. taesc-prep reads symrot_R.txt, so
SOC lost its symmetry export entirely.

The collinear writer also emits the orbital rotation matrices T, which only
exist after Symmetry_rotation::cal_Ms runs — the same branch that nspin=4
skips. A spinor exchange needs only the spatial parts, so add
print_symrot_info_R_spatial: same header, same operation and antiunitary
blocks, an explicit "Spatial-only export" marker where the T rows would be,
and no T rows. Call it from the non-collinear branch of cal_postSCF_exx.
read_symrot_operations needs the same adjustment as taesc-prep: an nspin=4
export writes no orbital rotation rows, so the stride skips 5 lines per
operation instead of 5 + (max_lmax + 1)^2.
… abacus-librpa-strict2d-oct17

Two conflicts, both from develop's esolver formatting pass.

esolver_lr_init.cpp: develop reflowed the call and dropped this branch's
make_exx_lri_runtime() argument, which the Exx_LRI constructor requires.
Keep the argument, take develop's spacing.

esolver_lr_lcao_bse.cpp: the two sides differ only in indentation and in
passing an explicit 0.0 threshold to read_Cs_ao_all. That threshold has a
default in lri_cv_tools.h, so take develop's form.
… abacus-librpa-strict2d-oct17

Two conflicts, both from develop's esolver formatting pass.

esolver_lr_init.cpp: develop reflowed the call and dropped this branch's
make_exx_lri_runtime() argument, which the Exx_LRI constructor requires.
Keep the argument, take develop's spacing.

esolver_lr_lcao_bse.cpp: the two sides differ only in indentation and in
passing an explicit 0.0 threshold to read_Cs_ao_all. That threshold has a
default in lri_cv_tools.h, so take develop's form.
…shold

Three required checks failed on the same line:

    esolver_lr_lcao_bse.cpp:563: error: too few arguments to function
    'LRI_CV_Tools::read_Cs_ao_all(const string&, const double&)'

This branch removed the forward declaration from lri_cv_tools.h when the
definition moved into write_ri_cv.hpp, and the BSE caller relies on the
default threshold that declaration carried. develop keeps the declaration
with `threshold = 1e-10`, so restore it there; the definition still takes
both parameters without repeating the default.

@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.

The direct-Coulomb filenames and SOC symmetry output failure handling still need correction. The radial-range failure is addressed in source; its requested regression remains outstanding.

Static review at c77e95c5 against c46ae1ed. Governance returned warnings without blockers; git diff --check reports the unchanged EOF blank in tests/08_RI/61_librpa_2d_reader_v1/producer_reference/KPT.info. No builds or product tests were run, and runtime/CI results remain unverified.

Three review rounds' worth of findings, plus one regression the rename
introduced.

The rename broke the LR/BSE readers. They scan their input directory with
readdir and match names by prefix ("coulomb_cut_", "coulomb_unshrinked_cut_",
"Cs_data_", "KS_eigenvector"), so every one of them stopped finding the
producer's files. Accept both spellings: detect whether the directory uses
the librpa_ prefix and pick the matching one.

Review findings:

- [P2] print_symrot_info_R_spatial returned silently on an open or write
  failure. After out_struc was removed, postSCF could then finish without
  usable symmetry data. Check the open and the post-close state, throw a
  path-bearing std::runtime_error, route it through the existing
  abort_output handler, and announce the written path in the running log
  (rule 16).
- Non-blocking: rule 14 asks for named locals instead of computed arguments.
  Hoist the ABF Lmax and the four nested librpa_output_path calls.

Also document the conversion contract in the producer README: the taesc-prep
revision, the command, and the fact that a converted directory must carry
the geometry, units, translations and SOC metadata the readers expect.

@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.

Two reader paths still mishandle directories containing both old and prefixed exports. The documented converter also retains some symmetry operations that do not preserve a shifted k-point mesh.

Scope: static review of the nine-file increment at cd0af6f, its affected callers, and taesc-prep source at 059c009087885a60f13f01c5ec13d57ca08b61c1. No build, product test, MPI run, or downstream LibRPA execution was performed.

const std::string prefix
= has_unshrinked ? (has_librpa_prefix ? "librpa_coulomb_unshrinked_cut_"
: "coulomb_unshrinked_cut_")
: (has_librpa_prefix ? "librpa_coulomb_cut_" : "coulomb_cut_");

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.

[P2] Select a Coulomb prefix that exists

With coulomb_unshrinked_cut_* and librpa_coulomb_cut_* in the same directory, these flags select librpa_coulomb_unshrinked_cut_* even when no such files exist. Both Coulomb readers then skip the available data and leave Vq empty. Select among complete prefixes actually found, or reject this mixed input clearly, and cover the combination in both reader tests.

while ((ptr = readdir(dir)) != NULL){// read all the files in the directory
std::string fm(ptr->d_name);
if (fm.find("KS_eigenvector") == 0)// find file KS_eigenvectorXXX
if (fm.find("KS_eigenvector") == 0 || fm.find("librpa_KS_eigenvector") == 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.

[P2] Avoid merging old and prefixed input sets

A directory containing old and prefixed eigenvectors for the same k-point is now read twice, tripping the duplicate-k assertion or overwriting values in a build without assertions. read_Cs_ao_all() likewise merges both naming families and silently overwrites duplicate tensor keys in directory order. Choose one coherent input family or reject the ambiguity, and test mixed files with distinguishable contents.


Requires taesc-prep `master` at or after the spatial-only symmetry-export
support (AESM-Group/taesc-prep#3), which is what makes `nspin 4` exports
readable. The command writes `stru_out.txt` and `bz_sample.txt` next to the

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.

[P2] Bound the converter's shifted-grid symmetry support

At taesc-prep 059c0090, _sampled_mesh() retains only mesh dimensions and both symmetry filters use zero offset. ABACUS exports the original crystal operations: for a nonmagnetic centrosymmetric cell on a Gamma grid with N_x=2 and x offset 0.25, inversion survives that filter even though it maps {1/8, 5/8} outside the sampled x points. Require a converter that filters against the actual full-grid points, or document and reject this unsupported case.

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

Features Needed The features are indeed needed, and developers should have sophisticated knowledge Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants