Skip to content

Commit

Permalink
Update lindbladian
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyed99 committed May 1, 2024
1 parent be05c28 commit 8a5632d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 174 deletions.
2 changes: 1 addition & 1 deletion src/models/contact_process_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def construct_num_op(L: int) -> tt.TT:

for i in range(L):
number_op = np.kron(np.array([[0, 0], [0, 1]]), np.eye(2)) + np.kron(np.eye(2), np.array([[0, 0], [0, 1]]))
op_cores[i] = np.zeros([2, 2, 2, 2], dtype=complex)
# op_cores[i] = np.zeros([2, 2, 2, 2], dtype=complex)
op_cores[i] = number_op.reshape(2, 2, 2, 2)

return tt.TT(op_cores)
116 changes: 0 additions & 116 deletions src/models/ising_model.py

This file was deleted.

6 changes: 4 additions & 2 deletions src/simulations/contact_process_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
# compute Hermitian part of mps
hermit_mps = (1 / 2) * (gs_mps + gs_mps_dag)

# compute observables
print("Compute particle numbers")
particle_nums = compute_site_expVal_vMPO(hermit_mps, construct_num_op(L))
print(f"Particle number/site: {particle_nums}")
Expand All @@ -83,10 +84,11 @@
purities[i] = compute_purity(gs_mps)
print(f"Purity: {purities[-1]}")

print("Compute half-chain density correlation for largest bond dimension")
print("Compute density correlation for largest bond dimension")
an_op = construct_num_op(1)
for k in range(L - 1):
correlations[i, k] = abs(compute_correlation_vMPO(gs_mps, an_op, r0=0, r1=k + 1))
correlations[i, k] = abs(compute_correlation_vMPO(gs_mps, an_op, r0=0,
r1=k + 1)) #NOTE: absolute value or not??

print("Compute half-chain entanglement entropy spectrum for largest bond dimension")
ent_ent_spectrum[i, :] = compute_entanglement_spectrum(gs_mps)
Expand Down
45 changes: 0 additions & 45 deletions src/simulations/ising_chain.py

This file was deleted.

4 changes: 3 additions & 1 deletion src/utilities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def compute_purity(mps: tt.TT) -> float:

def compute_site_expVal(mps: tt.TT, mpo: tt.TT) -> np.ndarray:
"""
Compute the expectation value < Ψ | onsiteOp | Ψ > for each site of the MPS
Args:
- mps: canonicalized mps
- mpo: cores that have dimension (2,2,2,2)
Expand All @@ -96,7 +98,7 @@ def compute_site_expVal(mps: tt.TT, mpo: tt.TT) -> np.ndarray:

def compute_site_expVal_vMPO(mps: tt.TT, mpo: tt.TT) -> np.ndarray:
"""
Compute ā = (1/L) * Σ_k Tr(ρ A_k)
Compute Tr(ρ A_k) for each k
"""

site_vals = np.zeros(mps.order, dtype=float)
Expand Down
18 changes: 9 additions & 9 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
import numpy as np

import src.models.contact_process_model as cp_model
import src.models.ising_model as ising_model
import src.models.diss_ising_model as diss_ising_model

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)

L = 3
GAMMA = 1
GAMMA = 1.0
OMEGA = 1.5
V = 5
DELTA = 0
V = 5.0
DELTA = 0.0


class ModelFunctions(unittest.TestCase):

def test_hermiticity(self):
ising_lindblad = ising_model.construct_lindblad(gamma=GAMMA, V=V, omega=OMEGA, delta=DELTA, L=L)
ising_lindblad_dag = ising_model.construct_lindblad_dag(gamma=GAMMA, V=V, omega=OMEGA, delta=DELTA, L=L)
ising_lindblad = diss_ising_model.construct_lindblad(gamma=GAMMA, V=V, omega=OMEGA, delta=DELTA, L=L)
ising_lindblad_dag = diss_ising_model.construct_lindblad_dag(gamma=GAMMA, V=V, omega=OMEGA, delta=DELTA, L=L)
assert np.array_equal(ising_lindblad.transpose(conjugate=True).matricize(), ising_lindblad_dag.matricize())

ising_lindblad_hermitian = ising_lindblad_dag @ ising_lindblad
Expand All @@ -37,16 +37,16 @@ def test_hermiticity(self):
cp_lindblad_hermitian = cp_lindblad_dag @ cp_lindblad
assert np.array_equal(np.conj(cp_lindblad_hermitian.matricize().T), cp_lindblad_hermitian.matricize())

def test_exact_diagonalization(self): #TODO: Add ising model too :)
def test_exact_diagonalization(self):
cp_lindblad = cp_model.construct_lindblad(gamma=GAMMA, omega=OMEGA, L=L)
cp_lindblad_dag = cp_model.construct_lindblad_dag(gamma=GAMMA, omega=OMEGA, L=L)
cp_lindblad_hermitian = cp_lindblad_dag @ cp_lindblad

evals, _ = np.linalg.eig(cp_lindblad_hermitian.matricize())
assert np.isclose(np.min(evals.real), 0.0)

ising_lindblad = ising_model.construct_lindblad(gamma=GAMMA, V=V, omega=OMEGA, delta=DELTA, L=L)
ising_lindblad_dag = ising_model.construct_lindblad_dag(gamma=GAMMA, V=V, omega=OMEGA, delta=DELTA, L=L)
ising_lindblad = diss_ising_model.construct_lindblad(gamma=GAMMA, V=V, omega=OMEGA, delta=DELTA, L=L)
ising_lindblad_dag = diss_ising_model.construct_lindblad_dag(gamma=GAMMA, V=V, omega=OMEGA, delta=DELTA, L=L)
ising_lindblad_hermitian = ising_lindblad_dag @ ising_lindblad

evals, _ = np.linalg.eig(ising_lindblad_hermitian.matricize())
Expand Down

0 comments on commit 8a5632d

Please sign in to comment.