class ActiveSpaceTransformer(num_electrons, num_spatial_orbitals, active_orbitals=None)[source]#

Bases: BaseTransformer

The Active-Space reduction.

The reduction is done by computing the inactive Fock operator which is defined as \(F^I_{pq} = h_{pq} + \sum_i 2 g_{iipq} - g_{iqpi}\) and the inactive energy which is given by \(E^I = \sum_j h_{jj} + F ^I_{jj}\), where \(i\) and \(j\) iterate over the inactive orbitals. By using the inactive Fock operator in place of the one-electron integrals the description of the active space contains an effective potential generated by the inactive electrons. Therefore, this method permits the exclusion of non-core electrons while retaining a high-quality description of the system.

For more details on the computation of the inactive Fock operator refer to

The active space can be configured in one of the following ways through the initializer:

  • when only num_electrons and num_spatial_orbitals are specified, these integers indicate the number of active electrons and orbitals, respectively. The active space will then be chosen around the Fermi level resulting in a unique choice for any pair of numbers. Nonetheless, the following criteria must be met:

    1. the remaining number of inactive electrons must be a positive, even number

    2. the number of active orbitals must not exceed the total number of orbitals minus the number of orbitals occupied by the inactive electrons

  • when, num_electrons is a tuple, this must indicate the number of alpha- and beta-spin electrons, respectively. The same requirements as listed before must be met.

  • finally, it is possible to select a custom set of active orbitals via their indices using active_orbitals. This allows selecting an active space which is not placed around the Fermi level as described in the first case, above. When using this keyword argument, the following criteria must be met in addition to the ones listed above:

    1. the length of active_orbitals must be equal to num_spatial_orbitals. Note, that we do not infer the number of active orbitals from this list of indices!

    2. when using a tuple of lists to indicate the alpha- and beta-spin orbital indices separately, both lists must fulfill the previous criterion.

    3. the largest orbital index may not exceed the available num_spatial_orbitals.

If you want to apply this transformer to a Hamiltonian outside of a Problem instance, you need to prepare the active space by providing the total system size information which would normally be extracted from the Problem object. You can do this like so:

# assuming you have the total Hamiltonian of your system available:
total_hamiltonian = ElectronicEnergy(...)

# now you want to reduce it to an active space of 2 electrons in 2 orbitals
transformer = ActiveSpaceTransformer(2, 2)

# assuming that your total system size is 10 electrons in 10 orbitals:
transformer.prepare_active_space(10, 10)

# after preparation, you can now transform only your Hamiltonian like so
reduced_hamiltonian = transformer.transform_hamiltonian(total_hamiltonian)


  • M. Rossmannek, P. Barkoutsos, P. Ollitrault, and I. Tavernelli, arXiv:2009.01872 (2020).


the inactive Fock operator. Setting this attribute allows you to enforce a custom reference operator to be used during transform_hamiltonian().


the inactive energy. Setting this attribute allows you to enforce a custom reference energy to be used during transform_hamiltonian().

  • num_electrons (int | tuple[int, int]) -- The number of active electrons. If this is a tuple, it represents the number of alpha- and beta-spin electrons, respectively. If this is a number, it is interpreted as the total number of active electrons, should be even, and implies that the number of alpha and beta electrons equals half of this value, respectively.

  • num_spatial_orbitals (int) -- The number of active orbitals.

  • active_orbitals (list[int] | tuple[list[int], list[int]] | None) -- A single or pair of lists of indices specifying the spatial orbitals of the active space. This argument must match with the remaining arguments and should only be used to enforce an active space that is not chosen purely around the Fermi level.


QiskitNatureError -- if an invalid configuration is provided.



Returns the BasisTransformer mapping from the total to the active space.


Returns the active electronic density.



Gets the active space density-component of the provided ElectronicIntegrals.


total_density (ElectronicIntegrals) -- the density in the total orbital space.


The active space component density obtained via active_space.

রিটার্ন টাইপ:


prepare_active_space(total_num_electrons, total_num_spatial_orbitals, *, occupation_alpha=None, occupation_beta=None)[source]#

Prepares the active space.

This method must be called manually when using this transformer on a hamiltonian outside of a problem instance. In all other cases, the information required here is extracted from the problem automatically.

  • total_num_electrons (int | tuple[int, int]) -- the total number of electrons in the system represented by the hamiltonian which is to be transformed. If this is a tuple of integers, it encodes the number of alpha- and beta-spin electrons separately. Otherwise the integer value is assumed to indicate the sum of these two numbers.

  • total_num_spatial_orbitals (int) -- the total number of spatial orbitals in the system represented by the hamiltonian which is to be transformed.

  • occupation_alpha (list[float] | ndarray | None) -- the occupation of the alpha-spin orbitals. If omitted, this information is inferred from the required arguments.

  • occupation_beta (list[float] | ndarray | None) -- the occupation of the beta-spin orbitals. If omitted, this information is inferred from the required arguments.


QiskitNatureError -- if any of the requirements for a valid active space configuration (documented in the class docstring) are not met.


Transforms one BaseProblem into another.


problem (BaseProblem) -- the problem to be transformed.


A new BaseProblem instance.

রিটার্ন টাইপ:



Transforms one Hamiltonian into another.


hamiltonian (Hamiltonian) -- the hamiltonian to be transformed.


A new Hamiltonian instance.

রিটার্ন টাইপ: