Skip to main content
added 229 characters in body
Source Link
Vitaliy Kaurov
  • 73.4k
  • 9
  • 206
  • 365

Update: art

============== update - animation ============== I made a special art animation base don this. Full code is HERE.

art

Update: art animation

This animation has about 50 frames - meaning it's obtained from tracking 50 independent events during single run of numerical solver:

enter image description here

Code is simply given by:

evs = Mod[t, 2 \[Pi]] == # & /@ (Range[0, 2 Pi - #, #] &@(2 Pi/50));

data = Block[{δ = 0.15, γ = 0.3}, Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[Evaluate@evs, 
       Sow[{x[t], x'[t]}, Round[100 Mod[t, 2 π]]]]}, {}, {t, 0, 
      200000}, MaxSteps -> ∞]]];

Export["test.gif",
 Table[ListPlot[data[[2]][[k]], PlotStyle -> PointSize[0], 
   PlotRange -> {1.8 {-1, 1}, 1.3 {-1, 1}}, AspectRatio -> 1, 
   Frame -> True, ImageSize -> 450], {k, 1, 50, 1}]
 ]

============== older - testing grounds ==============

Older: testing grounds

Put independent events in List when you need a few of them. Then to separate while Sow/Reap - use tags in Sow - for example for 4 different events. I'll show all of them on a single plot to compare. Just use Manipulate or Animate or ListAnimate for your goal.

data = Block[{δ = 0.15, γ = 0.3}, 
   Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[{Mod[t, 2 π] == 0, Mod[t, 2 π] == π/2, 
        Mod[t, 2 π] == π, Mod[t, 2 π] == (3 π)/2}, 
       Sow[{x[t], x'[t]}, Round@Mod[t, 2 π]]]}, {}, {t, 0, 
      100000}, MaxSteps -> ∞]]];


ListPlot[data[[2]], ImageSize -> Medium, 
 PlotRange -> {{-1.5, 1.5}, All}, PlotStyle -> PointSize[0.0025]]

enter image description here

============== update - animation ==============

This animation has about 50 frames - meaning it's obtained from tracking 50 independent events during single run of numerical solver:

enter image description here

Code is simply given by:

evs = Mod[t, 2 \[Pi]] == # & /@ (Range[0, 2 Pi - #, #] &@(2 Pi/50));

data = Block[{δ = 0.15, γ = 0.3}, Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[Evaluate@evs, 
       Sow[{x[t], x'[t]}, Round[100 Mod[t, 2 π]]]]}, {}, {t, 0, 
      200000}, MaxSteps -> ∞]]];

Export["test.gif",
 Table[ListPlot[data[[2]][[k]], PlotStyle -> PointSize[0], 
   PlotRange -> {1.8 {-1, 1}, 1.3 {-1, 1}}, AspectRatio -> 1, 
   Frame -> True, ImageSize -> 450], {k, 1, 50, 1}]
 ]

============== older - testing grounds ==============

Put independent events in List when you need a few of them. Then to separate while Sow/Reap - use tags in Sow - for example for 4 different events. I'll show all of them on a single plot to compare. Just use Manipulate or Animate or ListAnimate for your goal.

data = Block[{δ = 0.15, γ = 0.3}, 
   Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[{Mod[t, 2 π] == 0, Mod[t, 2 π] == π/2, 
        Mod[t, 2 π] == π, Mod[t, 2 π] == (3 π)/2}, 
       Sow[{x[t], x'[t]}, Round@Mod[t, 2 π]]]}, {}, {t, 0, 
      100000}, MaxSteps -> ∞]]];


ListPlot[data[[2]], ImageSize -> Medium, 
 PlotRange -> {{-1.5, 1.5}, All}, PlotStyle -> PointSize[0.0025]]

enter image description here

Update: art

I made a special art animation base don this. Full code is HERE.

art

Update: art animation

This animation has about 50 frames - meaning it's obtained from tracking 50 independent events during single run of numerical solver:

enter image description here

Code is simply given by:

evs = Mod[t, 2 \[Pi]] == # & /@ (Range[0, 2 Pi - #, #] &@(2 Pi/50));

