Esempio n. 1
0
def test_ford1984_fixed_sampling():
    """
    Compare EDP-calculation to published data of Ford1984 using fixed
    samplingpoints.
    """
    u_begin = 0.1
    u_end = 1e4
    u_sampling = 30
    a_range_ford = AngularRange(
        quantity="u",
        unit="None",
        begin=u_begin,
        end=u_end,
        sampling_points=u_sampling,
        scale="log")
    wl_ford = 633.

    edp = EDP(stack_ford(), wl_ford, a_range_ford)
    edp.calc()

    expected_us = np.logspace(
        np.log10(u_begin), np.log10(u_end), u_sampling)

    # Depending on the used integration rule for presampled data the expeced
    # results change. The choices for integration rules are
    #  'simpson rule' or 'trapezoidal rule'. We use simpson rule.
    expected_fu_simp = np.array([
        2.26251490e-10,  7.48538564e-10, 2.49354914e-09,  8.44135783e-09,
        2.97679978e-08,  1.19471423e-07,  4.12958094e-08,  4.59544802e-09,
        5.02343278e-09,  7.98190669e-09,  1.51456092e-08,  3.13764552e-08,
        6.74498466e-08,  1.46902522e-07,  3.20916627e-07,  6.99828263e-07,
        1.51834593e-06,  3.26581994e-06,  6.93147240e-06,  1.44198875e-05,
        2.91154047e-05,  5.62299028e-05,  1.01641970e-04,  1.66506172e-04,
        2.35615633e-04,  2.68167554e-04,  2.20773058e-04,  1.12272195e-04,
        2.78883745e-05,  2.38642019e-06
    ])

    # expected_fu_trapz = np.array([
    #     2.2209952640e-10,  7.3480208673e-10,  2.4477898665e-09,
    #     8.2864494495e-09,  2.9221722578e-08,  1.1727899292e-07,
    #     4.0537987838e-08,  4.5111162433e-09,  4.9312469264e-09,
    #     7.8354303257e-09,  1.4867671080e-08,  3.0800661873e-08,
    #     6.6212065183e-08,  1.4420670611e-07,  3.1502742945e-07,
    #     6.8698569979e-07,  1.4904825231e-06,  3.2058884131e-06,
    #     6.8042720600e-06,  1.4155266001e-05,  2.8581105859e-05,
    #     5.5198022429e-05,  9.9776726635e-05,  1.6345060860e-04,
    #     2.3129182464e-04,  2.6324636722e-04,  2.1672163426e-04,
    #     1.1021187688e-04,  2.7376590798e-05,  2.3426268963e-06
    # ])

    np.testing.assert_allclose(expected_us, edp.us, rtol=3e-07, atol=1e-16)
    np.testing.assert_allclose(
        expected_fu_simp, edp.f_u, rtol=3e-07, atol=1e-16)
Esempio n. 2
0
    def run_EDP(self):
        edp = EDP(self.stack, self.sp_sys.value, self.ar_sys)
        edp.calc()

        self.ang = AngularArray(self.angularrange_user.quantity,
                                self.angularrange_user.unit,
                                self.ang_conv.num_s_to_u(edp.us))
        ang_qtty = self.angularrange_user.quantity
        jcb_u_to_ang = self.ang_conv.jcb_s_to_u(edp.us)

        self.f_ang = QunttyArray("emission propability density", "?",
                                 "f({0})".format(ang_qtty),
                                 edp.f_u * jcb_u_to_ang)
        self.f_hTE_ang = QunttyArray("emission propability density hTE", "?",
                                     "f_hTE({0})".format(ang_qtty),
                                     edp.f_hTE_u * jcb_u_to_ang)
        self.f_hTM_ang = QunttyArray("emission propability density hTM", "?",
                                     "f_hTM({0})".format(ang_qtty),
                                     edp.f_hTM_u * jcb_u_to_ang)
        self.f_vTM_ang = QunttyArray("emission propability density vTM", "?",
                                     "f_vTM({0})".format(ang_qtty),
                                     edp.f_vTM_u * jcb_u_to_ang)

        self.p_ang = QunttyArray("power density", "?",
                                 "p({0})".format(ang_qtty),
                                 edp.p_u * jcb_u_to_ang)
        self.p_hTE_ang = QunttyArray("power density hTE", "?",
                                     "p_hTE({0})".format(ang_qtty),
                                     edp.p_hTE_u * jcb_u_to_ang)
        self.p_hTM_ang = QunttyArray("power density hTM", "?",
                                     "p_hTM({0})".format(ang_qtty),
                                     edp.p_hTM_u * jcb_u_to_ang)
        self.p_vTM_ang = QunttyArray("power density vTM", "?",
                                     "p_vTM({0})".format(ang_qtty),
                                     edp.p_vTM_u * jcb_u_to_ang)

        self.Re_w = QunttyArray("Re(w)", "None", "Re(w)", edp.we_u.real)
        self.Im_w = QunttyArray("Im(w)", "None", "Im(w)", edp.we_u.imag)
        self.PinP0 = QunttyValue("emitted power", "P0", "P", edp.P)