7

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.

Michael E2
  • 235,386
  • 17
  • 334
  • 747
user45824
  • 73
  • 5

2 Answers2

12
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

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
6

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

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