3

Here we discussed Poincare section for perturbed string model taken from the paper Chaotic dynamics of a suspended string in a gravitational background with magnetic field. We try to reproduce some data from Chaos of Wilson Loop from String Motion near Black Hole Horizon.
Code for the Poincare section of a chaotic system is given by

    value = {22.50340313, 60.54615508, 15.70200865, 6.12469956, 12.24939912, -1.68535, 12.4194}; {K1, K2, K3, K4, K5, \[Omega]sq[0], \[Omega]sq[1]} = Rationalize[value, 10^(-30)];

(* The Lagrangian of the system *)

lagrangian = Sum[Derivative[1][c[n]][t]^2 - c[n][t]^2*\[Omega]sq[n], {n, {0, 1}}] + K1*c[0][t]^3 + K2*c[0][t]*c[1][t]^2 + K3*c[0][t]*Derivative[1][c[0]][t]^2 + 
    K4*c[0][t]*Derivative[1][c[1]][t]^2 + K5*Derivative[1][c[0]][t]*c[1][t]*Derivative[1][c[1]][t]; 
c[0][t_] := OverTilde[c][0][t] + \[Alpha]1*OverTilde[c][0][t]^2 + \[Alpha]2*OverTilde[c][1][t]^2; 
c[1][t_] := OverTilde[c][1][t] + \[Alpha]3*OverTilde[c][0][t]*OverTilde[c][1][t]; 
\[Alpha]1 = -2; \[Alpha]2 = -2^(-1); \[Alpha]3 = -1; 
n = Expand[lagrangian]; 
vars = {OverTilde[c][0][t], OverTilde[c][1][t], Derivative[1][OverTilde[c][0]][t], Derivative[1][OverTilde[c][1]][t]}; 
lagrangian = Normal[Series[n /. Thread[vars -> m*vars], {m, 0, 3}]] /. m -> 1; 
momentum[n_] := D[lagrangian, Derivative[1][OverTilde[c][n]][t]]

(* Getting Hamiltonian from the given Lagrangian )
hamiltonian = Expand[Sum[momentum[n]
Derivative[1][OverTilde[c][n]][t], {n, {0, 1}}] - lagrangian];

(* Finding the equations of motion *) eulerLagrange[lagrangian_, vars_, dvars_] := Thread[Table[D[D[lagrangian, dvar], t], {dvar, dvars}] - Table[D[lagrangian, var], {var, vars}] == ConstantArray[0, Length[vars]]]; equationsOfMotion = eulerLagrange[lagrangian, {OverTilde[c][0][t], OverTilde[c][1][t]}, {Derivative[1][OverTilde[c][0]][t], Derivative[1][OverTilde[c][1]][t]}];

(* Finding the Poincare Section *) sol = Table[Block[{a, b, [Chi], d, habd}, habd = hamiltonian /. t -> 0 /. {OverTilde[c][0][0] -> a, Derivative[1][OverTilde[c][0]][0] -> b, OverTilde[c][1][0] -> [Chi], Derivative[1][OverTilde[c][1]][0] -> d}; {a, b, [Chi]} = {x, 0.0001, 0.0001}; d = d /. FindRoot[habd == 10^(-5), {d, -x}]; Reap[NDSolve[{equationsOfMotion, OverTilde[c][0][0] == a, Derivative[1][OverTilde[c][0]][0] == b, OverTilde[c][1][0] == [Chi], Derivative[1][OverTilde[c][1]][0] == d, WhenEvent[OverTilde[c][1][t] == 0 && Derivative[1][OverTilde[c][1]][t] >= 0, Sow[{OverTilde[c][0][t], Derivative[1][OverTilde[c][0]][t]}]]}, {OverTilde[c][0][t], OverTilde[c][1][t]}, {t, 0, 8000}, Method -> {"FixedStep", Method -> {"ImplicitRungeKutta", "DifferenceOrder" -> 10, "ImplicitSolver" -> {"Newton", AccuracyGoal -> MachinePrecision, PrecisionGoal -> MachinePrecision, "IterationSafetyFactor" -> 1}}}, StartingStepSize -> 1/10]]], {x, -0.002, -0.0001, 0.00005}]; ListPlot[Table[Flatten[sol[[i]][[2]], 1], {i, Length[sol]}], PlotTheme -> "Detailed", PlotRange -> {{-0.002, 0}, {-0.002, 0.002}}, FrameLabel -> {OverTilde[Subscript[c, 0]], OverDot[OverTilde[Subscript[c, 0]]]}, PlotStyle -> PointSize[0.005]]

How can I make it interactive using the ClickPoincarePlot2D resource function available in Wolfram function repository?

PS. The result of the execution of the code is as follows (Few warnings are omitted.). user64494 enter image description here

user64494
  • 26,149
  • 4
  • 27
  • 56
codebpr
  • 2,233
  • 1
  • 7
  • 26
  • 2
    It is difficult to answer your question because your code is not commented at all. – user64494 Jan 01 '24 at 21:13
  • Please add to your question the code you have tried for employing ClickPoincarePlot3D and describe the difficulties you have encountered. – bbgodfrey Jan 01 '24 at 22:34
  • I am going to edit my code now. – codebpr Jan 02 '24 at 04:57
  • I don’t understand why this question was closed when I already answered it, and my answer was accepted.? :) – Alex Trounev Jan 04 '24 at 07:30
  • 1
    @AlexTrounev I voted to re-open just because I liked your answer. A word of advice to the author of the question if I may: the questions -to a large extent- are too narrow in the sense of specific. Not sure if this was the original motivation for closure, as I was not amongst the five. Just keep in mind that questions of broader interest and minimal working examples are in general well received. – bmf Jan 05 '24 at 07:40
  • 1
    @bmf Thank you very much. As I remember we discussed ResourceFunction[ "ClickPoincarePlot2D"] with author, it is why I know how it working. :) – Alex Trounev Jan 05 '24 at 07:56
  • I have a pending task with Alex that I must finish this year, I hope, and it's good that my mate reopened the answer. I voted to close because some users did the same with the answers to another very good question about it, one in which Alex's answer also shed light on a new direction. – E. Chan-López Jan 06 '24 at 00:41
  • 1
    @bmf The response from Alex in another closed post is quite commendable, but some users decided otherwise and voted to close it. Thinking that perhaps it was not well-received, I ended up voting to close that question as well. I just voted to reopen that post, so I would greatly appreciate it if you would consider doing the same, my mate. Furthermore, if you wish to join forces with Alex and me to advocate for this, it would be an honor for me to collaborate with you. – E. Chan-López Jan 06 '24 at 01:00
  • @AlexTrounev Questions related to exercises on resource function examples provide a good opportunity for feedback, but having individuals who can edit is valuable because, at times, those asking the questions need assistance in organizing the code, especially when they are not experienced users. I'm not sure if this is generally well-received, but from what I've observed, it seems not to be, which is something I don't appreciate. However, I'm not among the influential members in this community. – E. Chan-López Jan 06 '24 at 01:04
  • 1
    @E.Chan-López I voted to re-open that particular question. To be honest, I think that the open threads on the site should be useful for the majority of users. That's the reason behind the comment I made here. About using ResourceFunctions, as you have observed I am not shy to use them and I agree that properly written answers is an excellent way to demonstrate how they work and perhaps suggestions for future modifications. – bmf Jan 06 '24 at 09:06

1 Answers1

4

To display Poincare section using ResourceFunction["ClickPoincarePlot2D"] we need to define Hamiltonian and equations of motion in the Hamilton form as follows

h := Function[{S}, -((33707 S[[1]]^2)/20000) - (
   815338710539 S[[1]]^3)/51728115000 + S[[2]]^2 + (
   154040173 S[[1]] S[[2]]^2)/20000000 + (62097 S[[3]]^2)/5000 - (
   20799664898903 S[[1]] S[[3]]^2)/248503740000 + (
   103117489 S[[2]] S[[3]] S[[4]])/12500000 + S[[4]]^2 + (
   103117489 S[[1]] S[[4]]^2)/25000000]
eqs = {Derivative[1][x][t] == px[t], 
   Derivative[1][px][t] == -((154040173 px[t]^2)/20000000) - (
     103117489 py[t]^2)/25000000 + (33707 x[t])/10000 + (
     815338710539 x[t]^2)/17242705000 + (20799664898903 y[t]^2)/
     248503740000, Derivative[1][y][t] == py[t], 
   Derivative[1][py][t] == -((103117489 px[t] py[t])/12500000) - (
     62097 y[t])/2500 + (20799664898903 x[t] y[t])/124251870000};

Then evaluate

ResourceFunction["ClickPoincarePlot2D"][eqs, h, 10^-5, t, 6000, 
 y[t], {x[t], px[t]}, {PlotTheme -> "Detailed", 
  PlotRange -> {{-0.002, 0}, {-0.002, 0.002}}, Frame -> True, 
  FrameLabel -> {OverTilde[Subscript[c, 0]], 
    OverDot[OverTilde[Subscript[c, 0]]]}, 
  PlotStyle -> PointSize[0.005]}]

Figure 1

Appendix 1. To compute expression h from initial code we use

value = {22.50340313, 60.54615508, 15.70200865, 6.12469956, 
  12.24939912, -1.68535, 12.4194}; {K1, K2, K3, K4, 
  K5, \[Omega]sq[0], \[Omega]sq[1]} = Rationalize[value, 10^(-30)];

(The Lagrangian of the system)

lagrangian = Sum[Derivative[1][c[n]][t]^2 - c[n][t]^2[Omega]sq[n], {n, {0, 1}}] + K1c[0][t]^3 + K2c[0][t]c[1][t]^2 + K3c[0][t]Derivative[1][c[0]][t]^2 + K4c[0][t]Derivative[1][c[1]][t]^2 + K5Derivative[1][c[0]][t]c[1][t]Derivative[1][c[1]][t]; c[0][t_] := OverTilde[c][0][t] + [Alpha]1OverTilde[c][0][t]^2 + [Alpha]2* OverTilde[c][1][t]^2; c[1][t_] := OverTilde[c][1][t] + [Alpha]3OverTilde[c][0][t]OverTilde[c][1][t]; [Alpha]1 = -2; [Alpha]2 = -2^(-1); [Alpha]3 = -1; n = Expand[lagrangian]; vars = {OverTilde[c][0][t], OverTilde[c][1][t], Derivative[1][OverTilde[c][0]][t], Derivative[1][OverTilde[c][1]][t]}; lagrangian = Normal[Series[n /. Thread[vars -> m*vars], {m, 0, 3}]] /. m -> 1; momentum[n_] := D[lagrangian, Derivative[1][OverTilde[c][n]][t]]

(Getting Hamiltonian from the given Lagrangian) hamiltonian = Expand[Sum[ momentum[n]*Derivative[1][OverTilde[c][n]][t], {n, {0, 1}}] - lagrangian]; rules = {OverTilde[c][0][t] -> S[[1]], Derivative[1][OverTilde[c][0]][t] -> S[[2]], OverTilde[c][1][t] -> S[[3]], Derivative[1][OverTilde[c][1]][t] -> S[[4]]}; hamiltonian /. rules

(-((33707 S[[1]]^2)/20000) - (815338710539 S[[1]]^3)/51728115000 + S[[2]]^2 + ( 154040173 S[[1]] S[[2]]^2)/20000000 + (62097 S[[3]]^2)/5000 - ( 20799664898903 S[[1]] S[[3]]^2)/248503740000 + ( 103117489 S[[2]] S[[3]] S[[4]])/12500000 + S[[4]]^2 + ( 103117489 S[[1]] S[[4]]^2)/25000000 )

Last expression used in definition h:=Function[{S},...]. Equations of motion

rules1 = {OverTilde[c][0][t] -> x[t], Derivative[1][OverTilde[c][0]][t] -> px[t], OverTilde[c][1][t] -> y[t], 
    Derivative[1][OverTilde[c][1]][t] ->py[t]};H= hamiltonian /. rules1; 
eqs = {x'[t] == px[t], px'[t] == -D[H, x[t]], y'[t] == py[t],
   py'[t] == -D[H, y[t]]}

Out[]= {Derivative[1][x][t] == px[t], Derivative[1][px][t] == -((154040173 px[t]^2)/20000000) - ( 103117489 py[t]^2)/25000000 + (33707 x[t])/10000 + ( 815338710539 x[t]^2)/17242705000 + (20799664898903 y[t]^2)/ 248503740000, Derivative[1][y][t] == py[t], Derivative[1][py][t] == -((103117489 px[t] py[t])/12500000) - ( 62097 y[t])/2500 + (20799664898903 x[t] y[t])/124251870000}

Alex Trounev
  • 44,369
  • 3
  • 48
  • 106
  • Thanks a lot for the informative answer! – codebpr Jan 04 '24 at 04:56
  • @codebpr You are welcome! – Alex Trounev Jan 04 '24 at 04:57
  • Can you kindly explain the difference in the pictures? TIA. – user64494 Jan 05 '24 at 07:02
  • @user64494 I am also have trouble understanding the difference in the output obtained from the two different approaches! Alex Trounev can you have a look please? – codebpr Jan 05 '24 at 07:04
  • @codebpr Please pay attention that using ResourceFunction["ClickPoincarePlot2D"] we control on click parameters a, b in your notation, while with your code we control parameters a, d at fixed b, \[Chi]. – Alex Trounev Jan 05 '24 at 08:02
  • @user64494 Do you mean how we should use code to get same picture? It is not so simple question since there are different initial parameters generated on click and with FindRoot. – Alex Trounev Jan 05 '24 at 08:18
  • So, in order to get the same picture, do we need to make appropriate adjustments in the source code of ResourceFunction["ClickPoincarePlot2D"]? – codebpr Jan 05 '24 at 08:21
  • @codebpr Actually it could be better to make a new code using your code since ResourceFunction["ClickPoincarePlot2D"] is already defined. – Alex Trounev Jan 05 '24 at 08:34
  • @AlexTrounev I think the main issue is not with click parameters but with the method which is used in NDSolve. Please see a modified form of a similar question here. – codebpr Mar 05 '24 at 08:25