0
$\begingroup$

I have set of data points but I want to draw the trajectory of particle moving inside this well either in phase space. How can I do this? I tried with VectorPlot but not come out with good and set of data point are as follows: mass of particle is 10^-24 kg and here in this data first column is position & second potential. I am very thankful to you if you can help me to do this. Thank you.

x={2.*10^-6, 1.9*10^-6, 1.8*10^-6, 1.7*10^-6, 1.6*10^-6, 1.5*10^-6, 
     1.4*10^-6, 1.3*10^-6, 1.2*10^-6, 1.1*10^-6, 1.*10^-6, 9.*10^-7, 
     8.*10^-7, 7.*10^-7, 6.*10^-7, 5.*10^-7, 4.*10^-7, 3.*10^-7, 2.*10^-7,
      1.*10^-7, 0, -1.*10^-7, -2.*10^-7, -3.*10^-7, -4.*10^-7, -5.*10^-7, \
    -6.*10^-7, -7.*10^-7, -8.*10^-7, -9.*10^-7, -1.*10^-6, -1.1*10^-6, \
    -1.2*10^-6, -1.3*10^-6, -1.4*10^-6, -1.5*10^-6, -1.6*10^-6, \
    -1.7*10^-6, -1.8*10^-6, -1.9*10^-6, -2.*10^-6}  

 Vx = {-2.39203*10^-19, -2.38026*10^-19, -2.37166*10^-19, -2.36809*10^-19, \
-2.37117*10^-19, -2.38208*10^-19, -2.40143*10^-19, -2.42925*10^-19, \
-2.46503*10^-19, -2.50782*10^-19, -2.55644*10^-19, -2.60954*10^-19, \
-2.6657*10^-19, -2.72342*10^-19, -2.78094*10^-19, -2.83618*10^-19, \
-2.88644*10^-19, -2.92835*10^-19, -2.95779*10^-19, -2.97001*10^-19, \
-2.96*10^-19, -2.92287*10^-19, -2.8545*10^-19, -2.75213*10^-19, \
-2.61492*10^-19, -2.44433*10^-19, -2.24423*10^-19, -2.0208*10^-19, \
-1.782*10^-19, -1.53693*10^-19, -1.29492*10^-19, -1.06466*10^-19, \
-8.5334*10^-20, -6.6606*10^-20, -5.0546*10^-20, -3.7171*10^-20, \
-2.6278*10^-20, -1.75*10^-20, -1.0373*10^-20, -4.409*10^-21, 
 1.*10^-21}
$\endgroup$
1
  • $\begingroup$ what are your initial conditions? $\endgroup$
    – Sumit
    Dec 10, 2017 at 10:33

2 Answers 2

7
$\begingroup$

Here is a general answer. I am rescaling your values for convenience.

x = x 10^6;
Vx = Vx 10^19;

pot[y_] = Interpolation[Transpose[{x , Vx }]][y]; (*potential function*)
f[y_] = -D[pot[y], y]; (*function for force*)

