Exemplo n.º 1
0
def test_twisted_target_mapping_3d_1():
    rdim = 3

    x1, x2, x3 = symbols('x1, x2, x3')

    constants = ['c1', 'c2', 'c3', 'D', 'k']
    c1, c2, c3, D, k = [Constant(i) for i in constants]

    M = TwistedTargetMapping('M', rdim)

    assert (not (M[0] == x1))
    assert (not (M[1] == x2))
    assert (not (M[2] == x3))

    expected = -D * x1**2 + c1 + x1 * (-k + 1) * cos(x2)
    assert (LogicalExpr(M[0], mapping=M, dim=rdim, subs=True) == expected)
    expected = c2 + x1 * (k + 1) * sin(x2)
    assert (LogicalExpr(M[1], mapping=M, dim=rdim, subs=True) == expected)
    expected = c3 + x1**2 * x3 * sin(2 * x2)
    assert (LogicalExpr(M[2], mapping=M, dim=rdim, subs=True) == expected)

    expected = -2 * D * x1 + (-k + 1) * cos(x2)
    assert (LogicalExpr(dx1(M[0]), mapping=M, dim=rdim, subs=True) == expected)
    expected = (k + 1) * sin(x2)
    assert (LogicalExpr(dx1(M[1]), mapping=M, dim=rdim, subs=True) == expected)
    expected = 2 * x1 * x3 * sin(2 * x2)
    assert (LogicalExpr(dx1(M[2]), mapping=M, dim=rdim, subs=True) == expected)

    expected = -x1 * (-k + 1) * sin(x2)
    assert (LogicalExpr(dx2(M[0]), mapping=M, dim=rdim, subs=True) == expected)
    expected = x1 * (k + 1) * cos(x2)
    assert (LogicalExpr(dx2(M[1]), mapping=M, dim=rdim, subs=True) == expected)
    expected = 2 * x1**2 * x3 * cos(2 * x2)
    assert (LogicalExpr(dx2(M[2]), mapping=M, dim=rdim, subs=True) == expected)

    expected = 0
    assert (expand(LogicalExpr(dx3(M[0]), mapping=M, dim=rdim,
                               subs=True)) == expand(expected))
    expected = 0
    assert (LogicalExpr(dx3(M[1]), mapping=M, dim=rdim, subs=True) == expected)
    expected = x1**2 * sin(2 * x2)
    assert (LogicalExpr(dx3(M[2]), mapping=M, dim=rdim, subs=True) == expected)

    expected = Matrix(
        [[-2 * D * x1 + (-k + 1) * cos(x2), -x1 * (-k + 1) * sin(x2), 0],
         [(k + 1) * sin(x2), x1 * (k + 1) * cos(x2), 0],
         [
             2 * x1 * x3 * sin(2 * x2), 2 * x1**2 * x3 * cos(2 * x2),
             x1**2 * sin(2 * x2)
         ]])
    assert (not (Jacobian(M) == expected))
    assert (expand(LogicalExpr(Jacobian(M), mapping=M, dim=rdim,
                               subs=True)) == expand(expected))
Exemplo n.º 2
0
def test_torus_mapping_3d_1():
    rdim = 3

    x1, x2, x3 = symbols('x1, x2, x3')
    R0 = Constant('R0')

    M = TorusMapping('M', rdim)

    assert (not (M[0] == x1))
    assert (not (M[1] == x2))
    assert (not (M[2] == x3))

    expected = (R0 + x1 * cos(x2)) * cos(x3)
    assert (LogicalExpr(M[0], mapping=M, dim=rdim, subs=True) == expected)
    expected = (R0 + x1 * cos(x2)) * sin(x3)
    assert (LogicalExpr(M[1], mapping=M, dim=rdim, subs=True) == expected)
    expected = x1 * sin(x2)
    assert (LogicalExpr(M[2], mapping=M, dim=rdim, subs=True) == expected)

    expected = cos(x2) * cos(x3)
    assert (LogicalExpr(dx1(M[0]), mapping=M, dim=rdim, subs=True) == expected)
    expected = sin(x3) * cos(x2)
    assert (LogicalExpr(dx1(M[1]), mapping=M, dim=rdim, subs=True) == expected)
    expected = sin(x2)
    assert (LogicalExpr(dx1(M[2]), mapping=M, dim=rdim, subs=True) == expected)

    expected = -x1 * sin(x2) * cos(x3)
    assert (LogicalExpr(dx2(M[0]), mapping=M, dim=rdim, subs=True) == expected)
    expected = -x1 * sin(x2) * sin(x3)
    assert (LogicalExpr(dx2(M[1]), mapping=M, dim=rdim, subs=True) == expected)
    expected = x1 * cos(x2)
    assert (LogicalExpr(dx2(M[2]), mapping=M, dim=rdim, subs=True) == expected)

    expected = -(R0 + x1 * cos(x2)) * sin(x3)
    assert (expand(LogicalExpr(dx3(M[0]), mapping=M, dim=rdim,
                               subs=True)) == expand(expected))
    expected = (R0 + x1 * cos(x2)) * cos(x3)
    assert (LogicalExpr(dx3(M[1]), mapping=M, dim=rdim, subs=True) == expected)
    expected = 0
    assert (LogicalExpr(dx3(M[2]), mapping=M, dim=rdim, subs=True) == expected)

    expected = Matrix([[
        cos(x2) * cos(x3), -x1 * sin(x2) * cos(x3),
        -(R0 + x1 * cos(x2)) * sin(x3)
    ],
                       [
                           sin(x3) * cos(x2), -x1 * sin(x2) * sin(x3),
                           (R0 + x1 * cos(x2)) * cos(x3)
                       ], [sin(x2), x1 * cos(x2), 0]])
    assert (not (Jacobian(M) == expected))
    assert (expand(LogicalExpr(Jacobian(M), mapping=M, dim=rdim,
                               subs=True)) == expand(expected))
