Solve MATLAB Source Potential Flow Issues

In summary, the conversation is about someone seeking help with plotting streamlines of a source flow in MATLAB. They are facing issues with the streamlines not changing when they adjust the strength and some code not working. They are asking for assistance in checking their code.
  • #1
physicsCU
202
1
Hey all:

I am trying to plot the streamlines of a source flow in MATLAB. I just have a couple issues. First, when I change the strength, it doesn't appear that the streamlines change at all. Second, the three lines commented out below, I used them from an example, but now they don't work.

If someone could give me a hand checking this code, that would be great.

Code:

clear all
close all
clc

nx = 100; xmin = -2; xmax = 2;
ny = 100; ymin = -2; ymax = 2;
[x y] = meshgrid(linspace(xmin,xmax,nx),linspace(ymin,ymax,ny));
M = 8; xM = 0; yM = 0;
PsiM = (M/(2*pi))*atan2(y - yM,x - xM);
% levmin = PsiM(1,nx);
% levmax = PsiM(ny,nx/2);
% levels = linspace(levmin,levmax,50);
contour(x,y,PsiM,100)
axis([xmin xmax ymin ymax])
xlabel('x'), ylabel('y')
title('Source of Strength M = 4')
 
Physics news on Phys.org
  • #2
Can anyone help me?
 
  • #3


Hi there,

I can see a few potential issues with your code that may be causing the problems you mentioned. Here are a few suggestions to help you solve them:

1. Make sure you are updating the strength (M) variable in your code before running it again. If you are not changing the strength, the streamlines will not change either.

2. Check the syntax for the atan2 function. It should be atan2(y-yM,x-xM), not atan2(y,x). Also, make sure the xM and yM values are updated to the coordinates of your source.

3. The commented lines that set the contour levels may be causing issues because they are not being used in the code. Try removing them and seeing if that makes a difference.

4. Check the axis limits you have set for your plot. Make sure they are wide enough to capture the streamlines.

I hope these suggestions help you solve the issues you are facing. If you need further assistance, feel free to reach out with specific error messages or screenshots of your plot. Good luck!
 

Related to Solve MATLAB Source Potential Flow Issues

1. What is the purpose of using MATLAB for solving potential flow issues?

MATLAB is a powerful computational tool that allows scientists and engineers to solve complex problems related to potential flow. It provides a user-friendly interface and a wide range of built-in functions and algorithms that make it easier to analyze and solve potential flow problems.

2. How does MATLAB solve potential flow issues?

MATLAB uses numerical methods and algorithms to solve potential flow problems. It breaks down the problem into smaller, more manageable steps and uses iterative processes to find a solution. It also allows for the visualization of the flow patterns and can handle both two-dimensional and three-dimensional problems.

3. Can MATLAB handle complex potential flow problems?

Yes, MATLAB has the capability to handle complex potential flow problems. It has a variety of built-in functions and toolboxes that can be used to model and solve complex flow situations, such as those involving multiple bodies, variable boundary conditions, and non-linear effects.

4. How accurate are the solutions obtained through MATLAB for potential flow problems?

The accuracy of the solutions obtained through MATLAB for potential flow problems depends on the accuracy of the input data and the chosen numerical methods. In general, MATLAB is known for its high accuracy and reliability in solving complex problems, but it is always important to validate the results and consider any potential sources of error.

5. Can I customize and optimize the code in MATLAB for solving potential flow problems?

Yes, MATLAB allows for customization and optimization of the code for solving potential flow problems. Users can write their own scripts and functions to tailor the code to their specific needs and can also use built-in optimization tools to improve the efficiency and accuracy of the solution.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
850
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • General Math
Replies
8
Views
1K
Replies
1
Views
2K
  • Programming and Computer Science
Replies
4
Views
966
  • General Math
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
Back
Top