Beispiel #1
0
def test_spatial_and_temporal_convergence(solver) -> None:
    """Test convergence rates for bidomain solver."""
    v_errors = []
    u_errors = []
    dts = []
    hs = []
    T = 0.1
    dt = 0.01
    theta = 0.5
    N = 10
    for level in (1, 2, 3):
        a = dt / (2**level)
        v_error, u_error, h, a, T = main(solver, N * (2**level), a, T, theta)
        v_errors.append(v_error)
        u_errors.append(u_error)
        dts.append(a)
        hs.append(h)

    v_rates = convergence_rate(hs, v_errors)
    u_rates = convergence_rate(hs, u_errors)
    print("v_errors = ", v_errors)
    print("u_errors = ", u_errors)
    print("v_rates = ", v_rates)
    print("u_rates = ", u_rates)

    assert all(v > 1.9 for v in v_rates), "Failed convergence for v"
    assert all(u > 1.9 for u in u_rates), "Failed convergence for u"
def test_temporal_convergence():
    """Take a small mesh, reduce timestep size, expect 2nd order convergence."""
    v_errors = []
    u_errors = []
    dts = []
    dt = 1.
    T = 1.
    N = 200
    for level in (0, 1, 2, 3):
        a = dt / (2**level)
        v_error, u_error, h, a, T = main(N, a, T)
        v_errors.append(v_error)
        u_errors.append(u_error)
        dts.append(a)

    print("v_errors = ", v_errors)
    print("u_errors = ", u_errors)
    v_rates = convergence_rate(dts, v_errors)
    u_rates = convergence_rate(dts, u_errors)
    print("v_rates = ", v_rates)
    print("u_rates = ", u_rates)

    assert v_rates[-1] > 1.95, "Failed convergence for v"
    # Increase spatial resolution to get better temporal convergence for u
    assert u_rates[-1] > 1.78, "Failed convergence for u"
def test_spatial_and_temporal_convergence() -> None:
    v_errors = []
    u_errors = []
    dts = []
    hs = []
    T = 0.5
    dt = 0.05
    theta = 0.5
    N = 5
    for level in (0, 1, 2, 3):
        a = dt / (2**level)
        v_error, u_error, h, a, T = main(N * 2**level, a, T, theta)
        v_errors.append(v_error)
        u_errors.append(u_error)
        dts.append(a)
        hs.append(h)

    v_rates = convergence_rate(hs, v_errors)
    u_rates = convergence_rate(hs, u_errors)
    print("v_errors = ", v_errors)
    print("u_errors = ", u_errors)
    print("v_rates = ", v_rates)
    print("u_rates = ", u_rates)

    assert v_rates[-1] > 1.95, "Failed convergence for v"
    assert u_rates[-1] > 1.9, "Failed convergence for u"
def test_spatial_convergence():
    """Take a very small timestep, reduce mesh size, expect 2nd order convergence."""
    v_errors = []
    u_errors = []
    hs = []
    dt = 0.01
    T = 1.0
    for N in (5, 10, 20, 40):
        v_error, u_error, h, dt_, T = main(N, dt, T)
        v_errors.append(v_error)
        u_errors.append(u_error)
        hs.append(h)

    v_rates = convergence_rate(hs, v_errors)
    u_rates = convergence_rate(hs, u_errors)
    print("dt, T = ", dt, T)
    print("v_errors = ", v_errors)
    print("u_errors = ", u_errors)
    print("v_rates = ", v_rates)
    print("u_rates = ", u_rates)

    assert all(v > 1.9 for v in v_rates), "Failed convergence for v"
    assert all(u > 1.85 for u in u_rates), "Failed convergence for u"
Beispiel #5
0
def test_spatial_convergence() -> None:
    """Take a very small time step, reduce mesh size, expect 2nd order convergence."""
    v_errors = []
    hs = []
    dt = 1e-6
    T = 10*dt

    for N in (5, 10, 20, 40):
        v_error, h, *_ = main(N, dt, T, theta=0.5)
        v_errors.append(v_error)
        hs.append(h)

    v_rates = convergence_rate(hs, v_errors)
    print("dt, T = {dt}, {T}".format(dt=dt, T=T))
    print("v_errors = ", v_errors)
    print("v_rates = ", v_rates)
def test_spatial_and_temporal_convergence() -> None:
    v_errors = []
    hs = []
    dt = 1e-3
    N = 5

    for level in range(3):
        a = dt/2**level
        T= 10*a
        v_error, h, *_ = main(N*2**level, a, T, theta=0.5)
        v_errors.append(v_error)
        hs.append(h)

    v_rates = convergence_rate(hs, v_errors)
    print(v_errors)
    print(v_rates)
    msg = "Failed convergence for v, v_rates: {}".format(", ".join(map(str, v_rates)))
    assert v_rates[-1] > 2, msg
def test_spatial_convergence() -> None:
    """Take a very small time step, reduce mesh size, expect 2nd order convergence."""
    v_errors = []
    hs = []
    dt = 1e-6
    T = 10*dt

    for N in (5, 10, 20, 40):
        v_error, h, *_ = main(N, dt, T, theta=0.5)
        v_errors.append(v_error)
        hs.append(h)

    v_rates = convergence_rate(hs, v_errors)
    print("dt, T = {dt}, {T}".format(dt=dt, T=T))
    print("v_errors = ", v_errors)
    print("v_rates = ", v_rates)

    msg = "Failed convergence for v. v_rates = {}".format(", ".join(map(str, v_rates)))
    assert all(v > 2 for v in v_rates), msg
Beispiel #8
0
def test_spatial_and_temporal_convergence(solver) -> None:
    """Test convergence rates for bidomain solver."""
    v_errors = []
    dts = []
    hs = []

    dt = 1e-3
    theta = 0.5
    N = 5

    for level in range(3):
        a = dt/(2**level)
        T = 10*a
        v_error, h, a, T = main(solver, N*(2**level), a, T, theta)
        v_errors.append(v_error)
        dts.append(a)
        hs.append(h)

    v_rates = convergence_rate(hs, v_errors)
    print("v_errors = {}".format(v_errors))
    print("v_rates = {}".format(v_rates))
    assert all(v > 1.9 for v in v_rates), "Failed convergence for v"