Skip to content

Add Hirshfeld partitioning to weights generation#209

Open
awvwgk wants to merge 1 commit into
wavefunction91:masterfrom
awvwgk:hirshfeld
Open

Add Hirshfeld partitioning to weights generation#209
awvwgk wants to merge 1 commit into
wavefunction91:masterfrom
awvwgk:hirshfeld

Conversation

@awvwgk
Copy link
Copy Markdown
Collaborator

@awvwgk awvwgk commented May 27, 2026

Add XCWeightAlg::Hirshfeld as a host molecular-weight partitioning scheme for host (OMP/MPI).

$$ w_A(r) = \rho_A^0(|r - R_A|) / \sum_B \rho_B^0(|r - R_B|) $$

Use a Gaussian shape-function where each atom contributes a normalized Gaussian shape and the normalization function is the sum of reference charges multiplied with the shape.

$$ \rho_A^0(r) = Z_A (\alpha_A / \pi)^{3/2} \exp(-\alpha_A |r - R_A|^2) \qquad\text{with}\quad \alpha_A = 0.5 / r_A^2 $$

Timings for some toy systems:

Threads Atoms Points/atom Becke SSF LKO Hirshfeld
1 12 256 361 314 463 84.8
1 64 128 10292 8340 6304 434
1 128 64 42538 25932 11930 878
1 256 32 177689 87608 20427 1888
4 12 256 89.8 76.4 121 22.2
4 64 128 2580 2610 1611 112
4 128 64 10677 8285 3021 223
4 256 32 45250 29550 5169 489

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new molecular partitioning scheme (XCWeightAlg::Hirshfeld) to GauXC’s host weight generation pipeline (Reference/Default host LWD), including analytical first-derivative support and C-API exposure, with new/updated tests to validate correctness and enum correspondence.

Changes:

  • Introduce XCWeightAlg::Hirshfeld in both C++ and C enums and wire it through the host reference local work driver.
  • Implement Hirshfeld partition weights and first-derivative (direct + contracted) reference routines on host.
  • Extend unit tests and C-API tests to cover Hirshfeld weight generation and factory usage.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/weights.cxx Adds Hirshfeld reference-data generation hook and new unit tests validating Hirshfeld invariants (normalization, translation, permutation).
tests/weights_host.hpp Extends host weight test switch to call the Hirshfeld reference implementation.
tests/weights_generate.hpp Extends reference-data generator to support Hirshfeld.
tests/weight_derivative_test.cxx Adds Hirshfeld to analytical derivative test dispatch and adds fdiff sections for it.
tests/c_api_test.cxx Verifies C/C++ enum correspondence for Hirshfeld; adds factory creation and modify-weights coverage for Hirshfeld in C-API.
src/xc_integrator/local_work_driver/host/reference/weights.hpp Declares Hirshfeld host reference routines (weights + derivatives + contraction).
src/xc_integrator/local_work_driver/host/reference/weights.cxx Implements Hirshfeld weights and derivative routines on host.
src/xc_integrator/local_work_driver/host/reference_local_host_work_driver.cxx Wires Hirshfeld into host “Reference/Default” local work driver switches.
include/gauxc/enums.hpp Adds XCWeightAlg::Hirshfeld to the public C++ enum.
include/gauxc/c/enums.h Adds GauXC_XCWeightAlg_Hirshfeld to the public C enum.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +404 to +408
struct hirshfeld_atom_data {
double x;
double y;
double z;
double alpha;
Comment on lines +768 to +774
struct hirshfeld_atom_data {
double x;
double y;
double z;
double alpha;
double scale;
};
Comment on lines +1146 to +1152
struct hirshfeld_atom_data {
double x;
double y;
double z;
double alpha;
double scale;
};
Comment thread tests/c_api_test.cxx
== static_cast<int>(GauXC_XCWeightAlg_SSF));
CHECK(static_cast<int>(XCWeightAlg::LKO)
== static_cast<int>(GauXC_XCWeightAlg_LKO));
CHECK(static_cast<int>(XCWeightAlg::Hirshfeld)
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