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