7
$\begingroup$

I have some explicit time-independent vector field on the plane, and I would like to study how points evolve under the flow generated by this vector field. The flow is rather complicated and cannot be solved explicitly.

For my purposes, it is important to analyze how a "curve" of initial conditions end up after a fixed time, say $t=1$. Is there any command in Mathematica that would do this job? I have read much documentation but could not find anything like this. Any help will be greatly appreciated.

To be concrete,

s = 
  NDSolve[
   {x'[t] == -y[t] + x[t]*Log[x[t]], y'[t] == x[t] + y[t]*Log[x[t]], 
    x[0] == 1, y[0] == 0}, 
   {x, y}, {t, 1}]

and I would like to plot the image of the line segment $1<x<2,\,y=0$ after time 1.

$\endgroup$
2
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ Feb 19 '16 at 18:35
  • $\begingroup$ Thank you very much for your comments! $\endgroup$
    – user45824
    Feb 19 '16 at 18:48
11
$\begingroup$
s = ParametricNDSolveValue[{x'[t] == -y[t] + x[t]*Log[x[t]], 
                            y'[t] ==  x[t] + y[t]*Log[x[t]], 
                            x[0] == x0, y[0] == 0}, {x, y}, {t, 1}, x0]
f[x0_, t_] := Through[Through[s@x0]@t]

pts = Table[f[x0, t], {x0, 1, 2, .2}, {t, 0, 1, .1}];
Show[Graphics[{Green, Arrow /@ pts, Black, Point /@ pts}, 
              Axes -> True, AxesOrigin -> {0, -1}], 
     ParametricPlot[f[x0, 1], {x0, 1, 2}, PlotStyle -> {Thick, Red}], 
     ParametricPlot[f[x0, 0], {x0, 1, 2}, PlotStyle -> {Thick, Blue}]]

Mathematica graphics

Or.

pts = Table[f[x0, t], {x0, 1, 2, .2}, {t, 0, 1, .1}];
ptsind = Transpose[{(Range@Length@# - 1)/(Length@# - 1), #} &@Transpose@pts];

Graphics[
  {Green, Arrow /@ pts,
  {Thick, Blend[{Blue, Red}, #[[1]]], Line@#[[2]]} & /@ ptsind},
  Axes -> True, AxesOrigin -> {0, -1}]

Mathematica graphics

$\endgroup$
1
  • 1
    $\begingroup$ Thank you very much! This is perfect for my purposes. It will be very useful in my studies. $\endgroup$
    – user45824
    Feb 19 '16 at 18:30
6
$\begingroup$

Make the position along the curve be another parameter of the differential equation.

s = NDSolve[{D[x[t, x0], t] == -y[t, x0] + x[t, x0]*Log[x[t, x0]], 
   D[y[t, x0], t] == x[t, x0] + y[t, x0]*Log[x[t, x0]], 
   x[0, x0] == x0, y[0, x0] == 0}, {x, y}, {t, 1}, {x0, 1, 2}];
ParametricPlot[
 Table[{x[t, x0], y[t, x0]} /. s, {t, 0, 1, 0.1}], {x0, 1, 2}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you very much! This was exactly what I was looking for; my apologies for not being able to accept multiple answers. $\endgroup$
    – user45824
    Feb 19 '16 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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