Quantum Chemistry (My Lab)

cahyati sangaji (cahya)
8 min readDec 11, 2020

Cahyati Supriyati Sangaji (My Note)

In this lab, you will run through an example of a quantum chemistry problem. You will be exploring the simulation of the molecule LiH in Qiskit. You will need to follow the video associated with this lab.

from qiskit.chemistry.drivers import PySCFDriver, UnitsTypemolecular_coordinates = 'Li 0 0 0; H 1.6 0 0'distance_unit = UnitsType.ANGSTROMbasis = 'sto3g'driver = PySCFDriver(molecular_coordinates, unit=distance_unit)molecule = driver.run()h1 = molecule.one_body_integralsprint(h1)

Out:

[[-4.72739313  0.10549968  0.16696141  0.          0.         -0.0346772
0. 0. 0. 0. 0. 0. ]
[ 0.10549968 -1.49264622 0.03289282 0. 0. -0.05270788
0. 0. 0. 0. 0. 0. ]
[ 0.16696141 0.03289282 -1.12554474 0. 0. 0.03044557
0. 0. 0. 0. 0. 0. ]
[ 0. 0. 0. -1.13579985 0. 0.
0. 0. 0. 0. 0. 0. ]
[ 0. 0. 0. 0. -1.13579985 0.
0. 0. 0. 0. 0. 0. ]
[-0.0346772 -0.05270788 0.03044557 0. 0. -0.95096659
0. 0. 0. 0. 0. 0. ]
[ 0. 0. 0. 0. 0. 0.
-4.72739313 0.10549968 0.16696141 0. 0. -0.0346772 ]
[ 0. 0. 0. 0. 0. 0.
0.10549968 -1.49264622 0.03289282 0. 0. -0.05270788]
[ 0. 0. 0. 0. 0. 0.
0.16696141 0.03289282 -1.12554474 0. 0. 0.03044557]
[ 0. 0. 0. 0. 0. 0.
0. 0. 0. -1.13579985 0. 0. ]
[ 0. 0. 0. 0. 0. 0.
0. 0. 0. 0. -1.13579985 0. ]
[ 0. 0. 0. 0. 0. 0.
-0.0346772 -0.05270788 0.03044557 0. 0. -0.95096659]]

Sintax:

h2 = molecule.two_body_integrals
print(h2)
nuclear_repulsion_energy = molecule.nuclear_repulsion_energyprint(nuclear_repulsion_energy)

Out:

0.992207270475

1. Creating a Fermionic Operator

from qiskit.chemistry import FermionicOperatorferOp = FermionicOperator(h1=h1, h2=h2)num_spin_orbitals = molecule.num_orbitals * 2
num_particles = molecule.num_alpha + molecule.num_beta
freeze_list = [0,6]remove_list = [3,8]ferOp_f, energy_shift = ferOp.fermion_mode_freezing(freeze_list)num_spin_orbitals -= len(freeze_list)
num_particles -= len(freeze_list)
print(ferOp_f.h1)

Out:

[[-0.77258172  0.0485796   0.          0.         -0.12679498  0.
0. 0. 0. 0. ]
[ 0.0485796 -0.35593954 0. 0. 0.06813315 0.
0. 0. 0. 0. ]
[ 0. 0. -0.35297897 0. 0. 0.
0. 0. 0. 0. ]
[ 0. 0. 0. -0.35297897 0. 0.
0. 0. 0. 0. ]
[-0.12679498 0.06813315 0. 0. -0.236054 0.
0. 0. 0. 0. ]
[ 0. 0. 0. 0. 0. -0.77258172
0.0485796 0. 0. -0.12679498]
[ 0. 0. 0. 0. 0. 0.0485796
-0.35593954 0. 0. 0.06813315]
[ 0. 0. 0. 0. 0. 0.
0. -0.35297897 0. 0. ]
[ 0. 0. 0. 0. 0. 0.
0. 0. -0.35297897 0. ]
[ 0. 0. 0. 0. 0. -0.12679498
0.06813315 0. 0. -0.236054 ]]

Sintax:

ferOp_fr = ferOp_f.fermion_mode_elimination(remove_list)num_spin_orbitals -= len(remove_list)print(ferOp_fr.h1)

Out:

