BasisTransformer#
- class BasisTransformer(initial_basis, final_basis, coefficients)[source]#
Bases:
BaseTransformer
A transformer to map from one basis to another.
Since problems have a basis associated with them (e.g. the
qiskit_nature.second_q.problems.ElectronicBasis
in the case of theqiskit_nature.second_q.problems.ElectronicStructureProblem
), this transformer can be used to map from oneinitial_basis
to anotherfinal_basis
.For example, this is how you can create an AO-to-MO transformer for an
qiskit_nature.second_q.problems.ElectronicStructureProblem
:# assuming you have the transformation coefficients from somewhere ao2mo_coeff, ao2mo_coeff_b = ... from qiskit_nature.second_q.operators import ElectronicIntegrals from qiskit_nature.second_q.problems import ElectronicBasis from qiskit_nature.second_q.transformers import BasisTransformer transformer = BasisTransformer( ElectronicBasis.AO, ElectronicBasis.MO, ElectronicIntegrals.from_raw_integrals(ao2mo_coeff, h1_b=ao2mo_coeff_b), ) problem_MO = transformer.transform(problem_AO)
- initial_basis#
the initial basis from which to map away from.
- final_basis#
the final basis into which to map into.
- coefficients#
the coefficients which transform from the initial to the final basis.
- Parameters:
initial_basis (ElectronicBasis) – the initial basis from which to map away from.
final_basis (ElectronicBasis) – the final basis into which to map into.
coefficients (PolynomialTensor | ElectronicIntegrals) – the coefficients which transform from the initial to the final basis.
Methods
- invert()[source]#
Invert the transformer to do the reversed transformation.
- Returns:
A new
BasisTransformer
mapping fromfinal_basis
toinitial_basis
.- Return type:
- transform(problem)[source]#
Transforms one
BaseProblem
into another. This may affect the size of the Hilbert space.- Parameters:
problem (BaseProblem) – the problem to be transformed.
- Raises:
NotImplementedError – when an unsupported problem type is provided.
- Returns:
A new BaseProblem instance.
- Return type:
- transform_electronic_integrals(integrals)[source]#
Transforms an
qiskit_nature.second_q.operators.ElectronicIntegrals
instance.- Parameters:
integrals (ElectronicIntegrals) – the
ElectronicIntegrals
to transform.- Raises:
QiskitNatureError – when using this method on a
BasisTransformer
that does not store itscoefficients
asElectronicIntegrals
, too.- Returns:
The transformed
ElectronicIntegrals
.- Return type:
- transform_hamiltonian(hamiltonian)[source]#
Transforms one
Hamiltonian
into another. This may affect the size of the Hilbert space.- Parameters:
hamiltonian (Hamiltonian) – the hamiltonian to be transformed.
- Raises:
NotImplementedError – when an unsupported hamiltonian type is provided.
- Returns:
A new Hamiltonian instance.
- Return type:
Hamiltonian