qmatbridge 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Roberto Reis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,388 @@
1
+ Metadata-Version: 2.4
2
+ Name: qmatbridge
3
+ Version: 0.1.0
4
+ Summary: Bridge from classical materials databases to first-quantized Hamiltonians for quantum simulation
5
+ Author-email: Roberto Reis <robertomsreis@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Roberto Reis
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/rmsreis/qmatbridge
29
+ Project-URL: Repository, https://github.com/rmsreis/qmatbridge
30
+ Project-URL: Issues, https://github.com/rmsreis/qmatbridge/issues
31
+ Keywords: quantum computing,quantum simulation,materials science,Hamiltonian simulation,block encoding,fault tolerant,resource estimation
32
+ Classifier: Development Status :: 2 - Pre-Alpha
33
+ Classifier: Intended Audience :: Science/Research
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3.10
37
+ Classifier: Programming Language :: Python :: 3.11
38
+ Classifier: Programming Language :: Python :: 3.12
39
+ Classifier: Topic :: Scientific/Engineering :: Physics
40
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
41
+ Requires-Python: >=3.10
42
+ Description-Content-Type: text/markdown
43
+ License-File: LICENSE
44
+ Provides-Extra: dev
45
+ Requires-Dist: pytest>=7.4; extra == "dev"
46
+ Requires-Dist: pytest-cov>=4.1; extra == "dev"
47
+ Requires-Dist: ruff>=0.4; extra == "dev"
48
+ Requires-Dist: mypy>=1.8; extra == "dev"
49
+ Provides-Extra: mp
50
+ Requires-Dist: mp-api>=0.41; extra == "mp"
51
+ Requires-Dist: pymatgen>=2024.1; extra == "mp"
52
+ Provides-Extra: ase
53
+ Requires-Dist: ase>=3.22; extra == "ase"
54
+ Provides-Extra: oqmd
55
+ Requires-Dist: qmpy-rester>=0.3; extra == "oqmd"
56
+ Provides-Extra: openfermion
57
+ Requires-Dist: openfermion>=1.6; extra == "openfermion"
58
+ Dynamic: license-file
59
+
60
+ # QMatBridge
61
+
62
+ **A Python library for bridging classical materials databases to first-quantized
63
+ Hamiltonians for fault-tolerant quantum simulation.**
64
+
65
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
66
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
67
+ [![CI](https://github.com/rmsreis/qmatbridge/actions/workflows/python-package.yml/badge.svg)](https://github.com/rmsreis/qmatbridge/actions)
68
+ [![PyPI](https://img.shields.io/badge/PyPI-not%20yet%20published-lightgrey.svg)](#installation)
69
+ [![Docs](https://img.shields.io/badge/docs-in%20progress-lightgrey.svg)](docs/)
70
+
71
+ > **Status:** early-stage, active development — schema is stabilizing, adapters
72
+ > are stubs, exporters are planned. The core NIR and I/O layer are functional.
73
+ > Breaking changes to `QMatEntry` before v1.0 will be announced in
74
+ > [CHANGELOG.md](CHANGELOG.md) and accompanied by migration notes.
75
+
76
+ ---
77
+
78
+ ## Why QMatBridge exists
79
+
80
+ Research groups developing fault-tolerant Hamiltonian-simulation algorithms —
81
+ block-encodings, qubitization variants, truncated Dyson series methods — need
82
+ realistic electronic-structure Hamiltonians to test and benchmark their
83
+ primitives. The standard path is to write one-off scripts that pull DFT data
84
+ from the Materials Project or similar databases, reformat it, and feed it into
85
+ a quantum compiler.
86
+
87
+ These scripts are rarely shared, almost never interoperable with more than one
88
+ quantum framework, and often omit the provenance information needed to reproduce
89
+ or compare results. When two groups report T-gate counts for "silicon", there
90
+ is no standard way to verify they used the same Hamiltonian.
91
+
92
+ QMatBridge addresses this by providing a **neutral intermediate representation
93
+ (NIR)** that any upstream database adapter can write to and any downstream
94
+ quantum compiler or resource estimator can read from, with full provenance
95
+ baked in.
96
+
97
+ ---
98
+
99
+ ## Core idea
100
+
101
+ ```text
102
+ Materials Project ──┐
103
+ OQMD ──┤ adapters ──▶ QMatEntry (NIR) ──▶ exporters ──▶ OpenFermion
104
+ OPTIMADE sources ──┤ ──▶ qualtran
105
+ Alexandria ──┘ ──▶ pyLIQTR
106
+ ──▶ Qiskit
107
+ ```
108
+
109
+ A `QMatEntry` records:
110
+
111
+ - **where** the material came from (`SourceProvenance` — database, functional,
112
+ pseudopotential, code version, retrieval timestamp)
113
+ - **what** it looks like (`StructureMetadata` — formula, lattice, spacegroup)
114
+ - **how** the Hamiltonian is constructed (`BasisMetadata` — plane-wave cutoff,
115
+ basis size)
116
+ - **what the oracle costs** (`OracleMetadata` — LCU 1-norm λ, term breakdown,
117
+ SELECT/PREPARE circuit parameters, complexity annotations)
118
+ - **where it has been exported** (`ExportMetadata` — framework, format, status,
119
+ artifact path)
120
+
121
+ Every entry carries a deterministic `canonical_hash()` over its physically
122
+ meaningful fields so that benchmark results can be traced to a specific
123
+ Hamiltonian without re-deriving it.
124
+
125
+ ---
126
+
127
+ ## Who it is for
128
+
129
+ QMatBridge is written for:
130
+
131
+ - **Algorithm researchers** implementing block-encodings, qubitization circuits,
132
+ LCU decompositions, and related fault-tolerant primitives who need real
133
+ materials data without building a database-integration layer themselves.
134
+ - **Research software engineers** building quantum-chemistry / quantum-computing
135
+ pipelines who need a stable, citable intermediate format between the DFT world
136
+ and the circuit world.
137
+ - **Resource estimation groups** running systematic T-count and qubit studies
138
+ across a library of materials, who need reproducible, provenance-rich
139
+ Hamiltonian records.
140
+
141
+ If you are looking for a general materials informatics library, use
142
+ [pymatgen](https://pymatgen.org) or [ASE](https://wiki.fysik.dtu.dk/ase/).
143
+ QMatBridge is intentionally narrow: it is a bridge, not a database.
144
+
145
+ ---
146
+
147
+ ## Current scope
148
+
149
+ **In scope (v0.1):**
150
+
151
+ - Periodic bulk materials in a plane-wave basis
152
+ - First-quantized Hamiltonian representation (T + U + V in reciprocal space)
153
+ - LCU / qubitization oracle metadata
154
+ - JSON serialization with canonical entry hashes
155
+ - Adapter stubs for Materials Project and OQMD
156
+ - Zero required dependencies in the core schema
157
+
158
+ **Out of scope (for now):**
159
+
160
+ - Gaussian / LCAO / real-space basis sets
161
+ - Molecular (non-periodic) systems
162
+ - Excited-state or TDDFT Hamiltonians
163
+ - Live API calls (adapters are stubs until v0.2)
164
+ - Exporter implementations (planned v0.4)
165
+
166
+ ---
167
+
168
+ ## Design principles
169
+
170
+ **Provenance-first.** Every `QMatEntry` records the exact upstream source,
171
+ DFT functional, pseudopotential family, and retrieval timestamp. The
172
+ `canonical_hash()` method produces a stable SHA-256 digest over the physically
173
+ meaningful fields so that published results can be precisely reproduced.
174
+
175
+ **Open and interoperable.** The core schema has zero required dependencies.
176
+ Adapters for upstream databases and exporters for downstream frameworks are
177
+ optional extras — install only what you need. The NIR is designed to be
178
+ targeted by any adapter or consumed by any exporter without coupling the two.
179
+
180
+ **Benchmark-oriented.** Field names, norm conventions, and oracle metadata
181
+ types are chosen to align with the quantities reported in fault-tolerant
182
+ resource-estimation literature (LCU 1-norm λ, plane-wave count N,
183
+ rotation-precision bits b_r). The library should make it easy to reproduce
184
+ or extend a published benchmark, not just run a new one.
185
+
186
+ **Representation-aware.** `OracleMetadata` distinguishes between LCU,
187
+ qubitization, sparse-access, and tensor-hypercontraction decompositions.
188
+ `TermMetadata` stores per-physical-term norms so that methods that weight
189
+ T, U, and V differently can extract exactly the quantities they need.
190
+
191
+ **Community-driven.** The schema is a shared contract. Changes to
192
+ `QMatEntry`, `MaterialReference`, or `HamiltonianMetadata` require a public
193
+ discussion period and a minor-version bump. The governance model is documented
194
+ in [GOVERNANCE.md](GOVERNANCE.md); design discussions happen in GitHub
195
+ Discussions before any code is written.
196
+
197
+ ---
198
+
199
+ ## Getting started
200
+
201
+ ### Installation
202
+
203
+ ```bash
204
+ # from source (recommended until PyPI publication)
205
+ git clone https://github.com/rmsreis/qmatbridge.git
206
+ cd qmatbridge
207
+ pip install -e ".[dev]"
208
+ ```
209
+
210
+ Optional extras:
211
+
212
+ ```bash
213
+ pip install -e ".[mp]" # Materials Project adapter (mp-api, pymatgen)
214
+ pip install -e ".[oqmd]" # OQMD adapter (qmpy-rester)
215
+ pip install -e ".[openfermion]" # OpenFermion exporter
216
+ ```
217
+
218
+ ### Minimal example
219
+
220
+ ```python
221
+ from qmatbridge.schema import (
222
+ ExternalIdentifier, SourceProvenance,
223
+ LatticeMetadata, StructureMetadata,
224
+ BasisMetadata, HamiltonianMetadata,
225
+ MaterialReference, QMatEntry,
226
+ )
227
+ from qmatbridge.io import write_entry_json
228
+
229
+ provenance = SourceProvenance(
230
+ primary=ExternalIdentifier(
231
+ source="materials_project", identifier="mp-149"
232
+ ),
233
+ functional="PBE",
234
+ pseudopotential="PAW_PBE",
235
+ code="VASP",
236
+ )
237
+
238
+ structure = StructureMetadata(
239
+ formula_reduced="Si",
240
+ formula_unit_cell="Si2",
241
+ num_sites=2,
242
+ species=["Si", "Si"],
243
+ lattice=LatticeMetadata(
244
+ a=3.867, b=3.867, c=3.867,
245
+ alpha=60.0, beta=60.0, gamma=60.0,
246
+ spacegroup_number=227, spacegroup_symbol="Fd-3m",
247
+ ),
248
+ )
249
+
250
+ hamiltonian = HamiltonianMetadata(
251
+ num_electrons=8,
252
+ spin_polarized=False,
253
+ basis=BasisMetadata(type="plane_wave", cutoff_energy_ev=520.0),
254
+ num_bands=16,
255
+ )
256
+
257
+ entry = QMatEntry(
258
+ reference=MaterialReference(provenance=provenance, structure=structure),
259
+ hamiltonian=hamiltonian,
260
+ tags=["silicon", "benchmark"],
261
+ )
262
+
263
+ print(entry) # QMatEntry(formula='Si', source='materials_project', ...)
264
+ print(entry.canonical_hash()) # deterministic SHA-256
265
+
266
+ write_entry_json(entry, "silicon.json") # full nested JSON, 2-space indent
267
+ ```
268
+
269
+ See [`examples/minimal_entry.py`](examples/minimal_entry.py) for a fully
270
+ populated silicon entry including oracle metadata and term breakdown.
271
+
272
+ ---
273
+
274
+ ## Repository layout
275
+
276
+ ```text
277
+ qmatbridge/
278
+ ├── qmatbridge/
279
+ │ ├── schema.py # Neutral intermediate representation (NIR)
280
+ │ ├── io.py # JSON serialization utilities
281
+ │ └── adapters/
282
+ │ ├── materials_project.py # Materials Project adapter stub (v0.2 target)
283
+ │ └── oqmd.py # OQMD adapter stub (v0.3 target)
284
+ ├── docs/
285
+ │ ├── vision.md # Design rationale and architectural constraints
286
+ │ ├── adapters.md # Upstream adapter documentation
287
+ │ └── oracle-model.md # Oracle abstraction and export model
288
+ ├── examples/
289
+ │ └── minimal_entry.py # Silicon QMatEntry with full oracle metadata
290
+ ├── benchmarks/
291
+ │ └── README.md # Benchmark methodology and Tier-1 material plan
292
+ ├── planning/
293
+ │ └── initial_issues.md # Scoped GitHub issue set for v0.1–v0.4
294
+ └── .github/workflows/
295
+ └── python-package.yml # CI: lint (ruff + mypy) + tests on 3.10–3.12
296
+ ```
297
+
298
+ ---
299
+
300
+ ## Roadmap
301
+
302
+ ### v0.1 — Schema and scaffold *(current)*
303
+
304
+ - [x] Core dataclasses: `MaterialReference`, `HamiltonianMetadata`, `QMatEntry`
305
+ - [x] Oracle and term metadata: `OracleMetadata`, `TermMetadata`, `ExportMetadata`
306
+ - [x] JSON serialization via `qmatbridge.io`
307
+ - [x] Canonical entry hash (`QMatEntry.canonical_hash()`)
308
+ - [x] Adapter stubs: Materials Project, OQMD
309
+ - [x] CI: ruff, mypy, pytest on Python 3.10–3.12
310
+ - [ ] JSON round-trip regression fixtures
311
+ - [ ] Oracle convention vocabulary (`oracle_type`, `index_encoding`)
312
+
313
+ ### v0.2 — Materials Project live integration
314
+
315
+ - [ ] `fetch_structure_metadata_from_mp` and `fetch_hamiltonian_metadata_from_mp`
316
+ - [ ] Plane-wave count utility (`num_plane_waves_from_ecut`)
317
+ - [ ] Tier-1 benchmark material fixtures (Si, LiH, Fe, MgO, TiO₂)
318
+ - [ ] MkDocs documentation site on GitHub Pages
319
+
320
+ ### v0.3 — OPTIMADE, OQMD, and Alexandria adapters
321
+
322
+ - [ ] Generic OPTIMADE adapter (AFLOW, JARVIS, NOMAD, MC3D)
323
+ - [ ] OQMD live fetch
324
+ - [ ] Alexandria adapter (PBEsol / HSE06 / r²SCAN, ~4.5 M structures)
325
+ - [ ] Cross-database deduplication via shared ICSD numbers
326
+
327
+ ### v0.4 — Hamiltonian exporters
328
+
329
+ - [ ] OpenFermion `InteractionOperator` exporter
330
+ - [ ] First-quantized plane-wave Hamiltonian (raw NumPy arrays)
331
+ - [ ] LCU coefficient export for `qualtran` / `pyLIQTR`
332
+
333
+ ### v0.5 — Resource estimation hooks
334
+
335
+ - [ ] T-count and Toffoli estimation interface
336
+ - [ ] Qubit footprint estimator
337
+ - [ ] Direct integration with `qualtran` / `pyLIQTR` resource analysis
338
+
339
+ ### Beyond v0.5
340
+
341
+ - Gaussian and real-space basis support
342
+ - Defect and surface slab geometries
343
+ - Community adapter registry (entry-point group)
344
+
345
+ ---
346
+
347
+ ## Community
348
+
349
+ | Document | Purpose |
350
+ | --- | --- |
351
+ | [CONTRIBUTING.md](CONTRIBUTING.md) | How to open issues, propose schema changes, and submit pull requests |
352
+ | [GOVERNANCE.md](GOVERNANCE.md) | Roles, decision process, and release policy |
353
+ | [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) | Community standards and enforcement |
354
+ | [SECURITY.md](SECURITY.md) | Private vulnerability reporting |
355
+ | [SUPPORT.md](SUPPORT.md) | Where to ask questions vs. file bugs |
356
+ | [GitHub Discussions](https://github.com/rmsreis/qmatbridge/discussions) | Q&A, design proposals, and architecture discussions |
357
+
358
+ Contributions are welcome at any level — bug reports, adapter implementations,
359
+ documentation improvements, and benchmark additions. Please read
360
+ [CONTRIBUTING.md](CONTRIBUTING.md) and the [project vision](docs/vision.md)
361
+ before opening a large pull request.
362
+
363
+ ---
364
+
365
+ ## Citation
366
+
367
+ QMatBridge does not yet have a formal publication. If you use it in
368
+ academic work, please cite the repository directly:
369
+
370
+ ```bibtex
371
+ @software{qmatbridge,
372
+ author = {Reis, Roberto},
373
+ title = {{QMatBridge}: A bridge from classical materials databases to
374
+ first-quantized Hamiltonians for quantum simulation},
375
+ url = {https://github.com/rmsreis/qmatbridge},
376
+ version = {0.1.0},
377
+ year = {2026},
378
+ }
379
+ ```
380
+
381
+ A citable release and, if the project grows, a JOSS submission are planned
382
+ once the v0.2 Materials Project adapter is complete and the API is stable.
383
+
384
+ ---
385
+
386
+ ## License
387
+
388
+ MIT — see [LICENSE](LICENSE).