Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General cleanup ef #133

Merged
merged 3 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from qiskit.algorithms.optimizers import SPSA, Optimizer, OptimizerResult
from qiskit.opflow import ListOp
from qiskit_nature.second_q.problems import (
BaseProblem,
ElectronicStructureProblem,
EigenstateResult,
ElectronicBasis,
Expand Down Expand Up @@ -250,16 +249,15 @@ def mo_coeff(self, mo_coeff: np.ndarray | None) -> None:

def solve(
self,
problem: BaseProblem,
) -> EigenstateResult:
problem: ElectronicStructureProblem,
) -> EntanglementForgingResult:
"""Compute Ground State properties.

Args:
- problem: a class encoding a problem to be solved.
- problem: a class encoding a problem to be solved

Returns:
- An interpreted :class:`~.EigenstateResult`. For more information see also
:meth:`~.BaseProblem.interpret`.
- A result object

Raises:
- ValueError:
Expand Down Expand Up @@ -363,19 +361,17 @@ def evaluate_eigenvalue(parameters: Sequence[float]) -> float:

def get_qubit_operators(
self,
problem: BaseProblem,
problem: ElectronicStructureProblem,
) -> ListOp:
"""Construct decomposed qubit operators from an ``ElectronicStructureProblem``.

Args:
- problem (BaseProblem): A class encoding a problem to be solved.
- problem (ElectronicStructureProblem): A class encoding a problem to be solved.

Returns:
- hamiltonian_ops: qubit operator representing the decomposed Hamiltonian.

Raises:
- ValueError:
Input problem was not an instance of ``ElectronicStructureProblem``
- ValueError:
The input problem is not in MO basis, and ``mo_coeff`` is set to ``None``
- ValueError:
Expand All @@ -391,12 +387,10 @@ def get_qubit_operators(
return hamiltonian_ops

@staticmethod
def _validate_problem_and_coeffs(problem: BaseProblem, mo_coeff: np.ndarray | None):
def _validate_problem_and_coeffs(
problem: ElectronicStructureProblem, mo_coeff: np.ndarray | None
):
"""Ensure the input problem can be translated to the MO basis."""
if not isinstance(problem, ElectronicStructureProblem):
raise TypeError(
"EntanglementForgingGroundStateSolver only supports ElectronicStructureProblem."
)
if (problem.basis != ElectronicBasis.MO) and (mo_coeff is None):
raise ValueError(
f"Cannot transform integrals to MO basis. The input problem is in the ({problem.basis}) basis, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,6 @@ class EntanglementForgingKnitter:
ansatz parameters and Schmidt coefficients.
"""

# Attributes:
# - _ansatz (EntanglementForgingAnsatz): the ansatz containing the
# information for the circuit structure and bitstrings to be used
# - _backend_names (list[str]): the names of the backends to use
# - _service (QiskitRuntimeService): the service used to access backends
# - _tensor_circuits_u (list[QuantumCircuit]): the set of circuits used for the first
# operator that have the same Schmidt values
# - _superposition_circuits_u (list[QuantumCircuit]): the set of circuits used for
# the first operator that have different Schmidt values
# - _tensor_circuits_v (list[QuantumCircuit]): the set of circuits used for the second
# operator that have the same Schmidt values
# - _superposition_circuits_v (list[QuantumCircuit]): the set of circuits used for
# the second operator that have different Schmidt values

def __init__(
self,
ansatz: EntanglementForgingAnsatz,
Expand Down