Hamiltonian Module
Hamiltonian construction from one-body and two-body integrals.
Assembles the second-quantized electronic Hamiltonian: H = Σ_{pq} h_{pq} a†_p a_q + ½ Σ_{pqrs} ⟨pq|rs⟩ a†_p a†_q a_s a_r and encodes it as a sum of Pauli strings using any provided encoding function. The function handles one-body terms, two-body terms, coefficient combination, and zero-term dropping.
Types
| Type | Description |
|
A function type that encodes a ladder operator into qubit Pauli strings. |
|
|
A two-body exchange term with indices i, j, k, l, representing ⟨ij|kl⟩ a†_i a†_j a_l a_k. |
|
|
A precomputed encoding skeleton separating Pauli structure from integral coefficients. |
|
|
Discriminated union representing a term in the Hamiltonian. |
|
|
A one-body overlap term with indices i and j, representing h_{ij} a†_i a_j. |
|
|
A single entry in a precomputed Hamiltonian skeleton. |
|
|
A pre-computed Pauli term with its signature cached. |
Functions and values
| Function or value |
Description
|
Full Usage:
applyCoefficients skeleton coefficientFactory
Parameters:
HamiltonianSkeleton
-
The precomputed skeleton from computeHamiltonianSkeleton.
coefficientFactory : string -> Complex option
-
A function returning Some(coefficient) for a given comma-separated index key, or None to skip.
Returns: PauliRegisterSequence
A PauliRegisterSequence representing the encoded Hamiltonian.
|
Apply integral coefficients to a precomputed skeleton.
Accumulates coefficients directly into a dictionary keyed by
pre-computed Pauli signatures. No Pauli algebra, no intermediate
Typical runtime is under 10 ms for systems up to ~20 qubits, making PES scans over hundreds of geometries essentially free after the one-time skeleton build.
|
Full Usage:
computeHamiltonian coefficientFactory n
Parameters:
string -> Complex option
-
A function that returns Some(coefficient) for a given comma-separated index key (e.g., "0,1" for one-body, "0,1,2,3" for two-body), or None if the term should be skipped.
n : uint32
-
The number of qubits/modes in the system.
Returns: PauliRegisterSequence
A PauliRegisterSequence representing the encoded Hamiltonian.
|
Compute a qubit Hamiltonian from integral coefficients using Jordan-Wigner encoding. Iterates over all one-body (i,j) and two-body (i,j,k,l) index combinations, retrieves coefficients from the factory function, and encodes non-zero terms using the Jordan-Wigner transformation. Keys are formatted as comma-separated indices: "i,j" for one-body and "i,j,k,l" for two-body terms.
|
Full Usage:
computeHamiltonianParallel coefficientFactory n
Parameters:
string -> Complex option
n : uint32
Returns: PauliRegisterSequence
|
Parallel version of computeHamiltonian (Jordan-Wigner).
|
Full Usage:
computeHamiltonianSkeleton encode n
Parameters:
EncoderFn
-
The encoding function.
n : uint32
-
The number of qubits/modes.
Returns: HamiltonianSkeleton
A HamiltonianSkeleton containing precomputed Pauli
structures for all one-body and two-body operator products.
|
Precompute the Pauli skeleton for a given encoding and system size.
Uses
|
Full Usage:
computeHamiltonianSkeletonFor encode coefficientFactory n
Parameters:
EncoderFn
-
The encoding function.
coefficientFactory : string -> Complex option
-
A function that returns Some for keys to include. Only the presence/absence matters; coefficient values are ignored.
n : uint32
-
The number of qubits/modes.
Returns: HamiltonianSkeleton
A HamiltonianSkeleton containing precomputed Pauli
structures only for index combinations where the factory returns Some.
|
Precompute a sparse Pauli skeleton using a coefficient factory to discover active keys.
For molecules, typically only 5–10% of possible index combinations have non-zero integrals. This variant precomputes only those entries, giving a proportional speedup over the full computeHamiltonianSkeleton. Use when all geometries in a scan share the same sparsity pattern (same basis set → same non-zero integral indices).
|
Full Usage:
computeHamiltonianWith encode coefficientFactory n
Parameters:
EncoderFn
-
The encoding function to transform ladder operators to Pauli strings.
coefficientFactory : string -> Complex option
-
A function that returns Some(coefficient) for a given comma-separated index key (e.g., "0,1" for one-body, "0,1,2,3" for two-body), or None if the term should be skipped.
n : uint32
-
The number of qubits/modes in the system.
Returns: PauliRegisterSequence
A PauliRegisterSequence representing the encoded Hamiltonian.
|
Compute a qubit Hamiltonian from integral coefficients using any encoding. Generic version that accepts any fermion-to-qubit encoding function. Useful for comparing different encodings (Jordan-Wigner, Bravyi-Kitaev, etc.) on the same Hamiltonian. Keys are formatted as comma-separated indices: "i,j" for one-body and "i,j,k,l" for two-body terms.
|
Full Usage:
computeHamiltonianWithParallel encode coefficientFactory n
Parameters:
EncoderFn
-
The encoding function to transform ladder operators to Pauli strings.
coefficientFactory : string -> Complex option
-
A function that returns Some(coefficient) for a given comma-separated index key.
n : uint32
-
The number of qubits/modes in the system.
Returns: PauliRegisterSequence
A PauliRegisterSequence representing the encoded Hamiltonian.
|
Parallel version of computeHamiltonianWith. Distributes encoding work across available CPU cores using Array.Parallel. The n² one-body and n⁴ two-body index loops are parallelised. Coefficient lookups remain sequential (cheap), while the expensive encode-and-multiply steps run across all cores. Produces results identical to the sequential computeHamiltonianWith.
|