Commit ca532fa7 authored by mgassner's avatar mgassner
Browse files

some minor verbesserungen

parent adff4c2a
......@@ -20,10 +20,9 @@ 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.01*(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))
+ 0.01*(np.kron(sigma_z, sigma_0) + np.kron(sigma_0, sigma_z))).astype('float64').tolist()
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:
raise NameError
......
......@@ -6,6 +6,13 @@ import matplotlib.pyplot as plt
from create_model import spin_model
from entropy_new import reduced_dm, compute_entropy
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--set_number_spins", "-d", dest='number_spins',type=int, required=False)
parser.add_argument("--set_param_range_and_steps", '-pr', dest='param_range', nargs='+', type=float, required=False)
parser.add_argument("--boundary_condition", "-b", dest='periodic' ,type=bool, required=False)
args = parser.parse_args()
def test_tfim():
model_name = 'tfim'
number_spins = 6
......@@ -30,12 +37,10 @@ def test_tfim():
print(sub_dims, bipartite_entropies)
def test_area_law_tfim():
def test_area_law(number_spins, periodic, param_range):
model_name = 'tfim'
number_spins = 14
periodic = True
spin_inversion = True
params = np.linspace(0.0, 1.5, 21)
spin_inversion = None
params = np.linspace(param_range[0], param_range[1], int(param_range[2]))
hamming_weight = None # TODO: ?????
entropies = {}
sub_dims = [i for i in range(1,number_spins)]
......@@ -87,10 +92,10 @@ def test_area_law_tfim():
plt.savefig('output/' + filename + '.jpg')
plt.figure(figsize=(20,20))
plt.figure(figsize=(12,12))
half_chain_ee = []
for key in entropies:
half_chain_ee.append(entropies[key][5])
half_chain_ee.append(entropies[key][number_spins // 2 - 1])
plt.plot(params, half_chain_ee, label='h over J:' + key)
plt.legend()
plt.xlabel('Delta / J')
......@@ -99,3 +104,10 @@ def test_area_law_tfim():
plt.grid(True)
plt.savefig('output/' + 'entropy_tfim_' + timestr + '.jpg')
if __name__ == "__main__":
param_range = args.param_range
number_spins = args.number_spins
periodic = args.periodic
test_area_law(number_spins, periodic, param_range)
......@@ -7,6 +7,14 @@ import matplotlib.pyplot as plt
from create_model import spin_model
from entropy_new import reduced_dm, compute_entropy
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--set_number_spins", "-d", dest='number_spins',type=int, required=False)
parser.add_argument("--set_param_range_and_steps", '-pr', dest='param_range', nargs='+', type=float, required=False)
parser.add_argument("--boundary_condition", "-b", dest='periodic' ,type=bool, required=False)
args = parser.parse_args()
def test_xxz():
model_name = 'xxz'
number_spins = 6
......@@ -35,14 +43,11 @@ def test_xxz():
print(entropy)
print('-------------------------------------------')
def test_area_law():
def test_area_law(number_spins, periodic, param_range):
model_name = 'xxz'
number_spins = 14
periodic = True
hamming_weight = number_spins // 2
params = np.linspace(-2.0, 2.0, 41)
spin_inversion=True
params = np.linspace(param_range[0], param_range[1], int(param_range[2]))
spin_inversion = None
entropies = {}
sub_dims = [i for i in range(1,number_spins)]
for param in params:
......@@ -94,10 +99,10 @@ def test_area_law():
plt.savefig('output/' + filename + '.jpg')
plt.figure(figsize=(8,8))
plt.figure(figsize=(12, 12))
half_chain_ee = []
for key in entropies:
half_chain_ee.append(entropies[key][7])
half_chain_ee.append(entropies[key][number_spins // 2 - 1])
plt.plot(params, half_chain_ee, label='Delta_over_J:' + key)
plt.legend()
plt.xlabel('Delta / J')
......@@ -106,3 +111,9 @@ def test_area_law():
plt.grid(True)
plt.savefig('output/' + 'entropy' + timestr + '.jpg')
if __name__ == "__main__":
param_range = args.param_range
number_spins = args.number_spins
periodic = args.periodic
test_area_law(number_spins, periodic, param_range)
Supports Markdown
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