Пример #1
0
def test_uniform_compare_with_CPA_general():
    num_block, block_size, matA, _, hf_average = uniform_parameter(
        block_size=1)
    matC_ = CPA_general(matA, hf_average)
    hf_Bii = generate_hf_Bii(np.ones((1, 1)))
    matC = CPA_block_general(matA, block_size, hf_Bii, hf_average)[:, 0, 0]
    assert hfe(matC_, matC) < 1e-7, f'num_block={num_block}'
Пример #2
0
def test_binary_compare_with_CPA_general():
    num_block, block_size, matA, _, hf_average = binary_parameter(block_size=1)
    matC_ = CPA_general(matA, hf_average)
    hf_Bii = generate_hf_Bii(np.ones((1, 1)))
    matC = CPA_block_general(matA, block_size, hf_Bii, hf_average)[:, 0, 0]
    tmp1 = hfe(matC_, matC)
    assert tmp1 < 1e-7, f'num_block={num_block}'
Пример #3
0
def demo_square_lattice_multiband_binary():
    ## parameter
    num_layer = 2
    NAPL = 4  #Number of Atoms Per Layer
    NBPA = 2  #Number of Bands Per Atom
    num_BF_sample = 100
    num_moment = 4

    EFNN = -1  #Energy of First Nearest Neighbor
    EOnsite_central = 0
    EOnsite_left = 0
    EOnsite_right = 0
    EDisorder = 0.2
    hf_rand = generate_binary_hf_rand(-EDisorder, 0.5, EDisorder)
    hf_average = generate_binary_hf_average(-EDisorder, 0.5, EDisorder)
    hf_Bii = generate_hf_Bii(np.array([[0, 1], [1, 0]]))
    energy = np.linspace(-4, 4, 50)
    energy_epsj = 1e-7j

    # calculation
    ham0 = EFNN * (np.diag(np.ones(NAPL - 1), 1) + np.diag(
        np.ones(NAPL - 1), -1)) + EOnsite_left * np.eye(NAPL)
    ham0 = np.kron(ham0, np.eye(NBPA))
    ham1 = EFNN * np.eye(NBPA * NAPL)
    HInfo = build_device_Hamiltonian_with_ham0_ham1(ham0, ham1, num_layer)

    tmp0 = [
        quick_transmission_moment_BF(x + energy_epsj, HInfo, num_moment,
                                     num_BF_sample, hf_rand, hf_Bii)
        for x in tqdm(energy)
    ]
    T_moment_BF = np.stack(tmp0, axis=1)

    matC0 = None
    T_moment_FCSCPA = []
    for x in tqdm(energy):
        tmp0, matC0 = quick_transmission_moment_FCSCPA(x + energy_epsj,
                                                       HInfo,
                                                       num_moment,
                                                       hf_average,
                                                       hf_Bii=hf_Bii,
                                                       matC0=matC0)
        T_moment_FCSCPA.append(tmp0)
    T_moment_FCSCPA = np.stack(T_moment_FCSCPA, axis=1)

    ## figure
    assert np.abs(T_moment_FCSCPA.imag).max() < 1e-4  #fail sometimes
    tableau_colorblind = [
        x['color']
        for x in plt.style.library['tableau-colorblind10']['axes.prop_cycle']
    ]
    fig, ax = plt.subplots()
    for x, y, z in zip(range(num_moment), T_moment_FCSCPA.real,
                       tableau_colorblind):
        ax.plot(energy, y, color=z, label='$tr(T^{}$)'.format(x + 1))
    for x, y, z in zip(range(num_moment), T_moment_BF.real.mean(axis=2),
                       tableau_colorblind):
        ax.plot(energy, y, 'x', color=z, markersize=2)
    ax.legend()
Пример #4
0
def test_uniform_real():
    num_block, block_size, matA, hf_rand, hf_average = uniform_parameter(
        tag_complex=False)
    hf_Bii = generate_hf_Bii(np.random.randn(block_size, block_size))
    N2 = 10000
    hf1 = lambda: Aii_to_matA(hf_Bii(hf_rand(num_block)).transpose(2, 0, 1))
    ret1 = sum(np.linalg.inv(matA - hf1()) for _ in range(N2)) / N2
    ret2 = sum(np.linalg.inv(matA - hf1()) for _ in range(N2)) / N2
    matC = CPA_block_general(matA,
                             block_size,
                             hf_Bii,
                             hf_average,
                             tag_complex=False)
    ret3 = np.linalg.inv(matA - Aii_to_matA(matC))
    tmp1 = hfe(ret1, ret2)
    tmp2 = hfe((ret1 + ret2) / 2, ret3)
    assert tmp2 < tmp1 * 2, f'num_block={num_block}, block_size={block_size}'