[[-0.77258172  0.0485796   0.         -0.12679498  0.          0.
0. 0. ]
[ 0.0485796 -0.35593954 0. 0.06813315 0. 0.
0. 0. ]
[ 0. 0. -0.35297897 0. 0. 0.
0. 0. ]
[-0.12679498 0.06813315 0. -0.236054 0. 0.
0. 0. ]
[ 0. 0. 0. 0. -0.77258172 0.0485796
0. -0.12679498]
[ 0. 0. 0. 0. 0.0485796 -0.35593954
0. 0.06813315]
[ 0. 0. 0. 0. 0. 0.
-0.35297897 0. ]
[ 0. 0. 0. 0. -0.12679498 0.06813315
0. -0.236054 ]]

2. Creating a Qubit Operator

map_type = 'parity'qubitOp = ferOp_fr.mapping(map_type=map_type)print(qubitOp)
print(qubitOp.print_details())

Out:

Representation: paulis, qubits: 8, size: 193
IIIIIIII (0.2956785198716418+0j)
IIIIIIIZ (-0.16924658692972677+0j)
IIIIIIZX (0.0016203457124659344+0j)
IIIIIIIX (-0.0016203457124659344+0j)
IIIIZXXX (0.00996005178043422+0j)
IIIIIYXY (0.00996005178043422+0j)
IIIIIIZZ (-0.25982209985094223+0j)
IIIIZXXZ (-0.01955876191930432+0j)
IIIIIYYI (-0.01955876191930432+0j)
IIIIIZZI (-0.2907871163406006+0j)
IIIIZZII (-0.43459982901406535+0j)
IIIZZIII (-0.16924658692972677+0j)
IIZXZIII (0.001620345712465934+0j)
IIIXIIII (-0.001620345712465934+0j)
ZXXXZIII (0.009960051780434234+0j)
IYXYIIII (0.009960051780434234+0j)
IIZZIIII (-0.2598220998509423+0j)
ZXXZIIII (-0.019558761919304325+0j)
IYYIIIII (-0.019558761919304325+0j)
IZZIIIII (-0.29078711634060056+0j)
ZZIIIIII (-0.43459982901406546+0j)
IIIIIIZI (0.052636515285500694+0j)
IIIIZXXI (-0.004191566320147111+0j)
IIIIIYYZ (-0.004191566320147111+0j)
IIIIIZZZ (0.06168720475907605+0j)
IIIIZZIZ (0.08247949378222773+0j)
IIIIZXYY (0.005456156289315983+0j)
IIIIIYYX (-0.005456156289315983+0j)
IIIIIZIX (-0.003377347600611614+0j)
IIIIIZZX (0.003377347600611614+0j)
IIIIZZZX (-0.0028624550781648616+0j)
IIIIZZIX (0.0028624550781648616+0j)
IIIIZYYX (-0.0008205597550617054+0j)
IIIIIXYY (0.0008205597550617054+0j)
IIIZZIIZ (0.12182774215822771+0j)
IIIZZIZX (-0.01214489722803717+0j)
IIIZZIIX (0.01214489722803717+0j)
IIIZIXXX (0.03169874598735458+0j)
IIIZZYXY (0.03169874598735458+0j)
IIIXIIIZ (0.01214489722803717+0j)
IIZXZIIZ (-0.01214489722803717+0j)
IIIXIIZX (-0.003265995499645631+0j)
IIZXZIZX (0.003265995499645631+0j)
IIIXIIIX (0.003265995499645631+0j)
IIZXZIIX (-0.003265995499645631+0j)
IIIXZXXX (0.008650156860594758+0j)
IIZXIXXX (-0.008650156860594758+0j)
IIIXIYXY (0.008650156860594758+0j)
IIZXZYXY (-0.008650156860594758+0j)
IIYYIZXX (0.00585566830994027+0j)
IZXXZZXX (0.00585566830994027+0j)
IIYYIIYY (0.00585566830994027+0j)
IZXXZIYY (0.00585566830994027+0j)
IYXYIIIZ (0.03169874598735458+0j)
ZXXXZIIZ (0.03169874598735458+0j)
IYXYIIZX (-0.008650156860594758+0j)
ZXXXZIZX (-0.008650156860594758+0j)
IYXYIIIX (0.008650156860594758+0j)
ZXXXZIIX (0.008650156860594758+0j)
IYXYZXXX (0.030981613344636828+0j)
ZXXXIXXX (0.030981613344636828+0j)
IYXYIYXY (0.030981613344636828+0j)
ZXXXZYXY (0.030981613344636828+0j)
IIZZIIIZ (0.055902510785146325+0j)
IIZZIIZX (0.0018710427514071766+0j)
IIZZIIIX (-0.0018710427514071766+0j)
IIZZZXXX (-0.0031040041160851563+0j)
IIZZIYXY (-0.0031040041160851563+0j)
IIXIIZXX (-0.004819223112130106+0j)
IZXZIZXX (0.004819223112130106+0j)
IIXIIIYY (-0.004819223112130106+0j)
IZXZIIYY (0.004819223112130106+0j)
IYYIIIIZ (-0.01284172318074187+0j)
ZXXZIIIZ (-0.01284172318074187+0j)
IYYIIIZX (0.0023521521732308274+0j)
ZXXZIIZX (0.0023521521732308274+0j)
IYYIIIIX (-0.0023521521732308274+0j)
ZXXZIIIX (-0.0023521521732308274+0j)
IYYIZXXX (-0.007975908750552737+0j)
ZXXZZXXX (-0.007975908750552737+0j)
IYYIIYXY (-0.007975908750552737+0j)
ZXXZIYXY (-0.007975908750552737+0j)
IZZIIIIZ (0.06754287306901632+0j)
IZZIIIZX (0.0014418755115184919+0j)
IZZIIIIX (-0.0014418755115184919+0j)
IZZIZXXX (-0.004073058646189673+0j)
IZZIIYXY (-0.004073058646189673+0j)
IXIIIZXX (0.004893618401251378+0j)
ZXZIIZXX (-0.004893618401251378+0j)
IXIIIIYY (0.004893618401251378+0j)
ZXZIIIYY (-0.004893618401251378+0j)
ZZIIIIIZ (0.11346110712686455+0j)
ZZIIIIZX (-0.010838363828717598+0j)
ZZIIIIIX (0.010838363828717598+0j)
ZZIIZXXX (0.033551353111247566+0j)
ZZIIIYXY (0.033551353111247566+0j)
IIIIIZIZ (0.06017866224139362+0j)
IIIIZZZZ (0.05374686574462638+0j)
IIIIZYYZ (-0.003990268012277302+0j)
IIIIIXXI (-0.003990268012277302+0j)
IIIZZIZZ (0.055902510785146325+0j)
IIIZIXXZ (-0.01284172318074187+0j)
IIIZZYYI (-0.01284172318074187+0j)
IIIXIIZZ (-0.0018710427514071766+0j)
IIZXZIZZ (0.0018710427514071766+0j)
IIIXZXXZ (-0.002352152173230828+0j)
IIZXIXXZ (0.002352152173230828+0j)
IIIXIYYI (-0.002352152173230828+0j)
IIZXZYYI (0.002352152173230828+0j)
IIYYIZXZ (0.0048192231121301065+0j)
IZXXZZXZ (0.0048192231121301065+0j)
IIYYIIXI (-0.0048192231121301065+0j)
IZXXZIXI (-0.0048192231121301065+0j)
IYXYIIZZ (-0.0031040041160851563+0j)
ZXXXZIZZ (-0.0031040041160851563+0j)
IYXYZXXZ (-0.007975908750552737+0j)
ZXXXIXXZ (-0.007975908750552737+0j)
IYXYIYYI (-0.007975908750552737+0j)
ZXXXZYYI (-0.007975908750552737+0j)
IIZZIIZZ (0.08447056807295142+0j)
IIZZZXXZ (0.008994911953942076+0j)
IIZZIYYI (0.008994911953942076+0j)
IIXIIZXZ (-0.010319173999275899+0j)
IZXZIZXZ (0.010319173999275899+0j)
IIXIIIXI (0.010319173999275899+0j)
IZXZIIXI (-0.010319173999275899+0j)
IYYIIIZZ (0.008994911953942078+0j)
ZXXZIIZZ (0.008994911953942078+0j)
IYYIZXXZ (0.006612047066142963+0j)
ZXXZZXXZ (0.006612047066142963+0j)
IYYIIYYI (0.006612047066142963+0j)
ZXXZIYYI (0.006612047066142963+0j)
IZZIIIZZ (0.07049783624066952+0j)
IZZIZXXZ (0.000559526364054557+0j)
IZZIIYYI (0.000559526364054557+0j)
IXIIIZXZ (0.0034307416482227456+0j)
ZXZIIZXZ (-0.0034307416482227456+0j)
IXIIIIXI (-0.0034307416482227456+0j)
ZXZIIIXI (0.0034307416482227456+0j)
ZZIIIIZZ (0.06035891281076934+0j)
ZZIIZXXZ (-0.011019231644697468+0j)
ZZIIIYYI (-0.011019231644697468+0j)
IIIIZIZI (0.0621015404189217+0j)
IIIZZZZI (0.06754287306901632+0j)
IIIXIZZI (-0.0014418755115184919+0j)
IIZXZZZI (0.0014418755115184919+0j)
IIYYZXZI (-0.004893618401251378+0j)
IZXXIXZI (-0.004893618401251378+0j)
IIYYIXII (0.004893618401251378+0j)
IZXXZXII (0.004893618401251378+0j)
IYXYIZZI (-0.004073058646189673+0j)
ZXXXZZZI (-0.004073058646189673+0j)
IIZZIZZI (0.07049783624066952+0j)
IIXIZXZI (0.0034307416482227448+0j)
IZXZZXZI (-0.0034307416482227448+0j)
IIXIIXII (-0.0034307416482227448+0j)
IZXZIXII (0.0034307416482227448+0j)
IYYIIZZI (0.000559526364054557+0j)
ZXXZIZZI (0.000559526364054557+0j)
IZZIIZZI (0.07823637778985218+0j)
IXIIZXZI (-0.004930564004023831+0j)
ZXZIZXZI (0.004930564004023831+0j)
IXIIIXII (0.004930564004023831+0j)
ZXZIIXII (-0.004930564004023831+0j)
ZZIIIZZI (0.06703210442294552+0j)
IIIZIZII (0.11346110712686455+0j)
IIIXZZII (0.010838363828717598+0j)
IIZXIZII (-0.010838363828717598+0j)
IYXYZZII (0.03355135311124757+0j)
ZXXXIZII (0.03355135311124757+0j)
IIZZZZII (0.06035891281076934+0j)
IYYIZZII (-0.011019231644697466+0j)
ZXXZZZII (-0.011019231644697466+0j)
IZZIZZII (0.06703210442294552+0j)
ZZIIZZII (0.11344680300368187+0j)
IIZIZIII (0.052636515285500694+0j)
ZXXIZIII (-0.004191566320147111+0j)
IYYZZIII (-0.004191566320147111+0j)
IZZZZIII (0.06168720475907605+0j)
ZZIZZIII (0.08247949378222773+0j)
ZXYYZIII (0.005456156289315983+0j)
IYYXIIII (-0.005456156289315983+0j)
IZIXZIII (-0.003377347600611614+0j)
IZZXIIII (0.003377347600611614+0j)
ZZZXZIII (-0.0028624550781648616+0j)
ZZIXIIII (0.0028624550781648616+0j)
ZYYXZIII (-0.0008205597550617054+0j)
IXYYIIII (0.0008205597550617054+0j)
IZIZIIII (0.06017866224139362+0j)
ZZZZIIII (0.05374686574462638+0j)
ZYYZIIII (-0.003990268012277302+0j)
IXXIIIII (-0.003990268012277302+0j)
ZIZIIIII (0.0621015404189217+0j)