Exemplo n.º 3
0
def test_torus_mapping_3d_1():
    dim = 3

    x1, x2, x3 = symbols('x1, x2, x3')
    R0 = Constant('R0')

    M = TorusMapping('M', dim=dim)

    domain = M(Domain('Omega', dim=dim))

    assert (not (M[0] == x1))
    assert (not (M[1] == x2))
    assert (not (M[2] == x3))

    expected = (R0 + x1 * cos(x2)) * cos(x3)
    assert (LogicalExpr(M[0], domain) == expected)
    expected = (R0 + x1 * cos(x2)) * sin(x3)
    assert (LogicalExpr(M[1], domain) == expected)
    expected = x1 * sin(x2)
    assert (LogicalExpr(M[2], domain) == expected)

    expected = cos(x2) * cos(x3)
    assert (LogicalExpr(dx1(M[0]), domain) == expected)
    expected = sin(x3) * cos(x2)
    assert (LogicalExpr(dx1(M[1]), domain) == expected)
    expected = sin(x2)
    assert (LogicalExpr(dx1(M[2]), domain) == expected)

    expected = -x1 * sin(x2) * cos(x3)
    assert (LogicalExpr(dx2(M[0]), domain) == expected)
    expected = -x1 * sin(x2) * sin(x3)
    assert (LogicalExpr(dx2(M[1]), domain) == expected)
    expected = x1 * cos(x2)
    assert (LogicalExpr(dx2(M[2]), domain) == expected)

    expected = -(R0 + x1 * cos(x2)) * sin(x3)
    assert (expand(LogicalExpr(dx3(M[0]), domain)) == expand(expected))
    expected = (R0 + x1 * cos(x2)) * cos(x3)
    assert (LogicalExpr(dx3(M[1]), domain) == expected)
    expected = 0
    assert (LogicalExpr(dx3(M[2]), domain) == expected)

    expected = Matrix([[
        cos(x2) * cos(x3), -x1 * sin(x2) * cos(x3),
        -(R0 + x1 * cos(x2)) * sin(x3)
    ],
                       [
                           sin(x3) * cos(x2), -x1 * sin(x2) * sin(x3),
                           (R0 + x1 * cos(x2)) * cos(x3)
                       ], [sin(x2), x1 * cos(x2), 0]])

    assert (all(e.expand().is_zero for e in (Jacobian(M) - expected)))
Exemplo n.º 4
0
def test_terminal_expr_bilinear_3d_1():

    domain = Domain('Omega', dim=3)
    M = Mapping('M', 3)

    mapped_domain = M(domain)

    V = ScalarFunctionSpace('V', domain)
    VM = ScalarFunctionSpace('VM', mapped_domain)

    u, v = elements_of(V, names='u,v')
    um, vm = elements_of(VM, names='u,v')

    int_0 = lambda expr: integral(domain, expr)
    int_1 = lambda expr: integral(mapped_domain, expr)

    J = M.det_jacobian
    det = dx1(M[0])*dx2(M[1])*dx3(M[2]) - dx1(M[0])*dx2(M[2])*dx3(M[1]) - dx1(M[1])*dx2(M[0])*dx3(M[2])\
        + dx1(M[1])*dx2(M[2])*dx3(M[0]) + dx1(M[2])*dx2(M[0])*dx3(M[1]) - dx1(M[2])*dx2(M[1])*dx3(M[0])

    a1 = BilinearForm((u, v), int_0(dot(grad(u), grad(v))))
    a2 = BilinearForm((um, vm), int_1(dot(grad(um), grad(vm))))
    a3 = BilinearForm((u, v), int_0(J * dot(grad(u), grad(v))))

    e1 = TerminalExpr(a1)
    e2 = TerminalExpr(a2)
    e3 = TerminalExpr(a3)

    assert e1[0].expr == dx1(u) * dx1(v) + dx2(u) * dx2(v) + dx3(u) * dx3(v)
    assert e2[0].expr == dx(um) * dx(vm) + dy(um) * dy(vm) + dz(um) * dz(vm)
    assert e3[0].expr.factor() == (dx1(u) * dx1(v) + dx2(u) * dx2(v) +
                                   dx3(u) * dx3(v)) * det
