Skip to content

Use mctc-lib Wigner-Seitz cell and cutoff-based EEQBC lattice sums - #75

Merged
awvwgk merged 2 commits into
grimme-lab:mainfrom
timchem1508:periodic_fix
Oct 26, 2026
Merged

awvwgk merged 2 commits into
grimme-lab:mainfrom
timchem1508:periodic_fix

Conversation

@timchem1508

Copy link
Copy Markdown
Contributor

Summary

EEQBC's periodic sums used a fixed ±2 cells of lattice translations, so results depended on the cell size: an n-fold supercell did not give n times the unit-cell energy. Small cells were affected most. This PR builds the EEQBC translations from the 25 bohr CN cutoff instead, and switches to the Wigner-Seitz cell from mctc-lib. The EEQ posseses the same problem, but not adressed here.

Changes

  • Replace multicharge_wignerseitz with mctc_wignerseitz from mctc-lib 0.7.0 and remove src/multicharge/wignerseitz.f90.
  • get_dir_trans now takes the structure and an optional cutoff.
  • Update the EEQ formamide energy reference.
  • Ignore subprojects/.wraplock.

Testing

  • Supercell scaling: n×1×1 supercells along each lattice vector (n up to 8), comparing E(n)/n with E(1) and the supercell charges with the tiled unit-cell charges. Worst case per unit cell:
System [2, 2, 2] translations Cutoff-based translations
ZnOH⁺ compact skew cell 1.2e-1 Eh 1.0e-8 Eh
NaCl, primitive cell 2.6e-2 Eh 4.4e-10 Eh
h-BN monolayer (slab, in-plane) 8.0e-3 Eh 9.1e-13 Eh
NaCl(001) bilayer (slab, in-plane) 2.6e-3 Eh 3.4e-10 Eh

Charge deviations follow the same pattern.

- Replace the local multicharge_wignerseitz module with mctc_wignerseitz
  from mctc-lib 0.7.0.
- get_dir_trans now takes the structure and an optional real-space
  cutoff. EEQBC builds its direct lattice translations from the CN
  cutoff instead of a fixed +/-2 cells, so the energy and charges of an
  n-fold supercell now match n unit cells. For small cells the error per
  cell drops from up to 0.12 Eh to below 1e-8 Eh. EEQ keeps the fixed
  +/-2 cells for its Ewald direct sum.
- Update the EEQ formamide energy reference.
- Ignore subprojects/.wraplock.
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 30.68%. Comparing base (282626e) to head (5c2011b).
⚠️ Report is 29 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #75       +/-   ##
===========================================
- Coverage   51.57%   30.68%   -20.90%     
===========================================
  Files          18        2       -16     
  Lines        1648      176     -1472     
  Branches      746       72      -674     
===========================================
- Hits          850       54      -796     
+ Misses        390       85      -305     
+ Partials      408       37      -371     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@awvwgk
awvwgk merged commit 3414b5f into grimme-lab:main Oct 26, 2026
9 of 10 checks passed
timchem1508 added a commit to timchem1508/multicharge that referenced this pull request Oct 27, 2026
…main

Main v0.6.0 brings the analytical charge Hessian (grimme-lab#71) and the mctc-lib
Wigner-Seitz cell (grimme-lab#75), both written against the dense solve and
cache_container API that this branch replaced. Port them onto the solver
architecture:

- get_charges(..., dqdL, cache, efield) retains the response in
  mchrg_cache (new dqdr field); add_charge_hessian reuses
  get_coulomb_derivs with the adjoint in place of the charges
- add_model_hessian for EEQ and EEQ-BC on the branch cache layout
  (element-indexed rvdw, EEQ-BC lattice cutoff)
- exact derivative of the regularised EEQ CN term in get_xvec_derivs
  and get_grad, as on main
- use new_wignerseitz_cell from mctc-lib and drop multicharge_wignerseitz;
  drop the CSR-list arguments of local_charge that mctc-lib lacks
- pin mctc-lib v0.7.0 and restore main's fpm.toml (mstore v0.4.0,
  fortitude configuration)
- add main's eeqbc-response-znoh tests and the updated formamide
  reference; use the EEQ-BC tolerance of test_dadr also in test_dadL

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants