Skip to content

Commit d4718d0

Browse files
committed
update
1 parent 8946f82 commit d4718d0

File tree

6 files changed

+5901
-758
lines changed

6 files changed

+5901
-758
lines changed

doc/Programs/LipkinModel/.ipynb_checkpoints/LipkinExample-checkpoint.ipynb

Lines changed: 2744 additions & 0 deletions
Large diffs are not rendered by default.

doc/Programs/LipkinModel/LipkinExample.ipynb

Lines changed: 2744 additions & 0 deletions
Large diffs are not rendered by default.

doc/Programs/LipkinModel/lipkin_model.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"name": "stderr",
115115
"output_type": "stream",
116116
"text": [
117-
"100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:04<00:00, 2.49it/s]\n"
117+
"100%|██████████████████████████████████████████████████████████████████| 10/10 [00:03<00:00, 2.52it/s]\n"
118118
]
119119
}
120120
],
@@ -166,14 +166,14 @@
166166
},
167167
{
168168
"cell_type": "code",
169-
"execution_count": 6,
169+
"execution_count": 5,
170170
"metadata": {},
171171
"outputs": [
172172
{
173173
"name": "stderr",
174174
"output_type": "stream",
175175
"text": [
176-
"/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_4617/1378722582.py:39: ComplexWarning: Casting complex values to real discards the imaginary part\n",
176+
"/var/folders/td/3yk470mj5p931p9dtkk0y6jw0000gn/T/ipykernel_42387/1378722582.py:39: ComplexWarning: Casting complex values to real discards the imaginary part\n",
177177
" eigvals_ana[index] = eigen[permute]\n"
178178
]
179179
}

doc/Programs/LipkinModel/two_qubit_VQE.ipynb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -318,17 +318,17 @@
318318
"name": "stdout",
319319
"output_type": "stream",
320320
"text": [
321-
"Lambda = 0.0, Energy = 0.0, Epochs = 25.0, Converged = True, Delta Energy = 0.0\n",
322-
"Lambda = 0.1, Energy = 0.30410000000000004, Epochs = 370.0, Converged = True, Delta Energy = 0.0\n",
323-
"Lambda = 0.2, Energy = 0.5723000000000003, Epochs = 233.0, Converged = True, Delta Energy = 0.0\n",
324-
"Lambda = 0.30000000000000004, Energy = 0.8340999999999998, Epochs = 1206.0, Converged = True, Delta Energy = 0.0\n",
325-
"Lambda = 0.4, Energy = 1.0969000000000002, Epochs = 1818.0, Converged = True, Delta Energy = 0.0\n",
326-
"Lambda = 0.5, Energy = 1.2645, Epochs = 15.0, Converged = True, Delta Energy = 0.0\n",
327-
"Lambda = 0.6000000000000001, Energy = 0.4413999999999998, Epochs = 3550.0, Converged = True, Delta Energy = 0.0\n",
328-
"Lambda = 0.7000000000000001, Energy = 0.0134000000000003, Epochs = 161.0, Converged = True, Delta Energy = 0.0\n",
329-
"Lambda = 0.8, Energy = -0.4352999999999998, Epochs = 72.0, Converged = True, Delta Energy = 0.0\n",
330-
"Lambda = 0.9, Energy = -0.8173000000000004, Epochs = 5000.0, Converged = False, Delta Energy = 0.1014999999999997\n",
331-
"Lambda = 1.0, Energy = -1.4000000000000004, Epochs = 286.0, Converged = True, Delta Energy = 0.0\n"
321+
"Lambda = 0.0, Energy = 0.0, Epochs = 10.0, Converged = True, Delta Energy = 0.0\n",
322+
"Lambda = 0.1, Energy = 0.29659999999999975, Epochs = 47.0, Converged = True, Delta Energy = 0.0\n",
323+
"Lambda = 0.2, Energy = 0.5769000000000002, Epochs = 638.0, Converged = True, Delta Energy = 0.0\n",
324+
"Lambda = 0.30000000000000004, Energy = 0.8503000000000003, Epochs = 1458.0, Converged = True, Delta Energy = 0.0\n",
325+
"Lambda = 0.4, Energy = 1.12, Epochs = 1820.0, Converged = True, Delta Energy = 0.0\n",
326+
"Lambda = 0.5, Energy = 0.8275000000000001, Epochs = 327.0, Converged = True, Delta Energy = 0.0\n",
327+
"Lambda = 0.6000000000000001, Energy = 0.34819999999999984, Epochs = 2861.0, Converged = True, Delta Energy = 0.0\n",
328+
"Lambda = 0.7000000000000001, Energy = 0.02059999999999995, Epochs = 5000.0, Converged = False, Delta Energy = 0.06200000000000028\n",
329+
"Lambda = 0.8, Energy = -0.44620000000000104, Epochs = 1115.0, Converged = True, Delta Energy = 0.0\n",
330+
"Lambda = 0.9, Energy = -0.9252000000000002, Epochs = 905.0, Converged = True, Delta Energy = 0.0\n",
331+
"Lambda = 1.0, Energy = -1.2655000000000003, Epochs = 468.0, Converged = True, Delta Energy = 0.0\n"
332332
]
333333
}
334334
],

