Esempio n. 1
0
def test_continuity(initial_conditions, solution, regtest, test_info, test_id):
    eqn = ((float_type(5) / float_type(2) - 2 * initial_conditions.β) *
           solution.v_r + solution.deriv.v_θ + (solution.v_θ / solution.ρ) *
           (solution.deriv.ρ - solution.ρ * tan(initial_conditions.angle)))
    test_info(eqn)
    regtest.identifier = test_id
    print(eqn, file=regtest)
    assert eqn == approx(0)
Esempio n. 2
0
def test_radial_momentum(initial_conditions, solution, regtest, test_info,
                         test_id):
    eqn = (solution.v_θ * solution.deriv.v_r -
           float_type(1) / float_type(2) * solution.v_r**2 - solution.v_θ**2 -
           solution.v_φ**2 + initial_conditions.norm_kepler_sq -
           2 * initial_conditions.β - initial_conditions.a_0 / solution.ρ *
           (solution.B_θ * solution.deriv.B_r + (initial_conditions.β - 1) *
            (solution.B_θ**2 + solution.B_φ**2)))
    test_info(eqn)
    regtest.identifier = test_id
    print(eqn, file=regtest)
    assert eqn == approx(0)
Esempio n. 3
0
def initial_conditions():
    values = SimpleNamespace()
    # These are all arbitrary values, this should not affect the result
    values.params = np.array([7 for i in range(ODE_NUMBER)], dtype=FLOAT_TYPE)
    values.β = float_type(5) / float_type(4)
    values.norm_kepler_sq = float_type(1000)
    values.a_0 = float_type(2)
    values.γ = 0

    values.params[ODEIndex.v_θ] = 0

    # This is slightly off the plane, this should mean we don't get
    # cancellation
    values.angle = float_type(0.01)
    return values
Esempio n. 4
0
def initial_conditions():
    values = SimpleNamespace()
    # These are all arbitrary values, this should not affect the result
    values.params = np.array([7 for i in range(ODE_NUMBER)], dtype=FLOAT_TYPE)
    values.β = float_type(2)
    values.norm_kepler_sq = float_type(2)
    values.a_0 = float_type(2)
    values.γ = 5 / 4 - values.β

    # This is slightly off the plane, this should mean we don't get
    # cancellation
    values.angle = float_type(0.1)

    values.params[ODEIndex.v_θ] = float_type(1)

    θ = values.angle
    a_0 = values.a_0
    γ = values.γ
    B_r = values.params[ODEIndex.B_r]
    B_φ = values.params[ODEIndex.B_φ]
    B_θ = values.params[ODEIndex.B_θ]
    v_φ = values.params[ODEIndex.v_φ]
    ρ = values.params[ODEIndex.ρ]
    B_φ_prime = values.params[ODEIndex.B_φ_prime]
    η_O = values.params[ODEIndex.η_O]
    η_A = values.params[ODEIndex.η_A]
    η_H = values.params[ODEIndex.η_H]

    B_mag = sqrt(B_r**2 + B_φ**2 + B_θ**2)
    with np.errstate(invalid="ignore"):
        norm_B_r, norm_B_φ, norm_B_θ = (B_r / B_mag, B_φ / B_mag, B_θ / B_mag)

    values.params[ODEIndex.v_r] = ρ * (η_O + η_A * (1 - norm_B_φ**2)) / (
        B_r * B_θ * a_0 - (1 / 2 - 2 * γ) * ρ *
        (η_O + η_A * (1 - norm_B_φ**2))) * (
            tan(θ) * (v_φ**2 + 1) + a_0 / ρ *
            (B_r * (B_r + B_φ_prime *
                    (η_H * norm_B_θ - η_A * norm_B_r * norm_B_φ) + B_φ *
                    (η_A * norm_B_φ * (norm_B_r * tan(θ) - norm_B_θ *
                                       (1 / 4 - γ)) - η_H *
                     (norm_B_r * (1 / 4 - γ) + norm_B_θ * tan(θ)))) /
             (η_O + η_A *
              (1 - norm_B_φ**2)) + B_φ * B_φ_prime - B_φ**2 * tan(θ)))

    return values
Esempio n. 5
0
def test_azimuthal_induction_numeric(initial_conditions, derivs, rhs_func,
                                     solution, regtest, test_info, test_id):
    step = float_type(1e-4)
    new_params = initial_conditions.params + derivs * step
    new_angle = initial_conditions.angle + step
    new_derivs = np.zeros(ODE_NUMBER)
    rhs_func(new_angle, new_params, new_derivs)
    dderiv_B_φ_hacked = ((new_derivs - derivs) / step)[ODEIndex.B_φ]
    eqn = dderiv_B_φ_hacked - solution.deriv.B_φ_prime
    test_info(eqn)
    regtest.identifier = test_id
    print(eqn, file=regtest)
    assert eqn == approx(0, abs=4e-12)