Пример #5
0
def demo_square_lattice_multiband_uniform():
    # parameter
    num_layer = 2
    NAPL = 4  #Number of Atom Per Layer
    num_sample = 1000
    num_moment = 4
    wave_number = np.linspace(10, 900, 100)  #cm-1
    angular_frequency = hf_wave_numer_to_angular_frequency(
        wave_number)  #equivalent to Hz
    energy_epsj = 1e-6j
    mass_carbon = 12.0107  #in AMU
    mass_left_lead = mass_carbon
    mass_right_lead = mass_carbon
    hf_rand = generate_uniform_hf_rand(0.9 * mass_carbon, 1.1 * mass_carbon)
    hf_average = generate_uniform_hf_average(0.9 * mass_carbon,
                                             1.1 * mass_carbon)

    # Hamiltonian
    ham1 = np.kron(np.eye(NAPL), hf_dynamic_matrix(30))
    if NAPL > 1:
        tmp1 = np.kron(np.diag(np.ones(NAPL - 1), 1), hf_dynamic_matrix(120))
        ham0 = tmp1 + tmp1.T
    else:
        ham0 = np.zeros(3)
    ham0 = build_phonon_ham0(3, ham0, ham1)
    HInfo = build_device_Hamiltonian_with_ham0_ham1(ham0, ham1, num_layer)

    T_moment_BF = []
    for x in tqdm(angular_frequency):
        hf_Bii = generate_hf_Bii(-np.ones((1, 1)) * x**2)
        T_moment_BF.append(
            quick_phonon_transmission_moment_BF(x, mass_left_lead,
                                                mass_right_lead, HInfo,
                                                num_moment, num_sample,
                                                hf_rand, hf_Bii, energy_epsj))
    T_moment_BF = np.stack(T_moment_BF, axis=1)

    matC0 = None
    T_moment_FCSCPA = []
    for x in tqdm(angular_frequency):
        hf_Bii = generate_hf_Bii(-np.ones((1, 1)) * x**2)
        tmp0, matC0 = quick_phonon_transmission_moment_FCSCPA(x,
                                                              mass_left_lead,
                                                              mass_right_lead,
                                                              HInfo,
                                                              num_moment,
                                                              hf_average,
                                                              hf_Bii,
                                                              energy_epsj,
                                                              matC0=matC0)
        T_moment_FCSCPA.append(tmp0)
    T_moment_FCSCPA = np.stack(T_moment_FCSCPA, axis=1)

    # assert np.abs(T_moment_FCSCPA.imag).max() < 1e-4
    tableau_colorblind = [
        x['color']
        for x in plt.style.library['tableau-colorblind10']['axes.prop_cycle']
    ]
    fig, ax = plt.subplots()
    for x, y, z in zip(range(num_moment), T_moment_FCSCPA.real,
                       tableau_colorblind):
        ax.plot(wave_number, y, color=z, label='$tr(T^{}$)'.format(x + 1))
    for x, y, z in zip(range(num_moment), T_moment_BF.real.mean(axis=2),
                       tableau_colorblind):
        ax.plot(wave_number, y, 'x', color=z, markersize=2)
    ax.legend()
