Пример #1
0
def test_trace_packet(
    packet,
    verysimple_numba_model,
    verysimple_numba_plasma,
    verysimple_estimators,
    set_seed_fixture,
):

    set_seed_fixture(1963)
    packet.initialize_line_id(verysimple_numba_plasma, verysimple_numba_model)
    distance, interaction_type, delta_shell = r_packet.trace_packet(
        packet,
        verysimple_numba_model,
        verysimple_numba_plasma,
        verysimple_estimators,
    )

    assert delta_shell == 1
    assert interaction_type == 3
    assert_almost_equal(distance, 22978745222176.88)
Пример #2
0
def single_packet_loop(r_packet, numba_model, numba_plasma, estimators,
                       vpacket_collection):
    """
    Parameters
    ----------
    r_packet : tardis.montecarlo.montecarlo_numba.r_packet.RPacket
    numba_model : tardis.montecarlo.montecarlo_numba.numba_interface.NumbaModel
    numba_plasma : tardis.montecarlo.montecarlo_numba.numba_interface.NumbaPlasma
    estimators : tardis.montecarlo.montecarlo_numba.numba_interface.Estimators
    vpacket_collection : tardis.montecarlo.montecarlo_numba.numba_interface.VPacketCollection

    Returns
    -------
    None
        This function does not return anything but changes the r_packet object
        and if virtual packets are requested - also updates the vpacket_collection
    """

    line_interaction_type = montecarlo_configuration.line_interaction_type

    if montecarlo_configuration.full_relativity:
        set_packet_props_full_relativity(r_packet, numba_model)
    else:
        set_packet_props_partial_relativity(r_packet, numba_model)
    r_packet.initialize_line_id(numba_plasma, numba_model)

    trace_vpacket_volley(r_packet, vpacket_collection, numba_model,
                         numba_plasma)

    if mc_logger.DEBUG_MODE:
        r_packet_track_nu = [r_packet.nu]
        r_packet_track_mu = [r_packet.mu]
        r_packet_track_r = [r_packet.r]
        r_packet_track_interaction = [InteractionType.BOUNDARY]
        r_packet_track_distance = [0.0]

    while r_packet.status == PacketStatus.IN_PROCESS:
        distance, interaction_type, delta_shell = trace_packet(
            r_packet, numba_model, numba_plasma, estimators)

        if interaction_type == InteractionType.BOUNDARY:
            move_r_packet(r_packet, distance, numba_model.time_explosion,
                          estimators)
            move_packet_across_shell_boundary(r_packet, delta_shell,
                                              len(numba_model.r_inner))

        elif interaction_type == InteractionType.LINE:
            r_packet.last_interaction_type = 2

            move_r_packet(r_packet, distance, numba_model.time_explosion,
                          estimators)
            line_scatter(
                r_packet,
                numba_model.time_explosion,
                line_interaction_type,
                numba_plasma,
            )
            trace_vpacket_volley(r_packet, vpacket_collection, numba_model,
                                 numba_plasma)

        elif interaction_type == InteractionType.ESCATTERING:
            r_packet.last_interaction_type = 1

            move_r_packet(r_packet, distance, numba_model.time_explosion,
                          estimators)
            thomson_scatter(r_packet, numba_model.time_explosion)

            trace_vpacket_volley(r_packet, vpacket_collection, numba_model,
                                 numba_plasma)
        if mc_logger.DEBUG_MODE:
            r_packet_track_nu.append(r_packet.nu)
            r_packet_track_mu.append(r_packet.mu)
            r_packet_track_r.append(r_packet.r)
            r_packet_track_interaction.append(interaction_type)
            r_packet_track_distance.append(distance)

    if mc_logger.DEBUG_MODE:
        return (
            r_packet_track_nu,
            r_packet_track_mu,
            r_packet_track_r,
            r_packet_track_interaction,
            r_packet_track_distance,
        )