Hi.

I don't know the answer to your question, as I am not familiar enough
with the vector or tensor modules, but if you don't get an answer here
I would suggest opening an issue about this on the issue tracker.

Aaron Meurer

On Fri, Apr 24, 2020 at 12:44 PM Alexander Lindsay
<alexlindsay...@gmail.com> wrote:
>
> I've been using the capabilities in sympy.vector for generating MMS solutions 
> for verifying FEM in MOOSE. I'm curious whether sympy supports calculation of 
> the gradient of a vector field (e.g. with the result being a tensor)? It 
> doesn't appear to me that it does, but I'm hoping I overlooked something. 
> Below is the sample code I'd like to be able to execute and the corresponding 
> backtrace. If the ability to take the gradient of a vector doesn't exist, I'm 
> curious whether it would be difficult to add? If it's not too much 
> anticipated work, I'd be willing to take a stab at it.
>
> from sympy.vector import gradient, CoordSys3D
> R = CoordSys3D('R')
> u = R.x*R.y * (R.i + R.j)
> gradient(u)
>
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
> <ipython-input-49-c095794df196> in <module>
>       5 u = R.x*R.y * (R.i + R.j)
>       6
> ----> 7 gradient(u)
>
> ~/miniconda3/envs/moose-boost/lib/python3.7/site-packages/sympy/vector/operators.py
>  in gradient(scalar_field, coord_sys, doit)
>     317
>     318         if doit:
> --> 319             return (vx * i + vy * j + vz * k).doit()
>     320         return vx * i + vy * j + vz * k
>     321     else:
>
> ~/miniconda3/envs/moose-boost/lib/python3.7/site-packages/sympy/vector/basisdependent.py
>  in doit(self, **hints)
>     169         """Calls .doit() on each term in the Dyadic"""
>     170         doit_components = [self.components[x].doit(**hints) * x
> --> 171                            for x in self.components]
>     172         return self._add_func(*doit_components)
>     173
>
> ~/miniconda3/envs/moose-boost/lib/python3.7/site-packages/sympy/vector/basisdependent.py
>  in <listcomp>(.0)
>     169         """Calls .doit() on each term in the Dyadic"""
>     170         doit_components = [self.components[x].doit(**hints) * x
> --> 171                            for x in self.components]
>     172         return self._add_func(*doit_components)
>     173
>
> ~/miniconda3/envs/moose-boost/lib/python3.7/site-packages/sympy/core/decorators.py
>  in __sympifyit_wrapper(a, b)
>      89                 if not hasattr(b, '_op_priority'):
>      90                     b = sympify(b, strict=True)
> ---> 91                 return func(a, b)
>      92             except SympifyError:
>      93                 return retval
>
> ~/miniconda3/envs/moose-boost/lib/python3.7/site-packages/sympy/core/decorators.py
>  in binary_op_wrapper(self, other)
>     127                     if f is not None:
>     128                         return f(self)
> --> 129             return func(self, other)
>     130         return binary_op_wrapper
>     131     return priority_decorator
>
> ~/miniconda3/envs/moose-boost/lib/python3.7/site-packages/sympy/vector/basisdependent.py
>  in __mul__(self, other)
>      34     @call_highest_priority('__rmul__')
>      35     def __mul__(self, other):
> ---> 36         return self._mul_func(self, other)
>      37
>      38     @_sympifyit('other', NotImplemented)
>
> ~/miniconda3/envs/moose-boost/lib/python3.7/site-packages/sympy/vector/vector.py
>  in __new__(cls, *args, **options)
>     412
>     413     def __new__(cls, *args, **options):
> --> 414         obj = BasisDependentMul.__new__(cls, *args, **options)
>     415         return obj
>     416
>
> ~/miniconda3/envs/moose-boost/lib/python3.7/site-packages/sympy/vector/basisdependent.py
>  in __new__(cls, *args, **options)
>     257         # Make sure incompatible types weren't multiplied
>     258         if count > 1:
> --> 259             raise ValueError("Invalid multiplication")
>     260         elif count == 0:
>     261             return Mul(*args, **options)
>
> ValueError: Invalid multiplication
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/29c041d5-1bab-4d54-9bea-fe5ba0d4a02a%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6L%3D9CgJ9LonakqV3SkzeyCBqt%2BZ4G26aA14Dpi0MbyM2g%40mail.gmail.com.

Reply via email to