示例#1
0
def demo_zigzag_lattice_oneband_uniform():
    ## parameter
    num_layer = 2
    NAPL = 4  #Number of Atoms Per Layer
    NBPA = 2  #Number of Bands Per Atom
    num_BF_sample = 1000
    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_uniform_hf_rand(-EDisorder, EDisorder)
    hf_average = generate_uniform_hf_average(-EDisorder, EDisorder)
    energy = np.linspace(-4, 4, 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)
    ham1 = 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]
                  ]))[: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 #fail
    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 uniform_parameter(tag_complex=False):
    N1 = np.random.randint(5, 10)
    matA = np.random.randn(N1, N1) + np.eye(N1) * N1 / 2
    if tag_complex:
        matA = matA + (np.random.randn(N1, N1) + np.eye(N1) * N1 / 2) * 1j
    x1 = np.random.rand() * 2 - 1
    x2 = np.random.rand() + x1
    hf_rand = generate_uniform_hf_rand(x1, x2)
    hf_average = generate_uniform_hf_average(x1, x2)
    return N1, matA, hf_rand, hf_average
示例#3
0
def uniform_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
    matA = matA + matA.T
    if tag_complex:
        matA = matA + (np.random.randn(N1, N1) + np.eye(N1) * N1 / 2) * 1j
    x1 = np.random.rand() * 2 - 1
    x2 = np.random.rand() + x1
    hf_rand = generate_uniform_hf_rand(x1, x2)
    hf_average = generate_uniform_hf_average(x1, x2)
    return num_block, block_size, matA, hf_rand, hf_average
示例#4
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()