Пример #1
0
def test_3d_4b():
    """Alfven operator."""
    x,y,z = symbols('x y z')

    u = IndexedBase('u')
    v = IndexedBase('v')

    bx = Constant('bx')
    by = Constant('by')
    bz = Constant('bz')
    b = Tuple(bx, by, bz)

    c0,c1,c2 = symbols('c0 c1 c2')

    a = Lambda((x,y,z,v,u), (  c0 * Dot(u, v)
                             - c1 * Div(u) * Div(v)
                             + c2 *Dot(Curl(Cross(b,u)), Curl(Cross(b,v)))))
    print('> input       := {0}'.format(a))

    expr = gelatize(a, dim=DIM)
    print('> gelatized   := {0}'.format(expr))

    expr, info = initialize_weak_form(expr, dim=DIM)
    print('> temp form   :=')
    # for a nice printing, we print the dictionary entries one by one
    for key, value in list(expr.items()):
        print('\t\t', key, '\t', value)

    expr = normalize_weak_from(expr)
    print('> normal form := {0}'.format(expr))

    print('')
Пример #2
0
def test_2d_1():
    x, y = symbols('x y')

    u = Symbol('u')
    v = Symbol('v')

    a = Lambda((x, y, v, u), Dot(Grad(u), Grad(v)) + u * v)
    print('> input       := {0}'.format(a))

    expr = gelatize(a, dim=DIM)
    print('> gelatized   := {0}'.format(expr))

    expr = normalize_weak_from(expr)
    print('> normal form := {0}'.format(expr))

    print('')
Пример #3
0
def test_3d_1():
    x,y,z = symbols('x y z')

    u = Symbol('u')
    v = Symbol('v')

    a = Lambda((x,y,z,v,u), Dot(Grad(u), Grad(v)))
    print('> input       := {0}'.format(a))

    expr = gelatize(a, dim=DIM)
    print('> gelatized   := {0}'.format(expr))

    expr, info = initialize_weak_form(expr, dim=DIM)
    print('> temp form   := {0}'.format(expr))

    expr = normalize_weak_from(expr)
    print('> normal form := {0}'.format(expr))

    print('')
Пример #4
0
def test_2d_3():
    x, y = symbols('x y')

    u = Symbol('u')
    v = Symbol('v')

    a = Lambda((x, y, v, u), Cross(Curl(u), Curl(v)) + 0.2 * u * v)
    print('> input       := {0}'.format(a))

    expr = gelatize(a, dim=DIM)
    print('> gelatized   := {0}'.format(expr))

    expr, info = initialize_weak_form(expr, dim=DIM)
    print('> temp form   := {0}'.format(expr))

    expr = normalize_weak_from(expr)
    print('> normal form := {0}'.format(expr))

    print('')
Пример #5
0
def test_1d_2():
    x,y = symbols('x y')

    u = Symbol('u')
    v = Symbol('v')

#    b = Function('b')
    b = Constant('b')

    a = Lambda((x,y,v,u), Dot(Grad(b*u), Grad(v)) + u*v)
    print('> input       := {0}'.format(a))

    expr = gelatize(a, dim=DIM)
    print('> gelatized   := {0}'.format(expr))

    expr = normalize_weak_from(expr)
    print('> normal form := {0}'.format(expr))

    print('')
Пример #6
0
def test_3d_3():
    x,y,z = symbols('x y z')

    u = IndexedBase('u')
    v = IndexedBase('v')

    a = Lambda((x,y,z,v,u), Dot(Curl(u), Curl(v)) + 0.2 * Dot(u, v))
    print('> input       := {0}'.format(a))

    expr = gelatize(a, dim=DIM)
    print('> gelatized   := {0}'.format(expr))

    expr, info = initialize_weak_form(expr, dim=DIM)
    print('> temp form   :=')
    # for a nice printing, we print the dictionary entries one by one
    for key, value in list(expr.items()):
        print('\t\t', key, '\t', value)

    expr = normalize_weak_from(expr)
    print('> normal form := {0}'.format(expr))

    print('')
Пример #7
0
def test_2d_4():
    x, y = symbols('x y')

    u = Symbol('u')
    v = Symbol('v')

    bx = Constant('bx')
    by = Constant('by')
    b = Tuple(bx, by)

    a = Lambda((x, y, v, u), 0.2 * u * v + Dot(b, Grad(v)) * u)
    print('> input       := {0}'.format(a))

    expr = gelatize(a, dim=DIM)
    print('> gelatized   := {0}'.format(expr))

    expr, info = initialize_weak_form(expr, dim=DIM)
    print('> temp form   := {0}'.format(expr))

    expr = normalize_weak_from(expr)
    print('> normal form := {0}'.format(expr))

    print('')