Making an animation of the motion of a particle

1

I am new here. I just installed Mathematica and am learning the basics. I need to solve three equations of the motion of a particle using Do, ListPlot, and Animate. Kindly help me to solve me one, then I will do the other two by myself.

vf = vi + a t
s =  vi t + (1/2)a t^2
2as = vf^2 + vi^2

This is what I have tried for first equation.

vi = 0;
vf = 22;
a = 10;
t = 60;
steps = 50;
vi[0] = 0.8;
vf[0] = 1.3;
a[0] = 0.7;
t[0] = 0.0;
Do[vf[n] = vi[n] + a[n]*t[n], {n, 0, steps}]
data = Table[vf[n], {n, 0, steps}];
ListPlot[data]

r = 0.5;
Animate[
  Show[Graphics[Disk[{vf[n]}, r], Axes -> True]], 
  {n, 0, steps, 30}] 

rabnawaz

Posted 2017-12-30T05:52:52.100

Reputation: 11

What are you trying to solve for? You have vi, vf, a, t, and vi[0], vf[0], a[0] t[0] conflicting. You can't do that. You can solve for at from the first equation with vi and vf, which is different ? from vi[0] and vf[0]. I don't know what vit is, but if you know it, you can solve for s in the second equation, and then solve for a in the last equation. – Bill Watts – 2017-12-30T08:15:50.313

@bill watts i am liitle confuse if you give me some hint to do it – rabnawaz – 2017-12-30T12:37:33.070

Can't do it with the data you have. vf does not equal vi + a t. Since you assign each variable in that equation, there is nothing to solve for. also 2as should be 2 a s. Multiplication is either * or space. Since s is not assigned, that is the only thing you can solve for, and that only requires your second equation. Everything else is overly and inconsistently specified. – Bill Watts – 2017-12-30T18:54:21.797

Answers

1

Math problem

vf = vi + a t /. {vi -> 0, a -> 10, t -> 60}

600

This is inconsistent with vf == 22

Mathematica problem

Making assignments to a simple variable and and an indexed variable of the same name (such as t = 60 and t[0] = 0.0) is asking for trouble. This is explained here, but may be too advanced for a beginner, so just accept that you shouldn't do it.

Kinematics problem

For simple kinematics problems like yours, I believe it is better to express the motion as a function rather than as an expression. So

v[t_] := v0 + a t
s[t_] := s0 + v0  t + a/2 t^2

My problem

I have no idea what you are trying to express with the reation

2 as = vf^2 + vi^2

Demonstrating the motion

Now let's see what I can do about making a demonstration of the kinematics. I choose to use Manipulate and Plot rather than Animate and ListPlot. Note that Manipulate supports animation. To run an animation, just click on the "+" on the right of the slider. I prefer Plot over ListPlot because motion is essentially continuous rather than discrete.

The velocity versus time plot

With[{tmax = 60},
  Manipulate[
    Block[{a = 10., v0 = 0.},
      Plot[v[t], {t, 0, tt}, PlotRange -> {{0, tmax}, {v0, v[tmax]}}]],
    {{tt, 1, "t"}, 1, tmax, 1, AppearanceElements -> All}]]

velocity

The distance versus time plot

With[{tmax = 60},
  Manipulate[
    Block[{a = 10., v0 = 0., s0 = 0.},
      Plot[s[t], {t, 0, tt}, PlotRange -> {{0, tmax}, {s0, s[tmax]}}]],
    {{tt, 1, "t"}, 1, tmax, 1, AppearanceElements -> All}]]

distance

If you insist on using Animate and ListPlot, you might do something like

With[{tmax = 20},
  DynamicModule[{vData, sData},
    Animate[
      Block[{a = 10., v0 = 0., s0 = 0.},
        vData = Table[{t, v[t]}, {t, 0, tt}];
        sData = Table[{t, s[t]}, {t, 0, tt}];
        ListPlot[{vData, sData},
          PlotRange -> {{0, tmax}, {0., s[tmax]}},
          PlotRangePadding -> Scaled[.05]]],
    {{tt, 0, "t"}, 0, tmax, 1}]]]

animation

but, in my opinion, it does not elucidate the kinematics a well as the two Manipulate expressions.

m_goldberg

Posted 2017-12-30T05:52:52.100

Reputation: 104 223

thanks for the help but i tell you seriously i did't understand a single thing. will you do for the first equation of the motion. – rabnawaz – 2017-12-30T12:50:06.277

0

There are several issues with your code and the Mathematica syntax. You have to describe your kinematics equations into finite elements. For a constant acceleration, each steps are $\delta t$ apart. You will notice I have used Print to get results out of the With (If not, only the last expression is printed out, the Animate). Try this:

With[{
vi = 0,
  \[Delta]t = 0.1,
  a = 10,
  steps = 50,
  r = 0.5},
  Do[vf[n] = vi + a*n*\[Delta]t, {n, 0, steps}];
 data = Table[vf[n], {n, 0, steps}]; 
 Print[ListPlot[data]];
 Animate[Show[Graphics[Disk[{n, vf[n]}, r], PlotRange -> {{0, 50}, {0, 50}}, 
Axes -> True]], {n, 0, steps, 1}]]

Gwanguy

Posted 2017-12-30T05:52:52.100

Reputation: 303