2
$\begingroup$

I am programming viscous terms of compressible Navier-Stokes equations

U = {u[t, x, y, z], v[t, x, y, z], w[t, x, y, z]};
a = Div[\[Mu][x, y, z]*(Grad[U, {x, y, z}] + Transpose[Grad[U, {x, y, z}]]), {x, y, z}];

Now, I want to prevent Mathematica from expanding the product rule. In other words I want to have

a = {d/dx( ... ) + d/dy( ... ) + d/dz( ... ), 
d/dx( ... ) + d/dy( ... ) + d/dz( ... ), 
d/dx( ... ) + d/dy( ... ) + d/dz( ... )}

Can you help me out with that? Thanks in advance!

$\endgroup$
1
  • $\begingroup$ use a new name e.g. "ddx" $\endgroup$ Sep 22, 2022 at 16:47

1 Answer 1

4
$\begingroup$

You can use Inactive[Div] instead of Div. When you are ready to evaluate the differentiations, use the substitution /.Inactive[x_]->x.

$\endgroup$
1
  • 6
    $\begingroup$ You could also use Activate instead of a replacement rule to get rid of the Inactive wrappers $\endgroup$
    – Lukas Lang
    Sep 22, 2022 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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