Asked by bharathi Dasari
on 18 Oct 2019

I had a set of discrete points whose velocities are known and postions and velocities will change with time , I want to use the streamline function, but in that , the condition is that the data sets should be monotonic . Is there any way to obtain stream lines for discrete particle locations which changes with time .

Answer by Bjorn Gustavsson
on 18 Oct 2019

Accepted Answer

Your question is a bit too vague. Or rather, the input-data you have is a bit vaguely described. The answer depends on how you'll specify that input...

If you have a reasonably low number of particles and their trajectories (something like ) you could simply go for a looped version of plot3, maybe something like:

clf

hold on

E_kin = squeeze(sum(v(:,1,:).^2,3));

g = (E_kin-min(E_kin))/(max(E_kin)-min(E_kin));

r = (r(:,1,1)-min(r(:,1,1)))/(max(r(:,1,1))-min(r(:,1,1)));

b = (r(:,1,2)-min(r(:,1,2)))/(max(r(:,1,2))-min(r(:,1,2)));

for i1 = num_particles:-1:1

ph(i1) = plot3(r(i1,:,1),r(i1,:,2),r(i1,:,3));

set(ph(i1),'color',[r(i1),g(i1),b(i1)])

end

That would plot the trajectories of all your particles in 3-D with the trajectories coloured according to their

initial x-y position (red and blue), and initial kinetic energy (green).

On the other hand that seems like such an obvious solution, so you might such a large number of particles that this doesnt work. For that perhaps you can use local averaged velocities, but that would involve a lot of looping:

for each time-step for each sub-volume, find all all particles inside, calculate their average velocity, when done with all subvolumes, you should be able to use streamline3, then on to next time-step

HTH

bharathi Dasari
on 25 Oct 2019

Bjron,

when i'm trying to use the syntax it was showing nan for some grid points in vx_at_t and vy_at_t.

Bjorn Gustavsson
on 26 Oct 2019

If your nans on the edges of the grid this might be because of a "simple" reason: the griddata (and the triscatteredinterp-functions (TriScatteredinterp, scatteredinterp, etc)) typically returns interpolated values inside the convex hull of the points you have data at - outside of that region (area in 2-D, volume in 3-D) it would be an extrapolation. You can test different interpolation-methods and some of the functions allow you to explicitly chose extrapolation methods.

How to handle extrapolation in the general case I dont know.

As far as I understand these methods should not return nan inside the convex hull - unless you have a nan in the input-data.

HTH

bharathi Dasari
on 26 Oct 2019

I don't have any data saying as nan ,my velocity values are small

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.