예제 #1
0
def demo_zigzag_lattice_oneband_binary():
    # parameter
    num_layer = 2
    NAPL = 4  #Number of Atoms Per Layer
    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)
    energy = np.linspace(-3, 3, 50)
    energy_epsj = 1e-7j

    # calculation
    assert NAPL % 4 == 0
    ham0 = EFNN * (np.diag(np.ones(NAPL - 1), 1) + np.diag(
        np.ones(NAPL - 1), -1)) + EOnsite_left * np.eye(NAPL)
    tmp1 = EFNN * np.kron(
        np.eye(NAPL // 4 + 1),
        np.array([[0, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 0]]))
    ham1 = tmp1[:NAPL, :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)
        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,
                                                       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
    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()
예제 #2
0
def binary_parameter(tag_complex=False):
    N1 = np.random.randint(5, 10)
    matA = np.random.randn(N1, N1) + np.eye(N1) * N1
    if tag_complex:
        matA = matA + (np.random.randn(N1, N1) + np.eye(N1) * N1 / 2) * 1j
    x1 = np.random.rand()
    x2 = np.random.rand() + x1
    c1 = np.random.rand()
    hf_rand = generate_binary_hf_rand(x1, c1, x2)
    hf_average = generate_binary_hf_average(x1, c1, x2)
    return N1, matA, hf_rand, hf_average
예제 #3
0
def binary_parameter(tag_complex=False, block_size=None):
    num_block = np.random.randint(5, 10)
    if block_size is None:
        block_size = np.random.randint(1, 4)
    else:  #used for compare with CPA_general
        assert isinstance(block_size, int) and block_size > 0
    N1 = num_block * block_size
    matA = np.random.randn(N1, N1) + np.eye(N1) * N1
    if tag_complex:
        matA = matA + (np.random.randn(N1, N1) + np.eye(N1) * N1 / 2) * 1j
    x1 = np.random.rand()
    x2 = np.random.rand() + x1
    c1 = np.random.rand()
    hf_rand = generate_binary_hf_rand(x1, c1, x2)
    hf_average = generate_binary_hf_average(x1, c1, x2)
    return num_block, block_size, matA, hf_rand, hf_average
예제 #4
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()
예제 #5
0
def demo_square_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, 1780, 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
    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_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()
예제 #7
0
line_width_left = 1j * (self_energy_left - hfH(self_energy_left))
line_width_left = np.pad(line_width_left, [(0,NBPL*(num_layer-1)), (0,NBPL*(num_layer-1))], mode='constant')

tmp1 = (mass_right_lead*angular_frequency**2 + energy_epsj) * np.eye(HInfo['ham_right_intra'].shape[0]) - HInfo['ham_right_intra']
tmp2 = inv_tridiagonal_matrix(-HInfo['ham_right_inter'], tmp1, -hfH(HInfo['ham_right_inter']))
self_energy_right = HInfo['ham_central_right_part'] @ np.linalg.solve(tmp2, hfH(HInfo['ham_central_right_part']))
line_width_right = 1j * (self_energy_right - hfH(self_energy_right))
line_width_right = np.pad(line_width_right, [(NBPL*(num_layer-1),0), (NBPL*(num_layer-1),0)], mode='constant')

inv_Green_part = np.eye(HInfo['ham_central'].shape[0])*energy_epsj - HInfo['ham_central']
inv_Green_part[:NBPL,:NBPL] -= self_energy_left
inv_Green_part[(-NBPL):,(-NBPL):] -= self_energy_right

cumulant = []
for mass_disorder_i in tqdm(mass_disorder):
    hf_average = generate_binary_hf_average(*mass_disorder_i)
    N_Gamma_trace = FCS_CPA_multiband(num_cumulant, inv_Green_part, line_width_right, line_width_left, hf_Bii, hf_average)
    tmp1 = np.array([np.dot(x, N_Gamma_trace[:x.shape[0]]) for x in cumulant_coeff])
    if np.abs(tmp1.imag).max()>1e-5:
        print('[WARNING] large image part "{}j" for mass_disorder_i={}'.format(np.abs(tmp1.imag).max(), mass_disorder_i))
    cumulant.append(tmp1)


## figure
fig,ax = plt.subplots(1,1)
tmp1 = np.array(cumulant).T.real
tableau_colorblind = [x['color'] for x in plt.style.library['tableau-colorblind10']['axes.prop_cycle']]
for x1,x2,x3,x4 in zip(tmp1[::2], tmp1[1::2], range(1,num_cumulant+1,2), tableau_colorblind):
    ax.plot(disorder_strength, x1, color=x4, label='T^{}'.format(x3))
    ax.plot(disorder_strength, x2*linear_factor, 'x', color=x4, label='aT^{}'.format(x3+1))
ax.set_yscale('log')
예제 #8
0
self_energy_right = HInfo['ham_central_right_part'] @ np.linalg.solve(
    tmp1, hfH(HInfo['ham_central_right_part']))
line_width_right = 1j * (self_energy_right - hfH(self_energy_right))
line_width_right = np.pad(line_width_right, [(NBPL * (num_layer - 1), 0),
                                             (NBPL * (num_layer - 1), 0)],
                          mode='constant')

ret = []
inv_Green_part = (energy + energy_epsj) * np.eye(
    HInfo['ham_central'].shape[0]) - HInfo['ham_central']
inv_Green_part[:NBPL, :NBPL] -= self_energy_left
inv_Green_part[(-NBPL):, (-NBPL):] -= self_energy_right

cumulant = []
for EDisorder_i in tqdm(EDisorder):
    hf_average = generate_binary_hf_average(-EDisorder_i, 0.5, EDisorder_i)
    N_Gamma_trace = FCS_CPA_multiband(num_cumulant, inv_Green_part,
                                      -line_width_right, line_width_left,
                                      hf_Bii, hf_average)
    tmp1 = np.array([(1 - 2 * (ind1 % 2)) * x / 2
                     for ind1, x in enumerate(N_Gamma_trace)])
    tmp1 = np.array(
        [np.dot(x, N_Gamma_trace[:x.shape[0]]) for x in cumulant_coeff])
    if np.abs(tmp1.imag).max() > 1e-5:
        print('[WARNING] large image part "{}j" for EDisorder_i={}'.format(
            np.abs(tmp1.imag).max(), EDisorder_i))
    cumulant.append(tmp1)

## figure
fig, ax = plt.subplots(1, 1)
tmp1 = np.array(cumulant).T.real