(self, scalar_field)
return result.doit()
Apply on a scalar field.

        The action of a vector field on a scalar field is a directional
        differentiation.

        If the argument is not a scalar field an error is raised.
Apply on a scalar field.
Apply on a scalar field .
def __call__(self, scalar_field):
        """Apply on a scalar field.

        The action of a vector field on a scalar field is a directional
        differentiation.

        If the argument is not a scalar field an error is raised.
        """
        if covariant_order(scalar_field) or contravariant_order(scalar_field):
            raise ValueError('Only scalar fields can be supplied as arguments to vector fields.')

        base_scalars = list(scalar_field.atoms(BaseScalarField))

        # First step: e_x(x+r**2) -> e_x(x) + 2*r*e_x(r)
        d_var = self._coord_sys._dummy
        # TODO: you need a real dummy function for the next line
        d_funcs = [Function('_#_%s' % i)(d_var) for i,
                   b in enumerate(base_scalars)]
        d_result = scalar_field.subs(list(zip(base_scalars, d_funcs)))
        d_result = d_result.diff(d_var)

        # Second step: e_x(x) -> 1 and e_x(r) -> cos(atan2(x, y))
        coords = self._coord_sys._dummies
        d_funcs_deriv = [f.diff(d_var) for f in d_funcs]
        d_funcs_deriv_sub = []
        for b in base_scalars:
            jac = self._coord_sys.jacobian(b._coord_sys, coords)
            d_funcs_deriv_sub.append(jac[b._index, self._index])
        d_result = d_result.subs(list(zip(d_funcs_deriv, d_funcs_deriv_sub)))

        # Remove the dummies
        result = d_result.subs(list(zip(d_funcs, base_scalars)))
        result = result.subs(list(zip(coords, self._coord_sys.coord_functions())))
        return result.doit()
def __call__ ( self , scalar_field ) : if covariant_order ( scalar_field ) or contravariant_order ( scalar_field ) : raise ValueError ( 'Only scalar fields can be supplied as arguments to vector fields.' ) base_scalars = list ( scalar_field . atoms ( BaseScalarField ) ) # First step: e_x(x+r**2) -> e_x(x) + 2*r*e_x(r) d_var = self . _coord_sys . _dummy # TODO: you need a real dummy function for the next line d_funcs = [ Function ( '_#_%s' % i ) ( d_var ) for i , b in enumerate ( base_scalars ) ] d_result = scalar_field . subs ( list ( zip ( base_scalars , d_funcs ) ) ) d_result = d_result . diff ( d_var ) # Second step: e_x(x) -> 1 and e_x(r) -> cos(atan2(x, y)) coords = self . _coord_sys . _dummies d_funcs_deriv = [ f . diff ( d_var ) for f in d_funcs ] d_funcs_deriv_sub = [ ] for b in base_scalars : jac = self . _coord_sys . jacobian ( b . _coord_sys , coords ) d_funcs_deriv_sub . append ( jac [ b . _index , self . _index ] ) d_result = d_result . subs ( list ( zip ( d_funcs_deriv , d_funcs_deriv_sub ) ) ) # Remove the dummies result = d_result . subs ( list ( zip ( d_funcs , base_scalars ) ) ) result = result . subs ( list ( zip ( coords , self . _coord_sys . coord_functions ( ) ) ) ) return result . doit ( )