Repository navigation
Conversation
Add configurable linear, Pulay, and Anderson polarization mixing with adaptive controls and diagnostics. Use a periodic mass-weighted ionic center consistently for PCC2D moments, energies, potentials, and forces, and extend relax, INPUT, and focused unit-test coverage.
Use existing Parallel_Global lifecycle wrappers in new SCCS tests, name intermediate potential/adapter arguments, and forward-declare ChargeReduction in PCC operator headers. No documentation update required: INPUT behavior and numerical formulas are unchanged. Verified an isolated GNU build and all 23 surchem CTest targets with OMP_NUM_THREADS=1.
…s-develop into sccs-pcc-port-7972
Broadcast the density residual only while SCCS awaits activation. Preserve synchronized activation, mixing-history reset, and the convergence veto for the activation iteration. Document that forces with lowpass disabled may differ from finite differences, recommend checking force accuracy for PCC geometry optimization, and regenerate the parameter documentation. Algorithms and defaults are unchanged. Verification: incremental abacus_std_para build passed; OMP_NUM_THREADS=1 python3 /tmp/test_sccs_broadcast_guard.py passed four MPI cases with mpirun -np 4 (ordinary, immediate, delayed, activation veto); ctest --test-dir /home/lyt/DFT/abacus_sccs/build_clean_20260929 --output-on-failure -R '^MODULE_HAMILT_surchem_h_corr_sccs$' passed 1/1. CLI help and documentation generation passed. git diff --check passed. Staged governance check passed with a test-evidence warning; focused runtime evidence is recorded here.
…ollectively Remove static Epcc and expose the valid energy of each solvent instance through its owning Potential. Pass that energy explicitly to ElecState::cal_energies at all production call sites, including energy-threshold and converged-potential updates. Preserve historical Ael and Acav statics. Add regressions for interleaved solvent and electronic-state instances and invalidated PCC results. Validate PCC summary readiness collectively in the computation path when SCCS/PCC debug output is enabled. Every rank takes the same failure branch; printing skips unavailable results and avoids throwing result accessors. Add a four-rank regression with an invalid result on rank zero only. This is defensive hardening, not a reproduced normal-run deadlock or performance regression. Verification (OMP_NUM_THREADS=1; toolchain/install/setup sourced; MPI outside sandbox): - cmake --build /home/lyt/DFT/abacus_sccs/build_clean_20260929 --target abacus_std_para MODULE_HAMILT_surchem_h_corr_sccs -j 12: passed after final edits. - Built MODULE_ESTATE_elecstate_energy, MODULE_ESTATE_potentials_new and MODULE_HAMILT_surchem_sol_force; focused CTest selection passed 4/4 before the printing follow-up. After the follow-up, ctest --test-dir /home/lyt/DFT/abacus_sccs/build_clean_20260929 --output-on-failure -R '^MODULE_HAMILT_surchem_h_corr_sccs$' passed 1/1. - mpirun -np 4 /home/lyt/DFT/abacus_sccs/build_clean_20260929/source/source_hamilt/module_surchem/test/MODULE_HAMILT_surchem_h_corr_sccs --gtest_filter=HCorrSccs.InvalidIterationResultIsReportedOnEveryRank: passed on every rank. - python3 /tmp/test_pcc_instance_energy.py: five four-rank SCF cases passed after final edits (ordinary, immediate SCCS, delayed SCCS, energy threshold, activation convergence veto). Immediate and delayed energies agreed within 1e-5 eV. - git diff --check: passed. - python3 tools/03_code_analysis/agent_governance_check.py --staged: no blocking findings; two warnings explained below. No INPUT behavior, default, or algorithm changes; no parameter documentation update required. The RDMFT PARAM usage is an unchanged call argument whose line was extended for the explicit PCC energy; added=1, removed=1, net change=0.
Assign the seven PW SCCS/PCC cases unique consecutive IDs 220-226. Update CASES_CPU.txt and README cross-references while preserving existing upstream cases. Verification: python3 /tmp/check_sccs_case_renumbering.py passed (42 renamed files match HEAD apart from intended README reference updates; unique case IDs; list/directory consistency; no old names in tracked files). python3 tools/03_code_analysis/agent_governance_check.py --staged reported no findings. git diff --cached --check passed. Calculations were not rerun because only directory names, list entries and README references changed; calculation inputs and references are byte-identical.
Compute grid coordinates, lattice-vector components, PCC gradients and forces, and nested geometry/moment helper results in named local variables before passing them to calls, following AGENTS.md rule 14. Preserve arithmetic grouping, including adding a and b, adding c, then scaling by 0.5 for the cell origin. Verification with OMP_NUM_THREADS=1 and toolchain/install/setup sourced: - cmake --build /home/lyt/DFT/abacus_sccs/build_clean_20260929 --target abacus_std_para MODULE_HAMILT_surchem_pw_grid MODULE_HAMILT_surchem_pcc_0d MODULE_HAMILT_surchem_pcc_2d MODULE_HAMILT_surchem_h_corr_sccs MODULE_HAMILT_surchem_sol_force -j 12: passed. Rebuilt affected production and correction/force targets after the final ionic-center helper edit; passed. - ctest --test-dir /home/lyt/DFT/abacus_sccs/build_clean_20260929 --output-on-failure -R '^(MODULE_HAMILT_surchem_pw_grid|MODULE_HAMILT_surchem_pcc_0d|MODULE_HAMILT_surchem_pcc_2d|MODULE_HAMILT_surchem_h_corr_sccs|MODULE_HAMILT_surchem_sol_force)$': 5/5 passed after final edits, outside the sandbox. - git diff --check and git diff --cached --check: passed. - python3 tools/03_code_analysis/agent_governance_check.py --staged: no blocking findings; warnings request test evidence and documentation rationale, provided here. This is a mechanical readability cleanup; existing numerical tests were rerun rather than adding tests that duplicate implementation. No INPUT behavior, algorithm or default change; no documentation update required. Runtime SCF calculations were not rerun.
Forward-declare Matrix3 in pw_grid.h and ChargeReduction in sccs_charge.h. Keep complete definitions in the implementation files and tests that require them. Include algorithm directly for std::find in read_inp_sccs.cpp and source_base/constants.h for the constants used by sccs_response.cpp. Verification: after sourcing toolchain/install/setup, OMP_NUM_THREADS=1 cmake --build /home/lyt/DFT/abacus_sccs/build_clean_20260929 -j 4 passed for all targets. The first build exposed an indirect ChargeReduction include in sccs_pw_nonel.cpp; that and dependent users were given explicit includes before the successful build. git diff --cached --check passed. The staged governance checker found no blockers; no INPUT behavior, algorithm or default changes, so no docs update is required. The complete CTest suite is scheduled to run with -j 4 after this commit, as requested by the user; test results are not claimed in this commit message.
Apply AGENTS.md rule 14 to the remaining new SCCS call sites that the PCC cleanup did not cover: cavity switching function, ionic normalization and far-field Gauss-law checks, Gaussian-ion force, surface-gradient norm, sqrt-CG residual norms, the deferred-SCCS and PCC-force buffers, and two exception messages. Each computed argument is assigned to a named local first; the arithmetic grouping is unchanged. Verification (OMP_NUM_THREADS=1, toolchain/install/setup sourced, MPI outside the sandbox): - cmake --build /home/lyt/DFT/abacus_sccs/build_clean_20260929 -j 12: passed. - ctest -R "MODULE_HAMILT_surchem|MODULE_IO_read_input_serial| MODULE_IO_input_test_para|MODULE_IO_input_help_test|MODULE_IO_read_item| MODULE_ESTATE_elecstate_energy|MODULE_ESTATE_elecstate_print| MODULE_ESTATE_potentials_new|MODULE_ESTATE_charge_mixing": 30/30 passed. - Autotest.sh -n 4 -o 1 for 01_PW '^22[0-6]_PW_SCCS' (41 checks), 02_NAO_Gamma and 03_NAO_multik scf_sccs_pcc2d (6 checks each): passed. Per-iteration E_KohnSham/E_Harris, E_sol_el, E_sol_cav, E_pcc, final energies and forces of all nine cases are bit-identical to the four-rank run at f48579d. - git diff --cached --check and agent_governance_check.py --staged: no blockers. No INPUT behavior, default or algorithm change; no documentation update is required, and the unchanged numerical results are the test evidence.
… PCC symmetry check pcc_symmetry_violation also checks the primitive-cell translations that rhog_symmetry applies when pricell_loop is set, and the antiunitary operations of magnetic groups. Add a regression for both: an in-plane supercell translation is accepted, half the open vector is rejected only with pricell_loop, and an antiunitary operation that exchanges the open vector with a periodic one is rejected while a mirror normal to it is accepted. The static pricell_loop flag is restored before the assertions. Verification (OMP_NUM_THREADS=1, toolchain/install/setup sourced): - cmake --build /home/lyt/DFT/abacus_sccs/build_clean_20260929 -j 12: passed. - MODULE_HAMILT_surchem_h_corr_sccs --gtest_filter='SurchemInput.*': 13/13 passed; the surchem/INPUT/elecstate ctest selection: 30/30 passed. - git diff --cached --check and agent_governance_check.py --staged: no blockers. Test-only change; no production code, INPUT or documentation change.
… check Finish AGENTS.md rule 14 in the two remaining PCC files: the minimum-image displacement and wrapped center of pcc_2d_system_center, and the translation and identity errors of the symmetry check, are assigned to named locals before they are passed on. The arithmetic is unchanged. Verification (OMP_NUM_THREADS=1, toolchain/install/setup sourced, MPI outside the sandbox): cmake --build of all targets passed; the surchem/INPUT/elecstate ctest selection passed 30/30; Autotest.sh -n 4 -o 1 for the seven PW SCCS/PCC cases and both NAO scf_sccs_pcc2d cases passed, with per-iteration energies, energy terms, final energies and forces bit-identical to the run at f48579d. No INPUT, default or documentation change.
… PCC code - Pcc2dGeometry defaulted to the y axis from before pcc_2d_axis existed; default it to axis 2 like the INPUT keyword, and state that the multipoles are taken about the origin with the coordinate cut half a cell away from it. Production always builds the geometry with pcc_2d_geometry(); the unit-test helper that relied on the old default now selects y explicitly. - The zero-dimensional cubic-cell error named SCCS although standalone PCC reaches it too. - evaluate_pw_sccs validated the PCC geometry right before constructing the Coulomb operators, whose constructors validate it again. - ADD_SCCS_REAL_ITEM used the full parameter description as the INPUT.info annotation, so every sccs_* line of INPUT.info carried hundreds of characters; give each item a one-line annotation like the other keywords. Verification (OMP_NUM_THREADS=1, toolchain/install/setup sourced, MPI outside the sandbox): cmake --build of all targets passed; the surchem/INPUT/elecstate ctest selection passed 30/30; abacus_std_para --generate-parameters-yaml is identical to docs/parameters.yaml (annotations are not part of it), so no documentation update is needed. No INPUT behavior or default change.
- Suites follow the file under test: SccsPcc2d -> Pcc2d, SccsPcc -> Pcc0d, SccsPwCharge -> PwGrid and SccsPeriodic -> SccsResponse. PCC and the grid helper are not SCCS code, and pw_grid replaced the old pw_charge helper. - Test names and comments from the y-only implementation now refer to the open axis or the cell boundary (AccumulatesOnlyNormalMoments, ReducesNormalMoments, L instead of L_y); the moment-reduction fragment selects its y open axis explicitly instead of relying on a default. - Drop an unused reversed-normal lattice: a reversed open vector has been accepted since the open axis became configurable. Verification (OMP_NUM_THREADS=1, toolchain/install/setup sourced): cmake --build of all targets passed; ctest -R MODULE_HAMILT_surchem passed 22/22, and --gtest_list_tests shows the new suite names. Test-only change; no production code, INPUT or documentation change.
- assume_isolated: name the point-counter-charge correction, state that the pcc_2d multipoles are taken about the mass-weighted ionic center and that the plane half a cell away must lie in vacuum, state the symmetry rules in one place (a mirror normal to the open vector may carry a fractional translation; primitive-cell translations are checked as well), move the text shared by pcc_0d and pcc_2d out of the pcc_2d bullet, list the calculation types the INPUT check allows, and cite Andreussi and Marzari (2014). - imp_sol: a charged solute needs PCC for any water preset, not only when sccs_epsilon exceeds 1; list the nspin, device, field, Makov-Payne and DFT-1/2 restrictions that check_solvation enforces; cite the SCCS paper. - pcc_2d_axis: drop the efield_dir comparison, efield is incompatible with PCC. - sccs_maxiter: drop the obsolete remark about a discrete adjoint. - sccs_start_drho: "at the start of the run" instead of "on a cold start", and note that the SCF does not stop in the activation iteration. - sccs_lowpass_p1: the continuum cavity potential uses the FFT gradient of the PCC-corrected potential, which oscillates around the potential step at the cell boundary (test SccsPcc2dSqrtCg.LayeredCavityMatchesOpenOneDimensionalField measures it); advise keeping the dielectric transition away from it. - docs/advanced/scf/advanced.md described only imp_sol 1; add a section on SCCS and the PCC open-boundary corrections. docs/parameters.yaml was regenerated with abacus_std_para --generate-parameters-yaml and input-main.md with docs/generate_input_main.py. Verification (OMP_NUM_THREADS=1, toolchain/install/setup sourced): cmake --build of all targets passed; ctest -R "MODULE_IO_read_input_serial| MODULE_IO_input_test_para|MODULE_IO_input_help_test|MODULE_IO_read_item| MODULE_HAMILT_surchem_h_corr_sccs" passed 6/6; abacus_std_para -h imp_sol and -h sccs_maxiter print the new text. Descriptions only; no INPUT behavior or default change.
…e READMEs - The two SCCS examples used a custom sccs_epsilon of 1.1, a numerical test setting rather than a solvent; use sccs_preset water-neutral and drop the keywords that repeat defaults or are overridden by the preset. - examples/27_imp_sol/README described only imp_sol 1: add the SCCS and PCC keywords, how to take the solvation energy with the same assume_isolated in both runs, and the SCCS and PCC references; rewrite the two SCCS example entries without the pre-pcc_2d_axis "(+y)" wording. - Shorten the SCCS/PCC integration-case READMEs to what each case checks. The 226 README still pointed to case 214, which is 220 after the renumbering. Verification (OMP_NUM_THREADS=1, toolchain/install/setup sourced, 8 MPI ranks): both new example INPUTs, and the same inputs with imp_sol 0, converged (#SCF IS CONVERGED#). Solvation energies: PW -0.339 eV, LCAO -0.400 eV for one water molecule per 10 x 10 bohr in-plane cell at ecutwfc 60 Ry. git grep finds no remaining old case numbers. Integration-case inputs and references are unchanged.
After the merge with develop, the cell object library contains mdcell_reader.cpp, which calls DomainDecomposition. The three surchem tests that link cell objects (sccs_gaussian_ion, h_corr_sccs, sol_force) failed to link in CI with undefined references to DomainDecomposition.
|
@Critsium-xy Thanks. The y restriction was a scope limit of the first implementation. It was not required by the numerical formulation and was not inherited from ENVIRON, which selects the axis with |
…c boundaries A charged solute in a dielectric solvent with assume_isolated none used to stop the run. The periodic Poisson solver drops the G = 0 component of the net charge, so such a calculation carries a cell-size error in an inhomogeneous dielectric, but it is well defined: the screening reduces the leading Madelung error by about 1/epsilon, and ENVIRON and VASPsol also allow it. It now runs with a warning that recommends pcc_0d or pcc_2d for converged charged energies. The imp_sol description and the SCCS section of advanced.md are updated, and docs/parameters.yaml and input-main.md are regenerated.
PW runs with pslibrary 1.0.0 USPP agree with QE-Environ: the solvation energies of H3O+ and m-nitrophenoxide differ by at most 0.08 meV. A finite-difference check on H3O+ with PCC0D and lowpass 10/5 matches the analytic solvation force to 1.1e-3 eV/A, as with norm-conserving PPs. make_parameters no longer takes use_uspp.
| gamma_only 0 | ||
| kpar 2 | ||
| nbands 8 | ||
| ecutwfc 100 |
There was a problem hiding this comment.
ecut is too large, we don't need to set this high in a integrated test, say 10 may be enough
There was a problem hiding this comment.
please keep the file smaller, we don't want to accept file that has size > 500 lines
There was a problem hiding this comment.
We don't allow creating new subdirectories undermodule_surchem . Given this, please either place all the files directly in this directory, or create a new directory at the same level asmodule_surchem .
| { | ||
| if (basis.gamma_only) | ||
| { | ||
| throw std::runtime_error("SCCS Gaussian ionic source requires the full G basis"); |
There was a problem hiding this comment.
try to use WARNING_QUIT defined in source_base
There was a problem hiding this comment.
the file is too long, try to keep it smaller than 500 lines
|
Since so many new files are added, it is almost unpractical for human to read every line of codes and propose comments. |
|
My main concern is long-term maintainability. Even if this code were merged, the maintenance burden would be considerable: the coding style and error-handling approach form a self-contained system that doesn't blend well with the existing ABACUS codebase. As a result, the chance of others reusing this code later is low, while the cost of debugging and fixing it down the road would be high. For example, basic routines such as defining geometry or charge should live in source_cell, but in the current PR all of this logic is entangled together. |
|
@mohanchen. Thanks for the suggestion. I will try to refactor these changes into several steps. |
Summary
This PR adds the self-consistent continuum solvation model (SCCS, Andreussi, Dabo & Marzari 2012) and point-counter-charge (PCC) open-boundary corrections for 0D and 2D systems to ABACUS. The implementation follows QE-Environclosely, so results can be checked against it directly.
Technical approach
sccs_rho_min,sccs_rho_max,sccs_epsilon). The water presets (water-neutral,water-cation,water-anion) are those of Environ.generalized_sqrt). The preconditioner's Coulomb operator is periodic, or periodic plus the PCC term, so a charged solute keeps its physical gauge and its screening charge. The solute charge is the electron density plus Gaussian ions (spread 0.5 bohr, as Environ).fullmode.assume_isolated pcc_0d: cubic cell, Madelung constant, origin at the mass-weighted ionic center.assume_isolated pcc_2d: slab periodic.imp_sol 0or2).sccs_solvent_mode full: Environsolvent_mode='full'.sccs_lowpass_p1/p2: Environderiv_lowpass, with the exact derivative of the discrete energy for the cavity potential.sccs_start_drho/sccs_start_nmax: delayed start of the solvent.sccs_debug: diagnostic output.imp_sol 2selects SCCS;imp_sol 1remains the legacy solvent.1. PCC: convergence with cell size
10.1103/PhysRevB.77.115139:

The test uses pyridazine (neutral) and pyridazinium (+1), LCAO APNS DZP, Gamma point, no solvent, with cubic cells of 12–30 bohr.
makov_payne.cpptakes the electronic dipole and quadrupole integrals at voxel centers, (i+0.5)/N.2. Comparison with QE-Environ's SCCS
fullmode, PW): 0.001 meV. ABACUS and QE both give −72.894 kcal/mol, against an experimental −73.4.electronicmode fails for S/Cl anions in both codes. The QE crash was "too many bands are not converged"; the reason is explained in section 3.Force check. O is displaced by ±0.01 Å. The table shows the analytic force minus the finite difference, for the solvation part only (solvent minus vacuum + PCC), in eV/Å.
full, corespread 1.53. Solvation energies: pseudopotentials and basis sets
Literature:

