Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
vutuanhai237 committed Mar 1, 2024
1 parent c91d873 commit 98bba9f
Show file tree
Hide file tree
Showing 14 changed files with 13,220 additions and 645 deletions.
1,106 changes: 1,106 additions & 0 deletions codes/Wchain_zxz.eps

Large diffs are not rendered by default.

942 changes: 942 additions & 0 deletions codes/cnot.eps

Large diffs are not rendered by default.

492 changes: 492 additions & 0 deletions codes/compare.ipynb

Large diffs are not rendered by default.

1,074 changes: 544 additions & 530 deletions codes/custom.eps

Large diffs are not rendered by default.

933 changes: 933 additions & 0 deletions codes/evolution_circuit_XY.eps

Large diffs are not rendered by default.

1,456 changes: 1,456 additions & 0 deletions codes/magnetization.eps

Large diffs are not rendered by default.

672 changes: 557 additions & 115 deletions codes/qsp.ipynb

Large diffs are not rendered by default.

1,290 changes: 1,290 additions & 0 deletions codes/zxz_WchainCNOT_2_2.eps

Large diffs are not rendered by default.

1,106 changes: 1,106 additions & 0 deletions codes/zxz_walltoallcnot.eps

Large diffs are not rendered by default.

1,212 changes: 1,212 additions & 0 deletions codes/zxz_walltoallcnot4.eps

Large diffs are not rendered by default.

1,052 changes: 1,052 additions & 0 deletions codes/zxz_walternatingcnot.eps

Large diffs are not rendered by default.

1,384 changes: 1,384 additions & 0 deletions codes/zxz_wchainCNOT_eq2.eps.eps

Large diffs are not rendered by default.

1,106 changes: 1,106 additions & 0 deletions codes/zxz_wchaincnot.eps

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions qsp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from qsee.compilation.qsp import QuantumStatePreparation
from qsee.core import ansatz, state
from qsee.backend import constant, utilities
import matplotlib.pyplot as plt
import numpy as np, qiskit
from scipy.linalg import expm
from qiskit.quantum_info import Pauli, Statevector
from qsee.compilation.qsp import QuantumStatePreparation

# Define Pauli matrices
XX = Pauli("XX").to_matrix()
YY = Pauli("YY").to_matrix()
ZZ = Pauli("ZZ").to_matrix()
ZI = Pauli("ZI").to_matrix()
IZ = Pauli("IZ").to_matrix()
# Set coefficients
J = 1.0
D = 0.0
h = 0.0
# Define H
H = J * (XX + YY) + D * ZZ + h * (ZI - IZ)
# define V(t), calculate U and local magnetization
time = np.linspace(0, 10, 10)
magnetization = []
for t in time:
V = expm(-1j * t * H)
compiler = QuantumStatePreparation(u=ansatz.zxz_WchainCNOT(2), target_state=V).fit(num_steps = 30)
statevector = Statevector.from_instruction(
compiler.u.assign_parameters(compiler.thetas)
)
# print(V)
# print(V)
print(compiler.fidelity)
# print(compiler.thetas)
psi_t = np.array(statevector.data).reshape(-1, 1)
psi_t_dag = np.conj(psi_t.T)
mag = (psi_t_dag @ ZI @ psi_t)[0][0] - (psi_t_dag @ IZ @ psi_t)[0][0]
magnetization.append(0.5 * mag)

plt.plot(time, magnetization)

0 comments on commit 98bba9f

Please sign in to comment.