mshqc 1.0.3__tar.gz

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.
mshqc-1.0.3/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Muhamad Syahrul Hidayat
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
mshqc-1.0.3/PKG-INFO ADDED
@@ -0,0 +1,244 @@
1
+ Metadata-Version: 2.4
2
+ Name: mshqc
3
+ Version: 1.0.3
4
+ Summary: mshqc: A C++20 Quantum Chemistry Engine for Orbital-Optimized Correlation Methods
5
+ Author: Muhamad Syahrul Hidayat
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/syahrulhidayat/mshqc
8
+ Project-URL: Bug Tracker, https://github.com/syahrulhidayat/mshqc/issues
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: C++
14
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: numpy>=1.22.0
19
+ Requires-Dist: scipy>=1.8.0
20
+ Requires-Dist: mkl
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest>=7.0; extra == "dev"
23
+ Requires-Dist: sphinx>=4.0; extra == "dev"
24
+ Requires-Dist: matplotlib>=3.5; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # mshqc
28
+
29
+ **A C++20 quantum chemistry engine for orbital-optimized Møller–Plesset perturbation theory**
30
+
31
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
32
+ [![C++20](https://img.shields.io/badge/C++-20-blue.svg)](https://en.cppreference.com/w/cpp/20)
33
+ [![Python 3.10+](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/downloads/)
34
+
35
+ ---
36
+
37
+ ## Overview
38
+
39
+ `mshqc` is a high-performance quantum chemistry package that implements a focused set of wave-function-based electronic structure methods — Hartree–Fock (`RHF`, `UHF`, `ROHF`), canonical Møller–Plesset perturbation theory (`RMP2`, `UMP2`, `RMP3`, `UMP3`), and orbital-optimized Møller–Plesset perturbation theory (`OMP2`, `OMP3`) — in a compact C++20 core with a `nanobind` Python interface.
40
+
41
+ All implemented solvers share a unified integral engine supporting exact four-center Electron Repulsion Integrals (`"exact"`), pivot-based Cholesky decomposition (`"cholesky"`), and auxiliary-basis Density Fitting / Resolution of the Identity (`"df"`), coupled with [TBLIS](https://github.com/devinamatthews/tblis) tensor contractions and a matrix-free Steihaug–Toint trust-region Second-Order SCF (`TrustRegionSOSCF`) orbital optimizer.
42
+
43
+ ---
44
+
45
+ ## Statement of Need
46
+
47
+ Mature quantum chemistry ecosystems such as Psi4 and PySCF provide broad method coverage, but their size and deep abstraction layers create a steep barrier to entry for researchers and students prototyping new orbital-optimization algorithms, three-index tensor factorizations, or custom contraction schedules. Conversely, lightweight educational codes typically implement only canonical RHF and RMP2 in pure Python, lacking open-shell references, third-order correlation (`MP3`/`OMP3`), point-group symmetry reduction, or rank-reduced three-index integrals.
48
+
49
+ `mshqc` bridges this gap by exposing a compact, inspectable C++20 codebase under a clean two-tier Python API:
50
+ 1. **High-Level Pipeline API (`mshqc.run`, `MSHQCSession`, `quick_calculation`):** Run complete multi-method workflows (`SCF -> MP2 -> OMP2 -> OMP3`) in a single call with automatic point-group alignment (`PointGroup`), `PetiteList` symmetry reduction, and matched `-RI` auxiliary basis resolution.
51
+ 2. **Low-Level C++20 Kernel API (`Molecule`, `BasisSet`, `IntegralEngine`, `RHF`/`UHF`/`ROHF`, `RMP2`/`UMP2`/`OMP2`, `RMP3`/`UMP3`/`OMP3`):** Instantiate C++20 solvers directly to inspect or modify intermediate matrices, orbital energies, and Cholesky/DF vectors with zero-copy `Eigen` <-> `NumPy` interoperability.
52
+
53
+ ---
54
+
55
+ ## Features
56
+
57
+ ### Core Infrastructure & Symmetry
58
+ - Molecular geometry initialization in Bohr or Angstrom — `Molecule`, `Atom`, `build_molecule` [1]
59
+ - Bundled library of 538 Gaussian basis sets (`.gbs`), including Dunning `cc-pVXZ`, `aug-cc-pVXZ`, Karlsruhe `def2`, and matched `-RI` / `-JKFIT` auxiliary basis sets — `BasisSet` [2, 7]
60
+ - Automated point-group detection, canonical axis alignment, and symmetry-unique shell-pair generation — `PointGroup`, `PetiteList`, `BasisSymmetrizer` [3]
61
+
62
+ ### Unified Integral Engine
63
+ - Analytical one- and two-electron integrals via `libcint` — `IntegralEngine` [4]
64
+ - Unified `eri_method` selection across all SCF and correlated solvers:
65
+ - `"exact"`: Four-center ERIs with Schwarz inequality prescreening — `Screening` [8]
66
+ - `"cholesky"`: Pivot-based three-index Cholesky decomposition — `CholeskyERI` [5, 6]
67
+ - `"df"`: Auxiliary-basis three-index Density Fitting (RI) with optional HDF5 out-of-core storage [7, 21]
68
+
69
+ ### Self-Consistent Field (SCF)
70
+ - Restricted (`RHF`), Unrestricted (`UHF`), and Restricted Open-Shell (`ROHF`) Hartree–Fock [9, 10, 11]
71
+ - Superposition of Atomic Densities (`SAD`) initial guess and Pulay `DIIS` extrapolation [12, 13]
72
+
73
+ ### Møller–Plesset Perturbation Theory & Orbital Optimization
74
+ - Canonical second- and third-order perturbation theory: `RMP2`, `UMP2`, `RMP3`, `UMP3` [14, 15, 17]
75
+ - Orbital-optimized second- and third-order perturbation theory: `OMP2`, `OMP3` driven by matrix-free Steihaug–Toint trust-region `SOSCF` (`TrustRegionSOSCF`) and Z-vector response densities [16, 18, 19]
76
+
77
+ ---
78
+
79
+ ## Prerequisites & Dependencies
80
+
81
+ | Category | Packages | Scope | Reference |
82
+ |---|---|---|---|
83
+ | Linear algebra & tensors | `eigen`, `tblis`, `mkl`, `mkl-include`, `liblapacke` | Build + runtime | [20, 22] |
84
+ | Integrals & I/O | `libcint`, `hdf5`, `jemalloc` | Build + runtime | [4, 21] |
85
+ | Parallelism | `llvm-openmp` / `libgomp` | Build + runtime | [23] |
86
+ | Python bindings & runtime | `nanobind`, `numpy`, `scipy` | Build + runtime | [24, 25] |
87
+ | Testing | `pytest` | Dev / test | — |
88
+
89
+ ---
90
+
91
+ ## Installation
92
+
93
+ A `conda-forge` environment is recommended to ensure ABI-compatible builds of MKL, HDF5, OpenMP, `libcint`, and `tblis`.
94
+
95
+ ```bash
96
+ # 1. Create and activate the Conda environment
97
+ conda env create -f environment.yml
98
+ conda activate mshqc_314
99
+
100
+ # 2. Build and install mshqc in editable mode
101
+ pip install -v -e . --no-build-isolation
102
+ ```
103
+
104
+ ### Build Options
105
+
106
+ By default, `mshqc` compiles with `-O3 -march=native` on local machines. When building portable binaries for heterogeneous clusters, override the C++ flags via `CMAKE_ARGS`:
107
+
108
+ ```bash
109
+ CMAKE_ARGS="-DCMAKE_CXX_FLAGS='-O3 -mavx2 -mfma -DNDEBUG'" pip install -v -e . --no-build-isolation
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Quickstart
115
+
116
+ ### 1. High-Level One-Liner API (`mshqc.run`)
117
+
118
+ `mshqc.run()` automatically detects molecular point-group symmetry, builds the `PetiteList`, resolves the auxiliary basis (`cc-pVTZ-RI` for `eri_method="df"`), and executes the requested method hierarchy in compiled C++20:
119
+
120
+ ```python
121
+ import mshqc
122
+
123
+ h2o_xyz = """
124
+ O 0.0000000000 0.0000000000 0.1173000000
125
+ H 0.0000000000 0.7572000000 -0.4692000000
126
+ H 0.0000000000 -0.7572000000 -0.4692000000
127
+ """
128
+
129
+ results = mshqc.run(
130
+ h2o_xyz,
131
+ method=["RHF", "RMP2", "OMP2", "OMP3"],
132
+ basis="cc-pVTZ",
133
+ eri_method="df",
134
+ units="angstrom",
135
+ threshold=1e-9,
136
+ )
137
+
138
+ for method_name, info in results.items():
139
+ print(f"{method_name:<5} : {info['energy']:.10f} Ha ({info['time']:.3f} s)")
140
+ ```
141
+
142
+ ### 2. Low-Level C++20 Kernel API
143
+
144
+ For method development and direct inspection of intermediate quantities, instantiate the C++20 classes directly:
145
+
146
+ ```python
147
+ import mshqc
148
+
149
+ # 1. Initialize molecule (supports atomic symbols/numbers and "angstrom" or "bohr" units)
150
+ mol = mshqc.Molecule(charge=0, multiplicity=1)
151
+ mol.add_atom("O", 0.0000, 0.0000, 0.1173, units="angstrom")
152
+ mol.add_atom("H", 0.0000, 0.7572, -0.4692, units="angstrom")
153
+ mol.add_atom("H", 0.0000, -0.7572, -0.4692, units="angstrom")
154
+
155
+ # 2. Load basis set and analytical integral engine
156
+ basis = mshqc.BasisSet("cc-pVTZ", mol)
157
+ integrals = mshqc.IntegralEngine(mol, basis)
158
+
159
+ # 3. Run RHF with Cholesky-decomposed ERIs (threshold = 1e-9 Ha)
160
+ scf_conf = mshqc.SCFConfig(eri_method="cholesky", threshold=1e-9)
161
+ scf_res = mshqc.RHF(mol, basis, integrals, scf_conf).compute()
162
+ print(f"RHF Total Energy : {scf_res.energy_total:.10f} Ha")
163
+
164
+ # 4. Run RMP2, OMP2, and OMP3 on the converged SCF reference
165
+ mp2_conf = mshqc.MP2Config(eri_method="cholesky", threshold=1e-9, gradient_threshold=1e-5)
166
+
167
+ rmp2_res = mshqc.RMP2(mol, basis, integrals, scf_res, mp2_conf).compute()
168
+ omp2_res = mshqc.OMP2(mol, basis, integrals, scf_res, mp2_conf).compute()
169
+ omp3_res = mshqc.OMP3(mol, basis, integrals, scf_res, mp2_conf).compute()
170
+
171
+ print(f"RMP2 Total Energy : {rmp2_res.energy_total:.10f} Ha (Corr: {rmp2_res.energy_mp2_corr:.10f} Ha)")
172
+ print(f"OMP2 Total Energy : {omp2_res.energy_total:.10f} Ha")
173
+ print(f"OMP3 Total Energy : {omp3_res.energy_total:.10f} Ha")
174
+ ```
175
+
176
+ See [`docs/QUICKSTART.md`](docs/QUICKSTART.md) for open-shell (`UHF`/`ROHF`/`UMP2`/`UMP3`), symmetry-adapted, and session-managed examples, and [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) for build and runtime diagnostics.
177
+
178
+ ---
179
+
180
+ ## Testing
181
+
182
+ Run the automated validation test suite via `pytest`:
183
+
184
+ ```bash
185
+ pytest tests/ -v
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Contributing
191
+
192
+ Bug reports and pull requests are welcome via the [GitHub issue tracker](https://github.com/syahrulhidayat/mshqc/issues). Please include your OS, compiler version, and `conda list` output when reporting build or runtime issues.
193
+
194
+ ---
195
+
196
+ ## Citing mshqc
197
+
198
+ If you use `mshqc` in published work, please cite:
199
+
200
+ ```bibtex
201
+ @software{mshqc2026,
202
+ author = {Hidayat, Muhamad Syahrul},
203
+ title = {mshqc: A C++20 Quantum Chemistry Engine for Orbital-Optimized M{\o}ller--Plesset Perturbation Theory},
204
+ year = {2026},
205
+ url = {https://github.com/syahrulhidayat/mshqc},
206
+ version = {1.0.3}
207
+ }
208
+ ```
209
+
210
+ ---
211
+
212
+ ## References
213
+
214
+ [1] Helgaker, T., Jørgensen, P., & Olsen, J. (2000). *Molecular Electronic-Structure Theory*. Wiley. https://doi.org/10.1002/9781119019572
215
+ [2] Dunning, T. H., Jr. (1989). Gaussian basis sets for use in correlated molecular calculations. I. *J. Chem. Phys.*, 90(2), 1007–1023. https://doi.org/10.1063/1.456153
216
+ [3] Atkins, P. W., Child, M. S., & Phillips, C. S. G. (1970). *Tables for Group Theory*. Oxford University Press.
217
+ [4] Sun, Q. (2015). Libcint: An efficient general integral library for Gaussian basis functions. *J. Comput. Chem.*, 36(22), 1664–1671. https://doi.org/10.1002/jcc.23981
218
+ [5] Beebe, N. H. F., & Linderberg, J. (1977). Simplifications in the generation and transformation of two-electron integrals in molecular calculations. *Int. J. Quantum Chem.*, 12(4), 683–705. https://doi.org/10.1002/qua.560120408
219
+ [6] Koch, H., Sánchez de Merás, A., & Pedersen, T. B. (2003). Reduced scaling in electronic structure calculations using Cholesky decompositions. *J. Chem. Phys.*, 118(21), 9481–9484. https://doi.org/10.1063/1.1578621
220
+ [7] Weigend, F. (2002). A fully direct RI-HF algorithm: Implementation, optimised auxiliary basis sets, demonstration of accuracy and efficiency. *Phys. Chem. Chem. Phys.*, 4(18), 4285–4291. https://doi.org/10.1039/B204199P
221
+ [8] Häser, M., & Ahlrichs, R. (1989). Improvements on the direct SCF method. *J. Comput. Chem.*, 10(1), 104–111. https://doi.org/10.1002/jcc.540100111
222
+ [9] Roothaan, C. C. J. (1951). New developments in molecular orbital theory. *Rev. Mod. Phys.*, 23(2), 69–89. https://doi.org/10.1103/RevModPhys.23.69
223
+ [10] Pople, J. A., & Nesbet, R. K. (1954). Self-consistent orbitals for radicals. *J. Chem. Phys.*, 22(3), 571–572. https://doi.org/10.1063/1.1740120
224
+ [11] Roothaan, C. C. J. (1960). Self-Consistent Field Theory for Open Shells of Electronic Systems. *Rev. Mod. Phys.*, 32(2), 179–185. https://doi.org/10.1103/RevModPhys.32.179
225
+ [12] Pulay, P. (1980). Convergence acceleration of iterative sequences. The case of SCF iteration. *Chem. Phys. Lett.*, 73(2), 393–398. https://doi.org/10.1016/0009-2614(80)80396-4
226
+ [13] Pulay, P. (1982). Improved SCF convergence acceleration. *J. Comput. Chem.*, 3(4), 556–560. https://doi.org/10.1002/jcc.540030413
227
+ [14] Møller, C., & Plesset, M. S. (1934). Note on an Approximation Treatment for Many-Electron Systems. *Phys. Rev.*, 46(7), 618–622. https://doi.org/10.1103/PhysRev.46.618
228
+ [15] Head-Gordon, M., Pople, J. A., & Frisch, M. J. (1988). MP2 energy evaluation by direct methods. *Chem. Phys. Lett.*, 153(6), 503–506. https://doi.org/10.1016/0009-2614(88)85250-3
229
+ [16] Neese, F., Schwabe, T., Kossmann, S., Schirmer, B., & Grimme, S. (2009). Assessment of Orbital-Optimized, Spin-Component Scaled Second-Order Many-Body Perturbation Theory for Thermochemistry and Kinetics. *J. Chem. Theory Comput.*, 5(11), 3060–3073. https://doi.org/10.1021/ct9003299
230
+ [17] Pople, J. A., Binkley, J. S., & Seeger, R. (1976). Theoretical models incorporating electron correlation. *Int. J. Quantum Chem.*, 10(S10), 1–19. https://doi.org/10.1002/qua.560100802
231
+ [18] Bozkaya, U., Turney, J. M., Yamaguchi, Y., Schaefer, H. F., & Sherrill, C. D. (2011). Quadratically convergent algorithm for orbital optimization in the orbital-optimized coupled-cluster doubles method and in orbital-optimized second-order Møller-Plesset perturbation theory. *J. Chem. Phys.*, 135(10), 104103. https://doi.org/10.1063/1.3631129
232
+ [19] Bozkaya, U. (2011). Orbital-optimized third-order Møller–Plesset perturbation theory and its spin-component and spin-opposite scaled variants: Application to symmetry-breaking problems. *J. Chem. Phys.*, 135(22), 224103. https://doi.org/10.1063/1.3665134
233
+ [20] Guennebaud, G., Jacob, B., et al. (2010). *Eigen v3*. https://eigen.tuxfamily.org
234
+ [21] The HDF Group. (1997–2026). *Hierarchical Data Format, version 5*. https://www.hdfgroup.org/HDF5/
235
+ [22] Matthews, D. A. (2017). High-Performance Tensor Contraction without Transposition. *SIAM J. Sci. Comput.*, 39(6), C476–C509. https://doi.org/10.1137/16M108968X
236
+ [23] Dagum, L., & Menon, R. (1998). OpenMP: an industry standard API for shared-memory programming. *IEEE Comput. Sci. Eng.*, 5(1), 46–55. https://doi.org/10.1109/99.660313
237
+ [24] Jakob, W. (2022). *nanobind: Tiny and efficient C++/Python bindings*. https://github.com/wjakob/nanobind
238
+ [25] Harris, C. R., Millman, K. J., van der Walt, S. J., et al. (2020). Array programming with NumPy. *Nature*, 585, 357–362. https://doi.org/10.1038/s41586-020-2649-2
239
+
240
+ ---
241
+
242
+ ## License
243
+
244
+ Apache License 2.0 — see [`LICENSE`](LICENSE) for details.
mshqc-1.0.3/README.md ADDED
@@ -0,0 +1,218 @@
1
+ # mshqc
2
+
3
+ **A C++20 quantum chemistry engine for orbital-optimized Møller–Plesset perturbation theory**
4
+
5
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
6
+ [![C++20](https://img.shields.io/badge/C++-20-blue.svg)](https://en.cppreference.com/w/cpp/20)
7
+ [![Python 3.10+](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/downloads/)
8
+
9
+ ---
10
+
11
+ ## Overview
12
+
13
+ `mshqc` is a high-performance quantum chemistry package that implements a focused set of wave-function-based electronic structure methods — Hartree–Fock (`RHF`, `UHF`, `ROHF`), canonical Møller–Plesset perturbation theory (`RMP2`, `UMP2`, `RMP3`, `UMP3`), and orbital-optimized Møller–Plesset perturbation theory (`OMP2`, `OMP3`) — in a compact C++20 core with a `nanobind` Python interface.
14
+
15
+ All implemented solvers share a unified integral engine supporting exact four-center Electron Repulsion Integrals (`"exact"`), pivot-based Cholesky decomposition (`"cholesky"`), and auxiliary-basis Density Fitting / Resolution of the Identity (`"df"`), coupled with [TBLIS](https://github.com/devinamatthews/tblis) tensor contractions and a matrix-free Steihaug–Toint trust-region Second-Order SCF (`TrustRegionSOSCF`) orbital optimizer.
16
+
17
+ ---
18
+
19
+ ## Statement of Need
20
+
21
+ Mature quantum chemistry ecosystems such as Psi4 and PySCF provide broad method coverage, but their size and deep abstraction layers create a steep barrier to entry for researchers and students prototyping new orbital-optimization algorithms, three-index tensor factorizations, or custom contraction schedules. Conversely, lightweight educational codes typically implement only canonical RHF and RMP2 in pure Python, lacking open-shell references, third-order correlation (`MP3`/`OMP3`), point-group symmetry reduction, or rank-reduced three-index integrals.
22
+
23
+ `mshqc` bridges this gap by exposing a compact, inspectable C++20 codebase under a clean two-tier Python API:
24
+ 1. **High-Level Pipeline API (`mshqc.run`, `MSHQCSession`, `quick_calculation`):** Run complete multi-method workflows (`SCF -> MP2 -> OMP2 -> OMP3`) in a single call with automatic point-group alignment (`PointGroup`), `PetiteList` symmetry reduction, and matched `-RI` auxiliary basis resolution.
25
+ 2. **Low-Level C++20 Kernel API (`Molecule`, `BasisSet`, `IntegralEngine`, `RHF`/`UHF`/`ROHF`, `RMP2`/`UMP2`/`OMP2`, `RMP3`/`UMP3`/`OMP3`):** Instantiate C++20 solvers directly to inspect or modify intermediate matrices, orbital energies, and Cholesky/DF vectors with zero-copy `Eigen` <-> `NumPy` interoperability.
26
+
27
+ ---
28
+
29
+ ## Features
30
+
31
+ ### Core Infrastructure & Symmetry
32
+ - Molecular geometry initialization in Bohr or Angstrom — `Molecule`, `Atom`, `build_molecule` [1]
33
+ - Bundled library of 538 Gaussian basis sets (`.gbs`), including Dunning `cc-pVXZ`, `aug-cc-pVXZ`, Karlsruhe `def2`, and matched `-RI` / `-JKFIT` auxiliary basis sets — `BasisSet` [2, 7]
34
+ - Automated point-group detection, canonical axis alignment, and symmetry-unique shell-pair generation — `PointGroup`, `PetiteList`, `BasisSymmetrizer` [3]
35
+
36
+ ### Unified Integral Engine
37
+ - Analytical one- and two-electron integrals via `libcint` — `IntegralEngine` [4]
38
+ - Unified `eri_method` selection across all SCF and correlated solvers:
39
+ - `"exact"`: Four-center ERIs with Schwarz inequality prescreening — `Screening` [8]
40
+ - `"cholesky"`: Pivot-based three-index Cholesky decomposition — `CholeskyERI` [5, 6]
41
+ - `"df"`: Auxiliary-basis three-index Density Fitting (RI) with optional HDF5 out-of-core storage [7, 21]
42
+
43
+ ### Self-Consistent Field (SCF)
44
+ - Restricted (`RHF`), Unrestricted (`UHF`), and Restricted Open-Shell (`ROHF`) Hartree–Fock [9, 10, 11]
45
+ - Superposition of Atomic Densities (`SAD`) initial guess and Pulay `DIIS` extrapolation [12, 13]
46
+
47
+ ### Møller–Plesset Perturbation Theory & Orbital Optimization
48
+ - Canonical second- and third-order perturbation theory: `RMP2`, `UMP2`, `RMP3`, `UMP3` [14, 15, 17]
49
+ - Orbital-optimized second- and third-order perturbation theory: `OMP2`, `OMP3` driven by matrix-free Steihaug–Toint trust-region `SOSCF` (`TrustRegionSOSCF`) and Z-vector response densities [16, 18, 19]
50
+
51
+ ---
52
+
53
+ ## Prerequisites & Dependencies
54
+
55
+ | Category | Packages | Scope | Reference |
56
+ |---|---|---|---|
57
+ | Linear algebra & tensors | `eigen`, `tblis`, `mkl`, `mkl-include`, `liblapacke` | Build + runtime | [20, 22] |
58
+ | Integrals & I/O | `libcint`, `hdf5`, `jemalloc` | Build + runtime | [4, 21] |
59
+ | Parallelism | `llvm-openmp` / `libgomp` | Build + runtime | [23] |
60
+ | Python bindings & runtime | `nanobind`, `numpy`, `scipy` | Build + runtime | [24, 25] |
61
+ | Testing | `pytest` | Dev / test | — |
62
+
63
+ ---
64
+
65
+ ## Installation
66
+
67
+ A `conda-forge` environment is recommended to ensure ABI-compatible builds of MKL, HDF5, OpenMP, `libcint`, and `tblis`.
68
+
69
+ ```bash
70
+ # 1. Create and activate the Conda environment
71
+ conda env create -f environment.yml
72
+ conda activate mshqc_314
73
+
74
+ # 2. Build and install mshqc in editable mode
75
+ pip install -v -e . --no-build-isolation
76
+ ```
77
+
78
+ ### Build Options
79
+
80
+ By default, `mshqc` compiles with `-O3 -march=native` on local machines. When building portable binaries for heterogeneous clusters, override the C++ flags via `CMAKE_ARGS`:
81
+
82
+ ```bash
83
+ CMAKE_ARGS="-DCMAKE_CXX_FLAGS='-O3 -mavx2 -mfma -DNDEBUG'" pip install -v -e . --no-build-isolation
84
+ ```
85
+
86
+ ---
87
+
88
+ ## Quickstart
89
+
90
+ ### 1. High-Level One-Liner API (`mshqc.run`)
91
+
92
+ `mshqc.run()` automatically detects molecular point-group symmetry, builds the `PetiteList`, resolves the auxiliary basis (`cc-pVTZ-RI` for `eri_method="df"`), and executes the requested method hierarchy in compiled C++20:
93
+
94
+ ```python
95
+ import mshqc
96
+
97
+ h2o_xyz = """
98
+ O 0.0000000000 0.0000000000 0.1173000000
99
+ H 0.0000000000 0.7572000000 -0.4692000000
100
+ H 0.0000000000 -0.7572000000 -0.4692000000
101
+ """
102
+
103
+ results = mshqc.run(
104
+ h2o_xyz,
105
+ method=["RHF", "RMP2", "OMP2", "OMP3"],
106
+ basis="cc-pVTZ",
107
+ eri_method="df",
108
+ units="angstrom",
109
+ threshold=1e-9,
110
+ )
111
+
112
+ for method_name, info in results.items():
113
+ print(f"{method_name:<5} : {info['energy']:.10f} Ha ({info['time']:.3f} s)")
114
+ ```
115
+
116
+ ### 2. Low-Level C++20 Kernel API
117
+
118
+ For method development and direct inspection of intermediate quantities, instantiate the C++20 classes directly:
119
+
120
+ ```python
121
+ import mshqc
122
+
123
+ # 1. Initialize molecule (supports atomic symbols/numbers and "angstrom" or "bohr" units)
124
+ mol = mshqc.Molecule(charge=0, multiplicity=1)
125
+ mol.add_atom("O", 0.0000, 0.0000, 0.1173, units="angstrom")
126
+ mol.add_atom("H", 0.0000, 0.7572, -0.4692, units="angstrom")
127
+ mol.add_atom("H", 0.0000, -0.7572, -0.4692, units="angstrom")
128
+
129
+ # 2. Load basis set and analytical integral engine
130
+ basis = mshqc.BasisSet("cc-pVTZ", mol)
131
+ integrals = mshqc.IntegralEngine(mol, basis)
132
+
133
+ # 3. Run RHF with Cholesky-decomposed ERIs (threshold = 1e-9 Ha)
134
+ scf_conf = mshqc.SCFConfig(eri_method="cholesky", threshold=1e-9)
135
+ scf_res = mshqc.RHF(mol, basis, integrals, scf_conf).compute()
136
+ print(f"RHF Total Energy : {scf_res.energy_total:.10f} Ha")
137
+
138
+ # 4. Run RMP2, OMP2, and OMP3 on the converged SCF reference
139
+ mp2_conf = mshqc.MP2Config(eri_method="cholesky", threshold=1e-9, gradient_threshold=1e-5)
140
+
141
+ rmp2_res = mshqc.RMP2(mol, basis, integrals, scf_res, mp2_conf).compute()
142
+ omp2_res = mshqc.OMP2(mol, basis, integrals, scf_res, mp2_conf).compute()
143
+ omp3_res = mshqc.OMP3(mol, basis, integrals, scf_res, mp2_conf).compute()
144
+
145
+ print(f"RMP2 Total Energy : {rmp2_res.energy_total:.10f} Ha (Corr: {rmp2_res.energy_mp2_corr:.10f} Ha)")
146
+ print(f"OMP2 Total Energy : {omp2_res.energy_total:.10f} Ha")
147
+ print(f"OMP3 Total Energy : {omp3_res.energy_total:.10f} Ha")
148
+ ```
149
+
150
+ See [`docs/QUICKSTART.md`](docs/QUICKSTART.md) for open-shell (`UHF`/`ROHF`/`UMP2`/`UMP3`), symmetry-adapted, and session-managed examples, and [`docs/TROUBLESHOOTING.md`](docs/TROUBLESHOOTING.md) for build and runtime diagnostics.
151
+
152
+ ---
153
+
154
+ ## Testing
155
+
156
+ Run the automated validation test suite via `pytest`:
157
+
158
+ ```bash
159
+ pytest tests/ -v
160
+ ```
161
+
162
+ ---
163
+
164
+ ## Contributing
165
+
166
+ Bug reports and pull requests are welcome via the [GitHub issue tracker](https://github.com/syahrulhidayat/mshqc/issues). Please include your OS, compiler version, and `conda list` output when reporting build or runtime issues.
167
+
168
+ ---
169
+
170
+ ## Citing mshqc
171
+
172
+ If you use `mshqc` in published work, please cite:
173
+
174
+ ```bibtex
175
+ @software{mshqc2026,
176
+ author = {Hidayat, Muhamad Syahrul},
177
+ title = {mshqc: A C++20 Quantum Chemistry Engine for Orbital-Optimized M{\o}ller--Plesset Perturbation Theory},
178
+ year = {2026},
179
+ url = {https://github.com/syahrulhidayat/mshqc},
180
+ version = {1.0.3}
181
+ }
182
+ ```
183
+
184
+ ---
185
+
186
+ ## References
187
+
188
+ [1] Helgaker, T., Jørgensen, P., & Olsen, J. (2000). *Molecular Electronic-Structure Theory*. Wiley. https://doi.org/10.1002/9781119019572
189
+ [2] Dunning, T. H., Jr. (1989). Gaussian basis sets for use in correlated molecular calculations. I. *J. Chem. Phys.*, 90(2), 1007–1023. https://doi.org/10.1063/1.456153
190
+ [3] Atkins, P. W., Child, M. S., & Phillips, C. S. G. (1970). *Tables for Group Theory*. Oxford University Press.
191
+ [4] Sun, Q. (2015). Libcint: An efficient general integral library for Gaussian basis functions. *J. Comput. Chem.*, 36(22), 1664–1671. https://doi.org/10.1002/jcc.23981
192
+ [5] Beebe, N. H. F., & Linderberg, J. (1977). Simplifications in the generation and transformation of two-electron integrals in molecular calculations. *Int. J. Quantum Chem.*, 12(4), 683–705. https://doi.org/10.1002/qua.560120408
193
+ [6] Koch, H., Sánchez de Merás, A., & Pedersen, T. B. (2003). Reduced scaling in electronic structure calculations using Cholesky decompositions. *J. Chem. Phys.*, 118(21), 9481–9484. https://doi.org/10.1063/1.1578621
194
+ [7] Weigend, F. (2002). A fully direct RI-HF algorithm: Implementation, optimised auxiliary basis sets, demonstration of accuracy and efficiency. *Phys. Chem. Chem. Phys.*, 4(18), 4285–4291. https://doi.org/10.1039/B204199P
195
+ [8] Häser, M., & Ahlrichs, R. (1989). Improvements on the direct SCF method. *J. Comput. Chem.*, 10(1), 104–111. https://doi.org/10.1002/jcc.540100111
196
+ [9] Roothaan, C. C. J. (1951). New developments in molecular orbital theory. *Rev. Mod. Phys.*, 23(2), 69–89. https://doi.org/10.1103/RevModPhys.23.69
197
+ [10] Pople, J. A., & Nesbet, R. K. (1954). Self-consistent orbitals for radicals. *J. Chem. Phys.*, 22(3), 571–572. https://doi.org/10.1063/1.1740120
198
+ [11] Roothaan, C. C. J. (1960). Self-Consistent Field Theory for Open Shells of Electronic Systems. *Rev. Mod. Phys.*, 32(2), 179–185. https://doi.org/10.1103/RevModPhys.32.179
199
+ [12] Pulay, P. (1980). Convergence acceleration of iterative sequences. The case of SCF iteration. *Chem. Phys. Lett.*, 73(2), 393–398. https://doi.org/10.1016/0009-2614(80)80396-4
200
+ [13] Pulay, P. (1982). Improved SCF convergence acceleration. *J. Comput. Chem.*, 3(4), 556–560. https://doi.org/10.1002/jcc.540030413
201
+ [14] Møller, C., & Plesset, M. S. (1934). Note on an Approximation Treatment for Many-Electron Systems. *Phys. Rev.*, 46(7), 618–622. https://doi.org/10.1103/PhysRev.46.618
202
+ [15] Head-Gordon, M., Pople, J. A., & Frisch, M. J. (1988). MP2 energy evaluation by direct methods. *Chem. Phys. Lett.*, 153(6), 503–506. https://doi.org/10.1016/0009-2614(88)85250-3
203
+ [16] Neese, F., Schwabe, T., Kossmann, S., Schirmer, B., & Grimme, S. (2009). Assessment of Orbital-Optimized, Spin-Component Scaled Second-Order Many-Body Perturbation Theory for Thermochemistry and Kinetics. *J. Chem. Theory Comput.*, 5(11), 3060–3073. https://doi.org/10.1021/ct9003299
204
+ [17] Pople, J. A., Binkley, J. S., & Seeger, R. (1976). Theoretical models incorporating electron correlation. *Int. J. Quantum Chem.*, 10(S10), 1–19. https://doi.org/10.1002/qua.560100802
205
+ [18] Bozkaya, U., Turney, J. M., Yamaguchi, Y., Schaefer, H. F., & Sherrill, C. D. (2011). Quadratically convergent algorithm for orbital optimization in the orbital-optimized coupled-cluster doubles method and in orbital-optimized second-order Møller-Plesset perturbation theory. *J. Chem. Phys.*, 135(10), 104103. https://doi.org/10.1063/1.3631129
206
+ [19] Bozkaya, U. (2011). Orbital-optimized third-order Møller–Plesset perturbation theory and its spin-component and spin-opposite scaled variants: Application to symmetry-breaking problems. *J. Chem. Phys.*, 135(22), 224103. https://doi.org/10.1063/1.3665134
207
+ [20] Guennebaud, G., Jacob, B., et al. (2010). *Eigen v3*. https://eigen.tuxfamily.org
208
+ [21] The HDF Group. (1997–2026). *Hierarchical Data Format, version 5*. https://www.hdfgroup.org/HDF5/
209
+ [22] Matthews, D. A. (2017). High-Performance Tensor Contraction without Transposition. *SIAM J. Sci. Comput.*, 39(6), C476–C509. https://doi.org/10.1137/16M108968X
210
+ [23] Dagum, L., & Menon, R. (1998). OpenMP: an industry standard API for shared-memory programming. *IEEE Comput. Sci. Eng.*, 5(1), 46–55. https://doi.org/10.1109/99.660313
211
+ [24] Jakob, W. (2022). *nanobind: Tiny and efficient C++/Python bindings*. https://github.com/wjakob/nanobind
212
+ [25] Harris, C. R., Millman, K. J., van der Walt, S. J., et al. (2020). Array programming with NumPy. *Nature*, 585, 357–362. https://doi.org/10.1038/s41586-020-2649-2
213
+
214
+ ---
215
+
216
+ ## License
217
+
218
+ Apache License 2.0 — see [`LICENSE`](LICENSE) for details.