Esempio n. 1
0
def test_check_poly_order():
    with pytest.raises(ValueError):
        analysis._check_poly_order(1)
Esempio n. 2
0
def test_check_poly_order():
    with pytest.raises(AssertionError):
        analysis._check_poly_order(1)
Esempio n. 3
0
def print_results(segment, data, settings, polyfit_order=None):

    polyfit_order = settings.degree_bandfit if polyfit_order is None else polyfit_order
    _check_poly_order(polyfit_order)

    print(segment.band_type, segment.direction)
    print("3-point finite difference mass is {:.2f}".format(
        segment.finite_difference_effmass()))
    print("5-point parabolic mass is {:.2f}".format(
        segment.five_point_leastsq_effmass()))
    try:
        print("weighted parabolic mass is {:.2f}".format(
            segment.weighted_leastsq_effmass()))
    except AssertionError as e:
        print("----------\n")
        print(e)
        print("\n-----------")

    try:
        print("alpha is {:.2f} 1/eV".format(
            segment.alpha(polyfit_order=polyfit_order) * ev_to_hartree))
        print("kane mass at bandedge is {:.2f}".format(
            segment.kane_mass_band_edge(polyfit_order=polyfit_order)))
        if segment.explosion_index(polyfit_order=polyfit_order) == len(
                segment.dE_eV):
            print(
                "the Kane quasi linear approximation is valid for the whole segment"
            )
        else:
            print(
                "the Kane quasi-linear approximation is valid until {:.2f} eV".
                format(segment.dE_eV[segment.explosion_index(
                    polyfit_order=polyfit_order)]))
    except AssertionError as e:
        print("----------\n")
        print(e)
        print("\n-----------")

    try:
        print(
            "optical mass at band edge (assuming the Kane dispersion) is {:.2f}"
            .format(segment.optical_effmass_kane_dispersion()))
    except AssertionError:
        pass

    plt.figure(figsize=(8, 8))
    plt.plot(np.linspace(segment.dk_angs[0], segment.dk_angs[-1], 100),
             np.divide(
                 segment.poly_fit(polyfit_order=polyfit_order,
                                  polyfit_weighting=False), ev_to_hartree),
             marker="x",
             ms=5,
             label="polynomial order {}".format(polyfit_order))
    plt.plot(np.linspace(segment.dk_angs[0], segment.dk_angs[-1], 100),
             np.divide(segment.finite_difference_fit(), ev_to_hartree),
             marker="<",
             ms=5,
             label="finite diff parabolic")
    plt.plot(np.linspace(segment.dk_angs[0], segment.dk_angs[-1], 100),
             np.divide(segment.five_point_leastsq_fit(), ev_to_hartree),
             marker="p",
             ms=5,
             label="five point parabolic")

    try:
        plt.plot(np.linspace(segment.dk_angs[0], segment.dk_angs[-1], 100),
                 np.divide(segment.weighted_leastsq_fit(), ev_to_hartree),
                 marker=">",
                 ms=5,
                 label="weighted parabolic")
    except AssertionError:
        pass

    try:
        plt.plot(np.linspace(segment.dk_angs[0], segment.dk_angs[-1], 100),
                 np.divide(segment.kane_fit(polyfit_order=polyfit_order),
                           ev_to_hartree),
                 marker="o",
                 ms=5,
                 label="Kane quasi-linear")
    except AssertionError as e:
        pass

    plt.xlabel(r"k ($ \AA^{-1} $)")
    plt.ylabel("energy (eV)")
    plt.scatter(segment.dk_angs, segment.dE_eV, marker="x", s=200, label="DFT")
    plt.legend()
    plt.show()

    fig, axes = plot_segments(data, settings, [segment])
    plt.show()

    plt.figure(figsize=(8, 8))
    idx = segment.explosion_index(polyfit_order=polyfit_order)
    plt.scatter(
        segment.dE_hartree[1:idx + 1],
        segment.transport_effmass(polyfit_order=polyfit_order,
                                  dk=segment.dk_bohr,
                                  polyfit_weighting=False)[1:idx + 1])
    plt.plot([0, segment.dE_hartree[idx]],
             np.polyval(
                 np.polyfit(
                     segment.dE_hartree[1:idx + 1],
                     segment.transport_effmass(polyfit_order=polyfit_order,
                                               dk=segment.dk_bohr,
                                               polyfit_weighting=False)[1:idx +
                                                                        1], 1),
                 [0, segment.dE_hartree[idx]]))
    plt.ylabel("transport mass")
    plt.xlabel("energy (hartree)")
    plt.xlim([0, segment.dE_hartree[idx]])
    plt.show()