Пример #6
0
def demo_zigzag_lattice_multiband_binary():
    # parameter
    num_layer = 2
    NAPL = 4  #Number of Atom Per Layer
    num_sample = 1000
    num_moment = 4
    wave_number = np.linspace(10, 1600, 100)  #cm-1
    angular_frequency = hf_wave_numer_to_angular_frequency(
        wave_number)  #equivalent to Hz
    energy_epsj = 1e-6j
    mass_carbon = 12.0107  #in AMU
    mass_left_lead = mass_carbon
    mass_right_lead = mass_carbon
    hf_rand = generate_binary_hf_rand(0.9 * mass_carbon, 0.5,
                                      1.1 * mass_carbon)
    hf_average = generate_binary_hf_average(0.9 * mass_carbon, 0.5,
                                            1.1 * mass_carbon)

    # Hamiltonian
    hf1 = lambda x: slice(3 * x, 3 * x + 3)
    ham1 = np.zeros([3 * NAPL, 3 * NAPL])
    for ind1, x in zip(range(NAPL),
                       itertools.cycle([None, (-1, -30), (1, 30), None])):
        if x is not None:
            ham1[hf1(ind1), hf1(ind1 + x[0])] = hf_dynamic_matrix(x[1])
    ham0 = np.zeros([3 * NAPL, 3 * NAPL])
    for ind1, theta in enumerate(
            np.tile(np.array([30, 90, 150, 90]),
                    [NAPL // 4 + 1])[:(NAPL - 1)]):
        ham0[hf1(ind1), hf1(ind1 + 1)] = hf_dynamic_matrix(theta)
    ham0 = build_phonon_ham0(3, ham0 + ham0.T, ham1)
    HInfo = build_device_Hamiltonian_with_ham0_ham1(ham0, ham1, num_layer)

    T_moment_BF = []
    for x in tqdm(angular_frequency):
        hf_Bii = generate_hf_Bii(-np.ones((1, 1)) * x**2)
        T_moment_BF.append(
            quick_phonon_transmission_moment_BF(x, mass_left_lead,
                                                mass_right_lead, HInfo,
                                                num_moment, num_sample,
                                                hf_rand, hf_Bii, energy_epsj))
    T_moment_BF = np.stack(T_moment_BF, axis=1)

    matC0 = None
    T_moment_FCSCPA = []
    for x in tqdm(angular_frequency):
        hf_Bii = generate_hf_Bii(-np.ones((1, 1)) * x**2)
        tmp0, matC0 = quick_phonon_transmission_moment_FCSCPA(x,
                                                              mass_left_lead,
                                                              mass_right_lead,
                                                              HInfo,
                                                              num_moment,
                                                              hf_average,
                                                              hf_Bii,
                                                              energy_epsj,
                                                              matC0=matC0)
        T_moment_FCSCPA.append(tmp0)
    T_moment_FCSCPA = np.stack(T_moment_FCSCPA, axis=1)

    # assert np.abs(T_moment_FCSCPA.imag).max() < 1e-4
    tableau_colorblind = [
        x['color']
        for x in plt.style.library['tableau-colorblind10']['axes.prop_cycle']
    ]
    fig, ax = plt.subplots()
    for x, y, z in zip(range(num_moment), T_moment_FCSCPA.real,
                       tableau_colorblind):
        ax.plot(wave_number, y, color=z, label='$tr(T^{}$)'.format(x + 1))
    for x, y, z in zip(range(num_moment), T_moment_BF.real.mean(axis=2),
                       tableau_colorblind):
        ax.plot(wave_number, y, 'x', color=z, markersize=2)
    ax.legend()
Пример #7
0
def demo_square_lattice_oneband_binary():
    # parameter
    num_layer = 20
    NAPL = 20  #Number of Atom Per Layer
    num_sample = 1000
    num_moment = 4
    wave_number = np.linspace(10, 1700, 100)  #cm-1
    angular_frequency = hf_wave_numer_to_angular_frequency(
        wave_number)  #equivalent to Hz
    energy_epsj = 1e-6j
    mass_carbon = 12.0107  #in AMU
    mass_left_lead = mass_carbon
    mass_right_lead = mass_carbon
    hf_rand = generate_binary_hf_rand(0.9 * mass_carbon, 0.5,
                                      1.1 * mass_carbon)
    hf_average = generate_binary_hf_average(0.9 * mass_carbon, 0.5,
                                            1.1 * mass_carbon)

    # Hamiltonian
    force_constant = -FORCE_CONSTANT_Dresselhaus[
        0, 0]  #see RGF.phonon_utils.FORCE_CONSTANT_Dresselhaus
    ham1 = np.ones((1, 1)) * force_constant
    ham0 = np.ones((1, 1)) * (-2 * force_constant)
    HInfo = build_device_Hamiltonian_with_ham0_ham1(ham0, ham1, num_layer)

    T_moment_BF = []
    for x in tqdm(angular_frequency):
        hf_Bii = generate_hf_Bii(-np.ones((1, 1)) * x**2)
        T_moment_BF.append(
            quick_phonon_transmission_moment_BF(x, mass_left_lead,
                                                mass_right_lead, HInfo,
                                                num_moment, num_sample,
                                                hf_rand, hf_Bii, energy_epsj))
    T_moment_BF = np.stack(T_moment_BF, axis=1)

    matC0 = None
    T_moment_FCSCPA = []
    for x in tqdm(angular_frequency):
        hf_Bii = generate_hf_Bii(-np.ones((1, 1)) * x**2)
        tmp0, matC0 = quick_phonon_transmission_moment_FCSCPA(x,
                                                              mass_left_lead,
                                                              mass_right_lead,
                                                              HInfo,
                                                              num_moment,
                                                              hf_average,
                                                              hf_Bii,
                                                              energy_epsj,
                                                              matC0=matC0)
        T_moment_FCSCPA.append(tmp0)
    T_moment_FCSCPA = np.stack(T_moment_FCSCPA, axis=1)
    # use previous matC0 doesn't make any help

    # assert np.abs(T_moment_FCSCPA.imag).max() < 1e-4
    tableau_colorblind = [
        x['color']
        for x in plt.style.library['tableau-colorblind10']['axes.prop_cycle']
    ]
    fig, ax = plt.subplots()
    for x, y, z in zip(range(num_moment), T_moment_FCSCPA.real,
                       tableau_colorblind):
        ax.plot(wave_number, y, color=z, label='$tr(T^{}$)'.format(x + 1))
    for x, y, z in zip(range(num_moment), T_moment_BF.real.mean(axis=2),
                       tableau_colorblind):
        ax.plot(wave_number, y, 'x', color=z, markersize=2)
    ax.legend()
Пример #8
0
hf_fL = generate_distribution_function(temperature_left)
fL = hf_fL(angular_frequency)
temperature_right = 295 #Kelvin
hf_fR = generate_distribution_function(temperature_right)
fR = hf_fR(angular_frequency)
linear_factor = linear_factor_with_hw_one(temperature_left, temperature_right, wave_number)

cumulant_coeff = []
for n in range(1, num_cumulant+1):
    tmp1 = []
    for m in range(1, n+1):
        matA,matB = Ymn_Leibniz_matAB(m, n)
        tmp1.append(Ymn_Leibniz(fL, fR, matA, matB, 'phonon') * (-1/(2*m)))
    cumulant_coeff.append(np.array(tmp1))

hf_Bii = generate_hf_Bii(-angular_frequency**2*np.eye(3))
disorder_strength = np.linspace(0.01, 0.5) #large disorder will case large image part
mass_disorder = [((1-x)*mass_carbon, 0.5, (1+x)*mass_carbon) for x in disorder_strength]


## Hamiltonian
ham1 = np.kron(np.eye(NAPL), hf_dynamic_matrix(30))
if NAPL>1:
    tmp1 = np.kron(np.diag(np.ones(NAPL-1),1), hf_dynamic_matrix(120))
    ham0 = tmp1 + tmp1.T
else:
    ham0 = np.zeros(3)
ham0 = build_phonon_ham0(3, ham0, ham1)
HInfo = build_device_Hamiltonian_with_ham0_ham1(ham0, ham1, num_layer)

Пример #9
0

## parameter
num_layer = 2
NAPL = 4  #Number of Atoms Per Layer
num_cumulant = 8  #the cumulant_coeff will diverge for num_cumulant>=10 (2147483647)
EFNN = -2.6  #Energy of First Nearest Neighbor
EOnsite_central = 0
EOnsite_left = 0
EOnsite_right = 0
chemical_potential_left = 0.5003
chemical_potential_right = 0.4997
temperature = 100  #kelvin
EDisorder = np.linspace(0.01, 1)
# hf_average = generate_binary_hf_average(-EDisorder, 0.5, EDisorder)
hf_Bii = generate_hf_Bii(np.array([[0, 1], [1, 0]]))
energy = 0.5
energy_epsj = 1e-7j

fL = hf_distribution_function(temperature, energy, chemical_potential_left)
fR = hf_distribution_function(temperature, energy, chemical_potential_right)
linear_factor = linear_factor_small_potential_difference_limit(
    chemical_potential_left, chemical_potential_right, temperature)

# Ymn_matAB = [[Ymn_Leibniz_matAB(m,n) for m in range(1,n+1)] for n in range(1, num_cumulant+1)]
cumulant_coeff = []
for n in range(1, num_cumulant + 1):
    tmp1 = []
    for m in range(1, n + 1):
        matA, matB = Ymn_Leibniz_matAB(m, n)
        tmp1.append(