Trying to plot streamlines and need some help

37 次查看(过去 30 天)
Hey everyone, I'm trying to plot the streamline of a rotating cylinder but when I run my code, I get a weird graph. If anyone can take a look and let me know what I can change, I'll really appraicate it.
clc
clear
close all
syms x y
x_axis = linspace(-1,1,50);
y_axis = linspace(-1,1,50);
[x,y] = meshgrid(x_axis,y_axis)
x = 50×50
-1.0000 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 -0.7551 -0.7143 -0.6735 -0.6327 -0.5918 -0.5510 -0.5102 -0.4694 -0.4286 -0.3878 -0.3469 -0.3061 -0.2653 -0.2245 -0.1837 -0.1429 -0.1020 -0.0612 -0.0204 0.0204 0.0612 0.1020 0.1429 0.1837 -1.0000 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 -0.7551 -0.7143 -0.6735 -0.6327 -0.5918 -0.5510 -0.5102 -0.4694 -0.4286 -0.3878 -0.3469 -0.3061 -0.2653 -0.2245 -0.1837 -0.1429 -0.1020 -0.0612 -0.0204 0.0204 0.0612 0.1020 0.1429 0.1837 -1.0000 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 -0.7551 -0.7143 -0.6735 -0.6327 -0.5918 -0.5510 -0.5102 -0.4694 -0.4286 -0.3878 -0.3469 -0.3061 -0.2653 -0.2245 -0.1837 -0.1429 -0.1020 -0.0612 -0.0204 0.0204 0.0612 0.1020 0.1429 0.1837 -1.0000 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 -0.7551 -0.7143 -0.6735 -0.6327 -0.5918 -0.5510 -0.5102 -0.4694 -0.4286 -0.3878 -0.3469 -0.3061 -0.2653 -0.2245 -0.1837 -0.1429 -0.1020 -0.0612 -0.0204 0.0204 0.0612 0.1020 0.1429 0.1837 -1.0000 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 -0.7551 -0.7143 -0.6735 -0.6327 -0.5918 -0.5510 -0.5102 -0.4694 -0.4286 -0.3878 -0.3469 -0.3061 -0.2653 -0.2245 -0.1837 -0.1429 -0.1020 -0.0612 -0.0204 0.0204 0.0612 0.1020 0.1429 0.1837 -1.0000 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 -0.7551 -0.7143 -0.6735 -0.6327 -0.5918 -0.5510 -0.5102 -0.4694 -0.4286 -0.3878 -0.3469 -0.3061 -0.2653 -0.2245 -0.1837 -0.1429 -0.1020 -0.0612 -0.0204 0.0204 0.0612 0.1020 0.1429 0.1837 -1.0000 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 -0.7551 -0.7143 -0.6735 -0.6327 -0.5918 -0.5510 -0.5102 -0.4694 -0.4286 -0.3878 -0.3469 -0.3061 -0.2653 -0.2245 -0.1837 -0.1429 -0.1020 -0.0612 -0.0204 0.0204 0.0612 0.1020 0.1429 0.1837 -1.0000 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 -0.7551 -0.7143 -0.6735 -0.6327 -0.5918 -0.5510 -0.5102 -0.4694 -0.4286 -0.3878 -0.3469 -0.3061 -0.2653 -0.2245 -0.1837 -0.1429 -0.1020 -0.0612 -0.0204 0.0204 0.0612 0.1020 0.1429 0.1837 -1.0000 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 -0.7551 -0.7143 -0.6735 -0.6327 -0.5918 -0.5510 -0.5102 -0.4694 -0.4286 -0.3878 -0.3469 -0.3061 -0.2653 -0.2245 -0.1837 -0.1429 -0.1020 -0.0612 -0.0204 0.0204 0.0612 0.1020 0.1429 0.1837 -1.0000 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 -0.7551 -0.7143 -0.6735 -0.6327 -0.5918 -0.5510 -0.5102 -0.4694 -0.4286 -0.3878 -0.3469 -0.3061 -0.2653 -0.2245 -0.1837 -0.1429 -0.1020 -0.0612 -0.0204 0.0204 0.0612 0.1020 0.1429 0.1837
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
y = 50×50
-1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -1.0000 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9592 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.9184 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8776 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.8367 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7959 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7551 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.7143 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6735 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327 -0.6327
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% need to convert cartensian to cylinderical%
r = sqrt((x.^2)+(y.^2));
theta = atan2(y./r,x./r);
U_flow = 100
U_flow = 100
a = 10
a = 10
gamma = 100
gamma = 100
velocity_pot = U_flow*r*cos(theta)*(1 + (a.^2./r^2))
velocity_pot = 50×50
1.0e-09 * 0.0280 -0.0413 -0.0239 0.0203 0.0024 0.0189 0.0227 -0.0479 0.0056 -0.0134 0.0093 0.0224 0.0008 0.0036 0.0159 -0.0058 -0.0450 0.0586 0.0414 -0.0923 -0.0306 0.0425 0.0100 -0.0890 -0.0251 -0.0251 -0.0890 0.0100 0.0425 -0.0306 -0.0613 -0.0700 -0.0977 -0.0217 0.0112 0.0129 -0.0763 0.0058 -0.0555 -0.0291 -0.0200 0.0296 0.0133 0.0161 0.0339 -0.0124 -0.0451 -0.0267 -0.0346 -0.1569 -0.0263 -0.0368 0.0032 -0.0360 -0.0205 -0.0205 -0.0360 0.0032 -0.0368 -0.0263 0.0319 -0.0315 -0.0222 0.0043 -0.0098 -0.0365 -0.0148 -0.0503 -0.1100 0.0305 -0.0310 -0.0745 -0.0174 -0.0815 -0.0887 -0.0326 -0.0110 -0.0262 0.0379 -0.0334 -0.0530 -0.0663 -0.0481 -0.0293 -0.0225 -0.0225 -0.0293 -0.0481 -0.0663 -0.0530 -0.0290 -0.0292 0.0309 0.0265 -0.0615 -0.1038 -0.0483 0.0139 -0.0111 0.0121 0.0014 -0.0726 -0.0883 -0.0606 -0.0949 0.0111 0.0328 -0.0126 0.0129 -0.0403 -0.0707 -0.1158 -0.0443 0.0158 -0.0018 -0.0018 0.0158 -0.0443 -0.1158 -0.0707 -0.0042 -0.0372 -0.0376 0.0005 0.0378 -0.1110 -0.0114 -0.0354 -0.0219 -0.0872 -0.0652 -0.0199 -0.0030 0.0194 -0.0102 0.0193 -0.0509 0.0188 -0.0250 0.0599 -0.0519 -0.0803 0.0316 -0.0290 0.0349 0.0349 -0.0290 0.0316 -0.0803 -0.0519 0.0019 0.0192 -0.0653 0.0285 -0.0001 -0.0084 -0.0083 -0.0059 0.0101 -0.0797 -0.0130 -0.0582 -0.0099 -0.0409 -0.0391 -0.0469 -0.0686 -0.0253 0.0146 -0.0351 -0.0128 0.0175 0.0297 -0.0701 0.0029 0.0029 -0.0701 0.0297 0.0175 -0.0128 -0.0176 -0.0353 -0.0442 0.0238 -0.0277 -0.0391 -0.0589 -0.0485 0.0020 -0.0176 -0.0606 0.0316 0.0149 0.0172 0.0114 -0.0133 -0.0337 -0.0064 -0.0289 -0.1340 0.0099 -0.0157 0.0334 -0.0140 0.0357 0.0357 -0.0140 0.0334 -0.0157 0.0099 -0.0177 -0.0214 -0.0036 -0.0045 -0.0068 -0.0067 0.0052 0.0059 -0.0112 0.0356 -0.0032 -0.0152 -0.0243 0.0085 0.0262 0.0023 0.0114 0.0430 -0.0541 -0.0065 -0.0501 0.0041 -0.0450 -0.0182 0.0107 0.0107 -0.0182 -0.0450 0.0041 -0.0501 -0.0044 -0.0579 -0.0009 -0.0486 0.0008 -0.0290 -0.0196 -0.0329 -0.0734 0.0006 -0.0418 -0.0315 -0.0459 0.0059 -0.0257 -0.0242 0.0052 -0.0283 -0.0098 -0.0731 -0.0738 -0.0698 -0.0282 -0.0214 0.0410 0.0410 -0.0214 -0.0282 -0.0698 -0.0738 -0.0322 -0.0132 -0.0206 -0.0461 -0.0419 -0.0053 0.0113 -0.0406 -0.0292 -0.0050 -0.0335 -0.0864 -0.0201 -0.0274 -0.0199 0.0400 -0.1165 -0.0049 -0.0042 -0.0413 -0.0027 -0.0145 -0.0297 -0.0782 0.0004 0.0004 -0.0782 -0.0297 -0.0145 -0.0027
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
u_r = (1 - r.^-2)*cos(theta)
u_r = 50×50
-8.8938 -8.7690 -8.6343 -8.4886 -8.3310 -8.1604 -7.9756 -7.7752 -7.5577 -7.3217 -7.0655 -6.7872 -6.4850 -6.1569 -5.8009 -5.4148 -4.9967 -4.5445 -4.0565 -3.5312 -2.9678 -2.3662 -1.7277 -1.0554 -0.3560 0.3560 1.0554 1.7277 2.3662 2.9678 -6.3996 -6.2897 -6.1713 -6.0437 -5.9058 -5.7570 -5.5962 -5.4225 -5.2347 -5.0316 -4.8123 -4.5754 -4.3198 -4.0443 -3.7480 -3.4302 -3.0903 -2.7286 -2.3459 -1.9445 -1.5285 -1.1053 -0.6880 -0.3020 -0.0152 0.0152 0.3020 0.6880 1.1053 1.5285 -3.6358 -3.5421 -3.4414 -3.3332 -3.2167 -3.0915 -2.9568 -2.8120 -2.6563 -2.4891 -2.3099 -2.1180 -1.9131 -1.6951 -1.4641 -1.2209 -0.9668 -0.7043 -0.4374 -0.1724 0.0808 0.3064 0.4777 0.5444 0.3688 -0.3688 -0.5444 -0.4777 -0.3064 -0.0808 -0.5622 -0.4860 -0.4045 -0.3173 -0.2241 -0.1245 -0.0181 0.0954 0.2161 0.3443 0.4798 0.6226 0.7721 0.9274 1.0869 1.2483 1.4083 1.5616 1.7008 1.8150 1.8878 1.8938 1.7907 1.4999 0.8037 -0.8037 -1.4999 -1.7907 -1.8938 -1.8878 2.8694 2.9266 2.9872 3.0516 3.1196 3.1915 3.2671 3.3464 3.4291 3.5147 3.6026 3.6918 3.7807 3.8672 3.9483 4.0199 4.0762 4.1091 4.1072 4.0543 3.9265 3.6874 3.2772 2.5841 1.2988 -1.2988 -2.5841 -3.2772 -3.6874 -3.9265 6.7170 6.7536 6.7917 6.8312 6.8719 6.9135 6.9556 6.9977 7.0388 7.0781 7.1139 7.1444 7.1669 7.1780 7.1729 7.1456 7.0874 6.9871 6.8287 6.5898 6.2383 5.7248 4.9691 3.8214 1.8658 -1.8658 -3.8214 -4.9691 -5.7248 -6.2383 11.0515 11.0658 11.0793 11.0918 11.1027 11.1114 11.1170 11.1184 11.1142 11.1027 11.0815 11.0476 10.9972 10.9253 10.8253 10.6887 10.5039 10.2558 9.9232 9.4769 8.8746 8.0525 6.9064 5.2422 2.5196 -2.5196 -5.2422 -6.9064 -8.0525 -8.8746 15.9601 15.9500 15.9368 15.9199 15.8984 15.8711 15.8368 15.7938 15.7400 15.6729 15.5891 15.4845 15.3539 15.1905 14.9856 14.7279 14.4026 13.9899 13.4628 12.7840 11.8998 10.7289 9.1395 6.8850 3.2790 -3.2790 -6.8850 -9.1395 -10.7289 -11.8998 21.5510 21.5144 21.4721 21.4231 21.3661 21.2996 21.2217 21.1300 21.0219 20.8937 20.7411 20.5586 20.3395 20.0750 19.7539 19.3618 18.8800 18.2835 17.5385 16.5981 15.3951 13.8282 11.7324 8.7991 4.1681 -4.1681 -8.7991 -11.7324 -13.8282 -15.3951 27.9605 27.8950 27.8210 27.7369 27.6412 27.5317 27.4060 27.2611 27.0932 26.8978 26.6695 26.4011 26.0841 25.7074 25.2572 24.7155 24.0589 23.2563 22.2660 21.0299 19.4650 17.4458 14.7679 11.0486 5.2186 -5.2186 -11.0486 -14.7679 -17.4458 -19.4650
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
u_o = - (1 + r.^-2)*sin(theta)
u_o = 50×50
1.0e-13 * 0.0050 -0.0172 0.0056 0.0078 -0.0178 0.0200 -0.0028 0.0316 -0.0078 0.0205 -0.0117 -0.0056 -0.0094 -0.0211 0.0250 0.0205 -0.0105 -0.0444 0.0006 0.0039 0.0094 0.0322 -0.0239 0.0583 0.0411 0.0411 0.0561 -0.0239 0.0322 0.0094 0.0141 0.0133 -0.0178 -0.0200 -0.0073 0.0016 -0.0008 0.0046 -0.0234 -0.0110 -0.0021 0.0209 -0.0157 -0.0186 0.0151 0.0007 -0.0220 -0.0133 0.0079 -0.0097 -0.0136 0.0148 0.0005 0.0029 -0.0310 -0.0310 0.0006 0.0005 -0.0208 -0.0136 0.0054 0.0227 0.0032 -0.0147 0.0040 0.0217 0.0005 -0.0028 0.0091 -0.0229 0.0278 0.0207 0.0063 0.0001 0.0088 -0.0111 -0.0482 -0.0278 0.0483 -0.0014 -0.0497 0.0155 -0.0017 0.0067 0.0208 -0.0147 0.0044 -0.0017 0.0155 -0.0497 -0.0095 0.0033 0.0146 -0.0272 -0.0124 -0.0145 -0.0133 -0.0024 -0.0167 0.0125 -0.0014 0.0115 -0.0073 0.0006 -0.0082 -0.0464 0.0143 0.0407 -0.0172 -0.0356 0.0089 0.0297 -0.0191 -0.0542 0.0387 0.0387 0.0146 -0.0191 0.0297 -0.0266 -0.0032 -0.0022 -0.0035 0.0136 0.0020 0.0187 0.0017 -0.0191 0.0185 -0.0007 0.0189 0.0111 0.0137 -0.0138 0.0114 -0.0307 -0.0058 -0.0128 0.0022 -0.0375 0.0239 0.0016 -0.0133 -0.0010 -0.0141 -0.0141 -0.0032 -0.0133 0.0016 0.0239 0.0203 -0.0046 0.0283 -0.0026 0.0047 0.0195 0.0043 -0.0050 -0.0026 -0.0267 0.0134 0.0067 0.0085 0.0146 0.0088 -0.0441 -0.0067 -0.0013 0.0624 -0.0493 -0.0650 -0.0436 0.0141 0.0076 -0.0012 -0.0012 0.0054 0.0141 -0.0436 -0.0650 0.0300 0.0011 0.0084 -0.0067 -0.0031 -0.0211 -0.0169 -0.0283 0.0296 -0.0191 0.0128 0.0231 -0.0034 0.0571 0.0025 0.0453 -0.0293 0.0114 -0.0266 -0.0444 -0.0160 0.0393 -0.0370 0.0175 0.0120 -0.0236 0.0152 -0.0370 -0.0317 0.0195 0.0035 0.0009 0.0170 -0.0001 -0.0011 0.0179 -0.0036 0.0061 0.0076 0.0089 0.0025 -0.0130 0.0415 0.0524 -0.0202 -0.0548 0.0447 0.0057 0.0128 0.0289 -0.0278 -0.0160 -0.0573 0.0135 0.0024 0.0024 0.0112 -0.0573 0.0373 -0.0278 0.0196 0.0018 0.0295 -0.0136 0.0135 0.0063 -0.0117 -0.0147 -0.0106 0.0261 0.0401 0.0016 0.0103 -0.0214 0.0587 -0.0468 0.0208 -0.0187 0.0418 0.0118 0.0142 -0.0081 -0.0457 -0.0315 -0.0321 0.0390 -0.0337 -0.0457 -0.0081 0.0142 -0.0192 0.0074 -0.0072 0.0274 0.0143 -0.0000 0.0323 -0.0304 -0.0283 -0.0066 0.0019 0.0042 -0.0127 -0.0433 -0.0406 -0.0123 -0.0205 -0.0232 -0.0312 0.0037 -0.0214 0.0099 0.0571 -0.0219 -0.0217 -0.0217 -0.0219 0.0571 -0.0256 -0.0392
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
%u = diff(Velocity_pot,x);
%v = diff(Velocity_pot,y);
figure(1)
quiver(x,y,u_r,u_o)
% figure(2)
% contour(x,y,velocity_pot,[-1:1:6])

