-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
068da96
commit e22fb29
Showing
4 changed files
with
131 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import tensornetwork as tn | ||
import numpy as np | ||
from mps import MPS | ||
from gates import * | ||
import matplotlib.pyplot as plt | ||
|
||
N = 10 | ||
cutoff = 1e-8 | ||
tau = 0.1 | ||
ttotal = 2.0 | ||
|
||
gates = [] | ||
N = 10 | ||
n = 3 | ||
mps = MPS("q", N, 2) | ||
evolution_range = np.linspace(0, 80, 7) | ||
js = np.arange(0, n) | ||
|
||
magnetization = [] | ||
|
||
for t in evolution_range: | ||
mag_t = [] | ||
for j in range(0, n): | ||
gate = sigmaZZ(t) | ||
print(gate.tensor , t, j) | ||
mps.apply_two_qubit_gate(sigmaZZ(t), [j, j+1]) | ||
mps.apply_two_qubit_gate(sigmaXnegXpos(t), [j, j+1]) | ||
mps.apply_two_qubit_gate(sigmaXposXneg(t), [j, j+1]) | ||
|
||
mag_t += [mps.get_expectation(zgate(), j)] | ||
|
||
magnetization += [mag_t] | ||
|
||
with plt.style.context('default'): | ||
plt.figure(figsize=(12, 7)) | ||
|
||
# plot the magnetization | ||
ax1 = plt.subplot(131) | ||
plt.pcolormesh(js, evolution_range, np.real(magnetization), vmin=-0.5, vmax=0.5) | ||
plt.set_cmap('RdYlBu') | ||
plt.colorbar() | ||
plt.title('Z-Magnetization') | ||
plt.xlabel('Site') | ||
plt.ylabel('time [ $Jt$ ]') | ||
|
||
plt.show() | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
import numpy as np | ||
import tensornetwork as tn | ||
import numpy as np | ||
from constants import _xmatrix, _cnot_matrix, _hmatrix | ||
from constants import * | ||
from copy import deepcopy | ||
|
||
def xgate() -> tn.Node: | ||
return tn.Node(deepcopy(_xmatrix), name="xgate") | ||
return tn.Node(deepcopy(xmatrix), name="xgate") | ||
|
||
def zgate() -> tn.Node: | ||
return tn.Node(deepcopy(zmatrix), name="xgate") | ||
|
||
def cnot() -> tn.Node: | ||
return tn.Node(deepcopy(_cnot_matrix), name="cnot") | ||
return tn.Node(deepcopy(cnot_matrix), name="cnot") | ||
|
||
def hgate() -> tn.Node: | ||
return tn.Node(deepcopy(_hmatrix), name="hgate") | ||
return tn.Node(deepcopy(hmatrix), name="hgate") | ||
|
||
def sigmaZZ(t) -> tn.Node: | ||
return tn.Node(deepcopy(np.exp(sigma_z_sigma_z_gate_matrix * -1j * t * 0.5)), name="sigmaZZ") | ||
|
||
def sigmaXposXneg(t) -> tn.Node: | ||
return tn.Node(deepcopy(np.exp(sigma_x_pos_sigma_x_neg_gate_matrix * -1j * t * 0.5)), name="sigmaXposXneg") | ||
|
||
def sigmaXnegXpos(t) -> tn.Node: | ||
return tn.Node(deepcopy(np.exp(sigma_x_neg_sigma_x_pos_gate_matrix * -1j * t * 0.5 )), name="sigmaXposXneg") | ||
|
||
def isingHamiltonian(t)-> tn.Node: | ||
return tn.Node(deepcopy(np.exp(ising_hamiltonian_matrix * -1j * t * 0.5))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters