• API
• FAQ
• Tools
• Archive
daily pastebin goal
68%
SHARE
TWEET

Liouville

a guest Oct 18th, 2018 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. \[Theta][t_, \[Theta]0_, \[Theta]d0_] := (-(\[Theta]0^2/
2.       Sqrt[\[Theta]0^2 + \[Theta]d0^2]) - \[Theta]d0^2/
3.      Sqrt[\[Theta]0^2 + \[Theta]d0^2] ) Cos[
4.     2 Pi t +
5.      ArcTan[-(\[Theta]0/Sqrt[\[Theta]0^2 + \[Theta]d0^2]), \[Theta]d0/
6.       Sqrt[\[Theta]0^2 + \[Theta]d0^2]]];
7. \[Theta]d[
8.    t_, \[Theta]0_, \[Theta]d0_] := -(-(\[Theta]0^2/
9.        Sqrt[\[Theta]0^2 + \[Theta]d0^2]) - \[Theta]d0^2/
10.       Sqrt[\[Theta]0^2 + \[Theta]d0^2]) Sin[
11.     2 Pi t +
12.      ArcTan[-(\[Theta]0/Sqrt[\[Theta]0^2 + \[Theta]d0^2]), \[Theta]d0/
13.       Sqrt[\[Theta]0^2 + \[Theta]d0^2]]];
14. n = 100;
15. p0s = RandomVariate[
16.    MultinormalDistribution[{0, 0}, DiagonalMatrix[{0.05, 0.001}]],
17.    n];
18. p0s = Sort[p0s]; cols =
19.  ColorData["DarkRainbow"] /@ (Range[1/n, 1, 1/n]);
20.
21. frame[t_] := (Show[
22.     Graphics[
23.      {
24.       PointSize[Medium],
25.       Point[{0, 0}],
26.       Opacity[0.7],
27.       Table[
28.        {
29.         cols[[i]],
30.         With[{p = {Sin[\[Theta][t, p0s[[i, 1]],
31.               p0s[[i, 2]]]], -Cos[\[Theta][t, p0s[[i, 1]],
32.                p0s[[i, 2]]]]},
33.
34.           p2 = {Sin[\[Theta][t, p0s[[i, 1]], p0s[[i, 2]]]],
35.             1 + \[Theta]d[t, p0s[[i, 1]], p0s[[i, 2]]]}},
36.          {
37.           {Black, Opacity[0.1], Line[{p, p2}]},
38.           {Black, Opacity[0.1], Line[{{0, 0}, p}]},
39.           Point[p],
40.           Point[p2]
41.           }
42.          ]
43.         },
44.        {i, n}
45.        ],
46.       {White, Rectangle[{-0.2, 0.15}, {0.2, 0.25}]},
47.       Text[Style["position", Medium], {0, 0.2}],
48.       Rotate[Text[Style["momentum", Medium], {0, 0.2}],
49.        Pi/2, {0, 1}],
50.       Scale[
51.        Inset[
52.         Histogram[
53.          Table[Sin[\[Theta][t, p0s[[i, 1]], p0s[[i, 2]]]], {i, n}],
54.          {0.05},
55.          "PDF", PlotRange -> {{-1, 1}, {0, 10}},
56.          ChartStyle -> Directive[cols[[3]], Opacity[0.5]],
57.          Axes -> None]
58.         ,
59.         {0, 0}, {Center, Bottom}, {2, Automatic}
60.         ],
61.        {1, 0.5}
62.        ],
63.       Rotate[
64.        Scale[
65.         Inset[
66.          Histogram[
67.           Table[\[Theta]d[t, p0s[[i, 1]], p0s[[i, 2]]], {i, n}],
68.           {0.05},
69.           "PDF", PlotRange -> {{-1, 1}, {0, 10}},
70.           ChartStyle -> Directive[cols[[3]], Opacity[0.5]],
71.           Axes -> None]
72.          ,
73.          {0, 0}, {Center, Bottom}, {2, Automatic}
74.          ],
75.         {1, 0.5}
76.         ],
77.        Pi/2,
78.        {0, 1}
79.        ]
80.       },
81.      PlotRange -> {{-1, 1}, {-1.1, 1.5}}
82.      ]]);
83. Manipulate[
84.  frame[t],
85.  {t, 0, 1}]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top