コード例 #1
0
def visualize_Lines():

    Lorentzian = LorentzianLine("Lorentzian1", (-energy_from_lambda(6.0), 15),
                                x0=-0.3,
                                width=0.5,
                                c=0.0)
    F_c = F_cLine("F_c1", (-energy_from_lambda(6.0), 15),
                  x0=-0.3,
                  width=0.5,
                  A=350.0,
                  q=0.02,
                  c=0.0,
                  weight=1)
    F_I = F_ILine("F_I1", (-energy_from_lambda(6.0), 15),
                  x0=-0.3,
                  width=0.008,
                  A=350.0,
                  q=0.02,
                  kappa=0.01,
                  c=0.0,
                  weight=1)
    print(F_I.integrate())
    F_I2 = F_ILine("F_I2", (-energy_from_lambda(6.0), 15),
                   x0=-0.3,
                   width=0.1,
                   A=367.0,
                   q=0.124,
                   kappa=0.065,
                   c=0.0,
                   weight=1)
    print(F_I2.integrate())

    e = np.linspace(-0.5, 0.0, 1201)

    plt.plot(e, Lorentzian(e))
    plt.plot(e, F_c(e) * F_c.normalize(), ls="--", lw=2.0)
    plt.plot(e, F_I(e), ls="dotted", lw=4.0)
    plt.plot(e, F_I2(e), ls="-.", lw=1.0)
    plt.show()
コード例 #2
0
def test_normalization():
    Lorentzian = LorentzianLine("Lorentzian1", (-5., 5),
                                x0=0.0,
                                width=0.5,
                                c=0.0)
    n = Lorentzian.normalize()

    from scipy.integrate import quad
    to_integrate = lambda x: Lorentzian(x)
    val, err = quad(to_integrate, min(Lorentzian.domain),
                    max(Lorentzian.domain))
    print(
        f"Integration value: {val:.5f} +- {err:.5f}   |   normalization factor: {n:.5f}"
    )
    print(f"Normalized Line area: {val*n}")

    # - - - - - - - - - - - - - - - - - - - -

    F_c = F_cLine("FcLine1", (-15, 15),
                  x0=0.0,
                  width=0.02,
                  A=350.0,
                  q=0.023,
                  c=0.0,
                  weight=1.0)
    nfc = F_c.normalize()
    ifc = F_c.integrate()

    x = np.linspace(-1000, 1000, 5000000)
    y = F_c.calc(x, **F_c.line_params)
    ifctrapz = np.trapz(y, x)
    ifcquadv, ifcquade = quad(lambda x: nfc * F_c(x), min(F_c.domain),
                              max(F_c.domain))
    print(f"{F_c.line_params}")
    print(f"Standard Integration value for 10000 steps: {ifc}")
    print(
        f"QUADPACK Integration value (after normal.): {ifcquadv} +- {ifcquade}"
    )
    print(f"TRAPEZOID Integration value -1e3 from 1e3 : {ifctrapz}")

    # - - - - - - - - - - - - - - - - - - - -

    F_I = F_ILine("FILine1", (-15, 15),
                  x0=0.0,
                  width=0.02,
                  A=350.0,
                  q=0.023,
                  kappa=0.01,
                  c=0.0,
                  weight=1.0)
    nfI = F_I.normalize()
    ifI = F_I.integrate()

    x = np.linspace(-1000, 1000, 5000000)
    y = F_I.calc(x, **F_I.line_params)
    ifItrapz = np.trapz(y, x)
    ifIquadv, ifIquade = quad(lambda x: F_I(x), min(F_I.domain),
                              max(F_I.domain))
    print(f"{F_I.line_params}")
    print(f"Standard Integration value for 10000 steps: {ifI}")
    print(
        f"QUADPACK Integration value                : {ifIquadv} +- {ifIquade}"
    )
    print(f"TRAPEZOID Integration value -1e3 from 1e3 : {ifItrapz}")