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 ce9a0cb4 authored by mgassner's avatar mgassner
Browse files

minor changes

parent 5728c117
......@@ -21,7 +21,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) + 0*1e-6 *(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()
#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()
#in the plus minus basis
return ( np.kron(sigma_x, sigma_x) - 0.5*param*(np.kron(sigma_z, sigma_0) + np.kron(sigma_0, sigma_z))).astype('float64').tolist()
else:
raise NameError
......
......@@ -13,28 +13,34 @@ parser.add_argument("--set_param_range_and_steps", '-pr', dest='param_range', na
parser.add_argument("--boundary_condition", "-b", dest='periodic' ,type=bool, required=False)
args = parser.parse_args()
def test_tfim():
def test_tfim(number_spins, param_range, periodic = False):
model_name = 'tfim'
number_spins = 8
periodic = True
hamming_weight = number_spins // 2
param = 0.5
hamming_weight = None #number_spins // 2
spin_inversion= None
model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic,
param=param, hamming_weight=None, spin_inversion=spin_inversion)
model.compute_ew_and_ev()
print('EIGENSTATE at h/J = ', param, 'is: ', model.eigenstates[:,0])
sub_dims = np.arange(1, number_spins)
bipartite_entropies = []
gs = model.eigenstates[:,0]
basis_states = model.basis.states
for sub_dim in sub_dims:
print('----------------------------------')
print('Sub Dimension is ', sub_dim)
rhos = reduced_dm(sub_dim, number_spins, hamming_weight, gs, basis_states, spin_inversion)
bipartite_entropies.append(compute_entropy(rhos))
del model
print(sub_dims, bipartite_entropies)
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)
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)
entropies.append(compute_entropy(rhos))
del model
plt.figure(figsize=(12, 12))
plt.plot(params, entropies, label="half chain entropy")
plt.legend()
plt.xlabel('h / J')
plt.ylabel('Bipartite Entanglement Entropy')
plt.title('Model:' + model_name + str(number_spins) + str(periodic))
plt.grid(True)
timestr = time.strftime("%Y%m%d-%H%M%S")
plt.savefig('output/' + timestr + 'entropytest.jpg')
def test_area_law(number_spins, periodic, param_range):
......@@ -110,4 +116,4 @@ if __name__ == "__main__":
number_spins = args.number_spins
periodic = args.periodic
#test_area_law(number_spins, periodic, param_range)
test_tfim()
test_tfim(number_spins, param_range)
......@@ -21,7 +21,7 @@ def test_xxz(number_spins, param_range, periodic=True):
entropies = []
hamming_weight = None #number_spins // 2
for param in params:
if param > -0.95:
if 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)
......@@ -30,20 +30,13 @@ def test_xxz(number_spins, param_range, periodic=True):
basis_states = model.basis.states
gs = model.eigenstates[:,0]
# just for testing
if number_spins == 16 and param <= -1.1 and param > -1.4:
if number_spins == 8 and param >= -1.1 and param > -1.4:
print(gs[0])
printi = []
for i, x in enumerate(gs):
if abs(x) > 1e-1:
printi.append([x, basis_states[i]])
print(printi)
if number_spins == 10 and param < -2.0:
print(gs[0])
printi = []
for i, x in enumerate(gs):
if abs(x) > 1e-2:
printi.append([x, basis_states[i]])
print(printi)
#print('Number Spins: ', model.basis.number_spins)
#print('States', model.basis.states)
sub_dim = number_spins // 2
......
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