Chemistry
problems
Classes:
Name | Description |
---|---|
FermionHamiltonianProblem |
Defines an electronic-structure problem using a Fermionic operator and electron count. |
FermionHamiltonianProblem
FermionHamiltonianProblem(
fermion_hamiltonian: FermionOperator,
n_particles: tuple[int, int],
n_orbitals: Optional[int] = None,
)
Defines an electronic-structure problem using a Fermionic operator and electron count.
Can also be constructed from a MolecularData
object using the from_molecule
method.
Attributes:
Name | Type | Description |
---|---|---|
fermion_hamiltonian |
FermionOperator
|
The fermionic hamiltonian of the problem. Assumed to be in the block-spin labeling. |
n_orbitals |
int
|
Number of spatial orbitlas. |
n_alpha |
int
|
Number of alpha particles. |
n_beta |
int
|
Number of beta particles. |
n_particles |
tuple[int, int]
|
Number of alpha and beta particles. |
Initializes a FermionHamiltonianProblem
from the fermion hamiltonian, number
of alpha and beta particles, and optionally the number of orbitals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fermion_hamiltonian
|
FermionHamiltonianProblem
|
The fermionic hamiltonian of the problem. Assumed to be in the block-spin labeling. |
required |
n_particles
|
tuple[int, int]
|
Number of alpha and beta particles. |
required |
n_orbitals
|
int
|
Number of spatial orbitals. If not specified,
the number is inferred from |
None
|
Methods:
Name | Description |
---|---|
from_molecule |
Constructs a |
fermion_hamiltonian
fermion_hamiltonian = fermion_hamiltonian
n_orbitals
n_orbitals = min_n_orbitals
n_particles
n_particles = n_particles
occupied
occupied: list[int]
Indices list of occupied alpha and beta particles.
occupied_alpha
occupied_alpha: list[int]
Indices list of occupied alpha particles.
occupied_beta
occupied_beta: list[int]
Indices list of occupied beta particles.
virtual
virtual: list[int]
Indices list of virtual alpha and beta particles.
virtual_alpha
virtual_alpha: list[int]
Indices list of virtual alpha particles.
virtual_beta
virtual_beta: list[int]
Indices list of virtual beta particles.
from_molecule
from_molecule(
molecule: MolecularData,
first_active_index: int = 0,
remove_orbitlas: Optional[Sequence[int]] = None,
op_compression_tol: float = 1e-13,
) -> FermionHamiltonianProblem
Constructs a FermionHamiltonianProblem
from a molecule data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
molecule
|
MolecularData
|
The molecule data. |
required |
first_active_index
|
int
|
The first active index, indicates all prior indices are freezed. |
0
|
remove_orbitlas
|
Sequence[int]
|
Active indices to be removed. |
None
|
op_compression_tol
|
float
|
Tolerance for trimming the fermion operator. |
1e-13
|
Returns:
Type | Description |
---|---|
FermionHamiltonianProblem
|
The fermion hamiltonian problem. |
mapping
Classes:
Name | Description |
---|---|
FermionToQubitMapper |
Mapper between fermionic operators to qubits operators, using one of the supported |
MappingMethod |
Mapping methods from fermionic operators to qubits operators. |
FermionToQubitMapper
FermionToQubitMapper(method: MappingMethod = JORDAN_WIGNER)
Mapper between fermionic operators to qubits operators, using one of the supported
mapping methods (see MappingMethod
).
Attributes:
Name | Type | Description |
---|---|---|
method |
MappingMethod
|
The mapping method. |
Initializes a FermionToQubitMapper
object using the specified method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
MappingMethod
|
The mapping method. |
JORDAN_WIGNER
|
Methods:
Name | Description |
---|---|
get_num_qubits |
Gets the number of qubits after mapping the given problem into qubits space. |
map |
Maps the given fermionic operator to a qubits operator using the mapper's |
method
method = method
get_num_qubits
get_num_qubits(problem: FermionHamiltonianProblem) -> int
Gets the number of qubits after mapping the given problem into qubits space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
FermionHamiltonianProblem
|
The fermion problem. |
required |
Returns:
Type | Description |
---|---|
int
|
The number of qubits. |
map
map(
fermion_op: FermionOperator, *args: Any, **kwargs: Any
) -> QubitOperator
Maps the given fermionic operator to a qubits operator using the mapper's configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fermion_op
|
FermionOperator
|
A fermionic operator. |
required |
*args
|
Any
|
Extra parameters which are ignored, may be used in subclasses. |
()
|
**kwargs
|
Any
|
Extra parameters which are ignored, may be used in subclasses. |
{}
|
Returns:
Type | Description |
---|---|
QubitOperator
|
The mapped qubits operator. |
MappingMethod
Bases: StrEnum
Mapping methods from fermionic operators to qubits operators.
Attributes:
Name | Type | Description |
---|---|---|
BRAVYI_KITAEV |
|
|
JORDAN_WIGNER |
|
BRAVYI_KITAEV
BRAVYI_KITAEV = 'bk'
JORDAN_WIGNER
JORDAN_WIGNER = 'jw'
z2_symmetries
Classes:
Name | Description |
---|---|
Z2SymTaperMapper |
Mapper between fermionic operators to qubits operators, using one of the supported |
Z2SymTaperMapper
Z2SymTaperMapper(
generators: Sequence[QubitOperator],
x_ops: Sequence[QubitOperator],
method: MappingMethod = JORDAN_WIGNER,
sector: Optional[Sequence[int]] = None,
tol: float = 1e-14,
)
Bases: FermionToQubitMapper
Mapper between fermionic operators to qubits operators, using one of the supported
mapping methods (see MappingMethod
), and taking advantage of Z2 symmetries in
order to taper off qubits.
Attributes:
Name | Type | Description |
---|---|---|
method |
MappingMethod
|
The mapping method. |
generators |
tuple[QubitOperator, ...]
|
Generators representing the Z2 symmetries. |
x_ops |
tuple[QubitOperator, ...]
|
Single-qubit X operations, such that each operation anti-commutes with its matching generator and commutes with all other generators. |
Initializes a Z2SymTaperMapper
object from the given configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
generators
|
Sequence[QubitOperator]
|
Generators representing the Z2 symmetries. |
required |
x_ops
|
Sequence[QubitOperator]
|
Single-qubit X operations, such that each operation anti-commutes with its matching generator and commutes with all other generators. |
required |
method
|
MappingMethod
|
The mapping method. |
JORDAN_WIGNER
|
sector
|
Optional[Sequence[int]]
|
(Sequence[int]): Symmetry sector coefficients, each is 1 or -1. If not specified, all coefficients defaults to 1. |
None
|
tol
|
float
|
Tolerance for trimming off terms. |
1e-14
|
Methods:
Name | Description |
---|---|
from_problem |
Initializes a |
get_num_qubits |
Gets the number of qubits after mapping the given problem into qubits space. |
map |
Maps the given fermionic operator to qubits operator by using the |
set_sector |
Sets the symmetry sector coefficients. |
generators
generators: tuple[QubitOperator, ...]
Generators representing the Z2 symmetries.
x_ops
x_ops: tuple[QubitOperator, ...]
Single-qubit X operations, such that each operation anti-commutes with its matching generator and commutes with all other generators.
from_problem
from_problem(
problem: FermionHamiltonianProblem,
method: MappingMethod = JORDAN_WIGNER,
sector_from_hartree_fock: bool = True,
tol: float = 1e-14,
) -> Z2SymTaperMapper
Initializes a Z2SymTaperMapper
object from a fermion problem (i.e. computing
the Z2 symmetries from the problem definition).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
FermionHamiltonianProblem
|
The fermion problem. |
required |
method
|
MappingMethod
|
The mapping method. |
JORDAN_WIGNER
|
sector_from_hartree_fock
|
bool
|
Whether to compute the symmetry sector coefficients according to the Hartree-Fock state. |
True
|
tol
|
float
|
Tolerance for trimming off terms. |
1e-14
|
Returns:
Type | Description |
---|---|
Z2SymTaperMapper
|
The Z2 symmetries taper mapper. |
get_num_qubits
get_num_qubits(problem: FermionHamiltonianProblem) -> int
Gets the number of qubits after mapping the given problem into qubits space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
FermionHamiltonianProblem
|
The fermion problem. |
required |
Returns:
Type | Description |
---|---|
int
|
The number of qubits. |
map
map(
fermion_op: FermionOperator,
*args: Any,
is_invariant: bool = False,
**kwargs: Any
) -> QubitOperator
Maps the given fermionic operator to qubits operator by using the mapper's method, and subsequently by tapering off qubits according to Z2 symmetries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fermion_op
|
FermionOperator
|
A fermionic operator. |
required |
is_invariant
|
bool
|
If |
False
|
Returns:
Type | Description |
---|---|
QubitOperator
|
The mapped qubits operator. |
set_sector
set_sector(sector: Sequence[int]) -> None
Sets the symmetry sector coefficients.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sector
|
Sequence[int]
|
(Sequence[int]): Symmetry sector coefficients, each is 1 or -1. |
required |
hartree_fock
Functions:
Name | Description |
---|---|
get_hf_fermion_op |
Constructs a fermion operator that creates the Hartree-Fock reference state in |
get_hf_state |
Computes the qubits state after applying the Hartree-Fock operator defined by the |
get_hf_fermion_op
get_hf_fermion_op(
problem: FermionHamiltonianProblem,
) -> FermionOperator
Constructs a fermion operator that creates the Hartree-Fock reference state in block-spin ordering.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
FermionHamiltonianProblem
|
The fermion problem. The Hartree-Fock fermion operator depends only on the number of spatial orbitals and the number of alpha and beta particles. |
required |
Returns:
Type | Description |
---|---|
FermionOperator
|
The Hartree-Fock fermion operator. |
get_hf_state
get_hf_state(
problem: FermionHamiltonianProblem,
mapper: FermionToQubitMapper,
) -> list[bool]
Computes the qubits state after applying the Hartree-Fock operator defined by the given problem and mapper.
The Qmod function prepare_basis_state
can be used on the returned value to
allocate and initialize the qubits array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
FermionHamiltonianProblem
|
The fermion problem. |
required |
mapper
|
FermionToQubitMapper
|
The mapper from fermion operator to qubits operator. |
required |
Returns:
Type | Description |
---|---|
list[bool]
|
The qubits state, given as a list of boolean values for each qubit. |
ucc
Functions:
Name | Description |
---|---|
get_excitations |
Gets all the possible excitations of the given problem according to the |
get_ucc_hamiltonians |
Computes the UCC hamiltonians of the given problem in the desired excitations, |
get_excitations
get_excitations(
problem: FermionHamiltonianProblem, num_excitations: int
) -> set[tuple[tuple[int, ...], tuple[int, ...]]]
Gets all the possible excitations of the given problem according to the given number of excitations, preserving the particles spin.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
FermionHamiltonianProblem
|
The fermion problem. |
required |
num_excitations
|
int
|
Number of excitations. |
required |
Returns:
Type | Description |
---|---|
set[tuple[tuple[int, ...], tuple[int, ...]]]
|
A set of all possible excitations, specified as a pair of source and target indices. |
get_ucc_hamiltonians
get_ucc_hamiltonians(
problem: FermionHamiltonianProblem,
mapper: FermionToQubitMapper,
excitations: Union[int, Sequence[int]],
) -> list[SparsePauliOp]
Computes the UCC hamiltonians of the given problem in the desired excitations, using the given mapper.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
problem
|
FermionHamiltonianProblem
|
The fermion problem. |
required |
mapper
|
FermionToQubitMapper
|
The mapper from fermion to qubits operators. |
required |
excitations
|
(int, Sequence[int])
|
A single desired excitation or an excitations list. |
required |
Returns:
Type | Description |
---|---|
list[SparsePauliOp]
|
The UCC hamiltonians. |