version-0.0.7

This commit is contained in:
guanjihuan 2021-07-19 23:35:25 +08:00
parent 6e498186c4
commit 7d699063ae
5 changed files with 47 additions and 2 deletions

View File

@ -64,6 +64,9 @@ eigenvalue_array = guan.calculate_eigenvalue_with_two_parameters(x, y, hamiltoni
# calculate wave functions
eigenvector = guan.calculate_eigenvector(hamiltonian)
# find vector with the same gauge
vector_target = find_vector_with_the_same_gauge_with_binary_search(vector_target, vector_ref, show_error=1, show_times=0, show_phase=0, n_test=10001, precision=1e-6)
# calculate Green functions
green = guan.green_function(fermi_energy, hamiltonian, broadening, self_energy=0)
green_nn_n = guan.green_function_nn_n(fermi_energy, h00, h01, green_nn_n_minus, broadening, self_energy=0)

View File

@ -1,7 +1,7 @@
[metadata]
# replace with your username:
name = guan
version = 0.0.6
version = 0.0.7
author = guanjihuan
author_email = guanjihuan@163.com
description = An open source python package

View File

@ -8,6 +8,7 @@ from .Hamiltonian_of_finite_size import *
from .Hamiltonian_of_models_in_the_reciprocal_space import *
from .calculate_band_structures import *
from .calculate_wave_functions import *
from .find_vector_with_the_same_gauge import *
from .calculate_Green_functions import *
from .calculate_density_of_states import *
from .calculate_conductance import *

View File

@ -0,0 +1,41 @@
# find vector with the same gauge
import numpy as np
import cmath
from math import *
def find_vector_with_the_same_gauge_with_binary_search(vector_target, vector_ref, show_error=1, show_times=0, show_phase=0, n_test=10001, precision=1e-6):
phase_1_pre = 0
phase_2_pre = pi
for i0 in range(n_test):
test_1 = np.sum(np.abs(vector_target*cmath.exp(1j*phase_1_pre) - vector_ref))
test_2 = np.sum(np.abs(vector_target*cmath.exp(1j*phase_2_pre) - vector_ref))
if test_1 < precision:
phase = phase_1_pre
if show_times==1:
print('Binary search times=', i0)
break
if i0 == n_test-1:
phase = phase_1_pre
if show_error==1:
print('Gauge not found with binary search times=', i0)
if test_1 < test_2:
if i0 == 0:
phase_1 = phase_1_pre-(phase_2_pre-phase_1_pre)/2
phase_2 = phase_1_pre+(phase_2_pre-phase_1_pre)/2
else:
phase_1 = phase_1_pre
phase_2 = phase_1_pre+(phase_2_pre-phase_1_pre)/2
else:
if i0 == 0:
phase_1 = phase_2_pre-(phase_2_pre-phase_1_pre)/2
phase_2 = phase_2_pre+(phase_2_pre-phase_1_pre)/2
else:
phase_1 = phase_2_pre-(phase_2_pre-phase_1_pre)/2
phase_2 = phase_2_pre
phase_1_pre = phase_1
phase_2_pre = phase_2
vector_target = vector_target*cmath.exp(1j*phase)
if show_phase==1:
print('Phase=', phase)
return vector_target

View File

@ -1,4 +1,4 @@
# tutorial (NOT for all functions)
# tutorial (not for all functions)
import guan
import functools