Sintax:

from qiskit.aqua.operators import Z2Symmetriespauli_symm = Z2Symmetries.find_Z2_symmetries(qubitOp)
print(pauli_symm)

Out:

Z2 symmetries:
Symmetries:
IIIIZIII
IZZIIZZI
ZIIIIIII
Single-Qubit Pauli X:
IIIIXIII
IIIIIIXI
XIIIIIII
Cliffords:
IIIIZIII (0.7071067811865475+0j)
IIIIXIII (0.7071067811865475+0j)

IZZIIZZI (0.7071067811865475+0j)
IIIIIIXI (0.7071067811865475+0j)

ZIIIIIII (0.7071067811865475+0j)
XIIIIIII (0.7071067811865475+0j)

Qubit index:
[3, 1, 7]
Tapering values:
- Possible values: [1, 1, 1], [1, 1, -1], [1, -1, 1], [1, -1, -1], [-1, 1, 1], [-1, 1, -1], [-1, -1, 1], [-1, -1, -1]

Sintax:

qubitOp_t = Z2Symmetries.two_qubit_reduction(qubitOp, num_particles)print(num_particles)print(qubitOp_t)
print(qubitOp_t.print_details())

Out:

2
Representation: paulis, qubits: 6, size: 175
IIIIII (0.2956785198716417+0j)
IIIIIZ (-0.16924658692972672+0j)
IIIIZX (0.0016203457124659337+0j)
IIIIIX (-0.0016203457124659337+0j)
IIIXXX (-0.009960051780434217+0j)
IIIYXY (0.009960051780434217+0j)
IIIIZZ (-0.2598220998509421+0j)
IIIXXZ (0.019558761919304314+0j)
IIIYYI (-0.019558761919304314+0j)
IIIZZI (-0.2907871163406005+0j)
IIIZII (0.4345998290140652+0j)
IIZIII (0.16924658692972672+0j)
IZXIII (-0.0016203457124659335+0j)
IIXIII (-0.0016203457124659335+0j)
XXXIII (-0.00996005178043423+0j)
YXYIII (0.00996005178043423+0j)
IZZIII (-0.2598220998509423+0j)
XXZIII (-0.019558761919304318+0j)
YYIIII (-0.019558761919304318+0j)
ZZIIII (-0.29078711634060045+0j)
ZIIIII (-0.4345998290140653+0j)
IIIIZI (-0.009465025133421005+0j)
IIIXXI (0.00020129830786980857+0j)
IIIYYZ (-0.00020129830786980857+0j)
IIIZZZ (0.007940339014449668+0j)
IIIZIZ (-0.0223008315408341+0j)
IIIXYY (-0.004635596534254276+0j)
IIIYYX (-0.004635596534254276+0j)
IIIZIX (-0.006239802678776473+0j)
IIIZZX (0.006239802678776473+0j)
IIZIIZ (-0.12182774215822767+0j)
IIZIZX (0.012144897228037166+0j)
IIZIIX (-0.012144897228037166+0j)
IIZXXX (0.03169874598735457+0j)
IIZYXY (-0.03169874598735457+0j)
IIXIIZ (0.012144897228037166+0j)
IZXIIZ (0.012144897228037166+0j)
IIXIZX (-0.0032659954996456303+0j)
IZXIZX (-0.0032659954996456303+0j)
IIXIIX (0.0032659954996456303+0j)
IZXIIX (0.0032659954996456303+0j)
IIXXXX (-0.008650156860594754+0j)
IZXXXX (-0.008650156860594754+0j)
IIXYXY (0.008650156860594754+0j)
IZXYXY (0.008650156860594754+0j)
IYYZXX (0.0058556683099402675+0j)
ZXXZXX (-0.0058556683099402675+0j)
IYYIYY (0.0058556683099402675+0j)
ZXXIYY (-0.0058556683099402675+0j)
YXYIIZ (0.03169874598735457+0j)
XXXIIZ (-0.03169874598735457+0j)
YXYIZX (-0.008650156860594754+0j)
XXXIZX (0.008650156860594754+0j)
YXYIIX (0.008650156860594754+0j)
XXXIIX (-0.008650156860594754+0j)
YXYXXX (-0.030981613344636817+0j)
XXXXXX (0.030981613344636817+0j)
YXYYXY (0.030981613344636817+0j)
XXXYXY (-0.030981613344636817+0j)
IZZIIZ (0.055902510785146305+0j)
IZZIZX (0.001871042751407176+0j)
IZZIIX (-0.001871042751407176+0j)
IZZXXX (0.0031040041160851554+0j)
IZZYXY (-0.0031040041160851554+0j)
IXIZXX (-0.004819223112130104+0j)
ZXZZXX (0.004819223112130104+0j)
IXIIYY (-0.004819223112130104+0j)
ZXZIYY (0.004819223112130104+0j)
YYIIIZ (-0.012841723180741865+0j)
XXZIIZ (-0.012841723180741865+0j)
YYIIZX (0.0023521521732308265+0j)
XXZIZX (0.0023521521732308265+0j)
YYIIIX (-0.0023521521732308265+0j)
XXZIIX (-0.0023521521732308265+0j)
YYIXXX (0.007975908750552733+0j)
XXZXXX (0.007975908750552733+0j)
YYIYXY (-0.007975908750552733+0j)
XXZYXY (-0.007975908750552733+0j)
ZZIIIZ (0.0675428730690163+0j)
ZZIIZX (0.0014418755115184912+0j)
ZZIIIX (-0.0014418755115184912+0j)
ZZIXXX (0.004073058646189671+0j)
ZZIYXY (-0.004073058646189671+0j)
XIIZXX (0.0048936184012513765+0j)
XZIZXX (-0.0048936184012513765+0j)
XIIIYY (0.0048936184012513765+0j)
XZIIYY (-0.0048936184012513765+0j)
ZIIIIZ (0.11346110712686452+0j)
ZIIIZX (-0.010838363828717595+0j)
ZIIIIX (0.010838363828717595+0j)
ZIIXXX (-0.03355135311124755+0j)
ZIIYXY (0.03355135311124755+0j)
IIZIZZ (-0.055902510785146305+0j)
IIZXXZ (-0.012841723180741865+0j)
IIZYYI (0.012841723180741865+0j)
IIXIZZ (-0.001871042751407176+0j)
IZXIZZ (-0.001871042751407176+0j)
IIXXXZ (0.002352152173230827+0j)
IZXXXZ (0.002352152173230827+0j)
IIXYYI (-0.002352152173230827+0j)
IZXYYI (-0.002352152173230827+0j)
IYYZXZ (0.004819223112130105+0j)
ZXXZXZ (-0.004819223112130105+0j)
IYYIXI (-0.004819223112130105+0j)
ZXXIXI (0.004819223112130105+0j)
YXYIZZ (-0.0031040041160851554+0j)
XXXIZZ (0.0031040041160851554+0j)
YXYXXZ (0.007975908750552733+0j)
XXXXXZ (-0.007975908750552733+0j)
YXYYYI (-0.007975908750552733+0j)
XXXYYI (0.007975908750552733+0j)
IZZIZZ (0.08447056807295139+0j)
IZZXXZ (-0.008994911953942072+0j)
IZZYYI (0.008994911953942072+0j)
IXIZXZ (-0.010319173999275896+0j)
ZXZZXZ (0.010319173999275896+0j)
IXIIXI (0.010319173999275896+0j)
ZXZIXI (-0.010319173999275896+0j)
YYIIZZ (0.008994911953942074+0j)
XXZIZZ (0.008994911953942074+0j)
YYIXXZ (-0.00661204706614296+0j)
XXZXXZ (-0.00661204706614296+0j)
YYIYYI (0.00661204706614296+0j)
XXZYYI (0.00661204706614296+0j)
ZZIIZZ (0.07049783624066949+0j)
ZZIXXZ (-0.0005595263640545568+0j)
ZZIYYI (0.0005595263640545568+0j)
XIIZXZ (0.0034307416482227443+0j)
XZIZXZ (-0.0034307416482227443+0j)
XIIIXI (-0.0034307416482227443+0j)
XZIIXI (0.0034307416482227443+0j)
ZIIIZZ (0.060358912810769313+0j)
ZIIXXZ (0.011019231644697465+0j)
ZIIYYI (-0.011019231644697465+0j)
IIZZZI (-0.0675428730690163+0j)
IIXZZI (-0.0014418755115184912+0j)
IZXZZI (-0.0014418755115184912+0j)
IYYXZI (0.0048936184012513765+0j)
ZXXXZI (-0.0048936184012513765+0j)
IYYXII (0.0048936184012513765+0j)
ZXXXII (-0.0048936184012513765+0j)
YXYZZI (-0.004073058646189671+0j)
XXXZZI (0.004073058646189671+0j)
IZZZZI (0.07049783624066949+0j)
IXIXZI (-0.0034307416482227434+0j)
ZXZXZI (0.0034307416482227434+0j)
IXIXII (-0.0034307416482227434+0j)
ZXZXII (0.0034307416482227434+0j)
YYIZZI (0.0005595263640545568+0j)
XXZZZI (0.0005595263640545568+0j)
ZZIZZI (0.07823637778985215+0j)
XIIXZI (0.004930564004023829+0j)
XZIXZI (-0.004930564004023829+0j)
XIIXII (0.004930564004023829+0j)
XZIXII (-0.004930564004023829+0j)
ZIIZZI (0.0670321044229455+0j)
IIZZII (0.11346110712686452+0j)
IIXZII (-0.010838363828717595+0j)
IZXZII (-0.010838363828717595+0j)
YXYZII (-0.03355135311124756+0j)
XXXZII (0.03355135311124756+0j)
IZZZII (-0.060358912810769313+0j)
YYIZII (0.011019231644697463+0j)
XXZZII (0.011019231644697463+0j)
ZZIZII (-0.0670321044229455+0j)
ZIIZII (-0.11344680300368182+0j)
IZIIII (0.009465025133421005+0j)
XXIIII (0.00020129830786980857+0j)
YYZIII (0.00020129830786980857+0j)
ZZZIII (-0.007940339014449668+0j)
ZIZIII (-0.0223008315408341+0j)
XYYIII (-0.004635596534254276+0j)
YYXIII (-0.004635596534254276+0j)
ZIXIII (0.006239802678776473+0j)
ZZXIII (0.006239802678776473+0j)