回答(2 个)

Umar
Umar 2024-10-20
编辑:Torsten 2024-10-20
Hi @Britney,
To address your query regarding plotting the streamlines of a rotating cylinder, let me first analyze the context and the issues you're facing. It appears that you are trying to visualize the flow field around a rotating cylinder but are encountering unexpected results in your graph. The main components of your code involve defining a grid, calculating velocities in cylindrical coordinates, and plotting with quiver. The key themes are listed below.
_Flow Field Calculation:_ You are using cylindrical coordinates to model the flow around a rotating cylinder.
_Visualization:_ The quiver function is being used for vector field visualization, which may not be yielding the expected results due to the nature of your velocity calculations or grid definitions. Here is an updated version of your code with detailed explanations and corrections:
clc;
clear;
close all;
% Define the grid for the x and y coordinates
x_axis = linspace(-1, 1, 50);
y_axis = linspace(-1, 1, 50);
[x, y] = meshgrid(x_axis, y_axis);
% Convert Cartesian to Polar Coordinates
r = sqrt(x.^2 + y.^2); % Radial distance
theta = atan2(y, x); % Angle
% Flow parameters
U_flow = 100; % Flow velocity
a = 10; % Parameter related to the cylinder
gamma = 100; % Circulation strength
% Calculate velocity potential
velocity_pot = U_flow * r .* cos(theta) .* (1 + (a^2 ./ r.^2));
%Calculate radial and angular components of velocity
u_r = (1 - r.^-2) .* cos(theta);
u_o = -(1 + r.^-2) .* sin(theta);
% Plotting the vector field using quiver
figure(1);
quiver(x, y, u_r, u_o);
axis equal; % Equal scaling for x and y axes
title('Velocity Field Around a Rotating Cylinder');
xlabel('X-axis');
ylabel('Y-axis');
grid on;
% Optional: Add streamlines for better visualization
hold on;
streamline(x, y, u_r, u_o, x(1:5:end), y(1:5:end)); % Adjust for streamline
density
Unrecognized function or variable 'density'.
hold off;
Let me explain the changes made in the code below.
_Grid Definition:_ Ensure that x and y meshgrid creation is correct.
_Cylindrical Conversion:_ The conversion from Cartesian to cylindrical coordinates is maintained correctly.
_Velocity Components:_ Ensure that you are correctly defining the radial (u_r) and angular (u_o) components based on the physical model you want to represent.
_Quiver Plot:_ Used quiver to plot the velocity vectors while ensuring equal axis scaling for proper representation.
_Streamlines:_ Added optional streamlines using streamline function for visual clarity. For more information on this function, please refer to
<https://www.mathworks.com/help/matlab/ref/streamline.html>
Please see attached.
<</matlabcentral/answers/uploaded_files/1796030/IMG_8165.jpeg>>
You might want to experiment with different values for U_flow, a, and gamma to see how they affect the flow field. Also, increasing the resolution of your meshgrid can lead to smoother visualizations.
This structured approach should help clarify your visualizations and provide you with a clearer representation of the flow around a rotating cylinder.
If you have further issues or specific outputs that still appear incorrect, please provide additional details so we can refine our approach.

