version 0.0.49
This commit is contained in:
		| @@ -5,6 +5,8 @@ | ||||
| import numpy as np | ||||
| import cmath | ||||
|  | ||||
| # Fourier_transform for discrete lattices | ||||
|  | ||||
| def one_dimensional_fourier_transform(k, unit_cell, hopping): | ||||
|     unit_cell = np.array(unit_cell) | ||||
|     hopping = np.array(hopping) | ||||
| @@ -24,4 +26,60 @@ def three_dimensional_fourier_transform_for_cubic_lattice(k1, k2, k3, unit_cell, | ||||
|     hopping_2 = np.array(hopping_2) | ||||
|     hopping_3 = np.array(hopping_3) | ||||
|     hamiltonian = unit_cell+hopping_1*cmath.exp(1j*k1)+hopping_1.transpose().conj()*cmath.exp(-1j*k1)+hopping_2*cmath.exp(1j*k2)+hopping_2.transpose().conj()*cmath.exp(-1j*k2)+hopping_3*cmath.exp(1j*k3)+hopping_3.transpose().conj()*cmath.exp(-1j*k3) | ||||
|     return hamiltonian | ||||
|     return hamiltonian | ||||
|  | ||||
|  | ||||
| ## calculate reciprocal lattice vectors | ||||
|  | ||||
| def calculate_one_dimensional_reciprocal_lattice_vector(a1): | ||||
|     b1 = 2*np.pi/a1 | ||||
|     return b1 | ||||
|  | ||||
| def calculate_two_dimensional_reciprocal_lattice_vectors(a1, a2): | ||||
|     a1 = np.array(a1) | ||||
|     a2 = np.array(a2) | ||||
|     a1 = np.append(a1, 0) | ||||
|     a2 = np.append(a2, 0) | ||||
|     a3 = np.array([0, 0, 1]) | ||||
|     b1 = 2*np.pi*np.cross(a2, a3)/np.dot(a1, np.cross(a2, a3)) | ||||
|     b2 = 2*np.pi*np.cross(a3, a1)/np.dot(a1, np.cross(a2, a3)) | ||||
|     b1 = np.delete(b1, 2) | ||||
|     b2 = np.delete(b2, 2) | ||||
|     return b1, b2 | ||||
|  | ||||
| def calculate_three_dimensional_reciprocal_lattice_vectors(a1, a2, a3): | ||||
|     a1 = np.array(a1) | ||||
|     a2 = np.array(a2) | ||||
|     a3 = np.array(a3) | ||||
|     b1 = 2*np.pi*np.cross(a2, a3)/np.dot(a1, np.cross(a2, a3)) | ||||
|     b2 = 2*np.pi*np.cross(a3, a1)/np.dot(a1, np.cross(a2, a3)) | ||||
|     b3 = 2*np.pi*np.cross(a1, a2)/np.dot(a1, np.cross(a2, a3)) | ||||
|     return b1, b2, b3 | ||||
|  | ||||
| def calculate_one_dimensional_reciprocal_lattice_vector_with_sympy(a1): | ||||
|     import sympy | ||||
|     b1 = 2*sympy.pi/a1 | ||||
|     return b1 | ||||
|  | ||||
| def calculate_two_dimensional_reciprocal_lattice_vectors_with_sympy(a1, a2): | ||||
|     import sympy | ||||
|     a1 = sympy.Matrix(1, 3, [a1[0], a1[1], 0]) | ||||
|     a2 = sympy.Matrix(1, 3, [a2[0], a2[1], 0]) | ||||
|     a3 = sympy.Matrix(1, 3, [0, 0, 1]) | ||||
|     cross_a2_a3 = a2.cross(a3) | ||||
|     cross_a3_a1 = a3.cross(a1) | ||||
|     b1 = 2*sympy.pi*cross_a2_a3/a1.dot(cross_a2_a3) | ||||
|     b2 = 2*sympy.pi*cross_a3_a1/a1.dot(cross_a2_a3) | ||||
|     b1 = sympy.Matrix(1, 2, [b1[0], b1[1]]) | ||||
|     b2 = sympy.Matrix(1, 2, [b2[0], b2[1]]) | ||||
|     return b1, b2 | ||||
|  | ||||
| def calculate_three_dimensional_reciprocal_lattice_vectors_with_sympy(a1, a2, a3): | ||||
|     import sympy | ||||
|     cross_a2_a3 = a2.cross(a3) | ||||
|     cross_a3_a1 = a3.cross(a1) | ||||
|     cross_a1_a2 = a1.cross(a2) | ||||
|     b1 = 2*sympy.pi*cross_a2_a3/a1.dot(cross_a2_a3) | ||||
|     b2 = 2*sympy.pi*cross_a3_a1/a1.dot(cross_a2_a3) | ||||
|     b3 = 2*sympy.pi*cross_a1_a2/a1.dot(cross_a2_a3) | ||||
|     return b1, b2, b3 | ||||
| @@ -1,6 +1,6 @@ | ||||
| # Guan is an open-source python package developed and maintained by https://www.guanjihuan.com/about. The primary location of this package is on website https://py.guanjihuan.com. | ||||
| 
 | ||||
| # calculate Green functions | ||||
| # Green functions | ||||
| 
 | ||||
| import numpy as np | ||||
| import guan | ||||
| @@ -6,12 +6,11 @@ from .basic_functions import * | ||||
| from .Fourier_transform import * | ||||
| from .Hamiltonian_of_finite_size_systems import * | ||||
| from .Hamiltonian_of_models_in_the_reciprocal_space import * | ||||
| from .calculate_band_structures_and_wave_functions import * | ||||
| from .calculate_Green_functions import * | ||||
| from .calculate_density_of_states import * | ||||
| from .calculate_conductance import * | ||||
| from .calculate_scattering_matrix import * | ||||
| from .calculate_topological_invariant import * | ||||
| from .band_structures_and_wave_functions import * | ||||
| from .Green_functions import * | ||||
| from .density_of_states import * | ||||
| from .quantum_transport import * | ||||
| from .topological_invariant import * | ||||
| from .read_and_write import * | ||||
| from .plot_figures import * | ||||
| from .others import * | ||||
| @@ -1,8 +1,8 @@ | ||||
| # Guan is an open-source python package developed and maintained by https://www.guanjihuan.com/about. The primary location of this package is on website https://py.guanjihuan.com. | ||||
| 
 | ||||
| # calculate_band_structures_and_wave_functions | ||||
| # band_structures_and_wave_functions | ||||
| 
 | ||||
| ## calculate band structures | ||||
| ## band structures | ||||
| 
 | ||||
| import numpy as np | ||||
| import cmath | ||||
| @@ -66,7 +66,7 @@ def calculate_eigenvalue_with_two_parameters(x_array, y_array, hamiltonian_funct | ||||
|             i0 += 1 | ||||
|     return eigenvalue_array | ||||
| 
 | ||||
| ## calculate wave functions | ||||
| ## wave functions | ||||
| 
 | ||||
| def calculate_eigenvector(hamiltonian): | ||||
|     eigenvalue, eigenvector = np.linalg.eigh(hamiltonian)  | ||||
| @@ -71,59 +71,4 @@ def sigma_zy(): | ||||
|     return np.kron(sigma_z(), sigma_y()) | ||||
|  | ||||
| def sigma_zz(): | ||||
|     return np.kron(sigma_z(), sigma_z()) | ||||
|  | ||||
| ## calculate reciprocal lattice vectors | ||||
|  | ||||
| def calculate_one_dimensional_reciprocal_lattice_vector(a1): | ||||
|     b1 = 2*np.pi/a1 | ||||
|     return b1 | ||||
|  | ||||
| def calculate_two_dimensional_reciprocal_lattice_vectors(a1, a2): | ||||
|     a1 = np.array(a1) | ||||
|     a2 = np.array(a2) | ||||
|     a1 = np.append(a1, 0) | ||||
|     a2 = np.append(a2, 0) | ||||
|     a3 = np.array([0, 0, 1]) | ||||
|     b1 = 2*np.pi*np.cross(a2, a3)/np.dot(a1, np.cross(a2, a3)) | ||||
|     b2 = 2*np.pi*np.cross(a3, a1)/np.dot(a1, np.cross(a2, a3)) | ||||
|     b1 = np.delete(b1, 2) | ||||
|     b2 = np.delete(b2, 2) | ||||
|     return b1, b2 | ||||
|  | ||||
| def calculate_three_dimensional_reciprocal_lattice_vectors(a1, a2, a3): | ||||
|     a1 = np.array(a1) | ||||
|     a2 = np.array(a2) | ||||
|     a3 = np.array(a3) | ||||
|     b1 = 2*np.pi*np.cross(a2, a3)/np.dot(a1, np.cross(a2, a3)) | ||||
|     b2 = 2*np.pi*np.cross(a3, a1)/np.dot(a1, np.cross(a2, a3)) | ||||
|     b3 = 2*np.pi*np.cross(a1, a2)/np.dot(a1, np.cross(a2, a3)) | ||||
|     return b1, b2, b3 | ||||
|  | ||||
| def calculate_one_dimensional_reciprocal_lattice_vector_with_sympy(a1): | ||||
|     import sympy | ||||
|     b1 = 2*sympy.pi/a1 | ||||
|     return b1 | ||||
|  | ||||
| def calculate_two_dimensional_reciprocal_lattice_vectors_with_sympy(a1, a2): | ||||
|     import sympy | ||||
|     a1 = sympy.Matrix(1, 3, [a1[0], a1[1], 0]) | ||||
|     a2 = sympy.Matrix(1, 3, [a2[0], a2[1], 0]) | ||||
|     a3 = sympy.Matrix(1, 3, [0, 0, 1]) | ||||
|     cross_a2_a3 = a2.cross(a3) | ||||
|     cross_a3_a1 = a3.cross(a1) | ||||
|     b1 = 2*sympy.pi*cross_a2_a3/a1.dot(cross_a2_a3) | ||||
|     b2 = 2*sympy.pi*cross_a3_a1/a1.dot(cross_a2_a3) | ||||
|     b1 = sympy.Matrix(1, 2, [b1[0], b1[1]]) | ||||
|     b2 = sympy.Matrix(1, 2, [b2[0], b2[1]]) | ||||
|     return b1, b2 | ||||
|  | ||||
| def calculate_three_dimensional_reciprocal_lattice_vectors_with_sympy(a1, a2, a3): | ||||
|     import sympy | ||||
|     cross_a2_a3 = a2.cross(a3) | ||||
|     cross_a3_a1 = a3.cross(a1) | ||||
|     cross_a1_a2 = a1.cross(a2) | ||||
|     b1 = 2*sympy.pi*cross_a2_a3/a1.dot(cross_a2_a3) | ||||
|     b2 = 2*sympy.pi*cross_a3_a1/a1.dot(cross_a2_a3) | ||||
|     b3 = 2*sympy.pi*cross_a1_a2/a1.dot(cross_a2_a3) | ||||
|     return b1, b2, b3 | ||||
|     return np.kron(sigma_z(), sigma_z()) | ||||
| @@ -1,84 +0,0 @@ | ||||
| # Guan is an open-source python package developed and maintained by https://www.guanjihuan.com/about. The primary location of this package is on website https://py.guanjihuan.com. | ||||
|  | ||||
| # calculate conductance | ||||
|  | ||||
| import numpy as np | ||||
| import copy | ||||
| import guan | ||||
|  | ||||
| def calculate_conductance(fermi_energy, h00, h01, length=100): | ||||
|     right_self_energy, left_self_energy, gamma_right, gamma_left = guan.self_energy_of_lead(fermi_energy, h00, h01) | ||||
|     for ix in range(length): | ||||
|         if ix == 0: | ||||
|             green_nn_n = guan.green_function(fermi_energy, h00, broadening=0, self_energy=left_self_energy) | ||||
|             green_0n_n = copy.deepcopy(green_nn_n) | ||||
|         elif ix != length-1: | ||||
|             green_nn_n = guan.green_function_nn_n(fermi_energy, h00, h01, green_nn_n, broadening=0) | ||||
|             green_0n_n = guan.green_function_in_n(green_0n_n, h01, green_nn_n) | ||||
|         else: | ||||
|             green_nn_n = guan.green_function_nn_n(fermi_energy, h00, h01, green_nn_n, broadening=0, self_energy=right_self_energy) | ||||
|             green_0n_n = guan.green_function_in_n(green_0n_n, h01, green_nn_n) | ||||
|     conductance = np.trace(np.dot(np.dot(np.dot(gamma_left, green_0n_n), gamma_right), green_0n_n.transpose().conj())) | ||||
|     return conductance | ||||
|  | ||||
| def calculate_conductance_with_fermi_energy_array(fermi_energy_array, h00, h01, length=100): | ||||
|     dim = np.array(fermi_energy_array).shape[0] | ||||
|     conductance_array = np.zeros(dim) | ||||
|     i0 = 0 | ||||
|     for fermi_energy_0 in fermi_energy_array: | ||||
|         conductance_array[i0] = np.real(calculate_conductance(fermi_energy_0, h00, h01, length)) | ||||
|         i0 += 1 | ||||
|     return conductance_array | ||||
|  | ||||
| def calculate_conductance_with_disorder(fermi_energy, h00, h01, disorder_intensity=2.0, disorder_concentration=1.0, length=100): | ||||
|     right_self_energy, left_self_energy, gamma_right, gamma_left = guan.self_energy_of_lead(fermi_energy, h00, h01) | ||||
|     dim = np.array(h00).shape[0] | ||||
|     for ix in range(length): | ||||
|         disorder = np.zeros((dim, dim)) | ||||
|         for dim0 in range(dim): | ||||
|             if np.random.uniform(0, 1)<=disorder_concentration: | ||||
|                 disorder[dim0, dim0] = np.random.uniform(-disorder_intensity, disorder_intensity) | ||||
|         if ix == 0: | ||||
|             green_nn_n = guan.green_function(fermi_energy, h00+disorder, broadening=0, self_energy=left_self_energy) | ||||
|             green_0n_n = copy.deepcopy(green_nn_n) | ||||
|         elif ix != length-1: | ||||
|             green_nn_n = guan.green_function_nn_n(fermi_energy, h00+disorder, h01, green_nn_n, broadening=0) | ||||
|             green_0n_n = guan.green_function_in_n(green_0n_n, h01, green_nn_n) | ||||
|         else: | ||||
|             green_nn_n = guan.green_function_nn_n(fermi_energy, h00+disorder, h01, green_nn_n, broadening=0, self_energy=right_self_energy) | ||||
|             green_0n_n = guan.green_function_in_n(green_0n_n, h01, green_nn_n) | ||||
|     conductance = np.trace(np.dot(np.dot(np.dot(gamma_left, green_0n_n), gamma_right), green_0n_n.transpose().conj())) | ||||
|     return conductance | ||||
|  | ||||
| def calculate_conductance_with_disorder_intensity_array(fermi_energy, h00, h01, disorder_intensity_array, disorder_concentration=1.0, length=100, calculation_times=1): | ||||
|     dim = np.array(disorder_intensity_array).shape[0] | ||||
|     conductance_array = np.zeros(dim) | ||||
|     i0 = 0 | ||||
|     for disorder_intensity_0 in disorder_intensity_array: | ||||
|         for times in range(calculation_times): | ||||
|             conductance_array[i0] = conductance_array[i0]+np.real(calculate_conductance_with_disorder(fermi_energy, h00, h01, disorder_intensity=disorder_intensity_0, disorder_concentration=disorder_concentration, length=length)) | ||||
|         i0 += 1 | ||||
|     conductance_array = conductance_array/calculation_times | ||||
|     return conductance_array | ||||
|  | ||||
| def calculate_conductance_with_disorder_concentration_array(fermi_energy, h00, h01, disorder_concentration_array, disorder_intensity=2.0, length=100, calculation_times=1): | ||||
|     dim = np.array(disorder_concentration_array).shape[0] | ||||
|     conductance_array = np.zeros(dim) | ||||
|     i0 = 0 | ||||
|     for disorder_concentration_0 in disorder_concentration_array: | ||||
|         for times in range(calculation_times): | ||||
|             conductance_array[i0] = conductance_array[i0]+np.real(calculate_conductance_with_disorder(fermi_energy, h00, h01, disorder_intensity=disorder_intensity, disorder_concentration=disorder_concentration_0, length=length)) | ||||
|         i0 += 1 | ||||
|     conductance_array = conductance_array/calculation_times | ||||
|     return conductance_array | ||||
|  | ||||
| def calculate_conductance_with_scattering_length_array(fermi_energy, h00, h01, length_array, disorder_intensity=2.0, disorder_concentration=1.0, calculation_times=1): | ||||
|     dim = np.array(length_array).shape[0] | ||||
|     conductance_array = np.zeros(dim) | ||||
|     i0 = 0 | ||||
|     for length_0 in length_array: | ||||
|         for times in range(calculation_times): | ||||
|             conductance_array[i0] = conductance_array[i0]+np.real(calculate_conductance_with_disorder(fermi_energy, h00, h01, disorder_intensity=disorder_intensity, disorder_concentration=disorder_concentration, length=length_0)) | ||||
|         i0 += 1 | ||||
|     conductance_array = conductance_array/calculation_times | ||||
|     return conductance_array | ||||
| @@ -1,6 +1,6 @@ | ||||
| # Guan is an open-source python package developed and maintained by https://www.guanjihuan.com/about. The primary location of this package is on website https://py.guanjihuan.com. | ||||
| 
 | ||||
| # calculate density of states | ||||
| # density of states | ||||
| 
 | ||||
| import numpy as np | ||||
| from math import * | ||||
| @@ -1,11 +1,93 @@ | ||||
| # Guan is an open-source python package developed and maintained by https://www.guanjihuan.com/about. The primary location of this package is on website https://py.guanjihuan.com. | ||||
| 
 | ||||
| # calculate scattering matrix | ||||
| # quantum transport | ||||
| 
 | ||||
| ## conductance | ||||
| 
 | ||||
| import numpy as np | ||||
| import copy | ||||
| import guan | ||||
| 
 | ||||
| def calculate_conductance(fermi_energy, h00, h01, length=100): | ||||
|     right_self_energy, left_self_energy, gamma_right, gamma_left = guan.self_energy_of_lead(fermi_energy, h00, h01) | ||||
|     for ix in range(length): | ||||
|         if ix == 0: | ||||
|             green_nn_n = guan.green_function(fermi_energy, h00, broadening=0, self_energy=left_self_energy) | ||||
|             green_0n_n = copy.deepcopy(green_nn_n) | ||||
|         elif ix != length-1: | ||||
|             green_nn_n = guan.green_function_nn_n(fermi_energy, h00, h01, green_nn_n, broadening=0) | ||||
|             green_0n_n = guan.green_function_in_n(green_0n_n, h01, green_nn_n) | ||||
|         else: | ||||
|             green_nn_n = guan.green_function_nn_n(fermi_energy, h00, h01, green_nn_n, broadening=0, self_energy=right_self_energy) | ||||
|             green_0n_n = guan.green_function_in_n(green_0n_n, h01, green_nn_n) | ||||
|     conductance = np.trace(np.dot(np.dot(np.dot(gamma_left, green_0n_n), gamma_right), green_0n_n.transpose().conj())) | ||||
|     return conductance | ||||
| 
 | ||||
| def calculate_conductance_with_fermi_energy_array(fermi_energy_array, h00, h01, length=100): | ||||
|     dim = np.array(fermi_energy_array).shape[0] | ||||
|     conductance_array = np.zeros(dim) | ||||
|     i0 = 0 | ||||
|     for fermi_energy_0 in fermi_energy_array: | ||||
|         conductance_array[i0] = np.real(calculate_conductance(fermi_energy_0, h00, h01, length)) | ||||
|         i0 += 1 | ||||
|     return conductance_array | ||||
| 
 | ||||
| def calculate_conductance_with_disorder(fermi_energy, h00, h01, disorder_intensity=2.0, disorder_concentration=1.0, length=100): | ||||
|     right_self_energy, left_self_energy, gamma_right, gamma_left = guan.self_energy_of_lead(fermi_energy, h00, h01) | ||||
|     dim = np.array(h00).shape[0] | ||||
|     for ix in range(length): | ||||
|         disorder = np.zeros((dim, dim)) | ||||
|         for dim0 in range(dim): | ||||
|             if np.random.uniform(0, 1)<=disorder_concentration: | ||||
|                 disorder[dim0, dim0] = np.random.uniform(-disorder_intensity, disorder_intensity) | ||||
|         if ix == 0: | ||||
|             green_nn_n = guan.green_function(fermi_energy, h00+disorder, broadening=0, self_energy=left_self_energy) | ||||
|             green_0n_n = copy.deepcopy(green_nn_n) | ||||
|         elif ix != length-1: | ||||
|             green_nn_n = guan.green_function_nn_n(fermi_energy, h00+disorder, h01, green_nn_n, broadening=0) | ||||
|             green_0n_n = guan.green_function_in_n(green_0n_n, h01, green_nn_n) | ||||
|         else: | ||||
|             green_nn_n = guan.green_function_nn_n(fermi_energy, h00+disorder, h01, green_nn_n, broadening=0, self_energy=right_self_energy) | ||||
|             green_0n_n = guan.green_function_in_n(green_0n_n, h01, green_nn_n) | ||||
|     conductance = np.trace(np.dot(np.dot(np.dot(gamma_left, green_0n_n), gamma_right), green_0n_n.transpose().conj())) | ||||
|     return conductance | ||||
| 
 | ||||
| def calculate_conductance_with_disorder_intensity_array(fermi_energy, h00, h01, disorder_intensity_array, disorder_concentration=1.0, length=100, calculation_times=1): | ||||
|     dim = np.array(disorder_intensity_array).shape[0] | ||||
|     conductance_array = np.zeros(dim) | ||||
|     i0 = 0 | ||||
|     for disorder_intensity_0 in disorder_intensity_array: | ||||
|         for times in range(calculation_times): | ||||
|             conductance_array[i0] = conductance_array[i0]+np.real(calculate_conductance_with_disorder(fermi_energy, h00, h01, disorder_intensity=disorder_intensity_0, disorder_concentration=disorder_concentration, length=length)) | ||||
|         i0 += 1 | ||||
|     conductance_array = conductance_array/calculation_times | ||||
|     return conductance_array | ||||
| 
 | ||||
| def calculate_conductance_with_disorder_concentration_array(fermi_energy, h00, h01, disorder_concentration_array, disorder_intensity=2.0, length=100, calculation_times=1): | ||||
|     dim = np.array(disorder_concentration_array).shape[0] | ||||
|     conductance_array = np.zeros(dim) | ||||
|     i0 = 0 | ||||
|     for disorder_concentration_0 in disorder_concentration_array: | ||||
|         for times in range(calculation_times): | ||||
|             conductance_array[i0] = conductance_array[i0]+np.real(calculate_conductance_with_disorder(fermi_energy, h00, h01, disorder_intensity=disorder_intensity, disorder_concentration=disorder_concentration_0, length=length)) | ||||
|         i0 += 1 | ||||
|     conductance_array = conductance_array/calculation_times | ||||
|     return conductance_array | ||||
| 
 | ||||
| def calculate_conductance_with_scattering_length_array(fermi_energy, h00, h01, length_array, disorder_intensity=2.0, disorder_concentration=1.0, calculation_times=1): | ||||
|     dim = np.array(length_array).shape[0] | ||||
|     conductance_array = np.zeros(dim) | ||||
|     i0 = 0 | ||||
|     for length_0 in length_array: | ||||
|         for times in range(calculation_times): | ||||
|             conductance_array[i0] = conductance_array[i0]+np.real(calculate_conductance_with_disorder(fermi_energy, h00, h01, disorder_intensity=disorder_intensity, disorder_concentration=disorder_concentration, length=length_0)) | ||||
|         i0 += 1 | ||||
|     conductance_array = conductance_array/calculation_times | ||||
|     return conductance_array | ||||
| 
 | ||||
| 
 | ||||
| ## scattering matrix | ||||
| 
 | ||||
| def if_active_channel(k_of_channel): | ||||
|     if np.abs(np.imag(k_of_channel))<1e-6: | ||||
|         if_active = 1 | ||||
| @@ -1,6 +1,6 @@ | ||||
| # Guan is an open-source python package developed and maintained by https://www.guanjihuan.com/about. The primary location of this package is on website https://py.guanjihuan.com. | ||||
| 
 | ||||
| # calculate topological invariant | ||||
| # topological invariant | ||||
| 
 | ||||
| import numpy as np | ||||
| import cmath | ||||
		Reference in New Issue
	
	Block a user