2
$\begingroup$

I have a vector

$\boldsymbol{u}(x,y) = \begin{bmatrix} u_x(x,y) \\ u_y(x,y) \\ \end{bmatrix}.$

I would like to get

$\boldsymbol{\sigma}(x,y) = \begin{bmatrix} \sigma_x \\ \sigma_y \\ \tau_{xy} \end{bmatrix} = \begin{bmatrix} \frac{\partial\:\! u_x}{\partial\:\! x} \\ \frac{\partial\:\! u_y}{\partial\:\! y} \\ \frac{\partial\:\! u_x}{\partial\:\! y} + \frac{\partial\:\! u_y}{\partial\:\! x} \end{bmatrix} = \begin{bmatrix} \frac{\partial}{\partial\:\! x} & 0 \\ 0 & \frac{\partial}{\partial\:\! y} \\ \frac{\partial}{\partial\:\! y} & \frac{\partial}{\partial\:\! x} \end{bmatrix} \boldsymbol{u}\,.$

I have to write a slightly lengthy and repetitive code:

σ[u_] :=
{
  { D[u[[1]], x] } ,
  { D[u[[2]], y] } ,
  { D[u[[1]], y] + D[u[[2]], x] }
};

Is there are more concise way to achieve this?

$\endgroup$
1
  • $\begingroup$ With[{ux = D[u[[1]], x], uy = D[u[[2]], y]}, {{ux}, {uy}, {ux + uy}}]? $\endgroup$
    – Michael E2
    Nov 25 '19 at 0:48
3
$\begingroup$

Do you actually need to have a tensor rank of 2? this gives you a rank 1enter image description here

$\endgroup$
0
$\begingroup$
U = {ux[x, y], uy[x, y]};
Append[Diagonal@Grad[U, {x, y}], Curl[{-1, 1} U, {x, y}]]

{(ux^(1,0))[x,y],(uy^(0,1))[x,y],(ux^(0,1))[x,y]+(uy^(1,0))[x,y]}

$\endgroup$

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.