y0 = 0.2; (*initial position*)
v0 = 0.5; (*initial velocity*)
tmax = 10;(*time range*) 
m=1;
(*now solve m y''[t]==f[y] within 0<t<tmax*)
sol[t] = y[t] /. NDSolve[{m y''[t] == f[y[t]], y[0]==y0, y'[0]==v0}, y[t], {t, 0, tmax}];

z[t_] = sol[t][[1]];  (*in case of multiple solutions, take the first one*)
v[t_] = D[z[t], t];

Animated Oscillation

Animate[Plot[pot[y], {y, x[[1]], x[[-1]]}, 
        Epilog -> {PointSize[Large], Point[{z[t], pot[z[t]]}],
                   Arrow[{{z[t], pot[z[t]]}, {z[t] + m v[t], pot[z[t]]}}]}, 
       FrameLabel -> {"x", "V(x)"}, Frame -> True], {t, 0, tmax}]

enter image description here

Compare the phase space trajectory and real motion

Animate[Grid[
{{Plot[z[t1], {t1, 0, tmax}, AxesLabel -> {"t", "x"},
   Epilog -> {PointSize[Large], Point[{t, z[t]}]}],
  Plot[v[t1], {t1, 0, tmax}, AxesLabel -> {"t", "v"}, 
   Epilog -> {PointSize[Large], Point[{t, v[t]}]}]},
 {ParametricPlot[{z[t1], v[t1]}, {t1, 0, tmax}, AxesLabel -> {"x", "v"}, 
   Epilog -> {PointSize[Large], Point[{z[t], v[t]}]}],
  Plot[pot[y], {y, x[[1]], x[[-1]]}, Epilog -> {PointSize[Large], 
   Point[{z[t], pot[z[t]]}], Arrow[{{z[t], pot[z[t]]}, {z[t] + m v[t], pot[z[t]]}}]}, 
  FrameLabel -> {"x", "V(x)"}, Frame -> True]}}], {t, 0, tmax}]]

enter image description here

Phase space diagram

Here I choose a large set of initial condition to span the phase space and choose a small time to see the instantaneous motion.

yv0 = Flatten[Table[{y, v}, {y, -0.401, 0.6, 0.05}, {v, -0.601, 0.65, 0.05}], 1];
(*initila y0,v0*)
nn = Length[yv0];(*number of inital data*)

tmax = 0.2;
m = 1;

data = Table[ sol[t] = 
y[t] /. NDSolve[{m y''[t] == f[y[t]], y[0] == yv0[[n, 1]], 
   y'[0] == yv0[[n, 2]]}, y[t], {t, 0, tmax}];
z[t_] = sol[t][[1]];
v[t_] = D[z[t], t];
 {{z[0], v[0]}, {z[tmax], v[tmax]} - {z[0], v[0]}},
{n, nn}];

ListVectorPlot[data, VectorStyle -> Red, PlotRange -> {{-0.4, 0.6}, {-0.6, 0.6}},
FrameLabel -> {"x", "Vx"}]

enter image description here

$\endgroup$
15
  • $\begingroup$ Can't we plot vector plot for this???? $\endgroup$
    – user51734
    Dec 10, 2017 at 12:29
  • $\begingroup$ To do that you need a list of initial conditions each of which will give a trajectory. Then you can make a ListVectorPlot. $\endgroup$
    – Sumit
    Dec 10, 2017 at 15:13
  • $\begingroup$ Thanku so much for your efforts. Actually my main target is to see motion of particle when my one axis follow this potential and other axis has harmonic 1/2kq^2. Can you please help me in that?? I will be highly Thank full to you. $\endgroup$
    – user51734
    Dec 11, 2017 at 4:38
  • $\begingroup$ @user51734, check my modification. Is that what you are looking for? $\endgroup$
    – Sumit
    Dec 11, 2017 at 8:13
  • $\begingroup$ Thank you so much for such a good visualization. Since we know motion is always three dimensional so here the data I provided is only 1D but lets assume I have V(x)=given data +1/2y^2. Then I want to see How particle will move in 3D. $\endgroup$
    – user51734
    Dec 11, 2017 at 10:07
3
$\begingroup$

Assigning anything to V(x) is not proper syntax. But this works:

x = {2.*10^-6, 1.9*10^-6, 1.8*10^-6, 1.7*10^-6, 1.6*10^-6, 1.5*10^-6, 
   1.4*10^-6, 1.3*10^-6, 1.2*10^-6, 1.1*10^-6, 1.*10^-6, 9.*10^-7, 
   8.*10^-7, 7.*10^-7, 6.*10^-7, 5.*10^-7, 4.*10^-7, 3.*10^-7, 
   2.*10^-7, 1.*10^-7, 
   0, -1.*10^-7, -2.*10^-7, -3.*10^-7, -4.*10^-7, -5.*10^-7, \
-6.*10^-7, -7.*10^-7, -8.*10^-7, -9.*10^-7, -1.*10^-6, -1.1*10^-6, \
-1.2*10^-6, -1.3*10^-6, -1.4*10^-6, -1.5*10^-6, -1.6*10^-6, \
-1.7*10^-6, -1.8*10^-6, -1.9*10^-6, -2.*10^-6};

V = {-2.39203*10^-19, -2.38026*10^-19, -2.37166*10^-19, \
-2.36809*10^-19, -2.37117*10^-19, -2.38208*10^-19, -2.40143*10^-19, \
-2.42925*10^-19, -2.46503*10^-19, -2.50782*10^-19, -2.55644*10^-19, \
-2.60954*10^-19, -2.6657*10^-19, -2.72342*10^-19, -2.78094*10^-19, \
-2.83618*10^-19, -2.88644*10^-19, -2.92835*10^-19, -2.95779*10^-19, \
-2.97001*10^-19, -2.96*10^-19, -2.92287*10^-19, -2.8545*10^-19, \
-2.75213*10^-19, -2.61492*10^-19, -2.44433*10^-19, -2.24423*10^-19, \
-2.0208*10^-19, -1.782*10^-19, -1.53693*10^-19, -1.29492*10^-19, \
-1.06466*10^-19, -8.5334*10^-20, -6.6606*10^-20, -5.0546*10^-20, \
-3.7171*10^-20, -2.6278*10^-20, -1.75*10^-20, -1.0373*10^-20, \
-4.409*10^-21, 1.*10^-21};

ListPlot[Transpose[{x, V}]]

enter image description here

$\endgroup$
1
  • $\begingroup$ My question is not about plotting its about motion. And V(x) is just data point. $\endgroup$
    – user51734
    Dec 12, 2017 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.