Beispiel #1
0
 def directional_derivative(field):
     field = express(field, other.system, variables=True)
     out = self.dot(other._i) * df(field, other._x)
     out += self.dot(other._j) * df(field, other._y)
     out += self.dot(other._k) * df(field, other._z)
     if out == 0 and isinstance(field, Vector):
         out = Vector.zero
     return out
Beispiel #2
0
 def directional_derivative(field):
     field = express(field, other.system, variables = True)
     out = self.dot(other._i) * df(field, other._x)
     out += self.dot(other._j) * df(field, other._y)
     out += self.dot(other._k) * df(field, other._z)
     if out == 0 and isinstance(field, Vector):
         out = Vector.zero
     return out
Beispiel #3
0
 def directional_derivative(field):
     from sympy.vector.operators import _get_coord_sys_from_expr
     coord_sys = _get_coord_sys_from_expr(field)
     if coord_sys is not None:
         field = express(field, coord_sys, variables=True)
         out = self.dot(coord_sys._i) * df(field, coord_sys._x)
         out += self.dot(coord_sys._j) * df(field, coord_sys._y)
         out += self.dot(coord_sys._k) * df(field, coord_sys._z)
         if out == 0 and isinstance(field, Vector):
             out = Vector.zero
         return out
     elif isinstance(field, Vector):
         return Vector.zero
     else:
         return S(0)
Beispiel #4
0
 def directional_derivative(field):
     from sympy.vector.operators import _get_coord_sys_from_expr
     coord_sys = _get_coord_sys_from_expr(field)
     if coord_sys is not None:
         field = express(field, coord_sys, variables=True)
         out = self.dot(coord_sys._i) * df(field, coord_sys._x)
         out += self.dot(coord_sys._j) * df(field, coord_sys._y)
         out += self.dot(coord_sys._k) * df(field, coord_sys._z)
         if out == 0 and isinstance(field, Vector):
             out = Vector.zero
         return out
     elif isinstance(field, Vector) :
         return Vector.zero
     else:
         return S(0)
Beispiel #5
0
    def diff(self, *args, **kwargs):
        """
        Implements the SymPy diff routine, for vectors.

        diff's documentation
        ========================

        """
        for x in args:
            if isinstance(x, BasisDependent):
                raise TypeError("Invalid arg for differentiation")
        diff_components = [df(v, *args, **kwargs) * k for
                           k, v in self.components.items()]
        return self._add_func(*diff_components)
Beispiel #6
0
    def diff(self, *args, **kwargs):
        """
        Implements the SymPy diff routine, for vectors.

        diff's documentation
        ========================

        """
        for x in args:
            if isinstance(x, Vector):
                raise TypeError("Cannot differentiate wrt a Vector")
        diff_components = [df(v, *args, **kwargs) * k for \
                           k, v in self.components.items()]
        return VectorAdd(*diff_components)