Effacer les filtres
Effacer les filtres

How to calculate the gradient of 3D velocity

28 vues (au cours des 30 derniers jours)
Xinchen Zhang
Xinchen Zhang le 21 Août 2020
Let's say the "wind.mat" in matlab. I was supposed to get 9 tensors of the velocity gradients, du/dx, du/dy, du/dz, dv/dx, dv/dy, dv/dz, dw/dx, dw/dy, dw/dz.
I calculate following dudx=gradient(u)./gradient(x), dudy=gradient(u)./gradient(y) ...
but the gradient(y)=0 and gradient(z)=0 for this equally-spaced mat, results in a infinity value in the du/dy tensor.
Anyone can help me to correct the script for the gradient calculation?
  1 commentaire
KSSV
KSSV le 21 Août 2020
Read the documentation properly......if you provide an array, you will get all the components at once.

Connectez-vous pour commenter.

Réponse acceptée

Bjorn Gustavsson
Bjorn Gustavsson le 21 Août 2020
Unfortunately you will have to do something like this:
[dudx,dudy,dudz] = gradient(u,squeeze(x(1,:,1)),squeeze(y(:,1,1)),squeeze(z(1,1,:)));
If you want the gradients of the wind-vector components in wind.mat.
Two additional points to mention about gradient:
1, it does not give a properly centred difference approximation to the gradient for cases where the coordinates are not varying linearly. It just uses a naive centred difference-scheme.
2, the above obviously requires the grid to be plaid.
HTH

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by