Exemplo n.º 5
0
def test_mapping_3d():
    print('============ test_mapping_3d ==============')

    rdim = 3

    F = Mapping('F', rdim)

    a,b,c = symbols('a b c')
    abc = Tuple(a, b, c)

    assert(F.name == 'F')

    # ...
    expected = Matrix([[dx1(F[0]), dx2(F[0]), dx3(F[0])],
                       [dx1(F[1]), dx2(F[1]), dx3(F[1])],
                       [dx1(F[2]), dx2(F[2]), dx3(F[2])]])
    assert(F.jacobian == expected)
    # ...

    # ...
    expected = (dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) -
                dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) +
                dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0]))
    assert(F.det_jacobian == expected)
    # ...

    # ...
    expected = Tuple (a*(dx2(F[1])*dx3(F[2]) - dx2(F[2])*dx3(F[1]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*(-dx1(F[1])*dx3(F[2]) + dx1(F[2])*dx3(F[1]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*(dx1(F[1])*dx2(F[2]) - dx1(F[2])*dx2(F[1]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])), a*(-dx2(F[0])*dx3(F[2]) + dx2(F[2])*dx3(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*(dx1(F[0])*dx3(F[2]) - dx1(F[2])*dx3(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*(-dx1(F[0])*dx2(F[2]) + dx1(F[2])*dx2(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])), a*(dx2(F[0])*dx3(F[1]) - dx2(F[1])*dx3(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*(-dx1(F[0])*dx3(F[1]) + dx1(F[1])*dx3(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*(dx1(F[0])*dx2(F[1]) - dx1(F[1])*dx2(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])))
    cov = Covariant(F, abc)
    assert(simplify(cov) == simplify(expected))
    # ...

    # ...
    expected = Tuple (a*dx1(F[0])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*dx2(F[0])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*dx3(F[0])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])), a*dx1(F[1])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*dx2(F[1])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*dx3(F[1])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])), a*dx1(F[2])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*dx2(F[2])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*dx3(F[2])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])))
    cov = Contravariant(F, abc)
    assert(simplify(cov) == simplify(expected))
Exemplo n.º 6
0
def test_mapping_3d():
    print('============ test_mapping_3d ==============')

    rdim = 3

    F = Mapping('F', rdim)

    a,b,c = symbols('a b c')
    abc = Tuple(a, b, c)

    assert(F.name == 'F')

    # ...
    expected = Matrix([[dx1(F[0]), dx2(F[0]), dx3(F[0])],
                       [dx1(F[1]), dx2(F[1]), dx3(F[1])],
                       [dx1(F[2]), dx2(F[2]), dx3(F[2])]])
    assert(Jacobian(F) == expected)
    # ...

    # ...
    expected = (dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) -
                dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) +
                dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0]))
    assert(Jacobian(F).det() == expected)
    # ...

    # ...
    expected = Tuple (a*(dx2(F[1])*dx3(F[2]) - dx2(F[2])*dx3(F[1]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*(-dx1(F[1])*dx3(F[2]) + dx1(F[2])*dx3(F[1]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*(dx1(F[1])*dx2(F[2]) - dx1(F[2])*dx2(F[1]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])), a*(-dx2(F[0])*dx3(F[2]) + dx2(F[2])*dx3(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*(dx1(F[0])*dx3(F[2]) - dx1(F[2])*dx3(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*(-dx1(F[0])*dx2(F[2]) + dx1(F[2])*dx2(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])), a*(dx2(F[0])*dx3(F[1]) - dx2(F[1])*dx3(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*(-dx1(F[0])*dx3(F[1]) + dx1(F[1])*dx3(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*(dx1(F[0])*dx2(F[1]) - dx1(F[1])*dx2(F[0]))/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])))
    cov      = Covariant(F, abc)
    cov      = Matrix(cov)
    expected = Matrix(expected)
    diff     = cov-expected
    diff.simplify()

    assert(diff.dot(diff).is_zero)
    # ...

    # ...
    expected = Tuple (a*dx1(F[0])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*dx2(F[0])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*dx3(F[0])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])), a*dx1(F[1])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*dx2(F[1])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*dx3(F[1])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])), a*dx1(F[2])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + b*dx2(F[2])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])) + c*dx3(F[2])/(dx1(F[0])*dx2(F[1])*dx3(F[2]) - dx1(F[0])*dx2(F[2])*dx3(F[1]) - dx1(F[1])*dx2(F[0])*dx3(F[2]) + dx1(F[1])*dx2(F[2])*dx3(F[0]) + dx1(F[2])*dx2(F[0])*dx3(F[1]) - dx1(F[2])*dx2(F[1])*dx3(F[0])))
    cov = Contravariant(F, abc)
    assert(simplify(cov) == simplify(expected))