Пример #1
0
def test_shallow_water_gc():
    import ibvp.sym as sym

    dim = 2
    col_height = sym.Field("eta")

    # "mom"entum really is column height * velocity
    mom = sym.MultiVectorField("mom")

    d1 = sym.Derivative()
    d2 = sym.Derivative()
    d3 = sym.Derivative()
    eqns = sym.join(
            sym.d_dt(col_height)
            + (d1.nabla | d1(mom)),

            sym.d_dt(mom)
            + d2(mom * (mom | d2.nabla)/col_height)
            + 0.5*d3.nabla*d3(col_height**2)
            )

    print(sym.pretty(eqns))

    from ibvp.language import PDESystem
    system = PDESystem(
            ambient_dim=dim,
            pde_system=eqns,
            unknowns=[col_height, mom],
            )

    from ibvp.target.proteus import generate_proteus_problem_file
    generate_proteus_problem_file(system, "ShallowWater")
Пример #2
0
def test_very_nonlinear_burgers():
    ambient_dim = 2

    p = 1
    q = 2
    r = 2

    u = sym.Field("u")

    B = np.array([1.0, 2.0])

    Adiff = 0.001
    C = 0.0001

    eqns = sym.join(
            sym.d_dt(u**p)
            + sym.div(B * u**q)
            - sym.div(Adiff * sym.grad(u**r))
            + C * u
            )

    print(sym.pretty(eqns))

    print(generate_proteus_problem_file(
            PDESystem(
                ambient_dim=ambient_dim,
                pde_system=eqns,
                unknowns=[u],
                ),
            "Burgers"))
Пример #3
0
def test_heat():
    ambient_dim = 2

    u = sym.Field("u")

    eqns = sym.join(
            sym.d_dt(u)
            - sym.div(sym.grad(u))
            )

    print(sym.pretty(eqns))

    generate_proteus_problem_file(
            PDESystem(
                ambient_dim=ambient_dim,
                pde_system=eqns,
                unknowns=[u],
                ),
            "Heat")
Пример #4
0
def test_parabolic_system():
    ambient_dim = 2

    u = sym.Field("u")
    v = sym.Field("v")

    eqns = sym.join(
            sym.d_dt(u) - sym.div(sym.grad(u-v)),
            sym.d_dt(v) - sym.div(sym.grad(u+v)),
            )

    print(sym.pretty(eqns))

    generate_proteus_problem_file(
            PDESystem(
                ambient_dim=ambient_dim,
                pde_system=eqns,
                unknowns=[u, v],
                ),
            "ParabolicSystem")
Пример #5
0
def test_burgers():
    ambient_dim = 2

    u = sym.Field("u")

    vec = np.array([1.0, 2.0])

    eqns = sym.join(
            sym.d_dt(u)
            + sym.div(vec * u**2)
            - sym.div(sym.grad(u))
            )

    print(sym.pretty(eqns))

    generate_proteus_problem_file(
            PDESystem(
                ambient_dim=ambient_dim,
                pde_system=eqns,
                unknowns=[u],
                ),
            "Burgers")
Пример #6
0
def test_advection():
    u = sym.Field("u")

    eqns = sym.join(sym.d_dt(u) + sym.d_dx(u))

    print(sym.pretty(eqns))

    print(generate_proteus_problem_file(
            PDESystem(
                ambient_dim=1,
                pde_system=eqns,
                unknowns=[u],
                ),
            "Advection"))
Пример #7
0
def test_wave():
    dim = 3
    u = sym.Field("u")
    f = sym.Field("f")
    c = sym.Parameter("c")
    v = sym.VectorField("v")

    eqns = sym.join(
            sym.d_dt(u)
            + c * sym.div(v) - f,

            sym.d_dt(v)
            + c * sym.grad(u)
            )

    print(sym.pretty(eqns))

    generate_proteus_problem_file(
            PDESystem(
                ambient_dim=dim,
                pde_system=eqns,
                unknowns=[u, v],
                ),
            "Wave")