occpy 0.7.5__cp312-abi3-macosx_11_0_arm64.whl → 0.7.7__cp312-abi3-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bin/occ CHANGED
Binary file
@@ -0,0 +1,12 @@
1
+ #pragma once
2
+ #include <occ/core/linear_algebra.h>
3
+ #include <occ/dma/mult.h>
4
+
5
+ namespace occ::dma {
6
+ void addqlm(int l, int lmax, double f, Eigen::Ref<const Vec> gx,
7
+ Eigen::Ref<const Vec> gy, Eigen::Ref<const Vec> gz, Mult &out);
8
+
9
+ void addql0(int l, double f, Eigen::Ref<const Vec> gx, Eigen::Ref<const Vec> gy,
10
+ Eigen::Ref<const Vec> gz, Mult &out);
11
+
12
+ } // namespace occ::dma
@@ -0,0 +1,51 @@
1
+ #pragma once
2
+ #include <occ/core/linear_algebra.h>
3
+
4
+ namespace occ::dma {
5
+
6
+ /**
7
+ * @brief Class to compute and store binomial coefficients
8
+ */
9
+ class BinomialCoefficients {
10
+ public:
11
+ /**
12
+ * @brief Constructor
13
+ * @param max_order Maximum order of binomial coefficients to compute
14
+ */
15
+ BinomialCoefficients(int max_order = 20);
16
+
17
+ /**
18
+ * @brief Get binomial coefficient (n choose k)
19
+ * @param k First parameter
20
+ * @param m Second parameter
21
+ * @return Binomial coefficient
22
+ */
23
+ double binomial(int k, int m) const;
24
+
25
+ /**
26
+ * @brief Get square root of binomial coefficient
27
+ * @param k First parameter
28
+ * @param m Second parameter
29
+ * @return Square root of binomial coefficient
30
+ */
31
+ double sqrt_binomial(int k, int m) const;
32
+
33
+ /**
34
+ * @brief Get matrix of all binomial coefficients
35
+ * @return Reference to matrix of binomial coefficients
36
+ */
37
+ const Mat &binomial_matrix() const;
38
+
39
+ /**
40
+ * @brief Get matrix of all square roots of binomial coefficients
41
+ * @return Reference to matrix of square roots of binomial coefficients
42
+ */
43
+ const Mat &sqrt_binomial_matrix() const;
44
+
45
+ private:
46
+ int m_max_order{20};
47
+ Mat m_binomial;
48
+ Mat m_sqrt_binomial;
49
+ };
50
+
51
+ } // namespace occ::dma
include/occ/dma/dma.h ADDED
@@ -0,0 +1,57 @@
1
+ #pragma once
2
+ #include <occ/core/atom.h>
3
+ #include <occ/core/linear_algebra.h>
4
+ #include <occ/core/molecule.h>
5
+ #include <occ/core/timings.h>
6
+ #include <occ/dma/mult.h>
7
+ #include <occ/qm/integral_engine.h>
8
+ #include <occ/qm/wavefunction.h>
9
+ #include <string>
10
+ #include <vector>
11
+
12
+ namespace occ::dma {
13
+
14
+ struct DMASettings {
15
+ int max_rank{4};
16
+ double big_exponent{4.0};
17
+ bool include_nuclei{true};
18
+ };
19
+
20
+ struct DMAResult {
21
+ int max_rank{4};
22
+ std::vector<Mult> multipoles;
23
+ };
24
+
25
+ struct DMASites {
26
+ inline auto size() const { return positions.cols(); }
27
+ inline auto num_atoms() const { return atoms.size(); }
28
+
29
+ std::vector<occ::core::Atom> atoms;
30
+ std::vector<std::string> name;
31
+ Mat3N positions;
32
+ IVec atom_indices;
33
+ Vec radii;
34
+ IVec limits;
35
+ };
36
+
37
+ class DMACalculator {
38
+ public:
39
+ DMACalculator(const qm::Wavefunction &wfn);
40
+ void update_settings(const DMASettings &settings);
41
+ inline const auto &settings() const { return m_settings; }
42
+ void set_radius_for_element(int atomic_number, double radius_angs);
43
+ void set_limit_for_element(int atomic_number, int limit);
44
+
45
+ inline const auto &sites() const { return m_sites; }
46
+
47
+ DMAResult compute_multipoles();
48
+ Mult compute_total_multipoles(const DMAResult &result) const;
49
+
50
+ private:
51
+ DMASites m_sites;
52
+ qm::AOBasis m_basis;
53
+ qm::MolecularOrbitals m_mo;
54
+ DMASettings m_settings;
55
+ };
56
+
57
+ } // namespace occ::dma
@@ -0,0 +1,9 @@
1
+ #include <array>
2
+ #include <occ/core/linear_algebra.h>
3
+
4
+ namespace occ::dma {
5
+
6
+ Vec gauss_hermite_points(int n);
7
+ Vec gauss_hermite_weights(int n);
8
+
9
+ } // namespace occ::dma
@@ -0,0 +1,158 @@
1
+ #pragma once
2
+ #include <occ/core/linear_algebra.h>
3
+ #include <occ/dma/mult.h>
4
+ #include <occ/qm/wavefunction.h>
5
+ #include <unsupported/Eigen/CXX11/Tensor>
6
+ #include <vector>
7
+
8
+ namespace occ::dma {
9
+
10
+ /**
11
+ * @brief Settings for linear multipole analysis
12
+ */
13
+ struct LinearDMASettings {
14
+ int max_rank = 4;
15
+ bool include_nuclei = true;
16
+ bool use_slices = false;
17
+ double tolerance = 2.30258 * 18; // Threshold for numerical significance
18
+ double default_radius = 0.5; // Default site radius in Å
19
+ double hydrogen_radius = 0.325; // Hydrogen site radius in Å
20
+ };
21
+
22
+ /**
23
+ * @brief Calculator for distributed multipole analysis of linear molecules
24
+ *
25
+ * This class encapsulates the functionality of the dmaql0 function,
26
+ * providing a cleaner interface for calculating multipole moments
27
+ * for linear molecules where only Qlm with m=0 are non-zero.
28
+ */
29
+ class LinearMultipoleCalculator {
30
+ public:
31
+ /**
32
+ * @brief Constructor for linear multipole calculator
33
+ *
34
+ * @param wfn Wavefunction containing basis set and density matrix
35
+ * @param settings Settings for the DMA calculation
36
+ */
37
+ LinearMultipoleCalculator(
38
+ const occ::qm::Wavefunction &wfn,
39
+ const LinearDMASettings &settings = LinearDMASettings{});
40
+
41
+ /**
42
+ * @brief Calculate all multipole moments for the linear molecule
43
+ *
44
+ * @return std::vector<Mult> Multipole moments for each site
45
+ */
46
+ std::vector<Mult> calculate();
47
+
48
+ private:
49
+ /**
50
+ * @brief Setup sites and their properties based on molecule atoms
51
+ */
52
+ void setup_sites();
53
+
54
+ /**
55
+ * @brief Setup slice information for slice-based calculations
56
+ */
57
+ void setup_slices();
58
+
59
+ /**
60
+ * @brief Process nuclear contributions to multipoles
61
+ *
62
+ * @param site_multipoles Vector to store multipole contributions
63
+ */
64
+ void process_nuclear_contributions(std::vector<Mult> &site_multipoles);
65
+
66
+ /**
67
+ * @brief Process electronic contributions from density matrix
68
+ *
69
+ * @param site_multipoles Vector to store multipole contributions
70
+ */
71
+ void process_electronic_contributions(std::vector<Mult> &site_multipoles);
72
+
73
+ /**
74
+ * @brief Process a shell pair for electronic contributions
75
+ *
76
+ * @param shell_i First shell
77
+ * @param shell_j Second shell
78
+ * @param i_shell_idx Index of first shell
79
+ * @param j_shell_idx Index of second shell
80
+ * @param atom_i Index of first atom
81
+ * @param atom_j Index of second atom
82
+ * @param site_multipoles Vector to store multipole contributions
83
+ */
84
+ void process_shell_pair(const occ::qm::Shell &shell_i,
85
+ const occ::qm::Shell &shell_j, int i_shell_idx,
86
+ int j_shell_idx, int atom_i, int atom_j,
87
+ std::vector<Mult> &site_multipoles);
88
+
89
+ /**
90
+ * @brief Process a primitive pair within shells
91
+ *
92
+ * @param shell_i First shell
93
+ * @param shell_j Second shell
94
+ * @param i_prim Index of primitive in first shell
95
+ * @param j_prim Index of primitive in second shell
96
+ * @param d_block Density matrix block for this shell pair
97
+ * @param atom_i Index of first atom
98
+ * @param atom_j Index of second atom
99
+ * @param site_multipoles Vector to store multipole contributions
100
+ */
101
+ void process_primitive_pair(const occ::qm::Shell &shell_i,
102
+ const occ::qm::Shell &shell_j, int i_prim,
103
+ int j_prim, const Mat &d_block, int atom_i,
104
+ int atom_j, std::vector<Mult> &site_multipoles);
105
+
106
+ /**
107
+ * @brief Calculate error function integrals for slices
108
+ *
109
+ * @param aa Sum of gaussian exponents
110
+ * @param la Angular momentum of first function
111
+ * @param lb Angular momentum of second function
112
+ * @param za Z-coordinate of first center relative to product center
113
+ * @param zb Z-coordinate of second center relative to product center
114
+ * @param z1 Lower bound of slice
115
+ * @param z2 Upper bound of slice
116
+ * @param gz Output tensor for integrals
117
+ * @param skip Flag set to true if all integrals are negligible
118
+ */
119
+ void calculate_slice_integrals(double aa, int la, int lb, double za,
120
+ double zb, double z1, double z2,
121
+ Eigen::Tensor<double, 3> &gz,
122
+ bool &skip) const;
123
+
124
+ /**
125
+ * @brief Get cartesian powers for a basis function
126
+ *
127
+ * @param bf_idx Basis function index within shell
128
+ * @param l Angular momentum of shell
129
+ * @param powers Output array for x,y,z powers
130
+ */
131
+ void get_cartesian_powers(int bf_idx, int l, int powers[3]) const;
132
+
133
+ /**
134
+ * @brief Apply scaling factors for higher angular momentum functions
135
+ *
136
+ * @param d_block Density matrix block to scale
137
+ * @param l Angular momentum
138
+ * @param size Size of shell
139
+ * @param is_row Whether to scale rows (true) or columns (false)
140
+ */
141
+ void apply_angular_scaling(Mat &d_block, int l, int size, bool is_row) const;
142
+
143
+ // Member variables
144
+ const occ::qm::Wavefunction &m_wfn;
145
+ const LinearDMASettings m_settings;
146
+
147
+ // Cached data from wavefunction
148
+ Mat3N m_sites; // Site positions (same as atom positions initially)
149
+ Vec m_site_radii; // Site radii
150
+ IVec m_site_limits; // Site multipole rank limits
151
+ std::vector<int> m_sort_indices; // Sorting indices for z-ordering
152
+ Vec m_slice_separations; // Separation planes for slices
153
+
154
+ // Density matrix (factor of 2 applied)
155
+ Mat m_density_matrix;
156
+ };
157
+
158
+ } // namespace occ::dma
@@ -0,0 +1,146 @@
1
+ #pragma once
2
+ #include <occ/core/linear_algebra.h>
3
+ #include <occ/dma/mult.h>
4
+ #include <vector>
5
+
6
+ namespace occ::dma {
7
+
8
+ /**
9
+ * @brief Handles 1D multipole shifting operations along a single axis
10
+ *
11
+ * This class encapsulates the functionality for shifting multipole moments
12
+ * along a linear axis (typically z-axis) and moving them between sites.
13
+ * It provides a modern C++ interface for operations that were originally
14
+ * implemented as separate shiftz/movez functions.
15
+ */
16
+ class LinearMultipoleShifter {
17
+ public:
18
+ /**
19
+ * @brief Construct a shifter for moving multipoles to sites along an axis
20
+ *
21
+ * @param position Source position along the axis
22
+ * @param multipoles Source multipoles to be moved
23
+ * @param site_positions Matrix of site positions (only z-component used)
24
+ * @param site_radii Vector of site radii
25
+ * @param site_limits Vector of maximum multipole ranks for each site
26
+ * @param site_multipoles Vector of multipoles at each site
27
+ * @param max_rank Maximum multipole rank to consider
28
+ */
29
+ LinearMultipoleShifter(double position, Mult &multipoles,
30
+ const Mat3N &site_positions, const Vec &site_radii,
31
+ const IVec &site_limits,
32
+ std::vector<Mult> &site_multipoles, int max_rank);
33
+
34
+ /**
35
+ * @brief Move multipoles from source position to nearest appropriate sites
36
+ *
37
+ * This implements the logic from the original movez function, distributing
38
+ * multipoles to the nearest sites along the axis based on distance and
39
+ * site limits.
40
+ */
41
+ void move_to_sites();
42
+
43
+ /**
44
+ * @brief Shift multipoles along the axis between two points
45
+ *
46
+ * @param source Source multipoles
47
+ * @param l1 Minimum rank to shift
48
+ * @param m1 Maximum rank to shift from source
49
+ * @param destination Destination multipoles
50
+ * @param m2 Maximum rank to keep at destination
51
+ * @param displacement Displacement along the axis
52
+ */
53
+ static void shift_along_axis(const Mult &source, int l1, int m1,
54
+ Mult &destination, int m2, double displacement);
55
+
56
+ private:
57
+ /**
58
+ * @brief Find nearest site with sufficient multipole limit
59
+ *
60
+ * @param low Minimum required limit
61
+ * @param start Starting site index for search
62
+ * @return Index of nearest suitable site
63
+ */
64
+ int find_nearest_site_with_limit(int low, int start) const;
65
+
66
+ /**
67
+ * @brief Find all sites at approximately the same distance
68
+ *
69
+ * @param primary_site Index of the primary (nearest) site
70
+ * @param low Minimum required limit
71
+ * @param tolerance Distance tolerance for considering sites equivalent
72
+ * @return Vector of site indices at similar distances
73
+ */
74
+ std::vector<int> find_equivalent_sites(int primary_site, int low,
75
+ double tolerance = 1.0e-8) const;
76
+
77
+ /**
78
+ * @brief Process multipoles for a specific rank range
79
+ *
80
+ * @param sites Vector of destination site indices
81
+ * @param low Starting rank
82
+ * @param high Ending rank
83
+ */
84
+ void process_rank_range(const std::vector<int> &sites, int low, int high);
85
+
86
+ /**
87
+ * @brief Calculate scaled distance to a site
88
+ *
89
+ * @param site_index Index of the site
90
+ * @return Scaled distance (distance / radius)
91
+ */
92
+ double scaled_distance_to_site(int site_index) const;
93
+
94
+ /**
95
+ * @brief Precompute powers of displacement for efficient shifting
96
+ *
97
+ * @param displacement The displacement value
98
+ * @param max_power Maximum power needed
99
+ * @return Vector of powers [1, z, z^2, z^3, ...]
100
+ */
101
+ static Vec compute_displacement_powers(double displacement, int max_power);
102
+
103
+ // Member variables
104
+ double m_position;
105
+ Mult &m_multipoles;
106
+ const Mat3N &m_site_positions;
107
+ const Vec &m_site_radii;
108
+ const IVec &m_site_limits;
109
+ std::vector<Mult> &m_site_multipoles;
110
+ int m_max_rank;
111
+ int m_num_sites;
112
+ int m_site_with_highest_limit;
113
+
114
+ // Cached calculations
115
+ Vec m_scaled_distances;
116
+ };
117
+
118
+ /**
119
+ * @brief Convenience function for 1D multipole shifting
120
+ *
121
+ * @param source Source multipoles
122
+ * @param l1 Minimum rank to shift
123
+ * @param m1 Maximum rank to shift from source
124
+ * @param destination Destination multipoles
125
+ * @param m2 Maximum rank to keep at destination
126
+ * @param displacement Displacement along the axis
127
+ */
128
+ void shiftz(const Mult &source, int l1, int m1, Mult &destination, int m2,
129
+ double displacement);
130
+
131
+ /**
132
+ * @brief Convenience function for moving multipoles to sites along an axis
133
+ *
134
+ * @param multipoles Multipole moments to be moved
135
+ * @param position Source position along the axis
136
+ * @param site_positions Matrix of site positions
137
+ * @param site_radii Vector of site radii
138
+ * @param site_limits Vector of maximum rank for each site
139
+ * @param site_multipoles Vector of multipoles at each site
140
+ * @param max_rank Maximum multipole rank
141
+ */
142
+ void movez(Mult &multipoles, double position, const Mat3N &site_positions,
143
+ const Vec &site_radii, const IVec &site_limits,
144
+ std::vector<Mult> &site_multipoles, int max_rank);
145
+
146
+ } // namespace occ::dma