ffsim

Gates

Fermionic quantum computation gates. See State vectors and gates.

apply_diag_coulomb_evolution(vec, mat, time, ...)

Apply time evolution by a (rotated) diagonal Coulomb operator.

apply_fsim_gate(vec, theta, phi, ...[, ...])

Apply an fSim gate.

apply_fswap_gate(vec, target_orbs, norb, nelec)

Apply an FSWAP gate.

apply_givens_rotation(vec, theta, ...[, ...])

Apply a Givens rotation gate.

apply_hop_gate(vec, theta, target_orbs, ...)

Apply a hop gate.

apply_num_interaction(vec, theta, ...[, ...])

Apply a number interaction gate.

apply_num_num_interaction(vec, theta, ...[, ...])

Apply a number-number interaction gate.

apply_num_op_prod_interaction(vec, theta, ...)

Apply interaction gate for product of number operators.

apply_num_op_sum_evolution(vec, coeffs, ...)

Apply time evolution by a (rotated) linear combination of number operators.

apply_on_site_interaction(vec, theta, ...[, ...])

Apply an on-site interaction gate.

apply_orbital_rotation(vec, mat, norb, nelec, *)

Apply an orbital rotation to a vector.

apply_quad_ham_evolution(vec, mat, time, ...)

Apply time evolution by a quadratic Hamiltonian.

apply_tunneling_interaction(vec, theta, ...)

Apply a tunneling interaction gate.

Hamiltonians

Classes for representing Hamiltonians. See Hamiltonians.

DiagonalCoulombHamiltonian(one_body_tensor, ...)

A diagonal Coulomb Hamiltonian.

DoubleFactorizedHamiltonian(one_body_tensor, ...)

A Hamiltonian in the double-factorized representation.

MolecularHamiltonian(one_body_tensor, ...[, ...])

A molecular Hamiltonian.

MolecularHamiltonianSpinless(...[, constant])

A spinless molecular Hamiltonian.

SingleFactorizedHamiltonian(one_body_tensor, ...)

A Hamiltonian in the single-factorized representation.

Initialize cache

The init_cache function prepares ffsim to perform operations with given values of norb and nelec. Typically there is no need to call this function.

init_cache(norb, nelec)

Initialize cached objects.

The MolecularData class

The MolecularData class stores molecular integrals, geometry, energies, and other data. It can be saved to and loaded from JSON (lossless) and FCIDUMP (integrals only) formats.

MolecularData(*, core_energy, ...[, atom, ...])

Class for storing molecular data.

Operators

The FermionOperator class and functions to construct FermionOperators. See The FermionOperator class.

FermionAction(action, spin, orb)

A fermionic action.

FermionOperator(coeffs)

A fermionic operator.

ccsd_generator_restricted(t1, t2)

Restricted coupled cluster, singles and doubles (CCSD) generator.

ccsd_generator_unrestricted(t1, t2)

Unrestricted coupled cluster, singles and doubles (CCSD) generator.

cre(spin, orb)

Create a fermion.

cre_a(orb)

Create a fermion with spin alpha.

cre_b(orb)

Create a fermion with spin beta.

des(spin, orb)

Destroy a fermion.

des_a(orb)

Destroy a fermion with spin alpha.

des_b(orb)

Destroy a fermion with spin beta.

doubles_excitations_restricted(t2)

Restricted doubles excitations operator.

doubles_excitations_unrestricted(t2)

Unrestricted doubles excitations operator.

fermi_hubbard_1d(norb, tunneling, interaction, *)

One-dimensional Fermi-Hubbard model Hamiltonian.

fermi_hubbard_2d(norb_x, norb_y, tunneling, ...)

Two-dimensional Fermi-Hubbard model Hamiltonian on a square lattice.

number_operator(orb[, spin])

Occupation number operator.

s_minus_operator(norb)

Spin lowering operator.

s_plus_operator(norb)

Spin raising operator.

s_squared_operator(norb)

Total spin operator \(S^2\).

s_x_operator(norb)

Spin X operator.

s_y_operator(norb)

Spin Y operator.

s_z_operator(norb)

Spin Z operator.

singles_excitations_restricted(t1)

Restricted singles excitations operator.

singles_excitations_unrestricted(t1)

Unrestricted singles excitations operator.

uccsd_generator_restricted(t1, t2)

Restricted unitary coupled cluster, singles and doubles (UCCSD) generator.

uccsd_generator_unrestricted(t1, t2)

Unestricted unitary coupled cluster, singles and doubles (UCCSD) generator.

Protocols

Python protocols defined in ffsim. See Protocols.

SupportsApplyUnitary(*args, **kwargs)

An object that can apply a unitary transformation to a vector.

SupportsApproximateEquality(*args, **kwargs)

An object that can be compared approximately.

SupportsDiagonal(*args, **kwargs)

A linear operator whose diagonal entries can be returned.

SupportsFermionOperator(*args, **kwargs)

An object that can be converted to a FermionOperator.

SupportsLinearOperator(*args, **kwargs)

