The Navier-Stokes equation contains term

$\vec{u} \cdot \nabla \vec{u}$

which should be equal to

$\nabla \cdot \left(\vec{u}\vec{u} \right)$


$\nabla \cdot \vec{u}=0$.

However this computation gives me different results for these two

In[70]:= u = {2*x^2*(x-1)^2*y*(2*y-1)*(y-1), -2*x*(x-1)*(2x-1)*y^2*(y-1)^2}
Out[70]= {2 (-1+x)^2 x^2 (-1+y) y (-1+2 y),-2 (-1+x) x (-1+2 x) (-1+y)^2 y^2}
In[72]:= div = Div[u, {x, y}, "Cartesian"] // Simplify
Out[72]= 0
In[73]:= adv = u.Grad[u, {x, y}, "Cartesian"] //Simplify
Out[73]= {4 (-1+x) x (-1+2 x) (-1+y)^2 y^2 (2 (-1+x)^2 x^2 (1-2 y)^2+(1-6 x+6 x^2) (-1+y)^2 y^2),4 (-1+x)^2 x^2 (-1+y) y (-1+2 y) (2 (1-2 x)^2 (-1+y)^2 y^2+(-1+x)^2 x^2 (1-6 y+6 y^2))}
In[74]:= adv2=Div[TensorProduct[u,u], {x, y}, "Cartesian"] //Simplify
Out[74]= {4 (-1+x)^3 x^3 (-1+2 x) (-1+y)^2 y^2 (1-2 y+2 y^2),4 (-1+x)^2 x^2 (1-2 x+2 x^2) (-1+y)^3 y^3 (-1+2 y)}
In[75]:= dadv = adv-adv2 //Simplify
Out[75]= {4 (-1+x) x (-1+2 x) (-1+y)^2 y^2 (2 (-1+x)^2 x^2 (1-2 y)^2+(1-6 x+6 x^2) (-1+y)^2 y^2-(-1+x)^2 x^2 (1-2 y+2 y^2)),4 (-1+x)^2 x^2 (-1+y) y (-1+2 y) (2 (1-2 x)^2 (-1+y)^2 y^2-(1-2 x+2 x^2) (-1+y)^2 y^2+(-1+x)^2 x^2 (1-6 y+6 y^2))}

I would expect the difference of the two to be 0. Why is that?

  • $\begingroup$ Is the output of TensorProduct[{x, y, z}, {x, y, z}] what you were expecting it to be? $\endgroup$ – J. M. will be back soon Oct 26 '17 at 13:24
  • $\begingroup$ Indeed, it seems to be. It agrees with the numerical computation. $\endgroup$ – Vladimir F Oct 26 '17 at 13:33

I've previously found that Mathematica's arrangement of Grad's output doesn't always agree with fluid mechanics conventions: try transposing it. In general for three dimensions:

gradu=Transpose[Grad[u,{x,y,z}]]; (* note the Transpose *)

FullSimplify[u.gradu - Div[uu,{x,y,z}], divu == 0]

This will return {0,0,0}, as expected.

And in two dimensions, as in the question:

u = {ux[x, y], uy[x, y]};
gradu = Transpose[Grad[u, {x, y}]]; (* note the Transpose *)
uu = TensorProduct[u, u];
divu = Div[u, {x, y}];

FullSimplify[u.gradu - Div[uu, {x, y}], divu == 0]

For all $\vec{u}$ where $\nabla\cdot \vec{u}=0$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.