To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 21d54c2b authored by mgassner's avatar mgassner
Browse files

just minor things

parent 1b7634dd
......@@ -132,4 +132,4 @@ def compute_MI(sub_dim, dim, hamming, amplitudes, states_of_amplitudes, spin_inv
rhos_A = reduced_dm(sub_dim, dim, hamming, amplitudes, states_of_amplitudes,
spin_inversion=spin_inversion, first_trace_spin=first_trace_spin_left)
S_A = compute_entropy(rhos_A)
return S_A + S_B - S_AB #[S_A, S_B, S_AB]
\ No newline at end of file
return [S_A, S_B, S_AB] #S_A + S_B -S_AB
\ No newline at end of file
......@@ -16,33 +16,33 @@ parser.add_argument("--set_spin_range", "-sr", dest='spin_range', nargs='+', typ
parser.add_argument("--set_param", "-p", dest='param',type=float, required=False)
args = parser.parse_args()
def test_mutual_information():
def test_mutual_information(param=0.5):
# change return in compute_MI to run this function [S_A, S_B, S_AB] instead of S_A + S_B - S_AB
model_name = 'xxz'
number_spins = 10
number_spins = 8
periodic = False
spin_inversion = None
param = 1.0
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)
model.compute_ew_and_ev()
print('EIGENSTATE at h/J = ', param, 'is: ', model.eigenstates[:,0])
sub_dim = 4
first_trace_spin = 4
sub_dim = 2
first_trace_spin = 2
basis_states = model.basis.states
gs = model.eigenstates[:,0]
print('Number Spins: ', model.basis.number_spins)
print('States', model.basis.states)
print('Sub Dimension is ', sub_dim)
entropies = compute_MI(sub_dim, number_spins, hamming_weight, gs, basis_states, spin_inversion=None, first_trace_spin=first_trace_spin)
MI = entropies[0] + entropies[1] - entropies[2]
"""MI = entropies[0] + entropies[1] - entropies[2]
print(MI)
print(entropies)
print('--------------------Test-----------------------')
rhos4 = reduced_dm(4, number_spins, hamming_weight, gs, basis_states)
rhos6 = reduced_dm(6, number_spins, hamming_weight, gs, basis_states)
print(compute_entropy(rhos4), compute_entropy(rhos6))
print(compute_entropy(rhos4), compute_entropy(rhos6))"""
print(entropies[2])
def MI_vs_Entropy(model_name, number_spins, param_range):
......@@ -51,29 +51,29 @@ def MI_vs_Entropy(model_name, number_spins, param_range):
periodic = False
params = np.linspace(param_range[0], param_range[1], int(param_range[2]))
sub_dim = 4
first_trace_spin = 4
sub_dim = 2
first_trace_spin = 2
S_As = []
S_ABs = []
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:
hamming_weight = None
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]
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)
S_A, S_B, S_AB = compute_MI(sub_dim, number_spins, hamming_weight, gs, basis_states, spin_inversion=None, first_trace_spin=first_trace_spin)
S_As.append(S_A)
S_ABs.append(S_AB)
MIs.append(S_A+S_B-S_AB)
del model
print(Entropies)
data = {
'Model': model_name,
'Number_spins': number_spins,
......@@ -81,9 +81,9 @@ def MI_vs_Entropy(model_name, number_spins, param_range):
'Hamming_weight': hamming_weight,
'Sub_dim': sub_dim,
'Delta or h over J': params.tolist(),
'Entropies half chain': np.array(Entropies).tolist(),
'Entropies 4 spin': np.array(Entropies4).tolist(),
'Mutual Informations': np.array(MIs).tolist()
'Mutual Informations': np.array(MIs).tolist(),
'Entropy of A': np.array(S_As).tolist(),
'Entropy of AuB': np.array(S_ABs).tolist()
}
timestr = time.strftime("%Y%m%d-%H%M%S")
......@@ -94,9 +94,7 @@ def MI_vs_Entropy(model_name, number_spins, param_range):
plt.figure(figsize=(12,12))
plt.title('MI: ' + model_name + ' ' + str(number_spins) + ' ' + str(periodic))
plt.plot(params, Entropies, label='Half-chain Entropy')
plt.plot(params, Entropies4, label='4 spin entropy')
plt.plot(params, MIs, label='Mutual Information')
plt.plot(params, MIs, label='rho_AB')
plt.grid(True)
plt.legend()
plt.savefig('output/' + filename + '.png')
......@@ -165,5 +163,6 @@ if __name__ == "__main__":
number_spins = args.number_spins
spin_range = args.spin_range
param = args.param
#test_mutual_information(param)
MI_vs_Entropy(model_name, number_spins, param_range)
#MutInf(model_name, param, spin_range)
\ No newline at end of file
#MutInf(model_name, param, spin_range)
......@@ -16,19 +16,19 @@ args = parser.parse_args()
def test_tfim(number_spins, param_range, periodic = False):
model_name = 'tfim'
hamming_weight = None #number_spins // 2
spin_inversion= None
spin_inversion= 1
params = np.linspace(param_range[0], param_range[1], int(param_range[2]))
entropies = []
for param in params:
model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic,
param=param, hamming_weight=hamming_weight)
param=param, hamming_weight=hamming_weight, spin_inversion=spin_inversion)
model.compute_ew_and_ev()
# print('EIGENSTATE at h/J = ', param, 'is: ', model.eigenstates[:,0])
gs = model.eigenstates[:,0]
basis_states = model.basis.states
sub_dim = number_spins // 2
first_trace_spin = None #number_spins // 4
rhos = reduced_dm(sub_dim, number_spins, hamming_weight, gs, basis_states, first_trace_spin=first_trace_spin)
rhos = reduced_dm(sub_dim, number_spins, hamming_weight, gs, basis_states, first_trace_spin=first_trace_spin, spin_inversion=spin_inversion)
entropies.append(compute_entropy(rhos))
del model
......
......@@ -15,7 +15,7 @@ parser.add_argument("--boundary_condition", "-b", dest='periodic' ,type=bool, re
args = parser.parse_args()
def test_xxz(number_spins, param_range, periodic=True):
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 = []
......@@ -26,7 +26,7 @@ def test_xxz(number_spins, param_range, periodic=True):
model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic,
param=param, hamming_weight=hamming_weight)
model.compute_ew_and_ev()
#print('EIGENSTATE at h/J = ', param, 'is: ', model.eigenstates[:,0])
print('EIGENSTATE at Delta/J = ', param, 'is: ', model.eigenstates[:,0])
basis_states = model.basis.states
gs = model.eigenstates[:,0]
# just for testing
......@@ -130,4 +130,4 @@ if __name__ == "__main__":
number_spins = args.number_spins
periodic = args.periodic
#test_area_law(number_spins, periodic, param_range)
test_xxz(number_spins, param_range)
\ No newline at end of file
test_xxz(number_spins, param_range)
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