Commit 352a6909 authored by mgassner's avatar mgassner
Browse files

minor changes in the code

parent 5b7ffa0a
......@@ -19,7 +19,7 @@ def create_2spin_matrix(model_name, param):
#return (0.5 * (np.kron(sigma_p, sigma_m) + np.kron(sigma_m, sigma_p)) +
# param * np.kron(sigma_z, sigma_z)).astype('float64').tolist()
return (0.5 * (np.kron(sigma_p, sigma_m) + np.kron(sigma_m, sigma_p)) +
param * np.kron(sigma_z, sigma_z) + 0*1e-10 *(np.kron(sigma_z, sigma_0) + np.kron(sigma_0, sigma_z))).astype('float64')
param * np.kron(sigma_z, sigma_z) + 1e-10 *(np.kron(sigma_z, sigma_0) + np.kron(sigma_0, sigma_z))).astype('float64')
elif model_name == 'tfim':
return ( np.kron(sigma_z, sigma_z) - 0.5*param*(np.kron(sigma_x, sigma_0) + np.kron(sigma_0, sigma_x))).astype('float64').tolist()
else:
......
......@@ -23,9 +23,6 @@ def test_mutual_information():
periodic = False
spin_inversion = None
param = 1.0
if param < -1.0:
hamming_weight = number_spins // 2
else:
hamming_weight = number_spins // 2
model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic,
param=param, hamming_weight=hamming_weight ,spin_inversion=spin_inversion)
......@@ -59,26 +56,22 @@ def MI_vs_Entropy(model_name, number_spins, param_range):
MIs = []
Entropies = []
Entropies4 = []
hamming_weight = number_spins // 2
print('Number Spins: ', number_spins)
print('Sub Dimension is ', sub_dim)
for param in params:
if param < -1.0 or model_name == 'tfim':
hamming_weight = number_spins // 2
else:
hamming_weight = number_spins // 2
model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic,
param=param, hamming_weight=hamming_weight)
model.compute_ew_and_ev()
basis_states = model.basis.states
gs = model.eigenstates[:,0]
MI = compute_MI(sub_dim, number_spins, hamming_weight, gs, basis_states, spin_inversion=None, first_trace_spin=first_trace_spin)
MIs.append(MI)
half_dim = number_spins // 2
rho_half = reduced_dm(half_dim, number_spins, hamming_weight, gs, basis_states)
Entropies.append(compute_entropy(rho_half))
rho_4spin = reduced_dm(4, number_spins, hamming_weight, gs, basis_states)
Entropies4.append(compute_entropy(rho_4spin))
MI = compute_MI(sub_dim, number_spins, hamming_weight, gs, basis_states, spin_inversion=None, first_trace_spin=first_trace_spin)
MIs.append(MI)
del model
data = {
......
......@@ -5,7 +5,7 @@ import time
import matplotlib.pyplot as plt
from create_model import spin_model
from entropy_new import reduced_dm, compute_entropy
from entropy_new import _hamming_weight, reduced_dm, compute_entropy
import argparse
parser = argparse.ArgumentParser()
......@@ -15,15 +15,12 @@ parser.add_argument("--boundary_condition", "-b", dest='periodic' ,type=bool, re
args = parser.parse_args()
def test_xxz(number_spins, periodic, param_range):
def test_xxz(number_spins, param_range, periodic=False):
model_name = 'xxz'
params = np.linspace(param_range[0], param_range[1], int(param_range[2]))
entropies = []
for param in params:
if param < -1.0:
hamming_weight = number_spins // 2
else:
hamming_weight = number_spins // 2
for param in params:
model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic,
param=param, hamming_weight=hamming_weight)
model.compute_ew_and_ev()
......@@ -122,4 +119,4 @@ if __name__ == "__main__":
number_spins = args.number_spins
periodic = args.periodic
#test_area_law(number_spins, periodic, param_range)
test_xxz(number_spins, periodic, param_range)
\ No newline at end of file
test_xxz(number_spins, param_range)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment