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

allow single flip index dis for qcc #247

Merged
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 @@ -62,7 +62,7 @@ def test_iqcc_ilc_h4(self):
iqcc_ilc_solver.build()
iqcc_ilc_energy = iqcc_ilc_solver.simulate()

self.assertAlmostEqual(iqcc_ilc_energy, -1.976817, places=4)
self.assertAlmostEqual(iqcc_ilc_energy, -1.9786, places=3)

def test_iqcc_ilc_h4_cation(self):
"""Test the energy after 2 iterations for H4+ using the maximum
Expand Down
2 changes: 1 addition & 1 deletion tangelo/algorithms/variational/tests/test_iqcc_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_iqcc_h4_cation(self):
iqcc.build()
iqcc_energy = iqcc.simulate()

self.assertAlmostEqual(iqcc_energy, -1.638524, places=4)
self.assertAlmostEqual(iqcc_energy, -1.639, places=3)

def test_iqcc_h4_double_cation(self):
"""Test the energy after 1 iteration for H4+2"""
Expand Down
6 changes: 3 additions & 3 deletions tangelo/toolboxes/ansatz_generator/_qubit_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def get_idxs_deriv(qham_term, *qham_qmf_data):
gen = (idx, "Y") if idxs == "" else (idx, "X")
idxs = idxs + f" {idx}" if idxs != "" else f"{idx}"
gen_tup += (gen, )
# Generators must have at least two flip indices
if len(gen_tup) > 1:
# Generators must have at least one flip index
if len(gen_tup) > 0:
alexfleury-sb marked this conversation as resolved.
Show resolved Hide resolved
qham_gen_comm = QubitOperator(qham_term, -1j * coef)
qham_gen_comm *= QubitOperator(gen_tup, 1.)
deriv = get_op_expval(qham_gen_comm, pure_params).real
Expand All @@ -152,7 +152,7 @@ def get_gens_from_idxs(group_idxs):
"""

dis_group_gens = []
for n_y in range(1, len(group_idxs), 2):
for n_y in range(1, len(group_idxs)+1, 2):
# Create combinations of odd numbers of flip indices for the Pauli Y operators
for xy_idx in combinations(group_idxs, n_y):
# If a flip index idx matches xy_idx, add a Y operator
Expand Down