doc/pub/week8/ipynb/LipkinExample.ipynb

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,49 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 4,
5+
"execution_count": 2,
66
"metadata": {},
7-
"outputs": [],
7+
"outputs": [
8+
{
9+
"data": {
10+
"text/plain": [
11+
"'\\nfrom qiskit.circuit import ParameterVector\\nfrom qiskit.opflow import X, Z, I, Y\\n\\n\\nfrom qiskit.algorithms import MinimumEigensolver, VQEResult\\n\\nfrom qiskit_ibm_runtime import (QiskitRuntimeService, Session,\\n Estimator as RuntimeEstimator,\\n Sampler as RuntimeSampler,\\n Options)\\nfrom qiskit.primitives import Sampler,Estimator\\nfrom qiskit import *\\nfrom qiskit.visualization import *\\nfrom qiskit.algorithms.optimizers import COBYLA,NFT,GradientDescent,ADAM,SPSA\\nfrom qiskit.algorithms.minimum_eigensolvers import VQE\\nfrom qiskit.circuit.library import EvolvedOperatorAnsatz,RXXGate,RZZGate\\n\\nfrom qiskit.opflow import PauliSumOp, SummedOp, PauliOp\\n'"
12+
]
13+
},
14+
"execution_count": 2,
15+
"metadata": {},
16+
"output_type": "execute_result"
17+
}
18+
],
819
"source": [
920
"import numpy as np\n",
1021
"import matplotlib.pyplot as plt\n",
1122
"\n",
12-
"\n",
23+
"\"\"\"\n",
1324
"from qiskit.circuit import ParameterVector\n",
1425
"from qiskit.opflow import X, Z, I, Y\n",
1526
"\n",
1627
"\n",
1728
"from qiskit.algorithms import MinimumEigensolver, VQEResult\n",
18-
"\"\"\"\n",
29+
"\n",
1930
"from qiskit_ibm_runtime import (QiskitRuntimeService, Session,\n",
2031
" Estimator as RuntimeEstimator,\n",
2132
" Sampler as RuntimeSampler,\n",
2233
" Options)\n",
23-
"\"\"\"\n",
2434
"from qiskit.primitives import Sampler,Estimator\n",
2535
"from qiskit import *\n",
2636
"from qiskit.visualization import *\n",
2737
"from qiskit.algorithms.optimizers import COBYLA,NFT,GradientDescent,ADAM,SPSA\n",
2838
"from qiskit.algorithms.minimum_eigensolvers import VQE\n",
2939
"from qiskit.circuit.library import EvolvedOperatorAnsatz,RXXGate,RZZGate\n",
3040
"\n",
31-
"from qiskit.opflow import PauliSumOp, SummedOp, PauliOp\n"
41+
"from qiskit.opflow import PauliSumOp, SummedOp, PauliOp\n",
42+
"\"\"\"\n"
3243
]
3344
},
3445
{
3546
"cell_type": "code",
36-
"execution_count": 5,
47+
"execution_count": 3,
3748
"metadata": {},
3849
"outputs": [],
3950
"source": [
@@ -43,7 +54,7 @@
4354
},
4455
{
4556
"cell_type": "code",
46-
"execution_count": 6,
57+
"execution_count": 4,
4758
"metadata": {},
4859
"outputs": [],
4960
"source": [
@@ -76,9 +87,21 @@
7687
},
7788
{
7889
"cell_type": "code",
79-
"execution_count": 7,
90+
"execution_count": 5,
8091
"metadata": {},
81-
"outputs": [],
92+
"outputs": [
93+
{
94+
"ename": "NameError",
95+
"evalue": "name 'MinimumEigensolver' is not defined",
96+
"output_type": "error",
97+
"traceback": [
98+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
99+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
100+
"Cell \u001b[0;32mIn[5], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Define a custome VQE class to orchestra the ansatz, classical optimizers, \u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;66;03m# initial point, callback, and final result\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m \u001b[38;5;28;01mclass\u001b[39;00m \u001b[38;5;21;01mQiskitVQE\u001b[39;00m(\u001b[43mMinimumEigensolver\u001b[49m):\n\u001b[1;32m 5\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__init__\u001b[39m(\u001b[38;5;28mself\u001b[39m,estimator, ansatz, optimizer,ham,initial_parameters\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m,callback\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[1;32m 6\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_estimator \u001b[38;5;241m=\u001b[39m estimator\n",
101+
"\u001b[0;31mNameError\u001b[0m: name 'MinimumEigensolver' is not defined"
102+
]
103+
}
104+
],
82105
"source": [
83106
"# Define a custome VQE class to orchestra the ansatz, classical optimizers, \n",
84107
"# initial point, callback, and final result\n",
@@ -122,7 +145,7 @@
122145
},
123146
{
124147
"cell_type": "code",
125-
"execution_count": 8,
148+
"execution_count": 6,
126149
"metadata": {},
127150
"outputs": [],
128151
"source": [
@@ -135,7 +158,7 @@
135158
},
136159
{
137160
"cell_type": "code",
138-
"execution_count": 9,
161+
"execution_count": 7,
139162
"metadata": {},
140163
"outputs": [],
141164
"source": [
@@ -147,7 +170,7 @@
147170
},
148171
{
149172
"cell_type": "code",
150-
"execution_count": 10,
173+
"execution_count": 8,
151174
"metadata": {},
152175
"outputs": [],
153176
"source": [
@@ -164,7 +187,7 @@
164187
},
165188
{
166189
"cell_type": "code",
167-
"execution_count": 11,
190+
"execution_count": 9,
168191
"metadata": {},
169192
"outputs": [],
170193
"source": [
@@ -187,20 +210,20 @@
187210
},
188211
{
189212
"cell_type": "code",
190-
"execution_count": 12,
213+
"execution_count": 10,
191214
"metadata": {},
192215
"outputs": [
193216
{
194-
"data": {
195-
"text/plain": [
196-
"PauliSumOp(SparsePauliOp(['II', 'ZI', 'IZ', 'II', 'IX', 'XI', 'ZX', 'XZ'],\n",
197-
" coeffs=[ 0. +0.j, -1. +0.j, -1. +0.j, 0. +0.j,\n",
198-
" 1.22474487+0.j, 1.22474487+0.j, 1.22474487+0.j, -1.22474487+0.j]), coeff=1.0)"
199-
]
200-
},
201-
"execution_count": 12,
202-
"metadata": {},
203-
"output_type": "execute_result"
217+
"ename": "NameError",
218+
"evalue": "name 'I' is not defined",
219+
"output_type": "error",
220+
"traceback": [
221+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
222+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
223+
"Cell \u001b[0;32mIn[10], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mLipkin_J2_decomposition_Pauli\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m,\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m)\u001b[49m[\u001b[38;5;241m0\u001b[39m]\n",
224+
"Cell \u001b[0;32mIn[9], line 2\u001b[0m, in \u001b[0;36mLipkin_J2_decomposition_Pauli\u001b[0;34m(E, V, W)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mLipkin_J2_decomposition_Pauli\u001b[39m(E,V,W):\n\u001b[0;32m----> 2\u001b[0m term1 \u001b[38;5;241m=\u001b[39m W \u001b[38;5;241m*\u001b[39m (\u001b[43mI\u001b[49m \u001b[38;5;241m^\u001b[39m I)\n\u001b[1;32m 3\u001b[0m term2 \u001b[38;5;241m=\u001b[39m (W\u001b[38;5;241m-\u001b[39mE) \u001b[38;5;241m*\u001b[39m (Z \u001b[38;5;241m^\u001b[39m I)\n\u001b[1;32m 4\u001b[0m term3 \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m-\u001b[39m(W\u001b[38;5;241m+\u001b[39mE) \u001b[38;5;241m*\u001b[39m (I \u001b[38;5;241m^\u001b[39m Z)\n",
225+
"\u001b[0;31mNameError\u001b[0m: name 'I' is not defined"
226+
]
204227
}
205228
],
206229
"source": [

0 commit comments

Comments
 (0)