Ejemplo n.º 1
0
    def test_expand(self):
        a, f, r = sp.symbols('a, f, r')
        (x1, x2, x3), (dx1, dx2, dx3) = pc.diffgeo_setup(3)

        c = a * (1 / a - a) + a**2
        w = c * dx1

        self.assertEqual(w.expand(), dx1)
Ejemplo n.º 2
0
    def test_simplify(self):
        a, f, r = sp.symbols('a, f, r')
        (x1, x2, x3), (dx1, dx2, dx3) = pc.diffgeo_setup(3)

        w = cos(x3)**2 * dx1 + sin(x3)**2 * dx1
        w.simplify()

        self.assertEqual(w, dx1)
Ejemplo n.º 3
0
    def test_subs(self):
        a, f, r = sp.symbols('a, f, r')
        (x1, x2, r), (dx1, dx2, dr) = pc.diffgeo_setup(3)
        #aa = a*dr-r*dx1-l*dx2

        w1 = dx1.subs(a, r)
        self.assertEqual(dx1, w1)

        w2 = dx1 + a * dx2 + f(x1, x2) * dr
        w3 = w2.subs(a, r)
        w4 = w2.subs(x1, r)

        sl = list(zip((a, x1), (r, 3 * r + 7)))
        w5 = w2.subs(sl)
        self.assertEqual(w3, dx1 + r * dx2 + f(x1, x2) * dr)
        self.assertEqual(w4, dx1 + a * dx2 + f(r, x2) * dr)
        self.assertEqual(w5, dx1 + r * dx2 + f(3 * r + 7, x2) * dr)
Ejemplo n.º 4
0
    def generate_basis(self):
        # TODO: not the most elegant way?
        # check highest order of derivatives
        highest_order = 0
        for n in self._myStack.transformation.H.atoms():
            if hasattr(n, "difforder"):
                if n.difforder>highest_order:
                    highest_order = n.difforder

        # generate vector with vec_x and its derivatives up to highest_order
        new_vector = self._myStack.vec_x
        for index in xrange(1, highest_order+1):
            vec_x_ndot = st.time_deriv(self._myStack.vec_x, self._myStack.vec_x, order=index)
            new_vector = st.concat_rows( new_vector, vec_x_ndot )

        # generate basis_1form up to this order
        basis, basis_1form = ct.diffgeo_setup(new_vector)

        # store
        self._myStack.basis = basis
        self._myStack.basis_1form = basis_1form
Ejemplo n.º 5
0
    def test_string_representation(self):
        a, f, r = sp.symbols('a, f, r')
        (x1, x2, x3), (dx1, dx2, dx3) = pc.diffgeo_setup(3)

        s1 = str(dx1)
        self.assertEqual(s1, '(1)dx1')

        s1 = str(0 * dx2)
        self.assertEqual(s1, '(0)dx1')

        s1 = str(7 * a * dx1 * dx2 - dx2 * dx3)
        self.assertEqual(s1, '(7*a)dx1^dx2  +  (-1)dx2^dx3')

        w2 = -sin(x3) * dx1 + cos(x3) * dx2
        w3 = dx3
        s1 = str(w2.d ^ w3)
        self.assertEqual(s1, '(0)dx1^dx2^dx3')

        s1 = str(w2.d ^ w2 ^ w3)
        self.assertEqual(s1, '(0)dx1^dx1^dx1^dx1')

        s1 = str(w2 ^ w2 ^ w2 ^ w2 ^ w2 ^ w2)
        self.assertEqual(s1, '(0)dx1' + '^dx1' * 5)
Ejemplo n.º 6
0
    def generate_basis(self):
        # TODO: not the most elegant way?
        # check highest order of derivatives
        highest_order = 0
        for n in self._myStack.transformation.H.atoms():
            if hasattr(n, "difforder"):
                if n.difforder > highest_order:
                    highest_order = n.difforder

        # generate vector with vec_x and its derivatives up to highest_order
        new_vector = self._myStack.vec_x
        for index in range(1, highest_order + 1):
            vec_x_ndot = st.time_deriv(self._myStack.vec_x,
                                       self._myStack.vec_x,
                                       order=index)
            new_vector = st.concat_rows(new_vector, vec_x_ndot)

        # generate basis_1form up to this order
        basis, basis_1form = ct.diffgeo_setup(new_vector)

        # store
        self._myStack.basis = basis
        self._myStack.basis_1form = basis_1form
Ejemplo n.º 7
0
 def test_rank(self):
     a, l, r = sp.symbols('a, l, r')
     (x1, x2, r), (dx1, dx2, dr) = pc.diffgeo_setup(3)
     aa = a * dr - r * dx1 - l * dx2
     self.assertEqual(aa.rank(), 1)