Commit 4ebc2a35 by mgassner

### removed magnitization restriction

parent 37c8f675
 import lattice_symmetries as ls import lattice_symmetries as ls import numpy as np import numpy as np import yaml # Spin operators # Spin operators sigma_x = np.array([[0., 1.], [1., 0.]]) sigma_x = np.array([[0., 1.], [1., 0.]]) ... @@ -20,7 +19,7 @@ def create_2spin_matrix(model_name, param): ... @@ -20,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)) + #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) + 1e-10 *(np.kron(sigma_z, sigma_0) + np.kron(sigma_0, sigma_z))).astype('float64') param * np.kron(sigma_z, sigma_z) + 0*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))).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: else: ... ...
 ... @@ -64,7 +64,7 @@ def MI_vs_Entropy(model_name, number_spins, param_range): ... @@ -64,7 +64,7 @@ def MI_vs_Entropy(model_name, number_spins, param_range): print('Sub Dimension is ', sub_dim) print('Sub Dimension is ', sub_dim) for param in params: for param in params: if param < -1.0 or model_name == 'tfim': if param < -1.0 or model_name == 'tfim': hamming_weight = None hamming_weight = number_spins // 2 else: else: hamming_weight = number_spins // 2 hamming_weight = number_spins // 2 model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic, model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic, ... @@ -74,7 +74,8 @@ def MI_vs_Entropy(model_name, number_spins, param_range): ... @@ -74,7 +74,8 @@ def MI_vs_Entropy(model_name, number_spins, param_range): gs = model.eigenstates[:,0] 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) MI = compute_MI(sub_dim, number_spins, hamming_weight, gs, basis_states, spin_inversion=None, first_trace_spin=first_trace_spin) MIs.append(MI) MIs.append(MI) rho_half = reduced_dm(number_spins // 2, number_spins, hamming_weight, gs, basis_states) half_dim = number_spins // 2 rho_half = reduced_dm(half_dim, number_spins, hamming_weight, gs, basis_states) Entropies.append(compute_entropy(rho_half)) Entropies.append(compute_entropy(rho_half)) rho_4spin = reduced_dm(4, number_spins, hamming_weight, gs, basis_states) rho_4spin = reduced_dm(4, number_spins, hamming_weight, gs, basis_states) Entropies4.append(compute_entropy(rho_4spin)) Entropies4.append(compute_entropy(rho_4spin)) ... @@ -122,9 +123,9 @@ def MutInf(model_name, param, spin_range): ... @@ -122,9 +123,9 @@ def MutInf(model_name, param, spin_range): print('Number Spins: ', number_spins) print('Number Spins: ', number_spins) print('Sub Dimension is ', sub_dim) print('Sub Dimension is ', sub_dim) if param < -1.0 or model_name == 'tfim': if param < -1.0 or model_name == 'tfim': hamming_weight = None hamming_weight = number_spins // 2 else: else: hamming_weight = number_spins //2 hamming_weight = number_spins // 2 model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic, model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic, param=param, hamming_weight=hamming_weight ,spin_inversion=spin_inversion) param=param, hamming_weight=hamming_weight ,spin_inversion=spin_inversion) ... ...
 ... @@ -15,10 +15,10 @@ args = parser.parse_args() ... @@ -15,10 +15,10 @@ args = parser.parse_args() def test_tfim(): def test_tfim(): model_name = 'tfim' model_name = 'tfim' number_spins = 6 number_spins = 8 periodic = True periodic = True hamming_weight = None hamming_weight = number_spins // 2 param = 1.0 param = 0.5 spin_inversion= None spin_inversion= None model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic, model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic, param=param, hamming_weight=None, spin_inversion=spin_inversion) param=param, hamming_weight=None, spin_inversion=spin_inversion) ... @@ -109,5 +109,5 @@ if __name__ == "__main__": ... @@ -109,5 +109,5 @@ if __name__ == "__main__": param_range = args.param_range param_range = args.param_range number_spins = args.number_spins number_spins = args.number_spins periodic = args.periodic periodic = args.periodic test_area_law(number_spins, periodic, param_range) #test_area_law(number_spins, periodic, param_range) test_tfim()
 ... @@ -15,15 +15,13 @@ parser.add_argument("--boundary_condition", "-b", dest='periodic' ,type=bool, re ... @@ -15,15 +15,13 @@ parser.add_argument("--boundary_condition", "-b", dest='periodic' ,type=bool, re args = parser.parse_args() args = parser.parse_args() def test_xxz(): def test_xxz(number_spins, periodic, param_range): model_name = 'xxz' model_name = 'xxz' number_spins = 16 params = np.linspace(param_range[0], param_range[1], int(param_range[2])) periodic = False params = np.linspace(-1.2, 3.0, 41) entropies = [] entropies = [] for param in params: for param in params: if param < -1.0: if param < -1.0: hamming_weight = None hamming_weight = number_spins // 2 else: else: hamming_weight = number_spins // 2 hamming_weight = number_spins // 2 model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic, model = spin_model(model_name=model_name, number_spins=number_spins, periodic=periodic, ... @@ -32,8 +30,8 @@ def test_xxz(): ... @@ -32,8 +30,8 @@ def test_xxz(): print('EIGENSTATE at h/J = ', param, 'is: ', model.eigenstates[:,0]) print('EIGENSTATE at h/J = ', param, 'is: ', model.eigenstates[:,0]) basis_states = model.basis.states basis_states = model.basis.states gs = model.eigenstates[:,0] gs = model.eigenstates[:,0] print('Number Spins: ', model.basis.number_spins) #print('Number Spins: ', model.basis.number_spins) print('States', model.basis.states) #print('States', model.basis.states) sub_dim = number_spins // 2 sub_dim = number_spins // 2 rhos = reduced_dm(sub_dim, number_spins, hamming_weight, gs, basis_states) rhos = reduced_dm(sub_dim, number_spins, hamming_weight, gs, basis_states) entropy = compute_entropy(rhos) entropy = compute_entropy(rhos) ... @@ -124,4 +122,4 @@ if __name__ == "__main__": ... @@ -124,4 +122,4 @@ if __name__ == "__main__": number_spins = args.number_spins number_spins = args.number_spins periodic = args.periodic periodic = args.periodic #test_area_law(number_spins, periodic, param_range) #test_area_law(number_spins, periodic, param_range) test_xxz() test_xxz(number_spins, periodic, param_range) \ No newline at end of file \ No newline at end of file
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