7 views (last 30 days)

I have the following subroutine which takes a point with radius 1 and then finds a velocity vector at that point.

p = [0.282 0 0.959]'; %specify point where velocity is to be evaluated%

[v]=StokesletVelocity(N,sing,p,Kn,f);

function[v]=StokesletVelocity(N,sing,p,Kn,f)

for i=1:N

rij= (p - sing(1:3,i));

FF(1:3, 3*i-2:3*i) =((1/(8*pi*Kn))*((eye(3)/norm(rij)) + (rij*rij')/norm(rij)^3))'; %subroutine to find velocity at the point %

end

v=FF*f;

end

What I would like to do is plug in points to the subroutine with a range of radii going from 1 to 10 and get velocities for all of them. I was thinking of doing this in steps of 0.2 at a time, so the next p to plug into the subroutine would be

[0.2*0.282 0 0.2*0.959]

the next would be

[0.4*0.282 0 0.4*0.959]

and so on up until a radius of 10. This will produce an array of velocity vectors and I then need to find the radial component for each one and plot the radial component of each velocity vector against the corresponding value for the radius ie. the number which is mutliplying the numbers in the position vector for the point. Is it possible to use the subroutine I have to generate the array of velocity vectors and then plot radial component against radius in this way? Let me know if it is not clear what I mean.

Jon
on 23 Aug 2019

Edited: Jon
on 23 Aug 2019

I think that what you describe could be implemented with a simple loop. So make a vector of radii that you want to evaluate, set up a for loop that goes through the radii values, calculates p, calls your stokes function, and saves the results. Once you exit the loop you extract your velocity component and plot it agains the radius.

What are the dimensions of the variable v, that is returned by StokesletVelocity?

For illustrative purposes I will assume it is 3 by 1.

Then you could do something like this

% define the radius values

radius = 0.2:0.2:10 % radius goes from 0.2 to 10 in increments of 0.2

% define initial position

p = [0.282 0 0.959]

% you will need to assign numerical values for these variables

% I put them outside the loop assuming that they are not functions of the radius

% you will get an error on these lines until you fill in something on the

% right hand side of these equations.

N =

sing =

Kn =

f =

% preallocate array to hold result

numRadius = length(radius); % number of radius values

V = zeros(3,numRadius); % columns are results for each radius value, rows are velocity components

% loop through the values of radius calculating velocities

for k = 1:numRadius

p = radius(k)*p;

% evaluate the velocity and store it

V(:,k) = StokesletVelocity(N,sing,p,Kn,f);

end

% plot one of the components versus radius

plot(radius,V(1,:))

You may have to tweak the above slightly, as there are aspects of your problem that I couldn't fully understand from your description. Hopefully this gets you close enough that you can adapt it from here.

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.