Ejemplo n.º 1
0
def test_GenericVector_check_Metric():
    syms = symbols("t x y z")
    t, x, y, z = syms
    obj = GenericVector([t, x, y, z],
                        syms=syms,
                        config="u",
                        parent_metric=None)
    obj.change_config("u", None)
Ejemplo n.º 2
0
def test_GenericVector_change_config_theoretical_test():
    # https://en.wikipedia.org/wiki/Covariance_and_contravariance_of_vectors#Definition
    a, b, th = symbols("a b theta")
    metric = euclidean_space_metric()
    # defining a contravariant vector
    cnvec = GenericVector([a, b], metric.syms, config="u", parent_metric=metric)
    covec = cnvec.change_config("l")  # get contravariant vector
    assert simplify(covec.tensor()[0] - (a + b * cos(th))) == 0
    assert simplify(covec.tensor()[1] - (b + a * cos(th))) == 0
Ejemplo n.º 3
0
def test_GenericVector_check_ValueErrors():
    a, b = symbols("a b")
    syms = symbols("e1 e2")
    # input a tensor with wring rank
    try:
        arr = [[a, b], [b, 1]]
        v1 = GenericVector(arr, syms, "l")
        boolstore = False
    except ValueError:
        boolstore = True
    assert boolstore
    # input a wrong length config
    try:
        arr = [a, b]
        v2 = GenericVector(arr, syms, "uu")
        boolstore = False
    except ValueError:
        boolstore = True
    assert boolstore
Ejemplo n.º 4
0
 def get_vector():
     syms = symbols("t x y z")
     t, x, y, z = syms
     return GenericVector([t, x, y, z], syms=syms, config="u")