Sintax:

from qiskit.aqua.algorithms import NumPyEigensolveree = NumPyEigensolver(qubitOp_t)result = ee.run()
ref = result['eigenvalues']
print(ref + nuclear_repulsion_energy + energy_shift)

Out:

[-7.88159204-3.82979521e-17j]

Creating a Variational Ansatz

from qiskit.chemistry.components.initial_states import HartreeFockinit_state = HartreeFock(num_orbitals=4, num_particles=2, qubit_mapping='jordan_wigner')print(init_state.bitstr)HF_circuit = init_state.construct_circuit('circuit')
HF_circuit.decompose().draw(output='mpl')
from qiskit.chemistry.components.variational_forms import UCCSDUCCSD_var_form = UCCSD(num_orbitals=4, num_particles=2, qubit_mapping='jordan_wigner',
excitation_type='s', method_singles='beta',
initial_state=init_state, two_qubit_reduction=False, reps=2)
print(UCCSD_var_form.single_excitations)
print(UCCSD_var_form.num_parameters)

Out:

[[2, 3]]
2

Sintax:

var_circuit = UCCSD_var_form.construct_circuit([1,2])var_circuit.decompose().draw(output='mpl')

Homework — The last symmetry standing

from qiskit.aqua.operators import Z2Symmetriespauli_symm = Z2Symmetries.find_Z2_symmetries(qubitOp_t)
print(pauli_symm)

