How do I plot Streamlines of velocity components of spherical coordinate system?

조회 수: 33 (최근 30일)
I solved Navier stokes in Spherical coordinates and I got velocity field inside a sphere i.e
If I plot contours using the code below its working. But, The same technique is not working for streamlines, instead I'm getting blank.
The streamlines are look like this
nr = 21;
nth = 21;
L = 1;
r = linspace(0,1,nr);
th = linspace(0,pi,nth);
[R,Th] = meshgrid(r,th);
Xi = R.*cos(Th); Yi = R.*sin(Th);
ui = (R.^2-1)/2/(L+1).*cos(Th);
vi = (1-2*R.^2)/2/(L+1).*sin(Th);
figure;contourf(Xi,Yi,ui,100,'LineStyle','none');axis image
figure;contourf(Xi,Yi,vi,100,'LineStyle','none');axis image
figure;streamline(Xi,Yi,ui,vi)
I'm getting streamlines as empty, can anyone help me in this regard?
Thanks in advance.

채택된 답변

VBBV
VBBV 2022년 12월 13일
verts = stream2(Xi,Yi,ui,vi,R,Th);
streamline(verts);
  댓글 수: 5
VBBV
VBBV 2022년 12월 15일
Ok, it seems your equations are in spherical coordinates, so use sph2cart function
clc
clear all
close all
nr = 21;
nth = 21;
L = 1;
r =linspace(-1,1,nr);
th =linspace(0,pi,nth);
[R,Th] = meshgrid(r,th);
[x y z] = sph2cart(cos(Th),sin(Th),R);
Xi = (R).*cos(Th);
Yi = R.*sin(Th);
ui = ((R.^2-1)/(2*(L+1))).*cos(Th);
vi = ((1-2*R.^2)/(2*(L+1))).*sin(Th);
% figure;contourf(Xi,Yi,ui,100,'LineStyle','none');axis image
% figure;contourf(Xi,Yi,vi,100,'LineStyle','none');axis image
streamslice(x,y,ui,vi);
Jagadeesh Korukonda
Jagadeesh Korukonda 2022년 12월 15일
Thank you @VBBV
I've made small modification to your code. now its working fine. since my r-domian is [0 1] only.
clc
clear all
close all
nr = 5;
nth = 5;
L = 1;
r =linspace(0,1,nr);
th =linspace(0,pi,nth);
[R,Th] = meshgrid(r,th);
[x y z] = sph2cart(cos(Th),sin(Th),R);
Xi = (R).*cos(Th);
Yi = R.*sin(Th);
ui = ((R.^2-1)/(2*(L+1))).*cos(Th);
vi = ((1-2*R.^2)/(2*(L+1))).*sin(Th);
UI = [fliplr(ui(:,2:end)) ui];
VI = [fliplr(vi(:,2:end)) vi];
X1 = [fliplr(-x(:,2:end)) x];
Y1 = [fliplr(-y(:,2:end)) y];
streamslice(X1,Y1,UI,VI); axis image

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by