# How do I fix tensor integration?

**URL:** <https://fenicsproject.discourse.group/t/how-do-i-fix-tensor-integration/10851>\
**Category:** General\
**Created:** [April 4, 2023, 9:56pm UTC](https://fenicsproject.discourse.group/t/how-do-i-fix-tensor-integration/10851 "2023-04-04T21:56:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bernard](https://avatars.discourse-cdn.com/v4/letter/b/df705f/32.png) [@Bernard](https://fenicsproject.discourse.group/u/Bernard)\
**Post date:** [April 4, 2023, 9:56pm UTC](https://fenicsproject.discourse.group/t/how-do-i-fix-tensor-integration/10851/1 "2023-04-04T21:56:44Z")

</div>

Here the D=D(x,y) is a variable diffusion coefficient. I have tried both inner product and dot product but getting the same problem. Can some help me with a suggestion to fix this problem?

Can only integrate scalar expressions. The integrand is a tensor expression with value shape (5,) and free indices with labels ().  
Traceback (most recent call last):  
File “SEIRD\_var.py”, line 137, in   
beta\_e / n \* s \* e, vs) \* dx + D\*dot(n \* grad(s), grad(vs)) \* dx  
File “/usr/local/lib/python3.6/dist-packages/ufl/measure.py”, line 420, in **rmul**  
(integrand.ufl\_shape, integrand.ufl\_free\_indices))  
File “/usr/local/lib/python3.6/dist-packages/ufl/log.py”, line 172, in error  
raise self.\_exception\_type(self.\_format\_raw(\*message))  
ufl.log.UFLException: Can only integrate scalar expressions. The integrand is a tensor expression with value shape (5,) and free indices with labels ().

---

<div class="post-metadata">

**Author:** ![Karlosjusus](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karlosjusus](https://fenicsproject.discourse.group/u/Karlosjusus)\
**Post date:** [April 4, 2023, 10:32pm UTC](https://fenicsproject.discourse.group/t/how-do-i-fix-tensor-integration/10851/2 "2023-04-04T22:32:43Z")

</div>

You can integrate only scalar, I think. If you want integrate a tensor, you need integrate each coordinate.