Out:

Z2 symmetries:
Symmetries:
ZZIZZI
Single-Qubit Pauli X:
IIIIXI
Cliffords:
ZZIZZI (0.7071067811865475+0j)
IIIIXI (0.7071067811865475+0j)

Qubit index:
[1]
Tapering values:
- Possible values: [1], [-1]

Sintax:

qubitOp_tt = pauli_symm.taper(qubitOp_t)print(qubitOp_t)
print(qubitOp_tt[0])
print(qubitOp_tt[1])
print(qubitOp_tt[-1])

Out:

Representation: paulis, qubits: 6, size: 175
Representation: paulis, qubits: 5, size: 155
Representation: paulis, qubits: 5, size: 155
Representation: paulis, qubits: 5, size: 155

Sintax:

from qiskit.aqua.algorithms import NumPyEigensolveree1 = NumPyEigensolver(qubitOp_tt[1])result1 = ee1.run()
ref1 = result1['eigenvalues']
print(ref1 + nuclear_repulsion_energy + energy_shift)

Out:

[-7.71609053+1.89760206e-17j]

Sintax:

from qiskit.aqua.algorithms import NumPyEigensolveree2 = NumPyEigensolver(qubitOp_tt[-1])result2 = ee2.run()
ref2 = result2['eigenvalues']
print(ref2 + nuclear_repulsion_energy + energy_shift)

Out:

[-7.71609053-3.64348312e-18j]

References:

Qiskit (Global Summer School), Introduction to Quantum Computing and Quantum Hardware — Lab 8.

--

--