Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Attached is what I have, I just want to numerically calculate position of a bouncing particle (elastically) in a 2D box at constant speed. Anyone can let me know how to overcome the problem that prime does not allow unit in x and y axis in the 3D plot? And does anyone know how I can make an animation of the trajectory of the particle in the 3D plot?
And would anyone suggest how I can achieve what I have done in the file using different approach? such as a better way to write the program or something with less programing. Please enlighten my mind.
Thanks a lot
Solved! Go to Solution.
Might be easier just to treat the walls as if they were particles of infinite mass and zero radius - see attached.
Alan
Edited to replace the worksheet with a corrected one.
henry leung wrote:
Anyone can let me know how to overcome the problem that prime does not allow unit in x and y axis in the 3D plot?
For some reason Prime only allows units to be attached to the z-axis (you should get an error message that says this if you try to assign units to, say, the x-axis).
And does anyone know how I can make an animation of the trajectory of the particle in the 3D plot?
Use Mathcad 15 (animation not yet available in Prime).
And would anyone suggest how I can achieve what I have done in the file using different approach? such as a better way to write the program or something with less programing.
See http://communities.ptc.com/thread/39681 for example.
Alan
I tried to make animation in mathcad 15 but it says "error initiating video stream"
What does that mean?
my FRAME setting is From: 0 To:9 At: 10 frames/second, tried different value but I still have the same error
Can someone tell me what is wrong with my file??
Thanks
I tried to make animation in mathcad 15 but it says "error initiating video stream"
What does that mean?
my FRAME setting is From: 0 To:9 At: 10 frames/second, tried different value but I still have the same error
Can someone tell me what is wrong with my file??
There is nothing wrong with you worksheet - it works as it should for me.
The problem you reported usually results from chosing a non existing or an inapproriate codec. You can change this in the record anomation window under options. Try "Microsoft Video 1" for a start which seems to be the default at least in my installation.
WE
The attached shows a different approach. An animation is included below.
Alan
ALAN STEVENS wrote:
... An animation is included below.
Or not!!! The animation doesn't seem to have appeared. However, you should find it straightforward to generate one from the file. 'll attach the .avi file here.
Alan
Thank you for the upload. I would never think like the way you do in programing......how long have you been doing this before you can think like that. I would not have thought of using the mod function in this case.
in terms of computation, does your way of programing use less resources? well, obviously my version has more command line in it.
BTW, i still cannot create an avi file. I tried all different compressor available in mathcad15. I see nothing in that preview window in the annimation record tool box. I can see my mathcad sheet is changing during the animation though. My avi file is either all black or just a white vertical stripe. see my attached avi.
is it because i am using window 7??
henry leung wrote:
....how long have you been doing this
A long, long time ...!!
BTW, i still cannot create an avi file. I tried all different compressor available in mathcad15. I see nothing in that preview window in the annimation record tool box. I can see my mathcad sheet is changing during the animation though. My avi file is either all black or just a white vertical stripe. see my attached avi.
is it because i am using window 7??
I don't know why you can't generate the .avi file. It isn't because of Windows 7 - that's what I'm using.
In the animation box, the FRAMES should go from 0 to 200. I set the frame rate at 20. Make sure the dotted box fully surrounds the graph (going well above and below and well to the left and right of it).
Alan
I finally figure out how to generate video! I am so silly....
I used to select the area then open the animation tool box.
Of course I should open the animation tool box, then click and drag the area. cann't believe how simple it is to make an animation! and it took me 1 whole night to figure that out!
I have a new question. How to generate random number between 0 and 1 with a mean of 0.8 using the poisson distribution? the rpois function gives integer only. I want to use this number as a coefficient of restitution for each bounce from the wall
Thanks
henry leung wrote:
I have a new question. How to generate random number between 0 and 1 with a mean of 0.8 using the poisson distribution? the rpois function gives integer only. I want to use this number as a coefficient of restitution for each bounce from the wall
Thanks
This is slightly odd, as Poisson is essentially discrete integers. However, you could generate a vector of, say 1000 Poisson integers, with a mean of 800; divide them by 1000, and then pick off the values one by one.i.e. construct vector, r = rpois(1000,800)/1000. This will give you 1000 numbers distributed between 0 and 1 (mostly, though not with certainty) with a mean of (approximately) 0.8.
Alan
Thanks.. I think I should really use a normal distribution but not a poisson..I misunderstood the meaning of a poisson, what I need is a normal. But how can I limit the value to be greater than zero and less than 1?
And based on Alan program,
I build one with a normal distribution of coefficient of restitution... But I think the program keep recalculating the position that the particles already passed each time
I have also modified mine with a similar problem. I think what the animation tool box does is that it calculate my whole sheet at every new frame. but that makes my particle have a different history at each frame. what can i do ??
by the way
i used mod(rnorm(1,0.8,0.1),1) as a way to generate random number less than 1...but this is not certain, is there a better way?
Is there a function that can store all the calculated values or symbolic expression of a mother function then disconnect from the mother function, so all value become constant number of symbolic expression as if they were entered manually in a matrix/vector?
See attached. My version doesn't generalise so easily.
Alan
Edited to replace attached file by one with corrected logic and improved animation (go from 0 to 999 at 30 frames/sec)
Thanks Alan.
I have generalized the program to two particle. I am so excited to see them bouncing around. To bad my wife do not appreciate it when I show it to her, so I must share my joy here!
Now I am working to make the two particle to be able to rebounce when they meet each other
Very good!
I'm slightly puzzled as to why you are using a random distribution for the restitution coefficient though - is there a particular physical phenomenon you are trying to represent with this?
How are you going to represent interparticle collisions - with an elastic contact or with action at a distance?
Alan
This is just a programing exercise for myself as I am new to mathcad.
I think no rebounce is exactly the same in the real world, so the restitution should not be a constant. There for I just introduce a little bit of randomness in it.
Eventually, I am want to have a simple model for particle coalescene.
But at the moment, I want them to be able to collide and rebounce through contact. I want my 2D particles to have an area so that when they touch each other, they slow down and run into each other, i.e. overlapping of of the circle. I will model the de-acceleration by modelling the force as a spring.
There is a two thing I want to do now,
I)
radius of particle1 = r1
radius of particle2 = r2
distance between center of two particle = x
k is some function of the relative velocity of the two particle
if r1+r2-x > 0
force = -k*(r1+r2-x)
otherwise
force = 0
then I have to decompose this force into the x and y component
then apply it to my particles, I think I will do this numerically again
I will first make a case where k is a constant, so that I can solve the deceleration symbolically.
for the coalescene part, I will add another force that will hold the two particle together, I do not have a picture of the nature of this force though...I guess I will just make up something for fun.
II)
count how many times the particle come into contact with each other in a given time with a set of initial condition. And hence the probability of collision .
The ultimate question is given a set of initial condition,
how likely is it for two particle to coalesces
if they do coalesces, what is the probability that this coalesces happen in a certain time frame
These are the things I want to do so far, for my personal enrichment.
Here is the latest progress. see attached file.
I need some help again.
Question1:
In my program, when I am trying to model 2 particles..I need parameters for 3 particles because of how I write my program.
Please see my for loop with j
How can I get around this? I do not want an imaginery particle just to satisfy the input of my program
Question2:
I tried to generalize my program so that I can just put in any number of particle...but I am stuck
because for n particles, if we consider interaction between 2 particle only, I need nC2 interaction and I do not know how to do that, that seems to be a very difficult program to write base on my current programming logic. Needless to say I if I want to account for 3 way or 4way interaction. I think it is better to tell each particle to find how many nearby particles are there, determine the number of way of interaction and hence how many particle has to change course for that particular rebounce....
Question 3:
I want to have a circle that represent the size of the particle during animation.
I have the center of particles, I can have a function that has circle of particle radius and a moving center. (y-y1)^2 + (x-x1^2) = r^2
But I do not know how to achieve that in mathcad
Question4 is about basic physics,
If by collision I mean: 2 particles touch each other, both experience a force = -kx, change travelling velocity and possibly run into each other, eventually slow down , maybe stopp and rebounce, or maybe deflected. Is what I have in my program describing this? Do I need conservation of momentum here? or I am already conserving momentum by equating action and reaction force? I just want to confirm the physics is right, because I am confused ...
Thank you and happy thanksgiving!
The force will be along the line connecting the centres of the two particles. You should really calculate the force along this line and then resolve it in the x and y directions before updating the velocities.
Alan
Alan,
I multiplied the magnitude of force by the unit vector along the center of two particle, calculated an acceleration in vector form then added that to my velocity vector. So the change in veocity is along the line connecting the two center. And I have solved my other questions! here is the latest version of my mathcad work sheet. I got what I wanted! And I think the interesting part is at the end of the video.
Thanks!
henry leung wrote:
Alan,
I multiplied the magnitude of force by the unit vector along the center of two particle, calculated an acceleration in vector form then added that to my velocity vector.
So you did - I missed the absolute value lines! Where to now - more particles?
Alan
with the way I wrote this program.
.for three particle, i need 3X 2way interaction and 1X 3way interaction..just too troublesome to write i think.
so I tried a different approach using odesolve after reading valery's 3-plant system (see his reply)
i have problem again...it says i am missing initial condition in the ode solve block.
but i gave the zero and first derivative already..what is wrong?
by the way, how to use lagrange notation in mathcad15 and prime2.0? what is the keyboard key for each version? how to get the " and ' as derivatives?
henry leung wrote:
i have problem again...it says i am missing initial condition in the ode solve block.
but i gave the zero and first derivative already..what is wrong?
See if the attached helps.
... how to get the " and ' as derivatives?
Use Ctrl_f7 (Use it twice for ``)
It's also on a key. On my laptop it's near the upper left on a key with ¬ and ¦, but it might be on a different key on different PCs.
Alan
It is like my first animation on PlanetPTC - see http://communities.ptc.com/videos/1356
Thanks valery
I think I will try odesolve, see if I get the same thing. That is a lot simpler to do the numerical myself
henry leung wrote:
Thanks valery
I think I will try odesolve, see if I get the same thing. That is a lot simpler to do the numerical myself
I have question with doing this problem with odesolve,
It said I am dividing by zero.
I tried to trace the value of each variable but I dont see any problem. The iteration stopped at i=61...
Please help me
Hi Henry,
I suspect that you need to use the xxn[i-1 & yyn[i-1 values in the ODE calls rather than the Xn & Yn initial values as you are at the moment
Regards
Andy
Thanks Andy!
Now the iteration complete.
But Now I have another problem. My two particle do not interact ! Is my odesolve not setup right? Now the two particle does not bounce off each other?
What is wrong with my program? The odesolve should do a recalculation each time any particle reaches the wall using the the current position and velocity of the two particles as input argument to the odesolve. Is it not what my program is doing?
Help is needed again
It will be better to lacate this video (20-30MB!!!) here - http://communities.ptc.com/community/mathcad?view=video
I am still stuck on the same problem. No interaction between the two particle in my odesolve program. Please see particle bouncing in a 2D box1_9_ode.xmcd.zip for the sheet. Hopefully someone can let me know what I did wrong. Thank you.
Besides, is there a way to simplify the program? In the program there are many "if" statement that are very similar. I want to replace all these check by referencing to another program or function but I dont know how to achieve that.
Henry