An object that can be converted to a SciPy LinearOperator.

SupportsTrace(*args, **kwargs)

A linear operator whose trace can be computed.

apply_unitary(vec, obj, norb, nelec[, copy])

Apply a unitary transformation to a vector.

approx_eq(obj, other[, rtol, atol])

Return whether two objects are approximately equal.

diag(obj, norb, nelec)

Return the diagonal entries of the linear operator.

fermion_operator(obj)

Return a FermionOperator representing the object.

linear_operator(obj, norb, nelec)

Return a SciPy LinearOperator representing the object.

trace(obj, norb, nelec)

Return the trace of the linear operator.

States

Functions for creating and manipulating fermionic quantum states. See State vectors and gates.

BitstringType(*values)

Enumeration for indicating the data type of bitstrings.

ProductStateSum(coeffs, states)

A linear combination of product states.

ReducedDensityMatrix(one_rdm, two_rdm)

Class to store one- and two-body reduced density matrices.

Spin(*values)

Enumeration for indicating alpha, beta, or both spins.

StateVector(vec, norb, nelec)

A state vector in the FCI representation.

addresses_to_strings(addresses, norb, nelec)

Convert state vector addresses to bitstrings.

dim(norb, nelec)

Get the dimension of the FCI space.

dims(norb, nelec)

Get the dimensions of the FCI space.

expectation_one_body_power(one_rdm, ...[, power])

Expectation of power of one-body operator w.r.t.

expectation_one_body_product(one_rdm, ...)

Expectation of product of one-body operators w.r.t.

hartree_fock_state(norb, nelec)

Return the Hartree-Fock state.

rdms(vec, norb, nelec, *[, rank, ...])

Return the reduced density matrices of a state vector.

sample_slater(norb, occupied_orbitals[, ...])

Collect samples of electronic configurations from a Slater determinant.

sample_state_vector(vec, *[, norb, nelec, ...])

Sample bitstrings from a state vector.

slater_determinant(norb, occupied_orbitals)

Return a Slater determinant.

slater_determinant_amplitudes(bitstrings, ...)

Compute state vector amplitudes for a Slater determinant.

slater_determinant_rdms(norb, occupied_orbitals)

Return the reduced density matrices of a Slater determinant.

spin_square(fcivec, norb, nelec)

Expectation value of spin squared operator on a state vector.

spinful_to_spinless_rdm1(mat_a, mat_b)

Convert a spinful 1-RDM to a spinless 1-RDM.

spinful_to_spinless_rdm2(mat_aa, mat_ab, mat_bb)

Convert a spinful 2-RDM to a spinless 2-RDM.

spinful_to_spinless_vec(vec, norb, nelec)

Convert a spinful state vector to a spinless state vector.

strings_to_addresses(strings, norb, nelec)

Convert bitstrings to state vector addresses.

Hamiltonian simulation

Functions to approximate time evolution by Hamiltonians.

simulate_qdrift_double_factorized(vec, ...)

Double-factorized Hamiltonian simulation via qDRIFT.

simulate_trotter_diag_coulomb_split_op(vec, ...)

Diagonal Coulomb Hamiltonian simulation using split-operator method.

simulate_trotter_double_factorized(vec, ...)

Double-factorized Hamiltonian simulation using Trotter-Suzuki formula.

Variational ansatzes

Variational ansatz classes and related functions. See Variational ansatzes.

GivensAnsatzOp(norb, interaction_pairs, ...)

A Givens rotation ansatz operator.

HopGateAnsatzOperator(norb, ...[, ...])

A hop gate ansatz operator.

NumNumAnsatzOpSpinBalanced(norb, ...)

A number-number interaction ansatz operator.

UCCSDOpRestricted(t1, t2[, ...])

Restricted unitary coupled cluster, singles and doubles operator.

UCCSDOpRestrictedReal(t1, t2[, ...])

Real-valued restricted unitary coupled cluster, singles and doubles operator.

UCCSDOpUnrestricted(t1, t2[, ...])

Unrestricted unitary coupled cluster, singles and doubles operator.

UCCSDOpUnrestrictedReal(t1, t2[, ...])

Real unrestricted unitary coupled cluster, singles and doubles operator.

UCJAnglesOpSpinBalanced(norb, ...[, ...])

A spin-balanced UCJ operator parameterized by gate rotation angles.

UCJOpSpinBalanced(diag_coulomb_mats, ...[, ...])

A spin-balanced unitary cluster Jastrow operator.

UCJOpSpinless(diag_coulomb_mats, ...[, ...])

A spinless unitary cluster Jastrow operator.

UCJOpSpinUnbalanced(diag_coulomb_mats, ...)

A spin-unbalanced unitary cluster Jastrow operator.

multireference_state(hamiltonian, ...[, root])

Compute multireference energy and state.

multireference_state_prod(hamiltonian, ...)

Compute multireference state for a product ansatz operator.

optimize_orbitals(rdm, hamiltonian, *[, ...])

Find orbitals that minimize the energy of a pair of one- and two-RDMs.