cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Need help in making an algorithm for plotting pathline, streamline, streakline and timeline

ptc-4735478
12-Amethyst

Need help in making an algorithm for plotting pathline, streamline, streakline and timeline

The goal is to generate streamline, pathline, streakline and timeline for any arbitary velocity field, 2D or 3D

attached is what I have so far...using odesolve. at this point, the worksheet works for some velocity field, but not all...the problem is in the streakline program I guess, or it is the odesolve fail to converge. Please see the red box in the file for my specific question..I have trouble with the steps used to define the initial condition of the odesolve. The problem only show up for some function.

Is there a better way to write this? This seems to be quite long, long enough that I am not sure if I am writing the logic correctly.

I also need a more robust way too, because right now it seems it work sometimes only. Please test it with any thing you can think of.

it seems my streakline program, which attempts to calculate n particles (or n+1?) that pass through a marker point, the way I do it is to:

say the streakline track n marked particles at time t

and the first particle passes the marker point at time t0

I create n initial condition at the marker position at different time with interval (t-t0)/n

then repeatly call the the odesolve

but for some function, like the one used in the mathcad, I must use an interval of (t-t0)/ (n-1) or anything with a denominator less than n

which means I will have a particle that passed the marker point after time t and I track it backward in time

I cannot use (t-t0)/n or (t-t0)/ (n+1) , why is that?

and calculate n (x, y, z) useing the function generated from odesolve, then plot it...but this does not seem to be the smartest way...

similar logic is used for the time timeline..

ultimately I want to incoorperate this with WE vector field mathcad file ( the one that can draw arrow). So I would like to keep all x , y, z paramertized.

Thank you

Please help

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:ptc-4735478)

The vectorfield_MC15 is WE's document, check it out on the PTC documents

I know it, its mine

I have made a video but I do not know why the pathline stop updating at some point. I have checked that the position is still being updated and it is not that it remains the same so it does not show a change.

The file you posted is not the version the video was made with.

How did you define t there? Its not seen.

If you did not define t as you did in other graphs, you are using Mathcads quickplot feature, which means that t is running from -10 to 10 - not sure about the step width but small enough to get the impression of a continous smooth graph. Think you should define t (or name it different for safety) as range variable yourself to get more control (you won't need negative values). Maybe its due to this this feature that you don't see any change for FRAME>10 in your movie.

View solution in original post

10 REPLIES 10
Werner_E
25-Diamond I
(To:ptc-4735478)

Have only looked at the stremline section. See my comments in the attached file.

Main problem seemd to have been a typo in the solve block. You had z(0)=... instead of z(t0)=...

Thank you so much WE!

It probably would have taken me 10 days before I notice that error. Love this community~

And thanks for the correction on the use of ORIGIN. I am forcing my self to start that habbit to make the worksheet more universal. But I am already very tired of typing ORIGIN here and there, maybe next time I should just define o := ORIGIN...to save me some typing.

Werner_E
25-Diamond I
(To:ptc-4735478)

Glad I could help.

Typing all the time ORIGIN is really very tedious and while I used to do so myself quite often, I often doubt if it really makes sense. Who should change the ORIGIN on my own worksheets? Nobody. So it makes only sense for general, all purpose routine which I and/or others may copy in other worksheets.

A remark to your streak(t) routine. I don't think that it works as expected. It will only take arguments in a very small range - in your sheet from 4.9<t<5. Lower values of t throw an error, as those values of t are not valid for the streakfn functions with higher index i which start at higher values of t0. The last streakfn with index 50 has a start value t0 of 4.9, so this is the lowest value allowed for streak(). Think you had something else in mind.

Oh.....you are right,

This routine can only calculate streakline at the end time of odesolve, defineed as t.e in the worksheet because

a streak(t) with t < t.e would means there are particles that has not passed through the marker point.......and the routine try to calculate where these "marked particles" are....I should set the routine such that argument to streak become argument to the end time of odesolve.......I have adjusted the routine to do this..but is there a better way to do this?

Because it is taking a long time to run and I can hear my lab top roaming!

Werner_E
25-Diamond I
(To:ptc-4735478)

Because it is taking a long time to run and I can hear my lab top roaming!

OK, so lets speed up things a bit

Thanks WE. That works like magic!

Learn something new today.

The vectorfield_MC15 is WE's document, check it out on the PTC documents

The plot is in the velocity field with XXXXXX

need all three file to run since I used reference

I have made a video but I do not know why the pathline stop updating at some point. I have checked that the position is still being updated and it is not that it remains the same so it does not show a change.

Thanks

Werner_E
25-Diamond I
(To:ptc-4735478)

The vectorfield_MC15 is WE's document, check it out on the PTC documents

I know it, its mine

I have made a video but I do not know why the pathline stop updating at some point. I have checked that the position is still being updated and it is not that it remains the same so it does not show a change.

The file you posted is not the version the video was made with.

How did you define t there? Its not seen.

If you did not define t as you did in other graphs, you are using Mathcads quickplot feature, which means that t is running from -10 to 10 - not sure about the step width but small enough to get the impression of a continous smooth graph. Think you should define t (or name it different for safety) as range variable yourself to get more control (you won't need negative values). Maybe its due to this this feature that you don't see any change for FRAME>10 in your movie.

Werner Exinger wrote:

The vectorfield_MC15 is WE's document, check it out on the PTC documents

I know it, its mine

Thank you! again that works like magic.

now I have it working!

Do anyone have some interesting time dependent vector field that I can test? Preferably defined at t=0 ,x=0, y=0 ,z=0

For the particular one shown in this video, the timeline always look the same, the relative position of each particle as time pass does not change too much, interesting....

Hey WE, or anyone reading this thread,

Do you have a rountine to generate random 3-D coodinate of N particles that is inside a region constrained by X, Y, Z?? for my timeline calculation

Werner_E
25-Diamond I
(To:ptc-4735478)

Lookup "Uniform distribution" in the help files and use rnd() or runif(). Of course you could use other distributions like rnorm() if that would be appropriate.

Announcements

Top Tags