Ejemplo n.º 1
0
def test_get_random_mu_different_output():
    """
    Ensure that different calls results
    """
    output1 = r_packet.get_random_mu()
    output2 = r_packet.get_random_mu()
    assert output1 != output2
Ejemplo n.º 2
0
def line_scatter(r_packet, time_explosion, line_interaction_type,
                 numba_plasma):
    """
    Line scatter function that handles the scattering itself, including new angle drawn, and calculating nu out using macro atom
    r_packet: RPacket
    time_explosion: float
    line_interaction_type: enum
    numba_plasma: NumbaPlasma
    """

    old_doppler_factor = get_doppler_factor(r_packet.r, r_packet.mu,
                                            time_explosion)
    r_packet.mu = get_random_mu()

    inverse_new_doppler_factor = get_inverse_doppler_factor(
        r_packet.r, r_packet.mu, time_explosion)

    comov_energy = r_packet.energy * old_doppler_factor
    r_packet.energy = comov_energy * inverse_new_doppler_factor

    if line_interaction_type == LineInteractionType.SCATTER:
        line_emission(r_packet, r_packet.next_line_id, time_explosion,
                      numba_plasma)
    else:  # includes both macro atom and downbranch - encoded in the transition probabilities
        emission_line_id = macro_atom(r_packet, numba_plasma)
        line_emission(r_packet, emission_line_id, time_explosion, numba_plasma)
Ejemplo n.º 3
0
def thomson_scatter(r_packet, time_explosion):
    """
    Thomson scattering — no longer line scattering
    2) get the doppler factor at that position with the old angle
    3) convert the current energy and nu into the comoving
        frame with the old mu
    4) Scatter and draw new mu - update mu
    5) Transform the comoving energy and nu back using the new mu

    Parameters
    ----------
    r_packet : RPacket
    time_explosion: float
        time since explosion in seconds

    """
    old_doppler_factor = get_doppler_factor(r_packet.r, r_packet.mu,
                                            time_explosion)
    comov_nu = r_packet.nu * old_doppler_factor
    comov_energy = r_packet.energy * old_doppler_factor
    r_packet.mu = get_random_mu()
    inverse_new_doppler_factor = get_inverse_doppler_factor(
        r_packet.r, r_packet.mu, time_explosion)

    r_packet.nu = comov_nu * inverse_new_doppler_factor
    r_packet.energy = comov_energy * inverse_new_doppler_factor
    if montecarlo_configuration.full_relativity:
        r_packet.mu = angle_aberration_CMF_to_LF(r_packet, time_explosion,
                                                 r_packet.mu)
Ejemplo n.º 4
0
def test_get_random_mu(set_seed_fixture):
    """
    Ensure that different calls results
    """
    set_seed_fixture(1963)

    output1 = r_packet.get_random_mu()
    assert output1 == 0.9136407866175174