hamiltonians-and-chemistry
Build deterministic lattice, jellium, plane-wave, and molecular Hamiltonian inputs; preserve chemistry data contracts; and route mapping or external chemistry work safely.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- hamiltonians-and-chemistry
- license
- Apache 2.0
- metadata
- { "parent": "openfermion", "disco-role": "operating" }
- description
- Build deterministic lattice, jellium, plane-wave, and molecular Hamiltonian inputs; preserve chemistry data contracts; and route mapping or external chemistry work safely.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md11.0 KB
- 参考文档references/data-formats.md7.7 KB
- 参考文档references/troubleshooting.md9.4 KB
- 参考文档references/workflows.md9.5 KB
- 脚本scripts/build_tiny_hamiltonian.py6.9 KB
03 SKILL.md 正文
Hamiltonians and chemistry
Load this skill when the task is about choosing or constructing a model Hamiltonian, a discretization, or chemistry metadata. It covers the symbolic input side of OpenFermion. It does not run a quantum-chemistry package, query PubChem, download a dataset, or choose a qubit mapping for the caller.
Decide the model before calling an API
- Hubbard/lattice model: choose the site shape, boundary condition,
spinless versus spinful convention, particle-hole shift, and units of the
coefficients. Use
fermi_hubbardfor the standard 2-D square model, orFermiHubbardModelplusHubbardSquareLatticefor multiple degrees of freedom and typed edges. - Uniform electron gas: choose a
Grid(dimension, point counts, and real-space cell), spin convention, plane-wave versus dual basis, cutoff, and whether a Madelung constant is actually wanted. Usejellium_model. - Nuclei in a periodic cell: validate a geometry list of
(element, coordinates)tuples against the grid dimension, then useplane_wave_hamiltonian. Coordinates are in atomic units for plane-wave constructors; do not silently passMolecularData's Angstrom geometry. - Molecular electronic structure: construct or load
MolecularDatawith geometry, basis, multiplicity, and charge. Metadata alone is not an integral or energy calculation. Callget_molecular_hamiltonian()only after the required integral data exists. - Reduced electronic Hamiltonian: start from an
InteractionOperator, pass a positive electron count tomake_reduced_hamiltonian, and record that the resulting two-body tensor is particle-number dependent.
The full signatures, index conventions, tensor shapes, and output contracts are in api-reference.md. Reusable recipes and decision gates are in workflows.md.
Minimal deterministic entry points
For a bounded smoke check, run the bundled build_tiny_hamiltonian.py helper by its resolved skill path from any working directory:
python <skill-directory>/scripts/build_tiny_hamiltonian.py --model hubbard --periodic
python <skill-directory>/scripts/build_tiny_hamiltonian.py --model molecular
The helper constructs a 2x2 spinful Hubbard operator (no file or network
access) or an H2 MolecularData metadata object. Its JSON output reports
choices and small structural facts, not an energy or a chemistry result.
Hubbard construction contract
fermi_hubbard(x_dimension, y_dimension, tunneling, coulomb, ...) returns a
FermionOperator. A spinful x * y grid has 2*x*y modes; a spinless grid
has x*y. Even modes are spin-up and odd modes are spin-down for the standard
constructor. Hopping is -t; chemical potential contributes -mu*n; in the
spinful case the magnetic field shifts up/down occupations with opposite
signs. The default is periodic and spinful, so state those flags explicitly
in reproducible work.
particle_hole_symmetry=True replaces each number factor by n - 1/2. This
changes both constants and interaction terms; it is not a cosmetic label.
For spinless models magnetic_field is ignored. Small dimensions and periodic
boundaries have deduplication behavior, so do not infer edge counts by
multiplying a generic degree by the number of sites; inspect the operator or
lattice iterator.
For a general model, HubbardSquareLattice exposes onsite, neighbor,
horizontal_neighbor, vertical_neighbor, and diagonal_neighbor edge types.
FermiHubbardModel parameter tuples are (edge_type, (dof_a, dof_b), coefficient[, spin_pairs]) for tunneling/interactions and (dof, coefficient)
for potentials. Validate same-dof onsite tunneling and same-spin self
interactions before constructing a large model.
Chemistry data lifecycle
MolecularData stores a molecule definition and calculation results in an
HDF5-backed record. Geometry is a list of (symbol, (x, y, z)) tuples in
Angstroms; basis is a basis-set label; multiplicity is a positive integer;
and charge is the total charge. The constructor derives a name, atom/proton
metadata, and electron count, but leaves orbitals, integrals, nuclear
repulsion, and method energies unset until supplied or loaded. save() writes
the record to filename + ".hdf5"; it is not needed for metadata-only use.
Use get_integrals() to require both one- and two-electron tensors. Use
get_molecular_hamiltonian() to obtain an InteractionOperator with the
nuclear-repulsion constant and spin-orbital tensors; optional active-space
indices are spatial-orbital indices and core adjustment changes the constant.
MissingCalculationError is the expected signal for absent computed data.
See data-formats.md before handing tensors to a
transform or resource-estimation workflow.
PubChem (geometry_from_pubchem) is an optional, network-dependent workflow;
the core distribution declares pubchempy, but the function imports it only
when called. structure is None, "2d", or "3d". PySCF and other chemistry
backends are separate plugins, not core constructors. ASE/JAX and the
resources extra are optional boundaries: detect and document their
installation and backend requirements, and do not claim that metadata
construction executed them.
Handoff and routing
After building a FermionOperator or InteractionOperator, route qubit
mapping, normal ordering, transforms, and operator-family conversion to
operators-and-transforms. Route circuit
synthesis or time evolution to the circuits sibling. Route sparse matrices,
eigensolvers, RDM reconstruction, or measurements to the analysis sibling.
This skill may provide the source operator and its mode/tensor contract, but it
does not silently map, simulate, diagonalize, or run an external plugin.
Before handoff, record:
- model, basis, units, geometry/grid, and all non-default flags;
- mode count or tensor shape and index convention;
- whether constants are included and whether a cutoff was applied;
- whether data is metadata, loaded integrals, or a computed method result;
- optional dependency, network, plugin, and workload boundaries; and
- the intended next sibling and requested acceptance check.
Use troubleshooting.md for actionable recovery of import, geometry, shape, file, plugin, and model-flag failures.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).