• API
• FAQ
• Tools
• Archive
SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. clearvars
2. close all
3.
4. OP = [.25 .25 7 7,];
5.
6. xmin = -5;
7. xmax = 5;
8. ymin = -5;
9. ymax = 5;
10. spacing = 0.01;
11.
12. %Define value for vortices and cross flow
13. Gamma1 = -20;
14. Gamma2 = 8;
15.
16. U = 5;
17. a = 0;
18.
19. x = (xmin:spacing:xmax);
20. y = (ymin:spacing:ymax);
21.
22. xsize = numel(x);
23. ysize = numel(y);
24.
25. [x,y] = meshgrid(x,y);
26.
27. %time step
28. ts = 0.00001;
29. dur = 0;
30.
31. %Vortex center location
32. yc1 = -1;
33. xc1= -1;
34. yc2 = 1;
35. xc2 = 1;
36.
37.
38. r1 = sqrt(((x-xc1).^2)+((y-yc1).^2));
39. r2 = sqrt(((x-xc2).^2)+((y-yc2).^2));
40.
41. %Psi defined for vortices and cross flow
42. Psi1= (Gamma1*log(r1)./(2*pi));
43.
44. Psi2 = Gamma2*log(r2)./(2*pi);
45.
46. Psi3 = U*((-sind(a).*x) + (cosd(a).*y));
47.
48. xloc1 = zeros(1,xsize); %x location of vortex 1
49. yloc1 = zeros(1,ysize); %y location of vortex 1
50.
51. xloc2 = zeros(1,xsize); %x location of vortex 2
52. yloc2 = zeros(1,ysize); %y location of vortex 2
53.
54.
55.
56. u1 = zeros(ysize,xsize);
57. v1 = zeros(ysize,xsize);
58.
59. dPsidy1 = zeros(ysize,xsize);
60. dPsidx1 = zeros(ysize,xsize);
61.
62. for i = 2:(ysize-1)
63.     for j = 2:xsize-1
64.         %The y value changes as you increase the row (so i)
65.         %Essentially this is delta y over delta x
66.         dPsidy1(i,j) = (Psi1(i+1,j) - Psi1(i-1,j) )/ (2*spacing);
67.         dPsidx1(i,j) = (Psi1(i,j+1) - Psi1(i,j-1)) / (2*spacing);
68.     end
69. end
70.
71. dPsidy2 = zeros(ysize,xsize);
72. dPsidx2 = zeros(ysize,xsize);
73.
74. for i = 2:(ysize-1)
75.     for j = 2:xsize-1
76.         %The y value changes as you increase the row (so i)
77.         %Essentially this is delta y over delta x
78.         dPsidy2(i,j) = (Psi2(i+1,j) - Psi2(i-1,j) )/ (2*spacing);
79.         dPsidx2(i,j) = (Psi2(i,j+1) - Psi2(i,j-1)) / (2*spacing);
80.     end
81. end
82.
83. u1 = dPsidy1;   %matrix of x velocity
84. v1 = -1* dPsidx1; %matrix of y velocity
85.
86. u1(u1>1000000) = 0;
87. u1(u1<-1000000) = 0;
88. v1(v1>1000000) = 0;
89. v1(v1<-1000000) = 0;
90.
91. for n1 = 1:(ysize)
92.     for m1 = 1:(xsize)
93.         xc2 = xc2 + (u1(n1, m1).*ts);
94.         yc2 = yc2 + (v1(n1, m1).*ts);
95.     end
96. end
97. %totalv = (u.^2 + v.^2).^.5;
98.
99. %hold on
100. %contourf(x,y,Psi, 1000, 'LineStyle', 'none');
101. %colormap
102. %colorbar
103. %h = colorbar;
104. %title(h, '\psi')
105. %hold on;
106.
107.
108. %ph = streamslice(x,y,u1,v1);
109.
110. %set(ph,'color','k');
111.
112. %axis([xmin xmax ymin ymax]);
113. %set(gcf,'Units','inches','OuterPosition',OP);
114.
115. %title('Streamlines for vortices');
116. %xlabel('x location');
117. %ylabel('y location');
118. %hold off
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top