The test set is 34 ions (15 cations, 19 anions) from 10.1063/1.4832475. All runs use LCAO DZP, PBE, PCC0D, and the water-cation or water-anion preset.
electronicfullWhen to use
sccs_solvent_mode fullsccs_rho_max. For example, APNS gives 1.2×10⁻³ for S and 4.5×10⁻³ for Cl. The presets userho_max= 3.5×10⁻³ (cation) and 1.55×10⁻² (anion). Inelectronicmode, dielectric then appears inside the atom and the SCF diverges.electronic, 6 of the 34 ions do not converge and 1 gives an unreasonable energy.fullmode adds Environ's core-electron Gaussians to the cavity density only. With it, all 34 ions converge in both codes.fullwhen the pseudo-valence density at a nucleus falls belowsccs_rho_max.fullchanges the energy by 3×10⁻⁸ eV.Basis set: DZP to TZP
Small anions are sensitive to the LCAO basis, because the extra electron is diffuse in vacuum. For ethanethiolate, the PBE HOMO in vacuum lies at +0.2 eV.
full)The DZP error comes mostly from the vacuum reference. Its vacuum total energy is 1.9 eV above PW, against 1.6 eV above PW in solvent. TZP reduces the error from 6.9 to 1.4 kcal/mol. For anions, use TZP or PW.
When to use
sccs_lowpass_p1/p2Below is an example that applied ccqn from atst-tools to search for TS (with sccs_lowpass_p1/p2=10/5) and then obtained sp energy with tzp level basis (without sccs_lowpass and with sccs_solvent_mode=full). And we got similar results compared with the literature.
Tests and verification
source/source_hamilt/module_surchem/test/, plus INPUT and elecstate tests. The 28 relevant ctest entries pass.tests/01_PW/214–219(SCCS with PCC2D, periodic, PCC0D, charged H3O⁺, lowpass);tests/02_NAO_Gamma/scf_sccs_pcc2d;tests/03_NAO_multik/scf_sccs_pcc2d.