qrunch.chemistry.ground_state_problem.calculators.vqe_ground_state_problem_calculator
Classes for calculating the ground state energy of a molecule using a VQE algorithm.
The module contains one class for using a non-adaptive VQE algorithm, BasicVqeGroundStateProblemCalculator, and one class for using an adaptive VQE algorithm, AdaptiveVqeGroundStateProblemCalculator.
The latter algorithm builds the circuit ansatz adaptively, and is thus much more gate efficient. The adaptive version is the recommended option, while the “basic” (non-adaptive) is meant for expert users, who want to build their own ansatz circuit.
Classes
Class for calculating the ground state energy of a molecule using an adaptive VQE algorithm. |
|
Class for calculating the ground state energy using a non-adaptive VQE algorithm. |
|
Class for calculating the ground state energy of a molecule using an adaptive VQE algorithm. |
|
Class for calculating the ground state energy of a molecule using a BEAST-VQE algorithm. |
- class AdaptiveVqeGroundStateProblemCalculator
Bases:
objectClass for calculating the ground state energy of a molecule using an adaptive VQE algorithm.
- __init__(vqe: SecondQuantizationAdaptiveVqeAlgorithm, *, paired_electron_approximation: bool, include_single_excitations: bool = True, include_double_excitations: bool = True) None
Initialize the molecular ground state energy calculator.
- Parameters:
vqe (SecondQuantizationAdaptiveVqeAlgorithm) – The VQE algorithm to use for the calculation. Must be a an adaptive VQE. If a basic VQE is desired, use the
BasicVqeGroundStateProblemCalculatorclass instead.paired_electron_approximation (bool) – Whether to use the paired-electron approximation.
include_single_excitations (bool) – whether to include single-excitation gates in the gate pool.
include_double_excitations (bool) – whether to include double-excitation gates in the gate pool.
- Return type:
None
- calculate(ground_state_problem: RestrictedGroundStateProblem | UnrestrictedGroundStateProblem, callback: AdaptiveIterationCallback | None = None, vqe_input_result: SecondQuantizationAdaptiveVqeResult[T] | None = None) AdaptiveVqeGroundStateProblemCalculatorResult
Calculate the expectation value of the ground state energy of the given molecule.
- Parameters:
ground_state_problem (RestrictedGroundStateProblem | UnrestrictedGroundStateProblem) – Ground state problem to calculate energy for.
callback (AdaptiveIterationCallback | None) – An optional callback function that is called at each outer iteration of the VQE.
vqe_input_result (SecondQuantizationAdaptiveVqeResult[T] | None) – A prior vqe results that should be refined.
- Return type:
- class BasicVqeGroundStateProblemCalculator
Bases:
objectClass for calculating the ground state energy using a non-adaptive VQE algorithm.
- __init__(vqe: SecondQuantizationVqeAlgorithm) None
Initialize the molecular ground state energy calculator.
- Parameters:
vqe (SecondQuantizationVqeAlgorithm) – The VQE algorithm to use for the calculation. Must be a non-adaptive VQE. If an adaptive VQE is desired, use the
AdaptiveVqeGroundStateProblemCalculatorinstead.- Return type:
None
- calculate(ground_state_problem: RestrictedGroundStateProblem | UnrestrictedGroundStateProblem, ansatz: Circuit, *, paired_electron_approximation: bool) GroundStateProblemCalculatorResult
Calculate the expectation value of the ground state energy of the given molecule.
- Parameters:
ground_state_problem (RestrictedGroundStateProblem | UnrestrictedGroundStateProblem) – Ground state problem to calculate energy for.
ansatz (Circuit) – The ansatz circuit to use in the VQE.
paired_electron_approximation (bool) – Whether to use the paired-electron approximation.
- Return type:
- class BeastAcceleratedAdaptiveVqeGroundStateProblemCalculator
Bases:
objectClass for calculating the ground state energy of a molecule using an adaptive VQE algorithm.
- __init__(beast_calculator: BeastVqeGroundStateProblemCalculator, adaptive_calculator: AdaptiveVqeGroundStateProblemCalculator) None
Initialize the molecular ground state energy calculator.
- Parameters:
beast_calculator (BeastVqeGroundStateProblemCalculator) – The initial BEAST calculator to use first.
adaptive_calculator (AdaptiveVqeGroundStateProblemCalculator) – The final ground state energy calculator.
- Return type:
None
- calculate(ground_state_problem: RestrictedGroundStateProblem | UnrestrictedGroundStateProblem, callback: AdaptiveIterationCallback | None = None) AdaptiveVqeGroundStateProblemCalculatorResult
Calculate the expectation value of the ground state energy of the given molecule.
- Parameters:
ground_state_problem (RestrictedGroundStateProblem | UnrestrictedGroundStateProblem) – Ground state problem to calculate energy for.
callback (AdaptiveIterationCallback | None) – An optional callback function that is called at each outer iteration of the VQE.
- Return type:
- class BeastVqeGroundStateProblemCalculator
Bases:
objectClass for calculating the ground state energy of a molecule using a BEAST-VQE algorithm.
The BEAST-VQE algorithm is a combination of using the FAST-VQE idea behind adaptively adding gates to a VQE (https://doi.org/10.1103/PhysRevA.108.052422) coupled with the orbital-optimization correction from (https://doi.org/10.1038/s41534-023-00730-8).
The latter is a necessary correction when using the paired-electron approximation thereby the name ‘BEAST’ (Bosonic Encoding Adaptive Sampling Theory).
- __init__(vqe: SecondQuantizationAdaptiveVqeAlgorithm, second_order_corrector: BeastSecondOrderPerturbationCorrector | None = None) None
Initialize the molecular ground state energy calculator.
- Parameters:
vqe (SecondQuantizationAdaptiveVqeAlgorithm) – The VQE algorithm to use for the calculation. Must be a an adaptive VQE.
second_order_corrector (BeastSecondOrderPerturbationCorrector | None) – Corrector used to calculate correction to the final energy.
- Return type:
None
- calculate(ground_state_problem: RestrictedGroundStateProblem | UnrestrictedGroundStateProblem, callback: AdaptiveIterationCallback | None = None) BeastVqeGroundStateProblemCalculatorResult
Calculate the expectation value of the ground state energy of the given molecule.
- Parameters:
ground_state_problem (RestrictedGroundStateProblem | UnrestrictedGroundStateProblem) – Ground state problem to calculate energy for.
callback (AdaptiveIterationCallback | None) – An optional callback function that is called at each outer iteration of the VQE.
- Return type:
- static extract_integrals_from_operator(operator: FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol) RestrictedElectronicStructureIntegrals
Return potentially orbital optimized integrals from the operator.
- Parameters:
operator (FermionHermitianSumProtocol | PairedHardcoreBosonHermitianSumProtocol) – The operator who hold the integrals.
- Return type:
RestrictedElectronicStructureIntegrals