Divyajyoti Nayak
Divyajyoti Nayak 2024-10-20
编辑:Divyajyoti Nayak 2024-10-20
I am assuming that you're trying to plot the streamlines of the potential flow around a cylinder of radius "a". To do so, the "streamline" function can be used, Here's the documentation for the same:
To use the "streamline" function, the radial and tangential velocity need to be converted to velocity in x and y direction. Before that, there are some corrections to be made in calculation of radial and tangential velocity. The radius of the cylinder, "a" is 10 which is bigger than the grid created. The cylinder radius should be some value less than 1, such as 0.3, and needs to be in the calculation of velocities. Moreover, the radial and tangential velocities are being calculated using matrix multiplication with "sin(theta)" and "cos(theta)", when they should be multiplied element wise. Also ideally, the flow velocity should also be multiplied. Here's the corrected code implementing all these fixes:
a = 0.3;
gamma = 100;
velocity_pot = U_flow*r.*cos(theta).*(1 + (a.^2./r^2));
u_r = U_flow.*(1 - (a./r).^2).*cos(theta);
u_o = -1*U_flow.*(1 + (a./r).^2).*sin(theta);
Now here's the code to convert the velocities from polar to cartesian form:
u_x = u_r.*cos(theta) - u_o.*sin(theta);
u_y = u_r.*sin(theta) + u_o.*cos(theta);
Lastly, to plot the streamlines, the "streamline" function can be used:
figure(1)
start_x = x(:,1); %X values of streamline starting point
start_y = y(:,1); %Y values of streamline starting point
streamline(x,y,u_x,u_y,start_x,start_y);
axis equal
Here's the final plot:
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Vector Fields 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by