data = Block[{δ = 0.15, γ = 0.3}, Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[Evaluate@evs, 
       Sow[{x[t], x'[t]}, Round[100 Mod[t, 2 π]]]]}, {}, {t, 0, 
      200000}, MaxSteps -> ∞]]];

Export["test.gif",
 Table[ListPlot[data[[2]][[k]], PlotStyle -> PointSize[0], 
   PlotRange -> {1.8 {-1, 1}, 1.3 {-1, 1}}, AspectRatio -> 1, 
   Frame -> True, ImageSize -> 450], {k, 1, 50, 1}]
 ]

Older: testing grounds

Put independent events in List when you need a few of them. Then to separate while Sow/Reap - use tags in Sow - for example for 4 different events. I'll show all of them on a single plot to compare. Just use Manipulate or Animate or ListAnimate for your goal.

data = Block[{δ = 0.15, γ = 0.3}, 
   Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[{Mod[t, 2 π] == 0, Mod[t, 2 π] == π/2, 
        Mod[t, 2 π] == π, Mod[t, 2 π] == (3 π)/2}, 
       Sow[{x[t], x'[t]}, Round@Mod[t, 2 π]]]}, {}, {t, 0, 
      100000}, MaxSteps -> ∞]]];


ListPlot[data[[2]], ImageSize -> Medium, 
 PlotRange -> {{-1.5, 1.5}, All}, PlotStyle -> PointSize[0.0025]]

enter image description here

deleted 51 characters in body
Source Link
Vitaliy Kaurov
  • 73.4k
  • 9
  • 206
  • 365

============== update - animation ==============

This animation has about 50 frames - meaning it's obtained from tracking 50 independent events during single run of numerical solver:

enter image description here

Code is simply given by:

evs = Mod[t, 2 \[Pi]] == # & /@ (Range[0, 2 Pi - #, #] &@(2 Pi/50));

data = Block[{\[Delta]δ = 0.15, \[Gamma]γ = 0.3}, 
   Reap[NDSolve[{x''[t] + \[Delta]δ x'[t] - x[t] + 
        x[t]^3 == \[Gamma]γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[Evaluate@evs, 
       Sow[{x[t], x'[t]}, Round[100 Mod[t, 2 \[Pi]]]]]π]]]]}, {}, {t, 0, 
      200000}, MaxSteps -> \[Infinity]]]];
∞]]];

Export["test.gif",
 Table[ListPlot[data[[2]][[k]], PlotStyle -> PointSize[0], 
   PlotRange -> {1.8 {-1, 1}, 1.3 {-1, 1}}, AspectRatio -> 1, 
   Frame -> True, ImageSize -> 450], {k, 1, 50, 1}]
 ]

============== older - testing grounds ==============

Put independent events in List when you need a few of them. Then to separate while Sow/Reap - use tags in Sow - for example for 4 different events. I'll show all of them on a single plot to compare. Just use Manipulate or Animate or ListAnimate for your goal.

data = Block[{δ = 0.15, γ = 0.3}, 
   Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[{Mod[t, 2 π] == 0, Mod[t, 2 π] == π/2, 
        Mod[t, 2 π] == π, Mod[t, 2 π] == (3 π)/2}, 
       Sow[{x[t], x'[t]}, Round@Mod[t, 2 π]]]}, {}, {t, 0, 
      100000}, MaxSteps -> ∞]]];


ListPlot[data[[2]], ImageSize -> Medium, 
 PlotRange -> {{-1.5, 1.5}, All}, PlotStyle -> PointSize[0.0025]]

enter image description here

============== update - animation ==============

This animation has about 50 frames - meaning it's obtained from tracking 50 independent events during single run of numerical solver:

enter image description here

Code is simply given by:

evs = Mod[t, 2 \[Pi]] == # & /@ (Range[0, 2 Pi - #, #] &@(2 Pi/50));

data = Block[{\[Delta] = 0.15, \[Gamma] = 0.3}, 
   Reap[NDSolve[{x''[t] + \[Delta] x'[t] - x[t] + 
        x[t]^3 == \[Gamma] Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[Evaluate@evs, 
       Sow[{x[t], x'[t]}, Round[100 Mod[t, 2 \[Pi]]]]]}, {}, {t, 0, 
      200000}, MaxSteps -> \[Infinity]]]];


Export["test.gif",
 Table[ListPlot[data[[2]][[k]], PlotStyle -> PointSize[0], 
   PlotRange -> {1.8 {-1, 1}, 1.3 {-1, 1}}, AspectRatio -> 1, 
   Frame -> True, ImageSize -> 450], {k, 1, 50, 1}]
 ]

============== older - testing grounds ==============

Put independent events in List when you need a few of them. Then to separate while Sow/Reap - use tags in Sow - for example for 4 different events. I'll show all of them on a single plot to compare. Just use Manipulate or Animate or ListAnimate for your goal.

data = Block[{δ = 0.15, γ = 0.3}, 
   Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[{Mod[t, 2 π] == 0, Mod[t, 2 π] == π/2, 
        Mod[t, 2 π] == π, Mod[t, 2 π] == (3 π)/2}, 
       Sow[{x[t], x'[t]}, Round@Mod[t, 2 π]]]}, {}, {t, 0, 
      100000}, MaxSteps -> ∞]]];


ListPlot[data[[2]], ImageSize -> Medium, 
 PlotRange -> {{-1.5, 1.5}, All}, PlotStyle -> PointSize[0.0025]]

enter image description here

============== update - animation ==============

This animation has about 50 frames - meaning it's obtained from tracking 50 independent events during single run of numerical solver:

enter image description here

Code is simply given by:

evs = Mod[t, 2 \[Pi]] == # & /@ (Range[0, 2 Pi - #, #] &@(2 Pi/50));

data = Block[{δ = 0.15, γ = 0.3}, Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[Evaluate@evs, 
       Sow[{x[t], x'[t]}, Round[100 Mod[t, 2 π]]]]}, {}, {t, 0, 
      200000}, MaxSteps -> ∞]]];

Export["test.gif",
 Table[ListPlot[data[[2]][[k]], PlotStyle -> PointSize[0], 
   PlotRange -> {1.8 {-1, 1}, 1.3 {-1, 1}}, AspectRatio -> 1, 
   Frame -> True, ImageSize -> 450], {k, 1, 50, 1}]
 ]

============== older - testing grounds ==============

Put independent events in List when you need a few of them. Then to separate while Sow/Reap - use tags in Sow - for example for 4 different events. I'll show all of them on a single plot to compare. Just use Manipulate or Animate or ListAnimate for your goal.

data = Block[{δ = 0.15, γ = 0.3}, 
   Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[{Mod[t, 2 π] == 0, Mod[t, 2 π] == π/2, 
        Mod[t, 2 π] == π, Mod[t, 2 π] == (3 π)/2}, 
       Sow[{x[t], x'[t]}, Round@Mod[t, 2 π]]]}, {}, {t, 0, 
      100000}, MaxSteps -> ∞]]];


ListPlot[data[[2]], ImageSize -> Medium, 
 PlotRange -> {{-1.5, 1.5}, All}, PlotStyle -> PointSize[0.0025]]

enter image description here

added 1002 characters in body
Source Link
Vitaliy Kaurov
  • 73.4k
  • 9
  • 206
  • 365

============== update - animation ==============

This animation has about 50 frames - meaning it's obtained from tracking 50 independent events during single run of numerical solver:

enter image description here

Code is simply given by:

evs = Mod[t, 2 \[Pi]] == # & /@ (Range[0, 2 Pi - #, #] &@(2 Pi/50));

data = Block[{\[Delta] = 0.15, \[Gamma] = 0.3}, 
   Reap[NDSolve[{x''[t] + \[Delta] x'[t] - x[t] + 
        x[t]^3 == \[Gamma] Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[Evaluate@evs, 
       Sow[{x[t], x'[t]}, Round[100 Mod[t, 2 \[Pi]]]]]}, {}, {t, 0, 
      200000}, MaxSteps -> \[Infinity]]]];


Export["test.gif",
 Table[ListPlot[data[[2]][[k]], PlotStyle -> PointSize[0], 
   PlotRange -> {1.8 {-1, 1}, 1.3 {-1, 1}}, AspectRatio -> 1, 
   Frame -> True, ImageSize -> 450], {k, 1, 50, 1}]
 ]

============== older - testing grounds ==============

Put independent events in List when you need a few of them. Then to separate while Sow/Reap - use tags in Sow - for example for 4 different events. I'll show all of them on a single plot to compare. Just use Manipulate or Animate or ListAnimate for your goal.

data = Block[{δ = 0.15, γ = 0.3}, 
   Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[{Mod[t, 2 π] == 0, Mod[t, 2 π] == π/2, 
        Mod[t, 2 π] == π, Mod[t, 2 π] == (3 π)/2}, 
       Sow[{x[t], x'[t]}, Round@Mod[t, 2 π]]]}, {}, {t, 0, 
      100000}, MaxSteps -> ∞]]];


ListPlot[data[[2]], ImageSize -> Medium, 
 PlotRange -> {{-1.5, 1.5}, All}, PlotStyle -> PointSize[0.0025]]

enter image description here

Put independent events in List when you need a few of them. Then to separate while Sow/Reap - use tags in Sow - for example for 4 different events. I'll show all of them on a single plot to compare. Just use Manipulate or Animate or ListAnimate for your goal.

data = Block[{δ = 0.15, γ = 0.3}, 
   Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[{Mod[t, 2 π] == 0, Mod[t, 2 π] == π/2, 
        Mod[t, 2 π] == π, Mod[t, 2 π] == (3 π)/2}, 
       Sow[{x[t], x'[t]}, Round@Mod[t, 2 π]]]}, {}, {t, 0, 
      100000}, MaxSteps -> ∞]]];


ListPlot[data[[2]], ImageSize -> Medium, 
 PlotRange -> {{-1.5, 1.5}, All}, PlotStyle -> PointSize[0.0025]]

enter image description here

============== update - animation ==============

This animation has about 50 frames - meaning it's obtained from tracking 50 independent events during single run of numerical solver:

enter image description here

Code is simply given by:

evs = Mod[t, 2 \[Pi]] == # & /@ (Range[0, 2 Pi - #, #] &@(2 Pi/50));

data = Block[{\[Delta] = 0.15, \[Gamma] = 0.3}, 
   Reap[NDSolve[{x''[t] + \[Delta] x'[t] - x[t] + 
        x[t]^3 == \[Gamma] Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[Evaluate@evs, 
       Sow[{x[t], x'[t]}, Round[100 Mod[t, 2 \[Pi]]]]]}, {}, {t, 0, 
      200000}, MaxSteps -> \[Infinity]]]];


Export["test.gif",
 Table[ListPlot[data[[2]][[k]], PlotStyle -> PointSize[0], 
   PlotRange -> {1.8 {-1, 1}, 1.3 {-1, 1}}, AspectRatio -> 1, 
   Frame -> True, ImageSize -> 450], {k, 1, 50, 1}]
 ]

============== older - testing grounds ==============

Put independent events in List when you need a few of them. Then to separate while Sow/Reap - use tags in Sow - for example for 4 different events. I'll show all of them on a single plot to compare. Just use Manipulate or Animate or ListAnimate for your goal.

data = Block[{δ = 0.15, γ = 0.3}, 
   Reap[NDSolve[{x''[t] + δ x'[t] - x[t] + 
        x[t]^3 == γ Cos[ t], x[0] == 0, x'[0] == 0, 
      WhenEvent[{Mod[t, 2 π] == 0, Mod[t, 2 π] == π/2, 
        Mod[t, 2 π] == π, Mod[t, 2 π] == (3 π)/2}, 
       Sow[{x[t], x'[t]}, Round@Mod[t, 2 π]]]}, {}, {t, 0, 
      100000}, MaxSteps -> ∞]]];


ListPlot[data[[2]], ImageSize -> Medium, 
 PlotRange -> {{-1.5, 1.5}, All}, PlotStyle -> PointSize[0.0025]]

enter image description here

added 171 characters in body
Source Link
Vitaliy Kaurov
  • 73.4k
  • 9
  • 206
  • 365
Loading
Source Link
Vitaliy Kaurov
  • 73.4k
  • 9
  • 206
  • 365
Loading