<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel rdf:about="https://community.wolfram.com">
    <title>Community RSS Feed</title>
    <link>https://community.wolfram.com</link>
    <description>RSS Feed for Wolfram Community showing any discussions tagged with Physics sorted by most likes.</description>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2411604" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/863933" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/235291" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/463721" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2051264" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/413906" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/595870" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2448552" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/121507" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1433064" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2399430" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/294122" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/3022104" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/131302" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2017849" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/3458262" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/418720" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/787142" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2085563" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/790989" />
      </rdf:Seq>
    </items>
  </channel>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2411604">
    <title>[WSG21] Daily Study Group: Differential Equations (begins November 29)</title>
    <link>https://community.wolfram.com/groups/-/m/t/2411604</link>
    <description>A new study group devoted to Differential Equations begins next Monday! A list of daily topics can be found on our [Daily Study Groups][1] page. This group will be led by one of our outstanding Wolfram certified instructors, Luke Titus, and will meet daily, Monday to Friday, over the next three weeks. Luke will share the excellent lesson videos created by him for the upcoming Wolfram U course &amp;#034;[Introduction to Differential Equations][2]&amp;#034;. Study group sessions include time for exercises, discussion and Q&amp;amp;A. This study group will help you achieve the &amp;#034;Course Completion&amp;#034; certificate for the &amp;#034;Introduction to Differential Equations&amp;#034; course after you complete the course quizzes.&#xD;
&#xD;
Sign up: [Study group registration page][3]&#xD;
&#xD;
&#xD;
  [1]: https://www.wolfram.com/wolfram-u/special-event/study-groups/&#xD;
  [2]: https://www.wolfram.com/wolfram-u/introduction-to-differential-equations/&#xD;
  [3]: https://www.bigmarker.com/series/daily-study-group-intro-to-differential-equations/series_details?utm_bmcr_source=community</description>
    <dc:creator>Devendra Kapadia</dc:creator>
    <dc:date>2021-11-22T16:35:30Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/863933">
    <title>Walking strandbeest dynamics</title>
    <link>https://community.wolfram.com/groups/-/m/t/863933</link>
    <description>Many of you have seen the strandbeest (from Dutch, meaning beach-beast). These PVC tube animals created by Theo Jansen walk along the beach and are wind powered:&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
Years ago (2009 to be more exact) I made a post on my blog about the movement of the legs, as evidenced by the still-nicely-working Mathematica notebook:&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
At the time the proportions of the legs were not known publicly so I meticulously studied frames of (low quality) YouTube videos. I made the following diagram in Illustrator of what I thought I saw:&#xD;
&#xD;
![enter image description here][3] ![enter image description here][4]&#xD;
&#xD;
On the left the length of the legs in red, and in blue the numbers of the joints. On the right the trajectory of the joints that I calculated at the time in Mathematica. It&amp;#039;s funny that my blog does not exist any more (for years actually), but these images live on, as I found out when I looked for strandbeest on Google Images:&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
My images! But not on my website! Nice to see people still use it. Now, in 2016, I saw these files on my laptop, and thought: is there finally more known about them? Well yes, there is! The exact proportions are now known and there is tons and tons of videos, lectures, 3D-printable strandbeest models, interviews with Theo Jansen and other stuff! So now we can find the exact dimensions readily on the internet:&#xD;
&#xD;
![enter image description here][6] &#xD;
&#xD;
Notice that I (wrongly) assumed that the legs had &amp;#039;feet&amp;#039;! oops! I was very happy to see that my lengths were not that wrong though! Let&amp;#039;s recreate the strandbeest. We do so by first creating a function that quickly finds the intersection of two circles:&#xD;
&#xD;
    Clear[FindPoint, FindLines]&#xD;
    FindPoint[p1 : {x1_, y1_}, p2 : {x2_, y2_}, R_, r_, side_] := Module[{d, x, y, vc1, vc2, p, sol, sol1, sol2, s1, s2, sr},&#xD;
      d = N@Sqrt[(x2 - x1)^2 + (y2 - y1)^2];&#xD;
      x = (d^2 - r^2 + R^2)/(2 d);&#xD;
      y = Sqrt[R^2 - x^2];&#xD;
      vc1 = Normalize[{x2 - x1, y2 - y1}];&#xD;
      vc2 = Cross[vc1];&#xD;
      p = {x1, y1} + x vc1;&#xD;
      {sol1, sol2} = {p + y vc2, p - y vc2};&#xD;
      s1 = Sign[Last[Cross[Append[(p2 - p1), 0], Append[(sol1 - p1), 0]]]];&#xD;
      s2 = Sign[Last[Cross[Append[(p2 - p1), 0], Append[(sol2 - p1), 0]]]];&#xD;
      sr = If[side === Left, 1, -1];&#xD;
      Switch[sr, s1,&#xD;
       sol1&#xD;
       ,&#xD;
       s2&#xD;
       ,&#xD;
       sol2&#xD;
       ]&#xD;
      ]&#xD;
&#xD;
This finds on the side &amp;#039;side&amp;#039; (Left/Right) the intersection point of two circles positioned at p1 and p2, with radii R and r, respectively. And now we can easily compute all the little vertices/joints of our beast:&#xD;
&#xD;
    FindLines[\[Theta]_] := Module[{p1, p2, p3, p4, p5, p6, p7, p8, p10, p11, p12, p13, p14, p15},&#xD;
      {p1, p2, p3, p4, p5, p6, p7, p8, p10, p11, p12, p13, p14, p15} = FindPoints[\[Theta]];&#xD;
      {{p1, p2}, {p2, p3}, {p3, p4}, {p1, p4}, {p2, p6}, {p4, p6}, {p3, p5}, {p4, p5}, {p5, p8}, {p6, p8}, {p6, p7}, {p7, p8}, {p1, &#xD;
        p11}, {p10, p11}, {p2, p10}, {p2, p13}, {p11, p13}, {p10, p12}, {p11, p12}, {p12, p14}, {p13, p14}, {p13, p15}, {p14, p15}}&#xD;
      ]&#xD;
    FindPoints[\[Theta]_] := Module[{p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16},&#xD;
      p1 = {0, 0};&#xD;
      p4 = {38, -7.8};&#xD;
      p11 = {-38, -7.8};&#xD;
      p2 = 15 {Cos[\[Theta]], Sin[\[Theta]]};&#xD;
      &#xD;
      p3 = FindPoint[p2, p4, 50, 41.5, Left];&#xD;
      p6 = FindPoint[p2, p4, 61.9, 39.3, Right];&#xD;
      p5 = FindPoint[p3, p4, 55.8, 41.5, Left];&#xD;
      p8 = FindPoint[p5, p6, 39.4, 36.7, Left];&#xD;
      p7 = FindPoint[p6, p8, 49, 65.7, Right];&#xD;
      &#xD;
      p10 = FindPoint[p2, p11, 50, 41.5, Right];&#xD;
      p13 = FindPoint[p2, p11, 61.9, 39.3, Left];&#xD;
      p12 = FindPoint[p10, p11, 55.8, 41.5, Right];&#xD;
      p14 = FindPoint[p12, p13, 39.4, 36.7, Right];&#xD;
      p15 = FindPoint[p13, p14, 49, 65.7, Left];&#xD;
      &#xD;
      {p1, p2, p3, p4, p5, p6, p7, p8, p10, p11, p12, p13, p14, p15}&#xD;
      ]&#xD;
&#xD;
Now we can plot it easily:&#xD;
&#xD;
    trajectoriesdata = (FindPoints /@ Subdivide[0, 2 Pi, 100])\[Transpose];&#xD;
    Manipulate[&#xD;
      Graphics[{Arrowheads[Large], Arrow /@ trajectoriesdata, Thick, Red, Line[FindLines[\[Theta]]]},&#xD;
       PlotRange -&amp;gt; {{-150, 150}, {-120, 70}}, &#xD;
       ImageSize -&amp;gt; 800&#xD;
      ]&#xD;
     ,&#xD;
     {\[Theta], 0, 2 \[Pi]}&#xD;
    ]&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
We can also make an entire bunch of legs at the same time and make a 3D beast!&#xD;
&#xD;
    Manipulate[&#xD;
     mp = 60;&#xD;
     n = 12;&#xD;
     \[CurlyPhi] = Table[Mod[5 \[Iota], n, 1], {\[Iota], 1, n}];&#xD;
     Graphics3D[{Darker@Yellow, Table[&#xD;
        Line[ &#xD;
         Map[Prepend[mp \[Iota]], &#xD;
          FindLines[\[Theta] + \[CurlyPhi][[\[Iota]]] (2 Pi/n)], {2}]],&#xD;
        {\[Iota], n}&#xD;
        ]&#xD;
       , Black, Line[{{mp 1, 0, 0}, {mp n, 0, 0}}]&#xD;
       }&#xD;
      ,&#xD;
      Lighting -&amp;gt; &amp;#034;Neutral&amp;#034;,&#xD;
      PlotRangePadding -&amp;gt; Scaled[.1],&#xD;
      PlotRange -&amp;gt; {{-mp, (n + 1) mp}, {-150, 150}, {-150, 150}},&#xD;
      Boxed -&amp;gt; False,&#xD;
      ImageSize -&amp;gt; 700&#xD;
      ]&#xD;
     ,&#xD;
     {\[Theta], 0, 2 \[Pi]}&#xD;
     ]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
From the side we can look at how the legs of 4-pair-legged and 6-pair-legged versions of the beasts work:&#xD;
&#xD;
![enter image description here][9] ![enter image description here][10]&#xD;
&#xD;
Hope you enjoyed this! Perhaps someone else can make this thing actually walk over a (bumpy) surface?&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=LVDKumerus2.jpg&amp;amp;userId=73716&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2016-05-29at00.51.53.png&amp;amp;userId=73716&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=strandbeest_sketch.png&amp;amp;userId=73716&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=strandbeest_trajectories.png&amp;amp;userId=73716&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2016-05-29at00.16.23.png&amp;amp;userId=73716&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Strandbeest_Leg_Proportions-01.png&amp;amp;userId=73716&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=3493strandwalk.gif&amp;amp;userId=73716&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=3587strandwalk3D.gif&amp;amp;userId=73716&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=4legged.gif&amp;amp;userId=73716&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=6legged.gif&amp;amp;userId=73716</description>
    <dc:creator>Sander Huisman</dc:creator>
    <dc:date>2016-05-28T23:02:16Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/235291">
    <title>Random Snowflake Generator Based on Cellular Automaton</title>
    <link>https://community.wolfram.com/groups/-/m/t/235291</link>
    <description>[img]/c/portal/getImageAttachment?filename=fig0.gif&amp;amp;userId=93201[/img]&#xD;
&#xD;
Some time ago one of my friends asked me whether it is possible to design a cellular automaton which can generate realistic snowflakes. I recall my crystallography and thermodynamics knowledge and came up a very simple yet impressive model.&#xD;
&#xD;
&#xD;
[size=5][b]The Regular Triangular Lattice[/b][/size]&#xD;
&#xD;
First of all, we are trying to simulate snowflake, which is a kind of hexagonal crystal. So it should be best to construct our CA on a regular hexagonal grid, i.e. regular triangular lattice.&#xD;
&#xD;
We all know [b]CellularAutomaton[/b] inherently works on rectangle lattices (&amp;#034;4-lattice&amp;#034; for short), so how can we deduce a triangular lattice (&amp;#034;3-lattice&amp;#034; for short) on it? Well, the differences between rect-lattice and triangular one is just a geometric transformation.&#xD;
&#xD;
To demonstrate that, have a look at the following 4-lattice, with a blue square highlighting the range-1 [url=http://mathworld.wolfram.com/MooreNeighborhood.html]Moore neighborhood[/url]:&#xD;
&#xD;
[img=width: 388px; height: 396px;]/c/portal/getImageAttachment?filename=fig1.gif&amp;amp;userId=93201[/img]&#xD;
&#xD;
Clearly there is always a hexagon (the green area) in this kind of neighborhood.&#xD;
&#xD;
So forming a regular 3-lattice is as straightforward as doing a simple affine transformation (basically a shearing and a scaling):&#xD;
&#xD;
[img=width: 484px; height: 304px;]/c/portal/getImageAttachment?filename=fig2.gif&amp;amp;userId=93201[/img]&#xD;
&#xD;
So to take advantage of all the power of [b]CellularAutomaton[/b], all we have to do, is to use a following special 6-neighborhood stencil on rectangle lattices, meanwhile our model can be discussed and constructed on regular triangular lattice convieniently:&#xD;
&#xD;
[img=width: 118px; height: 57px;]/c/portal/getImageAttachment?filename=fig3.png&amp;amp;userId=93201[/img]&#xD;
&#xD;
And after the calculation, we can perform the affine transformation with following functions to get a nice hexagonal grid picture.&#xD;
&#xD;
[mcode]Clear[vertexFunc]&#xD;
&#xD;
vertexFunc = &#xD;
        Compile[{{para, _Real, 1}}, &#xD;
            Module[{center, ratio}, center = para[[1 ;; 2]];&#xD;
                ratio = para[[3]];&#xD;
                {Re[#], Im[#]} + {{1, -(1/2)}, {0, &#xD;
                                        Sqrt[3]/2}}.Reverse[{-1, 1} center + {3, 0}] &amp;amp; /@ (ratio 1/&#xD;
                                Sqrt[3] E^(I ?/6) E^(I Range[6] ?/3))], &#xD;
            RuntimeAttributes -&amp;gt; {Listable}, Parallelization -&amp;gt; True, &#xD;
            RuntimeOptions -&amp;gt; &amp;#034;Speed&amp;#034;&#xD;
            (*,CompilationTarget?&amp;#034;C&amp;#034;*)];&#xD;
&#xD;
Clear[displayfunc]&#xD;
displayfunc[array_, ratio_] := &#xD;
    Graphics[{FaceForm[{ColorData[&amp;#034;DeepSeaColors&amp;#034;][3]}], &#xD;
            EdgeForm[{ColorData[&amp;#034;DeepSeaColors&amp;#034;][4]}], &#xD;
            Polygon[vertexFunc[Append[#, ratio]] &amp;amp; /@ Position[array, 1]]}, &#xD;
        Background -&amp;gt; ColorData[&amp;#034;DeepSeaColors&amp;#034;][0]][/mcode]&#xD;
&#xD;
&#xD;
[size=5][b]The Model[/b][/size]&#xD;
&#xD;
To construct the crystallization model, let&amp;#039;s consider one of the 6-neighborhood stencil, where each cell represents a minimal crystal unit:&#xD;
&#xD;
[img=width: 261px; height: 236px;]/c/portal/getImageAttachment?filename=fig4.png&amp;amp;userId=93201[/img]&#xD;
&#xD;
A simple model will need only 2 states: [b]0[/b] for &amp;#034;[i]It&amp;#039;s empty[/i]&amp;#034;, [b]1[/b] for &amp;#034;[i]There is a crystal unit[/i]&amp;#034;. So by considering all (except the [b]000000[/b] one, because we are generating ONE snowflake thus don&amp;#039;t want a crystall randomly arises from void) [b]6-bit[/b] non-negative numbers, we can have a finite set of possible arrangements of the neighborhood:&#xD;
&#xD;
[mcode]stateSet = Tuples[{0, 1}, 6] // Rest[/mcode]&#xD;
However, from the viewpoint of physics, any two arrangements which can be transformed into each other with only rotation and reflection should be considered as the same arrangement in the sense of their physical effects on the central cell (i.e. cell[size=1]2,2[/size]) are the same:&#xD;
&#xD;
[img=width: 363px; height: 117px;]/c/portal/getImageAttachment?filename=fig5.png&amp;amp;userId=93201[/img]&#xD;
&#xD;
So we should gather [b]stateSet[/b] with above equivalence class:&#xD;
&#xD;
[mcode]gatherTestFunc = Function[lst, Union[Join[&#xD;
&#xD;
                    RotateLeft[lst, # - 1] &amp;amp; /@ Flatten[Position[lst, 1]],&#xD;
                    RotateLeft[Reverse[lst], # - 1] &amp;amp; /@ &#xD;
                        Flatten[Position[Reverse[lst], 1]]&#xD;
                    ]]];&#xD;
&#xD;
stateClsSet = Sort /@ Gather[stateSet, gatherTestFunc[#1] == gatherTestFunc[#2] &amp;amp;];&#xD;
&#xD;
stateClsSetHomogeneous = ArrayPad[#, {{0, 12 - Length@#}, {0, 0}}] &amp;amp; /@ stateClsSet;[/mcode]&#xD;
Which turned out to be [b]12[/b] classes in total:&#xD;
&#xD;
[img=width: 710px; height: 127px;]/c/portal/getImageAttachment?filename=fig6.png&amp;amp;userId=93201[/img]&#xD;
&#xD;
Now from the viewpoint of cellular automaton, we need to establish a set of rules on how should any 6-neighborhood arrangement, i.e. those 12 kinds of equivalence classes, determine the state of the central cell.&#xD;
&#xD;
There are 4 kinds of possible transformations on cell[size=1]2,2[/size]: [b]0 --&amp;gt; 1[/b] is called [b]frozen[/b], [b]0 --&amp;gt; 0[/b] is [b]remaining empty[/b], [b]1 --&amp;gt; 1[/b] is [b]remaining frozen[/b], and [b]1 --&amp;gt; 0[/b] is called [b]melten[/b]. To make things more interesting and to explore more possibilities, we can introduce probability here, so certain arrangement will give certain probabilities corresponding to the 4 kinds of transformations. But notice that because of the unitarity of probability, we have Prob(frozen) + Prob(0-&amp;gt;0) = 1 and Prob(melten) + Prob(1-&amp;gt;1) = 1, so only 2 of the 4 probabilities are independent. In the following, we&amp;#039;ll choose Prob(frozen) and Prob(melten), and denote them as [b]pFrozen[/b] and [b]pMelten[/b].&#xD;
&#xD;
[img=width: 800px; height: 367px;]/c/portal/getImageAttachment?filename=fig7.png&amp;amp;userId=93201[/img]&#xD;
&#xD;
Back to physics / thermodynamics, those 24 probabilities, [b]pFrozen[/b] and [b]pMelten[/b], can of corse be determined by serious physical models, or they can be chosen randomly just for fun. For example, an intuitive (and naive) idea would be to believe an empty cell nearby a sharp pointed end or with abundant moisture source will have a high [b]pFrozen[/b]. (People who are interested in the serious physical models should not miss [url=http://psoup.math.wisc.edu/Snowfakes.htm]the Gravner-Griffeath Snowfakes model[/url].)&#xD;
&#xD;
Now we have the grid, the stencil, the neighborhood arrangement set and the transfer probabilities, we&amp;#039;re offically ready to construct our cellular automaton rules.&#xD;
Following the above discussion, the construction is straightforward. There are only two points which need to pay attention to. One is to keep in mind that the rule function is applied on the 3x3 stencil, so even cell[size=1]1,1[/size] and cell[size=1]3,3[/size] has nothing to do with our model, don&amp;#039;t forget handling them. The second is to use a [b]SeedRandom[/b] function to make sure same arrangement gives same result in same time step, otherwise the 6-fold rotational symmetry and 3 axes of reflection symmetry will both break!&#xD;
&#xD;
[mcode]Clear[ruleFunc]&#xD;
&#xD;
ruleFunc = With[{&#xD;
                stateClsSetHomogeneous = stateClsSetHomogeneous,&#xD;
                seedStore = RandomInteger[{0, 1000}, 1000],&#xD;
                pFreeze = {1,   0,     0.6,   0,     0.3,   0.15,   0,     0.2,   0,     0.2,   0,     0.8},&#xD;
                pMelt   = {0,   0.7,   0.5,   0.7,   0.7,   0.5,    0.3,   0.5,   0.3,   0.2,   0.1,   0  }&#xD;
                },&#xD;
            Compile[{{neighborarry, _Integer, 2}, {step, _Integer}},&#xD;
                Module[{cv, neighborlst, cls, rand},&#xD;
                    cv = neighborarry[[2, 2]];&#xD;
                    neighborlst = {#[[1, 2]], #[[1, 3]], #[[2, 3]], #[[3, 2]], #[[3, &#xD;
                                        1]], #[[2, 1]]} &amp;amp;[neighborarry];&#xD;
                    If[Total[neighborlst] == 0, cv,&#xD;
                        cls = Position[stateClsSetHomogeneous, neighborlst][[1, 1]];&#xD;
                        SeedRandom[seedStore[[step + 1]]];&#xD;
                        rand = RandomReal[];&#xD;
                        Boole@If[cv == 0, rand &amp;lt; pFreeze[[cls]], rand &amp;gt; pMelt[[cls]]]&#xD;
                        ]],&#xD;
                (*CompilationTarget -&amp;gt; &amp;#034;C&amp;#034;,*)&#xD;
                RuntimeAttributes -&amp;gt; {Listable}, Parallelization -&amp;gt; True, &#xD;
                RuntimeOptions -&amp;gt; &amp;#034;Speed&amp;#034;&#xD;
                ]&#xD;
            ];[/mcode]&#xD;
(Note: re-compile the rule function [b]ruleFunc[/b] will give a different set of [b]seedStore[/b] thus a different growth path.)&#xD;
&#xD;
Now everything is ready, let&amp;#039;s grow a snowflake from the beginning! :D&#xD;
&#xD;
[mcode]dataSet = Module[{&#xD;
&#xD;
                    rule,&#xD;
                    initM = {{&#xD;
                                    {0, 0, 0},&#xD;
                                    {0, 1, 0},&#xD;
                                    {0, 0, 0}&#xD;
                                }, 0},&#xD;
                    rspec = {1, 1},&#xD;
                    tmin = 0, tmax = 100, dt = 1},&#xD;
                rule = {ruleFunc, {}, rspec};&#xD;
                CellularAutomaton[rule, initM, {{tmin, tmax, dt}}]&#xD;
                ]; // AbsoluteTiming&#xD;
&#xD;
Animate[&#xD;
    Rotate[displayfunc[dataSet[[k]], .8], 90 °],&#xD;
    {k, 1, Length[dataSet], 1},&#xD;
    AnimationDirection -&amp;gt; ForwardBackward,&#xD;
    AnimationRunning -&amp;gt; False, DisplayAllSteps -&amp;gt; True&#xD;
    ][/mcode]&#xD;
&#xD;
[img]/c/portal/getImageAttachment?filename=fig0.gif&amp;amp;userId=93201[/img]&#xD;
&#xD;
&#xD;
&#xD;
[size=5][b]Possible Improvements[/b][/size]&#xD;
&#xD;
We used a [b]SeedRandom[/b] function in our CA rule function to force the 6-fold rotational symmetry and 3 axes of reflection symmetry, and performed the CA calculation on all cells. However, this so called [url=http://demonstrations.wolfram.com/DihedralGroupNOfOrder2n/][i]D[/i][size=1]6[/size] symmetry[/url] can (and should) be integrated into our model, which will saving [b]11/12[/b] of the calculation. Also, the randomness of the growth path comes from [b]seedStore[/b], so to generate a new growth path, we have to re-compile the rule function. But with a improved model as described above, this constraint will no longer exist.&#xD;
&#xD;
[img=width: 800px; height: 177px;]/c/portal/getImageAttachment?filename=fig8.png&amp;amp;userId=93201[/img]&#xD;
[b][size=4]&#xD;
&#xD;
[size=5]Open question [/size]&#xD;
[/size][/b]&#xD;
Can we construct a well-organized structure (like the crystals) from a cellular automaton defined on an [b]irregular[/b] grid? While I believe the answer is [i]yes[/i], the next question would be [i]how?[/i]</description>
    <dc:creator>Silvia Hao</dc:creator>
    <dc:date>2014-04-11T16:03:33Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/463721">
    <title>Aftermath of the solar eclipse</title>
    <link>https://community.wolfram.com/groups/-/m/t/463721</link>
    <description>![enter image description here][1]&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][2]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=4902Hero.gif&amp;amp;userId=20103&#xD;
  [2]: https://www.wolframcloud.com/obj/5838919a-e64d-49fe-9193-c6ce123184f2</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2015-03-21T01:18:08Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2051264">
    <title>Estimation of energy yield of 2020 Beirut port explosion</title>
    <link>https://community.wolfram.com/groups/-/m/t/2051264</link>
    <description>Probably most of you heard the sad news that there was a giant explosion in the port of Beirut today August 3rd 2020. Several videos were released on which we can do analysis. Note that the method I will use was also famously used by G.I. Taylor to find the energy of the Trinity nuclear bomb test, and he found the right amount to within 10%! We will not be so lucky as the video quality was relatively poor as compared to the high-speed imaging done back then.&#xD;
&#xD;
I extracted several frames from one of the videos:&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
    SetDirectory[NotebookDirectory[]];&#xD;
    v1 = Import[&amp;#034;1.mp4&amp;#034;];&#xD;
    fra = VideoExtractFrames[v1, Interval[{11, 12}]]&#xD;
    fra = ImageRotate[#, Right] &amp;amp; /@ fra;&#xD;
&#xD;
For each of the frames I identified the explosion by clicking 3 point on the circle:&#xD;
&#xD;
     data={&#xD;
    {7,{{157.15625,365.20703125000006`},{233.83984375,379.76562500000006`},{272.015625,312.91015625000006`}}},&#xD;
    {8,{{318.16796874999994`,322.81640625000006`},{228.7890625,462.8515625},{103.61328125,393.38281250000006`}}},&#xD;
    {9,{{341.03515625000006`,311.34765625},{308.27734375,478.125},{93.86328125,420.34375}}},&#xD;
    {10,{{359.08984375,315.546875},{351.48828125,478.63671875000006`},{86.55078125,454.5078125}}},&#xD;
    {11,{{375.62109375,325.64453125},{330.05859375,535.3984375},{62.0390625,434.51171875}}},&#xD;
    {12,{{376.0390625,326.765625},{337.94140625,539.9257812499999},{46.4140625,462.55859375}}}&#xD;
    };&#xD;
&#xD;
The first is the index of the frames, the last elements are points of the circle:&#xD;
&#xD;
    circs = CircleThrough /@ data[[;; 6, 2]];&#xD;
    r = circs[[All, 2]];&#xD;
&#xD;
Here is the visualization:&#xD;
&#xD;
    Table[HighlightImage[fra[[data[[i, 1]]]], circs[[i]], &amp;#034;Boundary&amp;#034;], {i, Length[data]}]&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
Notice that I tracked the orange &amp;#039;glow&amp;#039;, not the shockwave or the smoke that was there partially before the main explosion (so on the conservative side and underestimating the energy release).&#xD;
&#xD;
From Google earth I estimated the size of the face of the building on the left (a grain elevator) and found that every pixel corresponds to 0.59 m roughly (~22 meters corresponding to ~37 pixels).&#xD;
&#xD;
    cali = 0.5888486673789164`;&#xD;
    realr = r cali&#xD;
    &#xD;
The timestamps can be found from the video framerate.&#xD;
&#xD;
    Information[Import[&amp;#034;video.mp4&amp;#034;]].&#xD;
&#xD;
And so the timestamps are created and the dataset is created:&#xD;
&#xD;
    t = (Range[0, Length[realr] - 1]) 1/29.97;&#xD;
    tr = Transpose[{t, realr}]&#xD;
&#xD;
Since the explosion started between two frames we include that in the fit (the t0):&#xD;
    &#xD;
    fit = FindFit[&#xD;
      tr, { a (x + t0)^0.4, 0 &amp;lt; t0 &amp;lt; 1/30}, {{a, 200}, {t0, 1/60}}, x]&#xD;
    realfit = a (x + t0)^0.4 /. fit&#xD;
    tzero = t0 /. fit&#xD;
    realfitshifted = a (x)^0.4 /. fit&#xD;
    prefactor = a /. fit&#xD;
&#xD;
The fit can be found [here][3] and is based on dimensional analysis with the variable E (energy), r (radius of the explosion), t (time), and ρ (density). This also explains the exponent 0.4 used for fitting.&#xD;
&#xD;
We plot the data and the fit:&#xD;
&#xD;
    Show[{ListPlot[Transpose[{t + tzero, realr}]], &#xD;
      Plot[realfitshifted, {x, 0, 0.2}]}, &#xD;
     PlotRange -&amp;gt; {{0, 0.2}, {0, 120}}, Frame -&amp;gt; True, &#xD;
     FrameLabel -&amp;gt; {&amp;#034;t&amp;#034;, &amp;#034;r [m]&amp;#034;}]&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
Which is a pretty good fit. &#xD;
&#xD;
We can now calculate the energy back from the explosion:&#xD;
&#xD;
    ClearAll[r, e, t, \[Rho]]&#xD;
    r == (e t^2/\[Rho])^(1/5)&#xD;
    Refine[DivideSides[%, t^(2/5)], t &amp;gt; 0]&#xD;
    %[[2]] == Quantity[prefactor, &amp;#034;Meters&amp;#034;/&amp;#034;Seconds&amp;#034;^(2/5)]&#xD;
    % /. \[Rho] -&amp;gt; Quantity[1, &amp;#034;Kilograms&amp;#034;/&amp;#034;Meters&amp;#034;^3]&#xD;
    energy = e /. Solve[%, e][[1]]&#xD;
&#xD;
Yielding:&#xD;
&#xD;
    Quantity[4.2808721214488837`*^11, &amp;#034;Joules&amp;#034;]&#xD;
&#xD;
and we can convert it to kiloton of TNT:&#xD;
&#xD;
    UnitConvert[energy, &amp;#034;KilotonsOfTNT&amp;#034;]&#xD;
&#xD;
yielding:&#xD;
&#xD;
    Quantity[0.102315, &amp;#034;KilotonsOfTNT&amp;#034;]&#xD;
&#xD;
This number is comparable to the 2015 Tianjin explosion (0.3 kilo tonnes of TNT). &#xD;
    &#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2020-08-04at21.44.20.png&amp;amp;userId=73716&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2020-08-05at12.00.12.png&amp;amp;userId=73716&#xD;
  [3]: https://en.wikipedia.org/wiki/Nuclear_weapon_yield#Calculating_yields_and_controversy&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2020-08-04at21.53.18.png&amp;amp;userId=73716</description>
    <dc:creator>Sander Huisman</dc:creator>
    <dc:date>2020-08-04T19:57:48Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/413906">
    <title>Why are some professors negative on Mathematica?</title>
    <link>https://community.wolfram.com/groups/-/m/t/413906</link>
    <description>In discussions with several university physics professors,,,theoreticians...they profess a strong dislike for Mathematica and caution their students about using it. I can fully understand cautioning a user to make sure they have used the correct syntax or correctly formulated a problem or model, but their caution was stronger than that. They, in effect, prefer to roll their own algorithms. They also claim Mathematica gives bad results, though it was unclear whether the fault lay in the execution or the formulation of a problem.&#xD;
&#xD;
I am troubled by this attitude, since users in all technical disciplines use Mathematica and rely on it to supply solutions to various designs, models, and analyses, some that are mission critical.&#xD;
&#xD;
I performed a literature search on evaluation of Mathematica and the most recent published critique and evaluation I found was for Mathematica 5. Other than this, there does not appear to be an undercurrent of suspicion except from these specific profs.&#xD;
&#xD;
What is going on? I can defend my mathematical models but I cannot defend the outcomes of executions of these models if there is skepticism over the validity of solutions obtained by Mathematica. I can also understand that anyone who has not come up on the learning curve might simply be covering their own inadequacies, hence the attitude of rolling their own. However, everyone should be skeptical of published results from the use of personal algorithms, for which no validation or user community exists.&#xD;
&#xD;
How can the quality of the results from the use of Mathmatica be supported? Are there published evaluations? What might some organizations such as DARPA do to validate some work for which Mathematica has been a cornerstone of the analyses?&#xD;
&#xD;
Or am I the only person to have run into this level of skepticism...which is ironic since I am more skeptical of analytical results than most.</description>
    <dc:creator>Luther Nayhm</dc:creator>
    <dc:date>2014-12-30T15:36:06Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/595870">
    <title>Ocean currents: from Fukushima and rubbish, to Malaysian airplane MH370</title>
    <link>https://community.wolfram.com/groups/-/m/t/595870</link>
    <description>![Ocean currents: from Fukushima and rubbish, to Malaysian airplane MH370][1]&#xD;
&#xD;
In this post I will use data from NASA&amp;#039;s ECCO2 project (http://ecco2.jpl.nasa.gov/) to simulate various scenarios: the movement of radioactive particles from the Fukushima nuclear power plant and the accumulation of rubbish in the oceans. I download about 20 years worth of oceanographic data and study how the flow of water might transport particles. A slight modification of the program might be useful to determine the crash site of Malaysian airplane MH370. The work was done with [Bjoern Schelter][2], who is member of this community. &#xD;
&#xD;
We will first download the vector fields for u and v direction. We obtain data for different depth, but I will only use surface currents. We first generate a list of filenames.&#xD;
&#xD;
    filenamesU = (&amp;#034;http://ecco2.jpl.nasa.gov/opendap/data1/cube/cube92/lat_lon/quart_90S_90N/UVEL.nc/UVEL.1440x720x50.&amp;#034; &amp;lt;&amp;gt; # &amp;lt;&amp;gt; &amp;#034;.nc.ascii?UVEL[0:1:0][0:1:0][0:1:719][0:1:1439]&amp;#034; &amp;amp; /@ (StringJoin[{ToString[#[[1]]], StringTake[StringJoin[ToString /@ PadLeft[{#[[2]]}, 2]], -2], StringTake[StringJoin[ToString /@ PadLeft[{#[[3]]}, 2]], -2]}] &amp;amp; /@ Table[Normal[DatePlus[DateObject[{1992, 1, 2}], 3*n]], {n, 0, 2556}]));&#xD;
    &#xD;
    filenamesV = (&amp;#034;http://ecco2.jpl.nasa.gov/opendap/data1/cube/cube92/lat_lon/quart_90S_90N/VVEL.nc/VVEL.1440x720x50.&amp;#034; &amp;lt;&amp;gt; # &amp;lt;&amp;gt; &amp;#034;.nc.ascii?VVEL[0:1:0][0:1:0][0:1:719][0:1:1439]&amp;#034; &amp;amp; /@ (StringJoin[{ToString[#[[1]]], StringTake[StringJoin[ToString /@ PadLeft[{#[[2]]}, 2]], -2],StringTake[StringJoin[ToString /@ PadLeft[{#[[3]]}, 2]], -2]}] &amp;amp; /@ Table[Normal[DatePlus[DateObject[{1992, 1, 2}], 3*n]], {n, 0, 2556}]));&#xD;
&#xD;
These filenames cover a time interval from the beginning of 1992 to 2012. We then download the actual data (which can take really long):&#xD;
&#xD;
    Monitor[For[k = 1, k &amp;lt;= Length[filenamesV], k++, &#xD;
      Export[&amp;#034;~/Desktop/OceanVelocities/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;, &#xD;
       ToExpression[StringSplit[StringSplit[#, &amp;#034;],&amp;#034;][[2]], &amp;#034;,&amp;#034;]] &amp;amp; /@ &#xD;
        StringSplit[Import[filenamesV[[k]]], &amp;#034;VVEL.VVEL[VVEL.TIME=&amp;#034;][[&#xD;
         2 ;;]] ]], &#xD;
     ProgressIndicator[Dynamic[k], {0, Length[filenamesV]}]]&#xD;
&#xD;
and&#xD;
&#xD;
    Monitor[For[k = 1, k &amp;lt;= Length[filenamesU], k++, &#xD;
      Export[&amp;#034;~/Desktop/OceanVelocities/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;, &#xD;
       ToExpression[StringSplit[StringSplit[#, &amp;#034;],&amp;#034;][[2]], &amp;#034;,&amp;#034;]] &amp;amp; /@ &#xD;
        StringSplit[Import[filenamesU[[k]]], &amp;#034;UVEL.UVEL[UVEL.TIME=&amp;#034;][[&#xD;
         2 ;;]] ]], &#xD;
     ProgressIndicator[Dynamic[k], {0, Length[filenamesU]}]]&#xD;
&#xD;
This will download about 16GB worth of data. You will, however, get reasonable results if you only use 30 frames, i.e. if you substitute Length[filenamesU] and Length[filenamesV] by 30. We will now create a figure for the first frame.&#xD;
&#xD;
    velV1 = Import[&amp;#034;~/Desktop/OceanVelocities/velV1.csv&amp;#034;];&#xD;
    velU1 = Import[&amp;#034;~/Desktop/OceanVelocities/velU1.csv&amp;#034;];&#xD;
&#xD;
We can now generate the velocity vectors for each point on the surface of the earth&#xD;
&#xD;
    veltot = Table[{velU1[[i, j]], velV1[[i, j]]}, {i, 1, 720}, {j, 1, 1440}];&#xD;
&#xD;
and then clean the data&#xD;
&#xD;
    veltot2 = Table[If[((StringQ[#[[1]]] || StringQ[#[[2]]]) &amp;amp; /@ {veltot[[i, j]] })[[1]], {0., 0.}, {velU1[[i, j]], velV1[[i, j]]}], {i, 1, 720}, {j, 1, 1440}];&#xD;
&#xD;
We can also calculate the speed at each point.&#xD;
&#xD;
    veltottot = Table[If[((StringQ[#[[1]]] || StringQ[#[[2]]]) &amp;amp; /@ {veltot[[i, j]] })[[1]], 0., Norm[{velU1[[i, j]], velV1[[i, j]]}]], {i, 1, 720}, {j, 1, 1440}];&#xD;
&#xD;
This next function will produce a visualisation of the speed profile for the first frame.&#xD;
&#xD;
    Show[ArrayPlot[Reverse[veltottot], PlotLegends -&amp;gt; Automatic, ImageSize -&amp;gt; Full, ColorFunction -&amp;gt; &amp;#034;TemperatureMap&amp;#034;], ListVectorPlot[Transpose[veltot2], VectorPoints -&amp;gt; 50]]&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
Note the incredible fine-structure in that image. We could now produce an animation for all frames. This will, however, be too large for the memory of most computers, so I would not execute it. If you only use the first 30 frames you get a reasonable idea of its working.&#xD;
&#xD;
    framesflow = {}; Monitor[&#xD;
     For[k = 1, k &amp;lt;= Length[filenamesU], k++, &#xD;
      velU1 = Import[&amp;#034;~/Desktop/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;]; &#xD;
      velV1 = Import[&amp;#034;~/Desktop/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;];&#xD;
      veltot = Table[{velU1[[i, j]], velV1[[i, j]]}, {i, 1, 720}, {j, 1, 1440}]; &#xD;
      AppendTo[framesflow, ArrayPlot[Reverse[Table[If[((StringQ[#[[1]]] || StringQ[#[[2]]]) &amp;amp; /@ {veltot[[i,j]] })[[1]], 0., Norm[{velU1[[i, j]], velV1[[i, j]]}]], {i, 1, 720}, {j, 1, 1440}]], PlotLegends -&amp;gt; Automatic, ImageSize -&amp;gt; Full, ColorFunction -&amp;gt; &amp;#034;TemperatureMap&amp;#034;]]], k];&#xD;
&#xD;
This following command exports all the frames as individual gif files, which can later be combined into a gif animation. &#xD;
&#xD;
    Monitor[For[k = 1, k &amp;lt;= Length[filenamesU], k++, &#xD;
       velU1 = Import[&#xD;
         &amp;#034;~/Desktop/OceanVelocities/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;]; &#xD;
       velV1 = Import[&#xD;
         &amp;#034;~/Desktop/OceanVelocities/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;];&#xD;
       veltot = &#xD;
        Table[{velU1[[i, j]], velV1[[i, j]]}, {i, 1, 720}, {j, 1, 1440}]; &#xD;
       Export[&amp;#034;~/Desktop/MovieOut/frame&amp;#034; &amp;lt;&amp;gt; ToString[1000 + k] &amp;lt;&amp;gt; &amp;#034;.gif&amp;#034;, &#xD;
        ArrayPlot[Reverse[Table[If[((StringQ[#[[1]]] || StringQ[#[[2]]]) &amp;amp; /@ {veltot[[i,j]] })[[1]], 0., Norm[{velU1[[i, j]], velV1[[i, j]]}]], {i, 1, 720}, {j, 1, 1440}]], PlotLegends -&amp;gt; None, ImageSize -&amp;gt; {1440, 730}, ColorFunction -&amp;gt; &amp;#034;TemperatureMap&amp;#034;]]], k];&#xD;
&#xD;
Another advantage of saving the frames is that we can use them as background for various scenarios and thereby decrease our computation time substantially. Here is a short animation of the first couple of frames.&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
Now we get the trajectories of radioactive particles that are released into the ocean at the approximate site of the Fukushima power plant. We make the assumption that the particles simply follow the flow. Also, we use the vectorfield starting on 2nd January 1992. The overall patterns of the ocean currents seem to be reasonably stable over the years so that for this conceptual study this assumption will have to suffice. It is of course easy to adapt to the actual date. &#xD;
&#xD;
We first need to introduce a formula to convert the data grid to the surface of the earth. &#xD;
&#xD;
    ClearAll[&amp;#034;Global`*&amp;#034;];&#xD;
    f[teta_, r_, vx_, vy_] := {vx/(r*Sin[2*Pi*teta/4./360.]*2*Pi/360/4)*24*3600, vy/(N[r*2*Pi/360/4])*24*3600};&#xD;
    teta = 1; r = 6360000;&#xD;
&#xD;
We now place 20000 particle into the see close to the location of Fukushima. We add a small random number to the position to model a &amp;#034;cloud&amp;#034; of particles.&#xD;
&#xD;
    teilreinpos = &#xD;
     Table[{3, 511 + RandomVariate[NormalDistribution[0., 1.]], 568 + RandomVariate[NormalDistribution[0., 1.]]}, {m, 1, 20000}]; &#xD;
&#xD;
This is the main part of the program. We use the velocity to update the position of the particles. We then use the back-ground frames generated above and overlay the particle positions.&#xD;
&#xD;
    trajectories = {teilreinpos};&#xD;
    Monitor[Do[&#xD;
       velVt = Table[&#xD;
         If[StringQ[#], &#xD;
              0.1*(ToExpression[#[[&#xD;
                     3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
                StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
          Import[&amp;#034;~/Desktop/OceanVelocities/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &#xD;
            &amp;#034;.csv&amp;#034;, &amp;#034;CSV&amp;#034;], {k, i - 2, i + 2}];&#xD;
       velUt = &#xD;
        Table[If[StringQ[#], &#xD;
              0.1*(ToExpression[#[[&#xD;
                     3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
                StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
          Import[&amp;#034;~/Desktop/OceanVelocities/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &#xD;
            &amp;#034;.csv&amp;#034;, &amp;#034;CSV&amp;#034;], {k, i - 2, i + 2}];&#xD;
       xfunc = ListInterpolation[velUt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
       yfunc = ListInterpolation[velVt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
       AppendTo[trajectories, &#xD;
        Nest[({#[[1]], Mod[#[[2]], 720], &#xD;
               Mod[#[[3]], 1440]}) &amp;amp; /@ (# + {0.1, &#xD;
                0.1*f[#[[2]], r, xfunc[#[[1]] - i + 3., #[[2]], #[[3]]], &#xD;
                   yfunc[#[[1]] - i + 3., #[[2]], #[[3]]]][[2]] , &#xD;
                0.1*f[#[[2]], r, xfunc[#[[1]] - i + 3., #[[2]], #[[3]]], &#xD;
                   yfunc[#[[1]] - i + 3., #[[2]], #[[3]]]][[1]] } &amp;amp;) , # ,&#xD;
            10] &amp;amp; /@ trajectories[[-1]]]; &#xD;
       Export[&amp;#034;~/Desktop/OilSpillFrames/frame&amp;#034; &amp;lt;&amp;gt; ToString[1000 + i] &amp;lt;&amp;gt; &#xD;
         &amp;#034;.gif&amp;#034;, Show[&#xD;
         Import[&amp;#034;~/Desktop/MovieOut/frame&amp;#034; &amp;lt;&amp;gt; ToString[1000 + i] &amp;lt;&amp;gt; &#xD;
           &amp;#034;.gif&amp;#034;], &#xD;
         Graphics[{Red, Disk[#, 1]} &amp;amp; /@ (0.9361111 # + {44., 28.} &amp;amp; /@ &#xD;
             trajectories[[i - 2, All, {3, 2}]]), &#xD;
          PlotRange -&amp;gt; {{0, 1440}, {0, 720}}]]];&#xD;
       , {i, 3, 1238}], i];&#xD;
&#xD;
Here are a couple of frames:&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
All frames yield the following animation. &#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
Also see the higher quality animation on Youtube. [https://youtu.be/8icgMg6lt0Y][7]&#xD;
&#xD;
Similarly we can study where rubbish, such as plastic bags would accumulate in the oceans due to the currents; these are also called [gyres of marine debris particles][8]. See also [this link][9].&#xD;
&#xD;
We start out just like for the Fukushima simulation:&#xD;
&#xD;
    ClearAll[&amp;#034;Global`*&amp;#034;];&#xD;
    f[teta_, r_, vx_, vy_] := {vx/(r*Sin[2*Pi*teta/4./360.]*2*Pi/360/4)*24*3600, vy/(N[r*2*Pi/360/4])*24*3600};&#xD;
    teta = 1; r = 6360000;&#xD;
&#xD;
In this case we have to distribute the particles randomly in all oceans. So I will basically distribute them everywhere and then ingore the ones over land mass, by checking whether the background flow speed is zero. So we first calculate the speed.&#xD;
&#xD;
    velVt = Table[&#xD;
       If[StringQ[#], &#xD;
            0.1*(ToExpression[#[[3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
              StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
        Import[&amp;#034;~/Desktop/OceanVelocities/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;, &#xD;
         &amp;#034;CSV&amp;#034;], {k, 3 - 2, 3 + 2}];&#xD;
    velUt = Table[&#xD;
       If[StringQ[#], &#xD;
            0.1*(ToExpression[#[[3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
              StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
        Import[&amp;#034;~/Desktop/OceanVelocities/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &amp;#034;.csv&amp;#034;, &#xD;
         &amp;#034;CSV&amp;#034;], {k, 3 - 2, 3 + 2}];&#xD;
    &#xD;
    xfunc = ListInterpolation[velUt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
    yfunc = ListInterpolation[velVt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
&#xD;
We then distribute the particles everywhere&#xD;
&#xD;
    teilreinpospre = Table[{3, RandomReal[{0, 720}], RandomReal[{0, 1440}]}, {k, 1, 30000}];&#xD;
&#xD;
and delete the particles with zero-speed-background.&#xD;
&#xD;
    teilreinpos = Select[teilreinpospre, xfunc[3, #[[2]], #[[3]]] != 0. &amp;amp;&amp;amp; yfunc[3, #[[2]], #[[3]]] != 0. &amp;amp;];&#xD;
&#xD;
Now we iterate as before. &#xD;
&#xD;
    trajectories = {teilreinpos};&#xD;
    Monitor[Do[&#xD;
       velVt = Table[&#xD;
         If[StringQ[#], &#xD;
              0.1*(ToExpression[#[[&#xD;
                     3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
                StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
          Import[&amp;#034;~/Desktop/OceanVelocities/velV&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &#xD;
            &amp;#034;.csv&amp;#034;, &amp;#034;CSV&amp;#034;], {k, i - 2, i + 2}];&#xD;
       velUt = &#xD;
        Table[If[StringQ[#], &#xD;
              0.1*(ToExpression[#[[&#xD;
                     3]]]*10^(ToExpression[#[[1]]]) ) &amp;amp; /@ { &#xD;
                StringSplit[#, {&amp;#034; &amp;#034;, &amp;#034;*&amp;#034;}]}, 1.*#] &amp;amp; /@ # &amp;amp; /@ &#xD;
          Import[&amp;#034;~/Desktop/OceanVelocities/velU&amp;#034; &amp;lt;&amp;gt; ToString[k] &amp;lt;&amp;gt; &#xD;
            &amp;#034;.csv&amp;#034;, &amp;#034;CSV&amp;#034;], {k, i - 2, i + 2}];&#xD;
       xfunc = ListInterpolation[velUt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
       yfunc = ListInterpolation[velVt, {{1, 5}, {0, 720}, {0, 1440}}];&#xD;
       AppendTo[trajectories, &#xD;
        Nest[({#[[1]], Mod[#[[2]], 720], &#xD;
               Mod[#[[3]], 1440]}) &amp;amp; /@ (# + {0.1, &#xD;
                RandomVariate[NormalDistribution[0., 0.05]] + &#xD;
                 0.1*f[#[[2]], r, xfunc[#[[1]] - i + 3., #[[2]], #[[3]]], &#xD;
                    yfunc[#[[1]] - i + 3., #[[2]], #[[3]]]][[2]] , &#xD;
                RandomVariate[NormalDistribution[0., 0.05]] + &#xD;
                 &#xD;
                 0.1*f[#[[2]], r, xfunc[#[[1]] - i + 3., #[[2]], #[[3]]], &#xD;
                    yfunc[#[[1]] - i + 3., #[[2]], #[[3]]]][[&#xD;
                   1]] } &amp;amp;) , # , 10] &amp;amp; /@ trajectories[[-1]]]; &#xD;
       Export[&amp;#034;~/Desktop/Rubbish/frame&amp;#034; &amp;lt;&amp;gt; ToString[1000 + i] &amp;lt;&amp;gt; &amp;#034;.gif&amp;#034;, &#xD;
        Show[Import[&#xD;
          &amp;#034;~/Desktop/MovieOut/frame&amp;#034; &amp;lt;&amp;gt; ToString[1000 + i] &amp;lt;&amp;gt; &amp;#034;.gif&amp;#034;], &#xD;
         Graphics[{Red, Disk[#, 1]} &amp;amp; /@ (0.9361111 # + {44., 28.} &amp;amp; /@ &#xD;
             trajectories[[i - 2, All, {3, 2}]]), &#xD;
          PlotRange -&amp;gt; {{0, 1440}, {0, 720}}]]];&#xD;
       , {i, 3, 1238}], i];&#xD;
&#xD;
Here are some frames:&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
This leads to the following animation (due to file size I only show a later part of the simulation).&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
Please have a look at the [higher resolution and longer animation on Youtube][11]. &#xD;
&#xD;
It becomes clear that there are 5 large areas of rubbish in the oceans. This and their approximate positions are in accordance with their known positions and satellite data. &#xD;
&#xD;
This type of simulation is very much simplified. We are making many assumptions, but by using the &amp;#034;observed&amp;#034; velocity field, we get around the fluid mechanical problems usually involved in these problems. The main idea can be used for many other problems as well. For example, we could iterate backwards to see where particles came from. &#xD;
&#xD;
So I challenge you to simulate the following. Several fragments of the crashed Malaysian airplane have been found. Can you use the flow, invert the time direction and simulate where the parts must have come from? I wonder whether you can make better assmumptions than me (the larger fragments drift differently in the currents), and whether your point of origin correponds to mine.&#xD;
&#xD;
I would love to hear back from you, and get ideas of how to apply this. I had a previous discussion with Vitaliy Kaurov about this, and there are certainly much nicer ways of representing the results. Any ideas are welcome.&#xD;
&#xD;
Cheers,  &#xD;
Marco&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Rubbish-final-optimize.gif&amp;amp;userId=20103&#xD;
  [2]: http://community.wolfram.com/web/bschelter&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2015-10-24at01.21.46.png&amp;amp;userId=48754&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=VelocityField.gif&amp;amp;userId=48754&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2015-10-24at01.28.35.png&amp;amp;userId=48754&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Fukushima-ok.gif&amp;amp;userId=48754&#xD;
  [7]: https://youtu.be/8icgMg6lt0Y&#xD;
  [8]: https://en.wikipedia.org/wiki/Great_Pacific_garbage_patch&#xD;
  [9]: https://en.wikipedia.org/wiki/File:Garbage_Patch_Visualization_Experiment.webm&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2015-10-24at01.36.47.png&amp;amp;userId=48754&#xD;
  [11]: https://youtu.be/ttJPAIBch8U</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2015-10-24T00:43:19Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2448552">
    <title>[WSG22] Daily Study Group: Quantum Computation Framework (Jan 24, 2022)</title>
    <link>https://community.wolfram.com/groups/-/m/t/2448552</link>
    <description>![enter image description here][1]&#xD;
![enter image description here][2]&#xD;
A new study group devoted to [Quantum Computation Framework][3] begins Monday Jan 24th! A list of daily topics can be found on our Daily Study Groups page. This group will be led by me and few other developers from Wolfram Quantum Team. We will meet daily, Monday to Friday. Study group sessions include time for exercises, discussion and Q&amp;amp;A. This study group will help you acquire an intro knowledge of quantum computing and learn how to implement quantum algorithms in the [Wolfram Quantum Computation Framework][4]. Feel free to explore [our framework][5].&#xD;
&#xD;
Sign up: [Study group registration page][6]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2022-01-17at3.53.39PM.png&amp;amp;userId=1539902&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=FrontImage.jpeg&amp;amp;userId=1539902&#xD;
  [3]: https://www.bigmarker.com/series/daily-study-group-quantum-computation-framework/series_details?utm_bmcr_source=wolfram-u&#xD;
  [4]: https://www.wolframcloud.com/obj/wolframquantumframework/DeployedResources/Paclet/Wolfram/QuantumFramework/&#xD;
  [5]: https://www.wolframcloud.com/obj/wolframquantumframework/DeployedResources/Paclet/Wolfram/QuantumFramework/&#xD;
  [6]: https://www.bigmarker.com/series/daily-study-group-quantum-computation-framework/series_details?utm_bmcr_source=community</description>
    <dc:creator>Mohammad Bahrami</dc:creator>
    <dc:date>2022-01-17T18:20:25Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/121507">
    <title>Optimal lighting configuration of 5 lamps in a square room</title>
    <link>https://community.wolfram.com/groups/-/m/t/121507</link>
    <description>[b]With 5 point-source lights in a square room, what is the optimal configuration for even lighting?[/b]&#xD;
&#xD;
To make this question concrete, say that each wall has length 1, the room has no height (i.e., two dimensional) and we have five identical lights that are pointsized and want to know the optimal placement that maximizes even lighting.  That could mean&#xD;
[mcode]f = 1/((x - x1)^2 + (y - y1)^2) + 1/((x - x2)^2 + (y - y2)^2) + 1/((x - x3)^2 + (y - y3)^2) + 1/((x - x4)^2 + (y - y4)^2) + 1/((x - x5)^2 + (y - y5)^2);[/mcode]&#xD;
a) maximizing the value of the minimal illumination [mcode]Minimize[f, {x,0,1},{y,0,1}][/mcode]or an integral measure like&#xD;
&#xD;
b) maximizing the total illumination where the brightest areas are considered as being some default value, e.g., the value of [mcode]Integrate[Min[f, f0], {x,0,1},{y,0,1}][/mcode]&#xD;
For an example configuration of light sources with&#xD;
[mcode]f = With[{n = 5}, Sum[1/((x - (.5 + .45 Cos[2 Pi i/n]))^2 + (y - (.5 + .45 Sin[2 Pi i/n]))^2), {i, 0, n - 1}]]&#xD;
[/mcode]and then here is the minimum illumination&#xD;
[mcode]NMinimize[{f, 0 &amp;lt;= x &amp;lt;= 1 &amp;amp;&amp;amp; 0 &amp;lt;= y &amp;lt;= 1}, {x, y}] (*{14.349, {x -&amp;gt; 1., y -&amp;gt; 1.}}*)&#xD;
[/mcode]and here that point is shown on a contour plot&#xD;
&#xD;
[img=width: 360px; height: 359px;]/c/portal/getImageAttachment?filename=lights5.jpg&amp;amp;userId=23275[/img]&#xD;
&#xD;
For that configuration here is the integral (which I had to approximate with a Sum)&#xD;
[mcode]Sum[Min[1.2 (14.349), f], {x, 0.0001, 1, .01}, {y, 0.0001, 1, .01}]/10^4 (*17.2146*)&#xD;
[/mcode]I&amp;#039;d be interested in optimization approaches, but also aesthetic approaches, e.g., symmetries, angles, shadows, or patterns made by contour lines.&#xD;
&#xD;
To generalize, not only other numbers of lights, but try tacking on albedo of 50% so the wall reflect half of the light they receive.</description>
    <dc:creator>Todd Rowland</dc:creator>
    <dc:date>2013-09-10T16:45:23Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1433064">
    <title>Solver for unsteady flow with the use of Mathematica FEM</title>
    <link>https://community.wolfram.com/groups/-/m/t/1433064</link>
    <description>![fig7][331]&#xD;
&#xD;
I started the discussion  [here][1] but I also want to repeat on this forum. &#xD;
There are many commercial and open code for solving the problems of unsteady flows. &#xD;
We are interested in the possibility of solving these problems using Mathematica FEM. Previously proposed solvers for stationary incompressible isothermal flows:&#xD;
&#xD;
Solving 2D Incompressible Flows using Finite Elements: &#xD;
http://community.wolfram.com/groups/-/m/t/610335&#xD;
&#xD;
FEM Solver for Navier-Stokes equations in 2D: &#xD;
http://community.wolfram.com/groups/-/m/t/611304&#xD;
&#xD;
Nonlinear FEM Solver for Navier-Stokes equations in 2D: &#xD;
https://mathematica.stackexchange.com/questions/94914/nonlinear-fem-solver-for-navier-stokes-equations-in-2d/96579#96579&#xD;
&#xD;
We give several examples of the successful application of the finite element method for solving unsteady problem including nonisothermal and compressible flows. We will begin with two standard tests that were proposed to solve this class of problems by &#xD;
&#xD;
M. Schäfer and S. Turek, Benchmark computations of laminar ?ow around a cylinder (With support by F. Durst, E. Krause and R. Rannacher). In E. Hirschel, editor, Flow Simulation with High-Performance Computers II. DFG priority research program results 1993-1995, number 52 in Notes Numer. Fluid Mech., pp.547566. Vieweg, Weisbaden, 1996. https://www.uio.no/studier/emner/matnat/math/MEK4300/v14/undervisningsmateriale/schaeferturek1996.pdf&#xD;
&#xD;
&#xD;
&#xD;
![fig8][332]&#xD;
&#xD;
&#xD;
&#xD;
Let us consider the flow in a flat channel around a cylinder at Reynolds number = 100, when self-oscillations occur leading to the detachment of vortices in the aft part of cylinder. In this problem it is necessary to calculate drag coe?cient, lift coe?cient  and pressure di?erence  in the frontal and aft part of the cylinder as functions of time, maximum drag coe?cient, maximum lift coe?cient , Strouhal number  and pressure di?erence $\Delta P(t)$ at $t = t0 +1/2f$. The frequency f is determined by the period of oscillations of lift coe?cient f=f(c_L). The data for this test, the code and the results are shown below. &#xD;
&#xD;
    H = .41; L = 2.2; {x0, y0, r0} = {1/5, 1/5, 1/20}; &#xD;
    ? = RegionDifference[Rectangle[{0, 0}, {L, H}], Disk[{x0, y0}, r0]];&#xD;
    RegionPlot[?, AspectRatio -&amp;gt; Automatic]&#xD;
    &#xD;
    K = 2000; Um = 1.5; ? = 10^-3; t0 = .004;&#xD;
    U0[y_, t_] := 4*Um*y/H*(1 - y/H)&#xD;
    UX[0][x_, y_] := 0;&#xD;
    VY[0][x_, y_] := 0;&#xD;
    P0[0][x_, y_] := 0;&#xD;
    Do[&#xD;
      {UX[i], VY[i], P0[i]} = &#xD;
       NDSolveValue[{{Inactive[&#xD;
               Div][({{-?, 0}, {0, -?}}.Inactive[Grad][&#xD;
                 u[x, y], {x, y}]), {x, y}] + &#xD;
    \!\(\*SuperscriptBox[\(p\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;1&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;0&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x, y] + (u[x, y] - UX[i - 1][x, y])/t0 + &#xD;
             UX[i - 1][x, y]*D[u[x, y], x] + &#xD;
             VY[i - 1][x, y]*D[u[x, y], y], &#xD;
            Inactive[&#xD;
               Div][({{-?, 0}, {0, -?}}.Inactive[Grad][&#xD;
                 v[x, y], {x, y}]), {x, y}] + &#xD;
    \!\(\*SuperscriptBox[\(p\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;0&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;1&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x, y] + (v[x, y] - VY[i - 1][x, y])/t0 + &#xD;
             UX[i - 1][x, y]*D[v[x, y], x] + &#xD;
             VY[i - 1][x, y]*D[v[x, y], y], &#xD;
    \!\(\*SuperscriptBox[\(u\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;1&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;0&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x, y] + &#xD;
    \!\(\*SuperscriptBox[\(v\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;0&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;1&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x, y]} == {0, 0, 0} /. ? -&amp;gt; ?, {&#xD;
          DirichletCondition[{u[x, y] == U0[y, i*t0], v[x, y] == 0}, &#xD;
           x == 0.], &#xD;
          DirichletCondition[{u[x, y] == 0., v[x, y] == 0.}, &#xD;
           0 &amp;lt;= x &amp;lt;= L &amp;amp;&amp;amp; y == 0 || y == H], &#xD;
          DirichletCondition[{u[x, y] == 0, &#xD;
            v[x, y] == 0}, (x - x0)^2 + (y - y0)^2 == r0^2], &#xD;
          DirichletCondition[p[x, y] == P0[i - 1][x, y], x == L]}}, {u, v,&#xD;
          p}, {x, y} ? ?, &#xD;
        Method -&amp;gt; {&amp;#034;FiniteElement&amp;#034;, &#xD;
          &amp;#034;InterpolationOrder&amp;#034; -&amp;gt; {u -&amp;gt; 2, v -&amp;gt; 2, p -&amp;gt; 1}, &#xD;
          &amp;#034;MeshOptions&amp;#034; -&amp;gt; {&amp;#034;MaxCellMeasure&amp;#034; -&amp;gt; 0.001}}], {i, 1, K}];&#xD;
    {ContourPlot[UX[K/2][x, y], {x, y} ? ?, &#xD;
       AspectRatio -&amp;gt; Automatic, ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, &#xD;
       FrameLabel -&amp;gt; {x, y}, PlotLegends -&amp;gt; Automatic, Contours -&amp;gt; 20, &#xD;
       PlotPoints -&amp;gt; 25, PlotLabel -&amp;gt; u, MaxRecursion -&amp;gt; 2], &#xD;
      ContourPlot[VY[K/2][x, y], {x, y} ? ?, &#xD;
       AspectRatio -&amp;gt; Automatic, ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, &#xD;
       FrameLabel -&amp;gt; {x, y}, PlotLegends -&amp;gt; Automatic, Contours -&amp;gt; 20, &#xD;
       PlotPoints -&amp;gt; 25, PlotLabel -&amp;gt; v, MaxRecursion -&amp;gt; 2, &#xD;
       PlotRange -&amp;gt; All]} // Quiet&#xD;
    {DensityPlot[UX[K][x, y], {x, y} ? ?, &#xD;
       AspectRatio -&amp;gt; Automatic, ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, &#xD;
       FrameLabel -&amp;gt; {x, y}, PlotLegends -&amp;gt; Automatic, PlotPoints -&amp;gt; 25, &#xD;
       PlotLabel -&amp;gt; u, MaxRecursion -&amp;gt; 2], &#xD;
      DensityPlot[VY[K][x, y], {x, y} ? ?, &#xD;
       AspectRatio -&amp;gt; Automatic, ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, &#xD;
       FrameLabel -&amp;gt; {x, y}, PlotLegends -&amp;gt; Automatic, PlotPoints -&amp;gt; 25, &#xD;
       PlotLabel -&amp;gt; v, MaxRecursion -&amp;gt; 2, PlotRange -&amp;gt; All]} // Quiet&#xD;
    dPl = Interpolation[&#xD;
       Table[{i*t0, (P0[i][.15, .2] - P0[i][.25, .2])}, {i, 0, K, 1}]];&#xD;
    &#xD;
    &#xD;
    cD = Table[{t0*i, NIntegrate[(-?*(-Sin[?] (Sin[?] &#xD;
    \!\(\*SuperscriptBox[\(UX[i]\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;0&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;1&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x0 + r Cos[?], &#xD;
                     y0 + r Sin[?]] + Cos[?] &#xD;
    \!\(\*SuperscriptBox[\(UX[i]\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;1&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;0&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x0 + r Cos[?], &#xD;
                     y0 + r Sin[?]]) + Cos[?] (Sin[?] &#xD;
    \!\(\*SuperscriptBox[\(VY[i]\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;0&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;1&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x0 + r Cos[?], &#xD;
                     y0 + r Sin[?]] + Cos[?] &#xD;
    \!\(\*SuperscriptBox[\(VY[i]\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;1&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;0&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x0 + r Cos[?], &#xD;
                     y0 + r Sin[?]]))*Sin[?] - &#xD;
             P0[i][x0 + r Cos[?], y0 + r Sin[?]]*&#xD;
              Cos[?]) /. {r -&amp;gt; r0}, {?, 0, 2*Pi}]}, {i, &#xD;
         1000, 2000}]; // Quiet&#xD;
    &#xD;
    cL = Table[{t0*i, -NIntegrate[(-?*(-Sin[?] (Sin[?] &#xD;
    \!\(\*SuperscriptBox[\(UX[i]\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;0&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;1&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x0 + r Cos[?], &#xD;
                      y0 + r Sin[?]] + Cos[?] &#xD;
    \!\(\*SuperscriptBox[\(UX[i]\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;1&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;0&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x0 + r Cos[?], &#xD;
                      y0 + r Sin[?]]) + &#xD;
                 Cos[?] (Sin[?] &#xD;
    \!\(\*SuperscriptBox[\(VY[i]\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;0&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;1&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x0 + r Cos[?], &#xD;
                      y0 + r Sin[?]] + Cos[?] &#xD;
    \!\(\*SuperscriptBox[\(VY[i]\), &#xD;
    TagBox[&#xD;
    RowBox[{&amp;#034;(&amp;#034;, &#xD;
    RowBox[{&amp;#034;1&amp;#034;, &amp;#034;,&amp;#034;, &amp;#034;0&amp;#034;}], &amp;#034;)&amp;#034;}],&#xD;
    Derivative],&#xD;
    MultilineFunction-&amp;gt;None]\)[x0 + r Cos[?], &#xD;
                      y0 + r Sin[?]]))*Cos[?] + &#xD;
              P0[i][x0 + r Cos[?], y0 + r Sin[?]]*&#xD;
               Sin[?]) /. {r -&amp;gt; r0}, {?, 0, 2*Pi}]}, {i, &#xD;
         1000, 2000}]; // Quiet&#xD;
    {ListLinePlot[cD, &#xD;
      AxesLabel -&amp;gt; {&amp;#034;t&amp;#034;, &amp;#034;\!\(\*SubscriptBox[\(c\), \(D\)]\)&amp;#034;}], &#xD;
     ListLinePlot[cL, &#xD;
      AxesLabel -&amp;gt; {&amp;#034;t&amp;#034;, &amp;#034;\!\(\*SubscriptBox[\(c\), \(L\)]\)&amp;#034;}], &#xD;
     Plot[dPl[x], {x, 0, 8}, AxesLabel -&amp;gt; {&amp;#034;t&amp;#034;, &amp;#034;?P&amp;#034;}]}&#xD;
&#xD;
    f002 = FindFit[cL, a*.5 + b*.8*Sin[k*16*t + c*1.], {a, b, k, c}, t]&#xD;
    &#xD;
    &#xD;
    Plot[Evaluate[a*.5 + b*.8*Sin[k*16*t + c*1.] /. f002], {t, 4, 8}, &#xD;
     Epilog -&amp;gt; Map[Point, cL]]&#xD;
    &#xD;
    k0=k/.f002;&#xD;
    Struhalnumber = .1*16*k0/2/Pi&#xD;
&#xD;
    &#xD;
    cLm = MaximalBy[cL, Last]&#xD;
    &#xD;
    sol = {Max[cD[[All, 2]]], Max[cL[[All, 2]]], Struhalnumber, &#xD;
      dPl[cLm[[1, 1]] + Pi/(16*k0)]}&#xD;
&#xD;
In Fig. 1 shows the components of the flow velocity and the required coefficients. Our solution of the problem and what is required in the test&#xD;
&#xD;
    {3.17805, 1.03297, 0.266606, 2.60427}&#xD;
    &#xD;
    lowerbound= { 3.2200, 0.9900, 0.2950, 2.4600};&#xD;
    upperbound = {3.2400, 1.0100, 0.3050, 2.5000};&#xD;
&#xD;
![Fig1][2]&#xD;
Note that our results differ from allowable by several percent, but if you look at all the results of Table 4 from the cited article, then the agreement is quite acceptable.The worst prediction is for the Strouhal number. We note that we use the explicit Euler method, which gives an underestimate of the Strouhal number, as follows from the data in Table 4.  &#xD;
The next test differs from the previous one in that the input speed varies according to the `U0[y_, t_] := 4*Um*y/H*(1 - y/H)*Sin[Pi*t/8]`. It is necessary to determine the time dependence of the drag and lift parameters for a half-period of oscillation, as well as the pressure drop at the last moment of time. In Fig. 2 shows the components of the flow velocity and the required coefficients. Our solution of the problem and what is required in the test&#xD;
&#xD;
    sol = {3.0438934441256595`, &#xD;
       0.5073345082785012`, -0.11152933279750943`};&#xD;
    &#xD;
    lowerbound = {2.9300, 0.4700, -0.1150};&#xD;
    upperbound = {2.9700, 0.4900, -0.1050};&#xD;
![Fig2][3]&#xD;
For this test, the agreement with the data in Table 5 is good. Consequently, the two tests are almost completely passed. &#xD;
I wrote and debugged this code using Mathematics 11.01. But when I ran this code using Mathematics 11.3, I got strange pictures, for example, the disk is represented as a hexagon, the size of the area is changed. &#xD;
![Fig3][4]&#xD;
In addition, the numerical solution of the problem has changed, for example, test 2D2&#xD;
&#xD;
    {3.17805, 1.03297, 0.266606, 2.60427} v11.01&#xD;
    {3.15711, 1.11377, 0.266043, 2.54356} v11.03&#xD;
The attached file contains the working code for test 2D3 describing the flow around the cylinder in a flat channel with a change in the flow velocity.&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=test2D2.png&amp;amp;userId=1218692&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=test2D2.png&amp;amp;userId=1218692&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=test2D3.png&amp;amp;userId=1218692&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Math11.3.png&amp;amp;userId=1218692&#xD;
&#xD;
  [331]: http://community.wolfram.com//c/portal/getImageAttachment?filename=CylinderRe100test2D2.gif&amp;amp;userId=1218692&#xD;
  [332]: http://community.wolfram.com//c/portal/getImageAttachment?filename=2D2test.png&amp;amp;userId=1218692</description>
    <dc:creator>Alexander Trounev</dc:creator>
    <dc:date>2018-08-31T11:44:04Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2399430">
    <title>Rogue wave: stable fluids algorithm for air/water interface simulation</title>
    <link>https://community.wolfram.com/groups/-/m/t/2399430</link>
    <description>*SUPPLEMENTARY WOLFRAM MATERIALS for the ARTICLE:*&#xD;
&amp;gt; Sergio Manzetti, Alexander Trounev (2021).&#xD;
&#xD;
&amp;gt; A Navier-Stokes model for Rogue wave simulation.&#xD;
&#xD;
&amp;gt; ResearchGate, Technical Report. https://www.researchgate.net/publication/354527324&#xD;
&#xD;
&#xD;
------&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
ABSTRACT&#xD;
--------------------------------------&#xD;
&#xD;
Rogue waves are anomalous phenomena occurring over large sea bodies, where they are said appear out of nowhere and disappear without a trace. Simulations of rogue waves have been carried over the last 40 years, with several models published. In this paper we investigate the formation of rogue waves by two models: I. the Navier-Stokes equation where we take into account density and viscosity gradient on the air-water interface due to diffusion and II. a Korteveg de Vries-type model for quantum jumps which we developed earlier. We derive also a stable fluids algorithm which we use to compute nonlinear waves interaction produced by the wind. The results are discussed and compared.&#xD;
&#xD;
This code solves problem of viscous incompressible flow with gravitational force in a rectangle with periodic boundary condition on the left and right side and with Dirichlet condition on the top and bottom side. &#xD;
In the initial condition fluid velocity is periodic wave, and density has unit step like distribution on the air/water interface. &#xD;
Some other application of this code has been discussed on https://mathematica.stackexchange.com/questions/246091/stable-fluids-code-for-electromagnetic-mixture-application&#xD;
&#xD;
This model has been discussed in our report  [A Navier-Stokes model for Rogue wave simulation][2]&#xD;
&#xD;
Two phase model of air-water interface&#xD;
--------------------------------------&#xD;
&#xD;
Let us consider the system of equations describing nonlinear waves on the air-water interface. As it well known the air and the water can be considered as viscous incompressible fluids with density $\rho_a, \rho_w$,  and dynamical viscosity $\mu_a, \mu_w$ consequently. Taking into account the gravity force and diffusion on the air-water interface, we have &#xD;
$$\nabla.\bf{u}=0\\&#xD;
 \frac{\partial \mathbf{u}}{\partial t}+(\mathbf{u}.\nabla)\mathbf{u}+\frac{\nabla P}{\rho_i}=\nu_i\nabla ^2\mathbf{u}+\mathbf{f}\\\&#xD;
 \frac{\partial \phi}{\partial t} +(\mathbf{u}.\nabla)\phi=\frac{\nu_i}{Sc_i}\nabla ^2\phi\\ &#xD;
$$&#xD;
Here it is indicated $\rho_i, i=a,w $ - air and water density, $\mathbf{u}=(u_x,u_y)$ - flow velocity,  $P$ - pressure; $\bf{f}$ - force acting on the volume of the air-water mixture; $\phi$ - the interface function describing the averaged density of the air-water mixture; $Sc_i$ - analog of the Schmidt number characterized water diffusion in the air and air diffusion in the water. Note that we considered averaged effect of mass transfer on the air-water interface including drops and bubbles. &#xD;
Let us define the Cartesian coordinate system so that the $y$ axis is directed against the direction of the gravitational acceleration vector and the $x$ axis is parallel to horizon. Let suppose that the water surface relief is described by the equation $y=r(t,x,y)$ - Figure 1.&#xD;
![Figure 1. Flow geometry on the air-water interface with waves of small (left) and large (right) amplitude][3]&#xD;
&#xD;
We set the boundary conditions for the flow parameters on the top and bottom part of the boundary layer and periodic boundary conditions by coordinate $x$ as follows:&#xD;
&#xD;
$$ y=0: \mathbf{u}=0,\phi=\rho_w\\&#xD;
 y=H: \mathbf{u}=(U_0,0), \phi=\rho_a\\&#xD;
 \mathbf{u}(t,0,y)=\mathbf{u}(t,L,y)\\&#xD;
 \phi(t,0,y)=\phi(t,L,y).&#xD;
$$&#xD;
Here $H$ is the height of the boundary layer,$U_0$ is the wind velocity, $L$ is the period of the wave tray.&#xD;
We assume that at the initial time the flow velocity and interface function are given by&#xD;
&#xD;
$$ t=0, y&amp;lt;H/2:u_x = 0, u_y=V_0 \sin(2 \pi n x/L), \phi =\rho_w\\ &#xD;
 t=0, y\ge H/2: u_x=U_0, u_y=V_0\sin (2 \pi n x/L), \phi =\rho_a\\&#xD;
 $$&#xD;
This problem can be solved with using numerical methods and an appropriate turbulence model. &#xD;
We have used stable fluids algorithm (Stam1999, Stam 2000) to solve 2D Navier-Stokes equations and to simulate nonlinear waves interaction on the air-water interface with a given wind velocity on the top of the boundary layer. While in the standard gravity wave theory the air-water interface is considered mainly as a potential flow, in our approach we take into account velocity, viscosity and density gradients on the interface. Since air/water density ratio is about $10^{-3}$ we have some challenging numerical problem. To solve this problem we made some simplifications in the basic Navier-Stokes equations. First, we suppose that velocity is a continues field at $t&amp;gt;0$ so that flow in the water and flow in the air is an united flow continuously distributed from the bottom to the top and the periodic one in the $x$ direction. We neglect by the surface tension due to large scale of the waves.  Therefore we don&amp;#039;t need any boundary condition on the air-water interface. Second, at $t&amp;gt;0$ we introduce continues density as $\rho=\phi$ to compute velocity field on every step. Third, we use stable fluid algorithm in time in the very specific order described below.&#xD;
&#xD;
&#xD;
Stable fluids algorithm&#xD;
-----------------------&#xD;
&#xD;
&#xD;
&#xD;
1) Solve advection equation with using boundary conditions, initial data from the previous step, and an implicit algorithm&#xD;
&#xD;
$$ \frac{\partial \mathbf{u}_1}{\partial t}+(\mathbf{u}_1.\nabla) \bf{u}_1=0 $$&#xD;
&#xD;
2) Solve diffusion equation with $\nu_i=\nu_i(\phi)$, initial data $\mathbf{u}_1$, boundary conditions  and with using, for example, Gauss-Seidel relaxation algorithm  &#xD;
&#xD;
$$ \frac{\partial \mathbf {u}_2}{\partial t}-\nu_i \nabla^2 \mathbf{u}_2=0$$&#xD;
&#xD;
here $$\nu_i(\phi)=\nu_w \phi ^k, k=-0.4029$$ for the air temperature of 20C.&#xD;
&#xD;
3)  Add force to the velocity field from the previous step as follows&#xD;
&#xD;
$$&#xD;
\mathbf{u}_3=\mathbf{u}_2+\mathbf{f} dt\\&#xD;
$$&#xD;
&#xD;
To simulate force acting on the volume of air-water mixture we used approximation &#xD;
$$ f_y=-\frac{(\rho_w-\phi)(\phi-\rho_w/2)(\phi-\rho_a)}{\rho_w^2(\rho_w-\rho_a)Fr^2}&#xD;
 $$&#xD;
4) Make projection step. Here we can use two models. First model is standard projection (Stam 1999)  by solving Poison equation&#xD;
$$ t&amp;gt;0, \nabla^2 q=\nabla . \bf{u}_3\\&#xD;
 \bf{u}_4=\bf{u}_3-\nabla q&#xD;
  $$&#xD;
Note, that this step  allows us to define divergent free velocity field. &#xD;
   &#xD;
5) Update velocity field $\bf{u}_4\longrightarrow \bf{u}_5$ with using boundary conditions.&#xD;
&#xD;
6) Make diffusion step with interface function by solving diffusion equation with initial condition from the previous step, with boundary conditions, and with $\nu=\nu_i(\phi)/Sc$ as follows  &#xD;
$$ \frac{\partial \phi_1}{\partial t}-\nu \nabla^2 \phi_1=0&#xD;
$$&#xD;
7) Make advection step by solving advection equation with initial data from step 6 with boundary conditions using  an implicit algorithm (from step 1, for example),  &#xD;
$$ \frac{\partial \phi_2}{\partial t}+(\bf{u}_5.\nabla) \phi_2=0&#xD;
 $$&#xD;
8) Update interface function with boundary conditions.&#xD;
&#xD;
9) Return to step 1 with updated velocity and interface function.&#xD;
&#xD;
This algorithm can be also used in some different order, for example, in the beginning we can compute step 3 (Stam1999). Also we can make steps 6-8 first, and then compute velocity field with steps 1-5. The question about stability of the stable fluids algorithm not really solved yet. From our experience, we can&amp;#039;t do arbitrary time step, but $dt$ is limiting by the grid size as usual for more precise computation. In our computations we have used $dt=2/N$ for $N\times N$ grid. In general case the numerical solution depends on the Froude number $Fr=\frac{U_0}{\sqrt{g L}}$, Reynolds number $Re=\frac{U_0 L}{\nu_w}$, Schmidt number and number of waves in the initial data. In our computations we fixed the Froude number, so that we can put $H=L=1$. We also fixed the Reynolds number, therefore we can put $U_0=1.5, V_0=0.5$. The algorithm 1-9 has been implemented with FDM  and compiled to C with using Mathematica 12.3.  &#xD;
&#xD;
Code to simulate air/water interface with $Re=10^4, Fr=1$&#xD;
----&#xD;
&#xD;
    rhoWater20C = 1.027; nuW20C = 0.01007; rhoAir20C = 0.001204; nuA20C = 0.151;dif = 1/10000; pec = .1; U0 = 1.5; V0 = .5; dn0 = 0.997658; dn1 = 0.514102; kap = 1; n = 81; Fr = 1; F0 = 1; n1 = n + 1; sm = 600; r = 20; den = &#xD;
     ConstantArray[dn1 (1 + dn0 Tanh[-kap Range[-n1/2, n1/2]]), n1];u0 = ConstantArray[0, {n1, n1}]; Do[&#xD;
      u0[[i, j]] = U0 (1 + Tanh[kap (j - n1/2)])/2;, {i, n1}, {j, n1}];&#xD;
     v0 = ConstantArray[0., {n1, n1}]; Do[&#xD;
      v0[[i, j]] = V0 Sin[10 Pi (i - 1)/n];, {i, n1}, {j, n1}];periodic[n_, up_, ud_, ub_] := &#xD;
        Module[{bd = ub}, Do[bd[[1, i]] = .5 (bd[[n, i]] + bd[[2, i]]);&#xD;
          bd[[n + 1, i]] = bd[[1, i]]; bd[[i, 1]] = ud;&#xD;
          bd[[i, n + 1]] = up;, {i, 2, n}];&#xD;
         bd[[1, 1]] = .5 (bd[[2, 1]] + bd[[1, 2]]);&#xD;
         bd[[n + 1, n + 1]] = .5 (bd[[n, n + 1]] + bd[[n + 1, n]]);&#xD;
         bd[[n + 1, 1]] = .5 (bd[[n, 1]] + bd[[n + 1, 2]]);&#xD;
         bd[[1, n + 1]] = .5 (bd[[1, n]] + bd[[2, n + 1]]); bd];&#xD;
      &#xD;
      diffuse[n_, r_, a_, c_, c0_] := &#xD;
        Module[{c1 = c}, &#xD;
         Do[Do[Do[&#xD;
             c1[[i, j]] = (c0[[i, &#xD;
                   j]] + (a/den[[i, j]]^.4029) (c1[[i - 1, j]] + &#xD;
                     c1[[i + 1, j]] + c1[[i, j - 1]] + &#xD;
                     c1[[i, j + 1]]))/(1 + 4 a/den[[i, j]]^.4029);, {j, 2, &#xD;
              n}];, {i, 2, n}];&#xD;
          Do[c1[[1, i]] = c1[[n, i]]; c1[[n + 1, i]] = c1[[2, i]];&#xD;
           c1[[i, 1]] = c0[[i, 1]];&#xD;
           c1[[i, n + 1]] = c0[[i, n + 1]];, {i, 2, n}];&#xD;
          c1[[1, 1]] = .5 (c1[[2, 1]] + c1[[1, 2]]);&#xD;
          c1[[n + 1, n + 1]] = .5 (c1[[n, n + 1]] + c1[[n + 1, n]]);&#xD;
          c1[[n + 1, 1]] = .5 (c1[[n, 1]] + c1[[n + 1, 2]]);&#xD;
          c1[[1, n + 1]] = .5 (c1[[1, n]] + c1[[2, n + 1]]);, {k, 0, r}];&#xD;
         c1];&#xD;
      &#xD;
      advect[n_, d0_, u_, v_, dt_] := &#xD;
        Module[{x, y, d1, dt0, i0, i1, j0, j1, s0, s1, t0, t1}, &#xD;
         d1 = ConstantArray[0, {n + 1, n + 1}]; dt0 = dt n;&#xD;
         Do[Do[x = i - dt0 u[[i, j]]; y = j - dt0 v[[i, j]];&#xD;
            i0 = Which[x &amp;lt;= 1, 1, 1 &amp;lt; x &amp;lt; n, Floor[x], True, n];&#xD;
            i1 = i0 + 1;&#xD;
            j0 = Which[y &amp;lt;= 1, 1, 1 &amp;lt; y &amp;lt; n, Floor[y], True, n];&#xD;
            j1 = j0 + 1; s1 = x - i0; s0 = 1 - s1; t1 = y - j0; t0 = 1 - t1;&#xD;
            d1[[i, j]] = &#xD;
             s0 (t0 d0[[i0, j0]] + t1 d0[[i0, j1]]) + &#xD;
              s1 (t0 d0[[i1, j0]] + t1 d0[[i1, j1]]);, {j, 1, n + 1}];, {i, &#xD;
           1, n + 1}]; d1];&#xD;
      &#xD;
      project[n_, r_, u0_, v0_, u_, v_] := &#xD;
        Module[{ux = u, vy = v, div, p}, &#xD;
         p = ConstantArray[0, {n + 1, n + 1}];&#xD;
         div = ConstantArray[0, {n + 1, n + 1}];&#xD;
         ux = ConstantArray[0, {n + 1, n + 1}];&#xD;
         vy = ConstantArray[0, {n + 1, n + 1}];&#xD;
         Do[div[[i, &#xD;
             j]] = -.5/&#xD;
              n (u0[[i + 1, j]] - u0[[i - 1, j]] + v0[[i, 1 + j]] - &#xD;
               v0[[i, j - 1]]);, {i, 2, n}, {j, 2, n}];&#xD;
         Do[Do[Do[&#xD;
             p[[i, j]] = (div[[i, &#xD;
                   j]] + (p[[i - 1, j]] + p[[i + 1, j]] + p[[i, j - 1]] + &#xD;
                    p[[i, j + 1]]))/4;, {j, 2, n}], {i, 2, n}];, {k, 0, r}];&#xD;
         Do[ux[[i, j]] = u0[[i, j]] - .5 n (p[[i + 1, j]] - p[[i - 1, j]]);&#xD;
          vy[[i, j]] = &#xD;
           v0[[i, j]] - .5 n (p[[i, j + 1]] - p[[i, j - 1]]);, {i, 2, &#xD;
           n}, {j, 2, n}]; {ux, vy}];&#xD;
      &#xD;
      Fx[t_, x_, y_] := 0;&#xD;
      Fy[t_, x_, y_] := -1/Fr^2;&#xD;
      &#xD;
      onestep[n_, step_, r_, a_, uin_, vin_, dt_, c_] := &#xD;
       Module[{u1, v1, f1, f2, u, v, u0, v0}, &#xD;
        f1 = ConstantArray[0, {n + 1, n + 1}];&#xD;
        f2 = ConstantArray[0., {n + 1, n + 1}];&#xD;
        u0 = ConstantArray[0., {n + 1, n + 1}];&#xD;
        v0 = ConstantArray[0., {n + 1, n + 1}];&#xD;
        u = ConstantArray[0., {n + 1, n + 1}];&#xD;
        v = ConstantArray[0., {n + 1, n + 1}];&#xD;
        u1 = ConstantArray[0., {n + 1, n + 1}];&#xD;
        v1 = ConstantArray[0., {n + 1, n + 1}]; u0 = uin; v0 = vin; Do[&#xD;
         f2[[i, j]] = &#xD;
           1/Fr^2 (den[[i, j]] - rhoWater20C/2) (rhoWater20C - &#xD;
              den[[i, j]]) (den[[i, j]] - rhoAir20C)/(rhoWater20C - &#xD;
                rhoAir20C)/rhoWater20C^2;, {i, 2, n}, {j, 2, n}];&#xD;
        v0 += f2 dt;&#xD;
        u0 = advect[n, u0, u0, v0, dt]; v0 = advect[n, v0, u0, v0, dt]; &#xD;
        mnV = 0;&#xD;
        u0 = periodic[n, U0, 0, u0]; v0 = periodic[n, mnV, mnV, v0];&#xD;
        u0 = diffuse[n, r, a, c, u0]; v0 = diffuse[n, r, a, c, v0];&#xD;
        u0 = periodic[n, U0, 0, u0]; v0 = periodic[n, mnV, mnV, v0];&#xD;
        {u1, v1} = project[n, r, u0, v0, u, v];&#xD;
        u0 = periodic[n, U0, 0, u1]; &#xD;
        v0 = periodic[n, mnV, mnV, v1]; {u0, v0}]&#xD;
      &#xD;
      cf = With[{cg = Compile`GetElement, hp = HoldPattern, &#xD;
          dv = DownValues}, &#xD;
         Hold@Compile[{{u0argu, _Real, 2}, {v0argu, _Real, &#xD;
                   2}, {denargu, _Real, &#xD;
                   2}, {sm, _Integer}, {n, _Integer}, {r, _Integer}, dif, &#xD;
                  pec, F0}, &#xD;
                 Module[{u0 = u0argu, v0 = v0argu, uu, vv, dd, &#xD;
                   den = denargu, c = Table[0., {n + 1}, {n + 1}], &#xD;
                   dt = 40./n^2, a, dnup = den[[1, n + 1]], &#xD;
                   dnd = den[[1, 1]]}, a = dt dif n n;&#xD;
                  uu = vv = dd = Table[0., {sm + 1}, {n + 1}, {n + 1}];&#xD;
                  Do[&#xD;
                   &#xD;
                   den = advect[n, den, u0, v0, dt];&#xD;
                   den = periodic[n, dnup, dnd, den]; &#xD;
                   den = diffuse[n, r, a/pec, c, den];&#xD;
                   den = periodic[n, dnup, dnd, den];&#xD;
                   &#xD;
                   dd[[step + 1]] = den; {u0, v0} = &#xD;
                    onestep[n, step, r, a, u0, v0, dt, c];&#xD;
                   uu[[step + 1]] = u0;&#xD;
                   vv[[step + 1]] = v0;, {step, 0, sm}]; {uu, vv, dd}], &#xD;
                 CompilationTarget -&amp;gt; C, RuntimeOptions -&amp;gt; &amp;#034;Speed&amp;#034;] /. &#xD;
               dv@onestep /. &#xD;
              Flatten[dv /@ {Fx, Fy, advect, diffuse, periodic, project}] /. &#xD;
             hp@ConstantArray[c_, {i_, j_}] :&amp;gt; Table[0., {i}, {j}] /. &#xD;
            hp@Part[a__] :&amp;gt; cg[a] /. hp[cg[a__] = rhs_] :&amp;gt; (Part[a] = rhs) //&#xD;
           ReleaseHold];&#xD;
&#xD;
Visualization&#xD;
-------------&#xD;
&#xD;
    rst = cf[u0, v0, den, sm, n, r, dif, pec, F0];Do[lstu[k] = &#xD;
       Flatten[Table[{{(i - 1)/n, (j - 1)/n}, rst[[1, k, i, j]]}, {i, &#xD;
          n1}, {j, n1}], 1]; &#xD;
      lstv[k] = &#xD;
       Flatten[Table[{{(i - 1)/n, (j - 1)/n}, rst[[2, k, i, j]]}, {i, &#xD;
          n1}, {j, n1}], 1];, {k, sm}];&#xD;
    Do[Uvel[i] = Interpolation[lstu[i], InterpolationOrder -&amp;gt; 3];, {i, 1, &#xD;
       sm}];&#xD;
    Do[Vvel[i] = Interpolation[lstv[i], InterpolationOrder -&amp;gt; 3];, {i, 1, &#xD;
      sm}]; Do[lst4[k] = &#xD;
       Flatten[Table[{{(i - 1)/n, (j - 1)/n}, rst[[3, k, i, j]]}, {i, &#xD;
          n1}, {j, n1}], 1];, {k, sm}];&#xD;
    Do[rh[k] = Interpolation[lst4[k], InterpolationOrder -&amp;gt; 3];, {k, sm}];{ContourPlot[Uvel[10][x, y], {x, 0, 1}, {y, 0, 1}, &#xD;
      ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, Frame -&amp;gt; False, &#xD;
      PlotRange -&amp;gt; All, ImageSize -&amp;gt; Small, MaxRecursion -&amp;gt; 2, &#xD;
      Contours -&amp;gt; 15, ContourStyle -&amp;gt; Yellow, PlotLegends -&amp;gt; Automatic], &#xD;
     ContourPlot[Vvel[10][x, y], {x, 0, 1}, {y, 0, 1}, &#xD;
      ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, Frame -&amp;gt; False, &#xD;
      PlotRange -&amp;gt; All, ImageSize -&amp;gt; Small, MaxRecursion -&amp;gt; 2, &#xD;
      Contours -&amp;gt; 15, ContourStyle -&amp;gt; Yellow, PlotLegends -&amp;gt; Automatic], &#xD;
     ContourPlot[1 - rh[10][x, y], {x, 0, 1}, {y, 0, 1}, &#xD;
      ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, Frame -&amp;gt; False, &#xD;
      PlotRange -&amp;gt; All, ImageSize -&amp;gt; Small, MaxRecursion -&amp;gt; 2, &#xD;
      Contours -&amp;gt; 15, ContourStyle -&amp;gt; Yellow, PlotLegends -&amp;gt; Automatic], &#xD;
     ContourPlot[Uvel[sm][x, y], {x, 0, 1}, {y, 0, 1}, &#xD;
      ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, Frame -&amp;gt; False, &#xD;
      PlotRange -&amp;gt; All, ImageSize -&amp;gt; Small, MaxRecursion -&amp;gt; 2, &#xD;
      Contours -&amp;gt; 15, ContourStyle -&amp;gt; Yellow, PlotLegends -&amp;gt; Automatic], &#xD;
     ContourPlot[Vvel[sm][x, y], {x, 0, 1}, {y, 0, 1}, &#xD;
      ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, Frame -&amp;gt; False, &#xD;
      PlotRange -&amp;gt; All, ImageSize -&amp;gt; Small, MaxRecursion -&amp;gt; 2, &#xD;
      Contours -&amp;gt; 15, ContourStyle -&amp;gt; Yellow, PlotLegends -&amp;gt; Automatic], &#xD;
     ContourPlot[1 - rh[sm][x, y], {x, 0, 1}, {y, 0, 1}, &#xD;
      ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, Frame -&amp;gt; False, &#xD;
      PlotRange -&amp;gt; All, ImageSize -&amp;gt; Small, MaxRecursion -&amp;gt; 2, &#xD;
      Contours -&amp;gt; 8, ContourStyle -&amp;gt; Yellow, PlotLegends -&amp;gt; Automatic]}&#xD;
In this Figure are shown velocity components $u_x$ (left), $u_y$ (middle) and 1- density (right) on step 10 (upper line) and on final step $sm=600$&#xD;
![Figure 2][4]  &#xD;
&#xD;
UPDATE&#xD;
----------&#xD;
&#xD;
Next step is to animate wave transformation using interface function. We can show velocity field over density as follows&#xD;
&#xD;
    Show[ContourPlot[1 - rh[sm][x, y]/rhoWater20C, {x, 0, 1}, {y, 0, 1}, &#xD;
      PlotRange -&amp;gt; All, ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, Contours -&amp;gt; 8,&#xD;
       ContourStyle -&amp;gt; Yellow, Frame -&amp;gt; False, PlotLegends -&amp;gt; Automatic], &#xD;
     StreamPlot[{Uvel[sm][x, y], Vvel[sm][x, y]}, {x, 0, 1}, {y, 0, 1}, &#xD;
      PlotRange -&amp;gt; All, StreamColorFunction -&amp;gt; None, VectorPoints -&amp;gt; Fine,&#xD;
       VectorColorFunction -&amp;gt; Hue, PlotLegends -&amp;gt; Automatic, &#xD;
      StreamColorFunctionScaling -&amp;gt; True, StreamStyle -&amp;gt; LightGray]]&#xD;
![Figure 3][5]&#xD;
&#xD;
We can also compute frames for animation with using interface function  &#xD;
&#xD;
    frames=Table[ContourPlot[1 - rh[i][x, y], {x, 0, 1}, {y, 0, 1}, &#xD;
      ColorFunction -&amp;gt; &amp;#034;BlueGreenYellow&amp;#034;, Frame -&amp;gt; False, &#xD;
      PlotRange -&amp;gt; All, ImageSize -&amp;gt; Small, MaxRecursion -&amp;gt; 2, &#xD;
      Contours -&amp;gt; 8, ContourStyle -&amp;gt; Yellow, PlotLabel -&amp;gt; i], {i, 20, sm, &#xD;
      20}]; Animate[frames]&#xD;
![Figure 4][6]&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
References&#xD;
----------&#xD;
Jos Stam. Stable fluids. In Computer Graphics Proceedings Annual Conference Series, Los Angeles, Aug. 3&amp;#x2013;8, 199.&#xD;
&#xD;
Jos Stam. Interacting with smoke and fire in real time. Communications&#xD;
of the ACM, 43(7):77&amp;#x2013;83, July 2000.&#xD;
      &#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=RogueWave.gif&amp;amp;userId=11733&#xD;
  [2]: https://www.researchgate.net/publication/354527324_A_Navier-Stokes_model_for_Rogue_wave_simulation&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Figure1.jpg&amp;amp;userId=1218692&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Figure2.jpg&amp;amp;userId=1218692&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Figure3.jpg&amp;amp;userId=1218692&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Fr3v3.AW1300Q5.gif&amp;amp;userId=1218692</description>
    <dc:creator>Alexander Trounev</dc:creator>
    <dc:date>2021-11-03T06:49:53Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/294122">
    <title>Simulating brain tumor growth with diffusion-growth model</title>
    <link>https://community.wolfram.com/groups/-/m/t/294122</link>
    <description>![enter image description here][5]&#xD;
&#xD;
When playing with Mathematica 10 I constructed this very simple example of an application of the NDSolve command, which I wanted to share. The objective is to model the growth of a special kind of brain tumour which affects mainly glial cells in a highly simplified way. I follow modelling ideas discussed in the excellent book [&amp;#034;Mathematical Biology&amp;#034; (Vol 2) by J.D. Murray][1]. It turns out that Gliomas, which are neoplasms of glial cells, i.e. neural calls capable of division, can be be modelled by a rather simple diffusion-growth model. &#xD;
&#xD;
$$\frac{d c}{dt}=\nabla\left(D(x) \nabla c \right)+ \rho c$$ &#xD;
&#xD;
where c is the concentration of cancer cells and $D(x)$ is the diffusion coefficient, which depends on the coordinates; $\rho$ models the growth rate of the cells. The following boundary condition has to be observe (even though will be ignored in the model I use later on):&#xD;
&#xD;
$${\bf n} \cdot D(x) \nabla c = 0 \qquad \text{for}\; x\;  \text{on}\; \partial B.$$&#xD;
&#xD;
In reality the diffusion coefficient will depend on the tissue type, i.e. gray matter vs white matter. I will use an image from a CT can to describe the different densities of the tissue instead. &#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
In the book by Murray great care is taken to estimate the diffusion coefficient but I just want to show the principle here. I use the attached file &amp;#034;brain-crop.jpg&amp;#034; and import it:&#xD;
&#xD;
    img2=Import[&amp;#034;~/Desktop/brain-crop.jpg&amp;#034;]&#xD;
&#xD;
Then I sharpen it and convert it to gray-scale.&#xD;
&#xD;
img3 = Sharpen[ColorConvert[img2, &amp;#034;Grayscale&amp;#034;]]&#xD;
&#xD;
Then I use that image to determine the diffusion coefficient, locally:&#xD;
&#xD;
    diffcoeff = ListInterpolation[ImageData[img3], InterpolationOrder -&amp;gt; 3]&#xD;
&#xD;
I should now determine the boundaries using something like EdgeDetect. As the background is black and allows no diffusion at all, we can simplify this by just setting a larger (rectangular) boundary box like so:&#xD;
&#xD;
    boundaries = {-y, y - 1, -x, x - 1};&#xD;
    &#xD;
    \[CapitalOmega] = &#xD;
      ImplicitRegion[And @@ (# &amp;lt;= 0 &amp;amp; /@ boundaries), {x, y}];&#xD;
&#xD;
&#xD;
Next we can solve the ODE on the domain:&#xD;
&#xD;
    sols = NDSolveValue[{{Div[1./500.*(diffcoeff[798.*x, 654*y])^4*Grad[u[t, x, y], {x, y}], {x, y}] - D[u[t, x, y], t] + 0.025*u[t, x, y] == NeumannValue[0., x &amp;gt;= 1. || x &amp;lt;= 0. || y &amp;lt;= 0. || y &amp;gt;= 1.]}, {u[0, x, y] == Exp[-1000. ((x - 0.6)^2 + (y - 0.6)^2)]}}, u, {x, y} \[Element] \[CapitalOmega], {t, 0, 20}, Method -&amp;gt; {&amp;#034;FiniteElement&amp;#034;, &amp;#034;MeshOptions&amp;#034; -&amp;gt; {&amp;#034;BoundaryMeshGenerator&amp;#034; -&amp;gt; &amp;#034;Continuation&amp;#034;, MaxCellMeasure -&amp;gt; 0.002}}]&#xD;
&#xD;
Note that we start with an initially Gaussian distributed tumour and describe its growth from there. Also I took the fourth power of the diffcoeff function, which changes the relation between grayscale and diffusion rate. You can change the coefficient to get different patterns for the growth. Interestingly, this integration gives a warning about intersecting boundaries in MMA10, which it did not say in the Prerelease version; if someone can fix that, that would be great. For any time we can now overlay the resulting distribution onto the CT image:&#xD;
&#xD;
    ImageCompose[img3, {ContourPlot[&#xD;
       Max[sols[t, x, y], 0] /. t -&amp;gt; 2, {y, 0, 1}, {x, 0, 1}, &#xD;
       PlotRange -&amp;gt; {{0, 1}, {0, 1}, {0.01, All}}, PlotPoints -&amp;gt; 100, &#xD;
       Contours -&amp;gt; 200, ContourLines -&amp;gt; False, AspectRatio -&amp;gt; 798./654., &#xD;
       ColorFunction -&amp;gt; &amp;#034;Temperature&amp;#034;], 0.6}]&#xD;
&#xD;
This should give something like this:&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
Using &#xD;
&#xD;
    frames = Table[&#xD;
       ImageCompose[&#xD;
        img3, {ContourPlot[&#xD;
          Max[sols[d, x, y], 0] /. d -&amp;gt; t, {y, 0, 1}, {x, 0, 1}, &#xD;
          PlotRange -&amp;gt; {{0, 1}, {0, 1}, {0.01, All}}, PlotPoints -&amp;gt; 100, &#xD;
          Contours -&amp;gt; 200, ContourLines -&amp;gt; False, &#xD;
          AspectRatio -&amp;gt; 798./654., ColorFunction -&amp;gt; &amp;#034;Temperature&amp;#034;], &#xD;
         0.6}], {t, 0, 10, 0.5}];&#xD;
&#xD;
we get a list of images, &#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
which can be animated&#xD;
&#xD;
    ListAnimate[frames, DefaultDuration -&amp;gt; 20]&#xD;
&#xD;
 to give&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
This is only a very elementary demonstration, and certainly still far away from a &amp;#034;real&amp;#034; medical application, but it demonstrates the power of NDSolve and might, in a modified form, be useful as a case study for some introductory courses. &#xD;
&#xD;
Cheers,&#xD;
Marco&#xD;
&#xD;
&#xD;
  [1]: http://www.springer.com/new+&amp;amp;+forthcoming+titles+%28default%29/book/978-0-387-95228-4&#xD;
  [2]: /c/portal/getImageAttachment?filename=brain-crop.jpg&amp;amp;userId=48754&#xD;
  [3]: /c/portal/getImageAttachment?filename=BrainTumor-still.jpg&amp;amp;userId=48754&#xD;
  [4]: /c/portal/getImageAttachment?filename=1473BrainTumor-frames.jpg&amp;amp;userId=48754&#xD;
  [5]: /c/portal/getImageAttachment?filename=BrainTumor.gif&amp;amp;userId=48754</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2014-07-14T13:54:54Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/3022104">
    <title>Can Wolfram&amp;#039;s new compiler technology speed up this AABB tree code?</title>
    <link>https://community.wolfram.com/groups/-/m/t/3022104</link>
    <description>An axes aligned bounding box (AABB) tree, a type of [bounding volume hierarchy](https://en.wikipedia.org/wiki/Bounding_volume_hierarchy), is a spatial data structure designed to efficiently find overlapping bounding boxes. It is often used to find broad-level collisions in applications such as collision detection and ray tracing.&#xD;
&#xD;
## Question&#xD;
&#xD;
I have an implementation in WL that uses some [`Compile`](https://reference.wolfram.com/language/ref/Compile) and [`DataStructure`](https://reference.wolfram.com/language/ref/DataStructure), but is mostly top-level WL code. I&amp;#039;m looking to increase performance, while staying in the WL ecosystem.&#xD;
&#xD;
Are there any tips to speed up my code? In particular any tips to port this over to compiled code using [`FunctionCompile`](https://reference.wolfram.com/language/ref/FunctionCompile.html) &amp;amp; friends? Side note, would be nice if this was a builtin `DataStructure` :)&#xD;
&#xD;
I&amp;#039;ve posted the code below. Feel free to ask any questions about how it works, etc.&#xD;
&#xD;
## Examples&#xD;
&#xD;
### Basic example&#xD;
&#xD;
Bounding boxes are of the form $\{\{x_{min}, x_{max}\}, \{y_{min}, y_{max}\}, \{z_{min}, z_{max}\}\}$.&#xD;
&#xD;
Let&amp;#039;s create the AABB tree over 3 bounding boxes and make 1 query bounding box:&#xD;
&#xD;
    bboxes = {&#xD;
      {{0, 1}, {0, 1}, {0, 1}},&#xD;
      {{0.5, 1.5}, {0.25, 1.5}, {0.3, 0.7}}, &#xD;
      {{0.7, 0.8}, {0.8, 2}, {0.2, 0.8}}&#xD;
    };&#xD;
    testbbox = {{0.6, 0.9}, {1.1, 1.4}, {0.6, 0.9}};&#xD;
Create the data structure:&#xD;
&#xD;
    aabbtree = AABBTree[bboxes];&#xD;
&#xD;
Find the indices of the bounding boxes that overlap `testbbox`:&#xD;
&#xD;
    overlaps = OverlappingBBoxes[aabbtree, testbbox]&#xD;
    (* {2, 3} *)&#xD;
Visualize (query box in blue, overlapping in red, disjoint in green):&#xD;
&#xD;
    Graphics3D[{&#xD;
      {FaceForm[Green], Cuboid @@@ Transpose[Delete[bboxes, Partition[overlaps, 1]], {1, 3, 2}]},&#xD;
      {FaceForm[Red], Cuboid @@@ Transpose[bboxes[[overlaps]], {1, 3, 2}]},&#xD;
      {Blue, Cuboid @@ Transpose[testbbox]}&#xD;
     }]&#xD;
&amp;lt;img src=&amp;#034;https://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2023-09-26at10.48.42AM.png&amp;amp;userId=46025&amp;#034; width=&amp;#034;360&amp;#034;&amp;gt;&#xD;
&#xD;
### 4000 bounding boxes, 1 query&#xD;
&#xD;
    randomBBox[n_] :=&#xD;
      With[{llcorners = RandomReal[{-10, 10}, {n, 3}]},&#xD;
        Transpose[{llcorners, llcorners + RandomReal[{1, 1}, {n, 3}]}, {3, 1, 2}]&#xD;
      ]&#xD;
    &#xD;
    SeedRandom[1];&#xD;
    bboxes = randomBBox[4000];&#xD;
    testbbox = randomBBox[1][[1]];&#xD;
    &#xD;
    aabbtree = AABBTree[bboxes]; // AbsoluteTiming&#xD;
    (* {0.018875, Null} *)&#xD;
    &#xD;
    (overlaps = OverlappingBBoxes[aabbtree, testbbox]) // AbsoluteTiming&#xD;
    (* {0.000692, {1817, 3935, 878, 87}} *)&#xD;
    &#xD;
    Graphics3D[Cuboid @@@ Transpose[bboxes, {1, 3, 2}]]&#xD;
&amp;lt;img src=&amp;#034;https://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2023-09-26at10.52.43AM.png&amp;amp;userId=46025&amp;#034; width=&amp;#034;360&amp;#034;&amp;gt;&#xD;
&#xD;
    Graphics3D[{&#xD;
      {FaceForm[Green], Cuboid @@@ Transpose[Delete[bboxes, Partition[overlaps, 1]], {1, 3, 2}]},&#xD;
      {FaceForm[Red], Cuboid @@@ Transpose[bboxes[[overlaps]], {1, 3, 2}]},&#xD;
      {Blue, Cuboid @@ Transpose[testbbox]}},&#xD;
     PlotRange -&amp;gt; testbbox,&#xD;
     PlotRangePadding -&amp;gt; Scaled[0.25]&#xD;
    ]&#xD;
&amp;lt;img src=&amp;#034;https://community.wolfram.com//c/portal/getImageAttachment?filename=Screenshot2023-09-26at10.52.58AM.png&amp;amp;userId=46025&amp;#034; width=&amp;#034;360&amp;#034;&amp;gt;&#xD;
&#xD;
### 100000 bounding boxes, 100000 queries&#xD;
&#xD;
    SeedRandom[1];&#xD;
    bboxes = randomBBox[100000];&#xD;
    testbboxes = randomBBox[100000];&#xD;
    &#xD;
    aabbtree = AABBTree[bboxes]; // AbsoluteTiming&#xD;
    (* {0.235465, Null} *)&#xD;
    &#xD;
    OverlappingBBoxes[aabbtree, testbboxes[[1]]]; // AbsoluteTiming&#xD;
    (* {0.001988, Null} *)&#xD;
&#xD;
I suspect this can be sped up substantially:&#xD;
&#xD;
    Scan[OverlappingBBoxes[aabbtree, #]&amp;amp;, testbboxes]; // AbsoluteTiming&#xD;
    (* {44.8445, Null} *)&#xD;
&#xD;
## Code&#xD;
&#xD;
    AABBTree[bboxes_] :=&#xD;
    	Block[{$RecursionLimit = ∞},&#xD;
    		iAABBTree[1, MapIndexed[Join, Flatten /@ bboxes][[Ordering[bboxes[[All, 1, 1]]]]]]&#xD;
    	]&#xD;
    &#xD;
    iAABBTree[d_, bboxestagged_] :=&#xD;
    	Block[{len, n, x, Sleft, Scent, Sright, node},&#xD;
    		len = Length[bboxestagged];&#xD;
    		If[len &amp;lt;= 16, Return[centerNode3D[d, Null, bboxestagged]]];&#xD;
    		&#xD;
    		n = Ordering[bboxestagged[[All, 2d-1]], {Quotient[len+1, 2]}][[1]];&#xD;
    		x = Mean[bboxestagged[[n, 2d-1 ;; 2d]]];&#xD;
    		&#xD;
    		{Sleft, Scent, Sright} = partitionIntervals3D[d, bboxestagged, x];&#xD;
    		&#xD;
    		node = centerNode3D[d, x, Scent];&#xD;
    		If[Length[Sleft] &amp;gt; 0, node[&amp;#034;SetLeft&amp;#034;, iAABBTree[Mod[d+1, 3, 1], Sleft]];];&#xD;
    		If[Length[Sright] &amp;gt; 0, node[&amp;#034;SetRight&amp;#034;, iAABBTree[Mod[d+1, 3, 1], Sright]];];&#xD;
    		&#xD;
    		node&#xD;
    	]&#xD;
    &#xD;
    centerNode3D[d_, x_, {}] := CreateDataStructure[&amp;#034;BinaryTree&amp;#034;, {x, {}, {}, {}, {}, {}, {}, {}, -$MaxMachineNumber, $MaxMachineNumber, d}]&#xD;
    &#xD;
    (* {center ordinate, xmins, ymins, zmins, xmaxs, ymaxs, zmaxs, inds, dmin, dmax, d} *)&#xD;
    (* xmins are the xmin values of all bboxes in this node, ymins, etc follow suit *)&#xD;
    (* inds are the respective indices of the bboxes in this node *)&#xD;
    (* dmin &amp;amp; dmax are the bounds of all bounding boxes in dimension d (the splitting dimension) *)&#xD;
    centerNode3D[d_, x_, intstagged_] := &#xD;
    	CreateDataStructure[&amp;#034;BinaryTree&amp;#034;, &#xD;
    		{&#xD;
    			x, &#xD;
    			#1, #2, &#xD;
    			#3, #4, &#xD;
    			#5, #6, &#xD;
    			Developer`ToPackedArray[#7, Integer], &#xD;
    			Switch[d, 1, #1[[1]], 2, Min[#3], 3, Min[#5]], Max[Switch[d, 1, #2, 2, #4, 3, #6]], &#xD;
    			d&#xD;
    		}&amp;amp; @@ Transpose[intstagged]&#xD;
    	]&#xD;
    &#xD;
    partitionIntervals3D[d_, intstagged_, x_] :=&#xD;
    	Block[{data, spec},&#xD;
    		data = Partition[partitionIntervals3DC[d, intstagged, x], 7];&#xD;
    		spec = Round[data[[-1]]];&#xD;
    		&#xD;
    		{data[[1 ;; spec[[1]]]], data[[spec[[1]]+1 ;; spec[[2]]]], data[[spec[[2]]+1 ;; -2]]}&#xD;
    	]&#xD;
    &#xD;
    partitionIntervals3DC = Compile[{{d, _Integer}, {intstagged, _Real, 2}, {x, _Real}},&#xD;
    	Block[{mnp, mxp, cright = 0., ccenter = 0., bagright = Internal`Bag[Most[{0.}]], bagcenter = Internal`Bag[Most[{0.}]], bagleft = Internal`Bag[Most[{0.}]]},&#xD;
    		mnp = 2d-1;&#xD;
    		mxp = mnp+1;&#xD;
    		Do[&#xD;
    			If[Compile`GetElement[i, mxp] &amp;lt; x,&#xD;
    				Internal`StuffBag[bagright, i, 1];&#xD;
    				cright++,&#xD;
    				If[Compile`GetElement[i, mnp] &amp;gt; x,&#xD;
    					Internal`StuffBag[bagleft, i, 1],&#xD;
    					Internal`StuffBag[bagcenter, i, 1];&#xD;
    					ccenter++&#xD;
    				]&#xD;
    			],&#xD;
    			{i, intstagged}&#xD;
    		];&#xD;
    		&#xD;
    		Join[Internal`BagPart[bagright, All], Internal`BagPart[bagcenter, All], Internal`BagPart[bagleft, All], {cright, cright + ccenter, 0., 0., 0., 0., 0.}]&#xD;
    	],&#xD;
    	CompilationTarget -&amp;gt; &amp;#034;C&amp;#034;,&#xD;
    	RuntimeOptions -&amp;gt; &amp;#034;Speed&amp;#034;&#xD;
    ];&#xD;
    &#xD;
    OverlappingBBoxes[tree_?DataStructureQ, bbox:{{x1_, x2_}, {y1_, y2_}, {z1_, z2_}}] :=&#xD;
    	Block[{bag, stack, node, a, b, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11},&#xD;
    		bag = Internal`Bag[];&#xD;
    		stack = CreateDataStructure[&amp;#034;Stack&amp;#034;];&#xD;
    		stack[&amp;#034;Push&amp;#034;, tree];&#xD;
    		&#xD;
    		While[!stack[&amp;#034;EmptyQ&amp;#034;],&#xD;
    			node = stack[&amp;#034;Pop&amp;#034;];&#xD;
    			{d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11} = node[&amp;#034;Data&amp;#034;];&#xD;
    			{a, b} = bbox[[d11]];&#xD;
    			If[Length[d2] &amp;gt; 0 &amp;amp;&amp;amp; (d9 &amp;lt;= a &amp;lt;= d10 || d9 &amp;lt;= b &amp;lt;= d10 || a &amp;lt;= d9 &amp;lt;= d10 &amp;lt;= b),&#xD;
    				Internal`StuffBag[bag, Pick[d8, bboxOverlaps[d2, d3, d4, d5, d6, d7, x1, x2, y1, y2, z1, z2], 1], 1];&#xD;
    			];&#xD;
    			&#xD;
    			If[d1 =!= Null, &#xD;
    				If[a &amp;lt; d1 &amp;amp;&amp;amp; !node[&amp;#034;LeftNullQ&amp;#034;], stack[&amp;#034;Push&amp;#034;, node[&amp;#034;Left&amp;#034;]]];&#xD;
    				If[d1 &amp;lt; b &amp;amp;&amp;amp; !node[&amp;#034;RightNullQ&amp;#034;], stack[&amp;#034;Push&amp;#034;, node[&amp;#034;Right&amp;#034;]]];&#xD;
    			];&#xD;
    		];&#xD;
    		&#xD;
    		Internal`BagPart[bag, All]&#xD;
    	]&#xD;
    &#xD;
    bboxOverlaps = Compile[{{epx1, _Real}, {epx2, _Real}, {epy1, _Real}, {epy2, _Real}, {epz1, _Real}, {epz2, _Real}, {x1, _Real}, {x2, _Real}, {y1, _Real}, {y2, _Real}, {z1, _Real}, {z2, _Real}}, &#xD;
    	Boole @ And[&#xD;
    		epx1 &amp;lt;= x1 &amp;lt;= epx2 || epx1 &amp;lt;= x2 &amp;lt;= epx2 || (x1 &amp;lt;= epx1 &amp;lt;= epx2 &amp;lt;= x2),&#xD;
    		epy1 &amp;lt;= y1 &amp;lt;= epy2 || epy1 &amp;lt;= y2 &amp;lt;= epy2 || (y1 &amp;lt;= epy1 &amp;lt;= epy2 &amp;lt;= y2),&#xD;
    		epz1 &amp;lt;= z1 &amp;lt;= epz2 || epz1 &amp;lt;= z2 &amp;lt;= epz2 || (z1 &amp;lt;= epz1 &amp;lt;= epz2 &amp;lt;= z2)&#xD;
    	],&#xD;
    	CompilationTarget -&amp;gt; &amp;#034;C&amp;#034;,&#xD;
    	Parallelization -&amp;gt; True,&#xD;
    	RuntimeOptions -&amp;gt; &amp;#034;Speed&amp;#034;,&#xD;
    	RuntimeAttributes -&amp;gt; {Listable}&#xD;
    ];</description>
    <dc:creator>Greg Hurst</dc:creator>
    <dc:date>2023-09-26T15:12:15Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/131302">
    <title>Plotting electronic orbitals with Wolfram Language</title>
    <link>https://community.wolfram.com/groups/-/m/t/131302</link>
    <description>I am reposting this here from the [url=http://mathematica.blogoverflow.com/]Stackexchange Mathematica blog[/url] so that more people might see it.  I&amp;#039;d be very happy to get some feedback on this plotting function.  If anyone can use the function, let me know how it works out for you, and if you&amp;#039;d recommend any changes.  If so, I can edit this post to have to most up-to-date version.&#xD;
&#xD;
As a chemist it is often useful to plot electronic orbitals.  These are used to describe the wave function of electrons in atoms or molecules.  Typically, these are output from electronic structure software in the form of a cube file, first developed by Gaussian.  These files contain volumetric data for a given orbital on a three-dimensional grid.&#xD;
&#xD;
&#xD;
There exist many applications to visualize cube files, such as [url=http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/cubeplugin.html]VMD [/url]or [url=http://www.gaussian.com/g_tech/gv5ref/results.htm]GaussView[/url], but I wanted to take advantage of Mathematicas  capability to easily combine graphics, as well as the ability to automate the process in order to efficiently create frames for a [url=http://www.pnas.org/content/suppl/2013/09/05/1308604110.DCSupplemental/sm01.mp4]movie[/url].&#xD;
&#xD;
First off, we need a function to extract the data from the cube file. In the process, we will create the text for an XYZ file, a format also developed by Gaussian. The function [b]OutForm[/b] is used here to mimic the printf function found in other programming languages.&#xD;
&#xD;
[mcode]OutForm[num_?NumericQ, width_Integer, ndig_Integer, &#xD;
   OptionsPattern[]] :=&#xD;
  Module[{mant, exp, val},&#xD;
   {mant, exp} = MantissaExponent[num];&#xD;
   mant = ToString[NumberForm[mant, {ndig, ndig}]];&#xD;
   exp = If[Sign[exp] == -1, &amp;#034;-&amp;#034;, &amp;#034;+&amp;#034;] &amp;lt;&amp;gt; IntegerString[exp, 10, 2];&#xD;
   val = mant &amp;lt;&amp;gt; &amp;#034;E&amp;#034; &amp;lt;&amp;gt; exp;&#xD;
   StringJoin@PadLeft[Characters[val], width, &amp;#034; &amp;#034;]&#xD;
   ];&#xD;
&#xD;
ReadCube[cubeFileName_?StringQ] := Module[&#xD;
   {moltxt, nAtoms, lowerCorner, nx, ny, nz, xstep, ystep, zstep, &#xD;
    atoms, desc1, desc2, xyzText, cubeDat, xgrid, ygrid, zgrid, &#xD;
    dummy1, dummy2, atomicNumber, atomx, atomy, atomz, tmpString, &#xD;
    headerTxt,bohr2angstrom},&#xD;
   bohr2angstrom = 0.529177249;&#xD;
   moltxt = OpenRead[cubeFileName];&#xD;
   desc1 = Read[moltxt, String];&#xD;
   desc2 = Read[moltxt, String];&#xD;
   lowerCorner = {0, 0, 0}; &#xD;
   {nAtoms, lowerCorner[[1]], lowerCorner[[2]], lowerCorner[[3]]} = &#xD;
    Read[moltxt, String] // ImportString[#, &amp;#034;Table&amp;#034;][[1]] &amp;amp;;&#xD;
   xyzText = ToString[nAtoms] &amp;lt;&amp;gt; &amp;#034;\n&amp;#034;;&#xD;
   xyzText = xyzText &amp;lt;&amp;gt; desc1 &amp;lt;&amp;gt; desc2 &amp;lt;&amp;gt; &amp;#034;\n&amp;#034;;&#xD;
   {nx, xstep, dummy1, dummy2} = &#xD;
    Read[moltxt, String] // ImportString[#, &amp;#034;Table&amp;#034;][[1]] &amp;amp;;&#xD;
   {ny, dummy1, ystep, dummy2} = &#xD;
    Read[moltxt, String] // ImportString[#, &amp;#034;Table&amp;#034;][[1]] &amp;amp;;&#xD;
   {nz, dummy1, dummy2, zstep} = &#xD;
    Read[moltxt, String] // ImportString[#, &amp;#034;Table&amp;#034;][[1]] &amp;amp;;&#xD;
   Do[&#xD;
    {atomicNumber, dummy1, atomx, atomy, atomz} = &#xD;
     Read[moltxt, String] // ImportString[#, &amp;#034;Table&amp;#034;][[1]] &amp;amp;;&#xD;
    xyzText = If[Sign[lowerCorner[[1]]] == 1,&#xD;
      xyzText &amp;lt;&amp;gt; ElementData[atomicNumber, &amp;#034;Abbreviation&amp;#034;] &amp;lt;&amp;gt; &#xD;
       OutForm[atomx, 17, 7] &amp;lt;&amp;gt; OutForm[atomy, 17, 7] &amp;lt;&amp;gt; &#xD;
       OutForm[atomz, 17, 7] &amp;lt;&amp;gt; &amp;#034;\n&amp;#034;,&#xD;
      xyzText &amp;lt;&amp;gt; ElementData[atomicNumber, &amp;#034;Abbreviation&amp;#034;] &amp;lt;&amp;gt; &#xD;
       OutForm[bohr2angstrom atomx, 17, 7] &amp;lt;&amp;gt; &#xD;
       OutForm[bohr2angstrom atomy, 17, 7] &amp;lt;&amp;gt; &#xD;
       OutForm[bohr2angstrom atomz, 17, 7] &amp;lt;&amp;gt; &amp;#034;\n&amp;#034;];&#xD;
    , {nAtoms}];&#xD;
   cubeDat = &#xD;
    Partition[Partition[ReadList[moltxt, Number, nx ny nz], nz], ny];&#xD;
   Close[moltxt];&#xD;
   moltxt = OpenRead[cubeFileName];&#xD;
   headerTxt = Read[moltxt, Table[String, {2 + 4 + nAtoms}]];&#xD;
   Close[moltxt];&#xD;
   headerTxt = StringJoin@Riffle[headerTxt, &amp;#034;\n&amp;#034;];&#xD;
   xgrid = &#xD;
    Range[lowerCorner[[1]], lowerCorner[[1]] + xstep (nx - 1), xstep];&#xD;
   ygrid = &#xD;
    Range[lowerCorner[[2]], lowerCorner[[2]] + ystep (ny - 1), ystep];&#xD;
   zgrid = &#xD;
    Range[lowerCorner[[3]], lowerCorner[[3]] + zstep (nz - 1), zstep];&#xD;
   {cubeDat, xgrid, ygrid, zgrid, xyzText, headerTxt}&#xD;
   ];[/mcode]&#xD;
If you need to create a cube file, then the following function can be used:&#xD;
[mcode]WriteCube[cubeFileName_?StringQ, headerTxt_?StringQ, cubeData_] := &#xD;
 Module[{stream}, &#xD;
  stream = OpenWrite[cubeFileName, FormatType -&amp;gt; FortranForm];&#xD;
  WriteString[stream, headerTxt, &amp;#034;\n&amp;#034;];&#xD;
  Map[WriteString[stream, ##, &amp;#034;\n&amp;#034;] &amp;amp; @@ &#xD;
     Riffle[ScientificForm[#, {3, 4}, &#xD;
         NumberFormat -&amp;gt; (Row[{#1, &amp;#034;E&amp;#034;, If[#3 == &amp;#034;&amp;#034;, &amp;#034;+00&amp;#034;, #3], &#xD;
              &amp;#034;\t&amp;#034;}] &amp;amp;), NumberPadding -&amp;gt; {&amp;#034;&amp;#034;, &amp;#034;0&amp;#034;}, &#xD;
         NumberSigns -&amp;gt; {&amp;#034;-&amp;#034;, &amp;#034; &amp;#034;}] &amp;amp; /@ #, &amp;#034;\n&amp;#034;, {7, -1, 7}] &amp;amp;, &#xD;
   cubeData, {2}];&#xD;
  Close[stream];][/mcode]Next we need the function to plot the orbital,&#xD;
[mcode]CubePlot[{cub_, xg_, yg_, zg_, xyz_}, plotopts : OptionsPattern[]] := &#xD;
   Module[{xyzplot, bohr2picometer, datarange3D, pr},&#xD;
    bohr2picometer = 52.9177249;&#xD;
    datarange3D = &#xD;
      bohr2picometer {{xg[[1]], xg[[-1]]}, {yg[[1]], &#xD;
         yg[[-1]]}, {zg[[1]], zg[[-1]]}};&#xD;
    xyzplot = ImportString[xyz, &amp;#034;XYZ&amp;#034;];&#xD;
    Show[xyzplot, &#xD;
     ListContourPlot3D[Transpose[cub, {3, 2, 1}], &#xD;
       Evaluate[FilterRules[{plotopts}, Options[ListContourPlot3D]]], &#xD;
       Contours -&amp;gt; {-.02, .02}, ContourStyle -&amp;gt; {Blue, Red}, &#xD;
       DataRange -&amp;gt; datarange3D, MeshStyle -&amp;gt; Gray, &#xD;
       Lighting -&amp;gt; {{&amp;#034;Ambient&amp;#034;, White}}], &#xD;
       Evaluate[&#xD;
        FilterRules[{plotopts}, {ViewPoint, ViewVertical, ImageSize}]]]&#xD;
    ];    [/mcode]Lets look at an example.  First we need to read in a cube file, download this cube file and place it in your base directory:  [url=https://dl.dropboxusercontent.com/s/rdsxcnqudn1s76n/cys-MO35.cube]cys-MO35cube[/url]&#xD;
[mcode]{cubedata,xg,yg,zg,xyz,header}= ReadCube[&amp;#034;cys-MO35.cube&amp;#034;];[/mcode]Then plot it via[mcode]CubePlot[{cubedata, xg, yg, zg, xyz}][/mcode][img=width: 300px; height: 291px;]http://mathematica.blogoverflow.com/files/2013/09/pizCq-300x291.jpg[/img]&#xD;
When I want to create a movie file, I want all the images to have exactly the same [b]ViewAngle[/b], [b]ViewPoint[/b], and [b]ViewCenter[/b].  When you give these options to [b]CubePlot[/b], it feeds them directly to the [b]Show[/b] function&#xD;
[mcode]vp = {ViewCenter -&amp;gt; {0.5, 0.5, 0.5}, &#xD;
   ViewPoint -&amp;gt; {1.072, 0.665, -3.13}, &#xD;
   ViewVertical -&amp;gt; {0.443, 0.2477, 1.527}};&#xD;
&#xD;
&#xD;
CubePlot[{cubedata, xg, yg, zg, xyz}, vp][/mcode][img=width: 280px; height: 300px;]http://mathematica.blogoverflow.com/files/2013/09/Q1mjs-280x300.jpg[/img]&#xD;
Finally, you can also give any options that normally go to [b]ListContourPlot3D[/b][mcode]CubePlot[{cubedata, xg, yg, zg, xyz}, vp, &#xD;
 ContourStyle -&amp;gt; {Texture[ExampleData[{&amp;#034;ColorTexture&amp;#034;, &amp;#034;Vavona&amp;#034;}]], &#xD;
   Texture[ExampleData[{&amp;#034;ColorTexture&amp;#034;, &amp;#034;Amboyna&amp;#034;}]]}, &#xD;
 Contours -&amp;gt; {-.015, .015}][/mcode][img=width: 288px; height: 300px;]http://mathematica.blogoverflow.com/files/2013/09/fLyJ7-288x300.jpg[/img]&#xD;
&#xD;
Many thanks to Daniel Healion for the [b]ReadCube[/b] and [b]WriteCube[/b] functions.</description>
    <dc:creator>Jason Biggs</dc:creator>
    <dc:date>2013-09-27T18:35:45Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2017849">
    <title>How black holes and accretion disks around them actually look</title>
    <link>https://community.wolfram.com/groups/-/m/t/2017849</link>
    <description>#Introduction&#xD;
&#xD;
One of the most thrilling parts in Nolan&amp;#039;s movie &amp;#034;Interstellar&amp;#034; is the black hole Gargantua and its accretion disk. Its weird shape has surely attracted lots of attention. But do black holes and their accretion disks actually look like that? Not exactly.&#xD;
&#xD;
![BH and accretion disk in Interstellar][1]&#xD;
&#xD;
In the paper &amp;#034;Gravitational lensing by spinning black holes in astrophysics, and in the movie Interstellar&amp;#034;, the authors say that in the movie, redshift and blueshift, as well as the intensity difference is ignored to prevent confusion to the audience. So, although the outline of the accretion disk in &amp;#034;Interstellar&amp;#034; is accurate, the color and the intensity are not. Furthermore, even in the paper, effects brought by the time delay in the propagation of light are ignored, and the influence of gravity lensing on light intensity is simplified.&#xD;
&#xD;
Though I cannot easily render a spinning black hole (Kerr black hole), what I can do is try to render an accretion disk around a Schwarzschild black hole, and as physically correct as possible. The result would be something like this (observer static at 6 times the Schwarzschild radius):&#xD;
&#xD;
![my rendering result, static observer][2]&#xD;
&#xD;
I strongly recommend you to see the videos at [Bilibili](https://www.bilibili.com/video/BV1Fp4y1S7EF) or [Youtube](https://www.youtube.com/watch?v=Dux1NkTaqwo) (Both have English subtitles) first to have a first impression, and it would be the best if you can click the vote up button XD. After that, If you would like to know more about the Mathematica realization and physical principles behind the scene, please continue.&#xD;
&#xD;
**A disclaimer first:** I know nothing about accretion disk physics, so the property of accretion disks are set arbitrarily. Furthermore, actual accretion disks are actually blazingly bright, and you would be blind instantly if you are looking at it from a short distance, so I have to make some modifications.&#xD;
&#xD;
#Analytics&#xD;
&#xD;
###Physics Perspective&#xD;
&#xD;
First, we need to analyze this problem from the physics perspective, get to know about the problems we should consider. **For observers**, the intensity of light is determined by how much photons reached their eye in a certain angle range, and the color is determined by the spectrum of the light. However, the orientation, spectrum, and intensity of light beams can be influenced by the observer&amp;#039;s movement, so we have to consider that. Naturally, the next question should be, where the light comes? Well, all the light must have come from some **light-emitting materials**, so we have to consider the light-emitting materials&amp;#039; property and movement. But the **light should travel** for some time and distance before reaching the observer&amp;#039;s eye. This process involves tracing the light from the emitter to the observer to determine the direction of light the observer perceived, as well as how much portion of light can reach the observer&amp;#039;s eyes. Till now, we have already listed out all effects, from the emission to the perception, which could influence our view, so I believe this rendering is &amp;#034;physically accurate&amp;#034;.&#xD;
&#xD;
&#xD;
### Programming Perspective&#xD;
&#xD;
But view from the programming perspective, the zeroth problem should be how lights travel around a black hole: we need the light path to calculate all other effects. Then, based on the light path, we can directly compute the equivalent of &amp;#034;brighter when closer&amp;#034; rule, as well as the time delay between light emission and observation. If combined with the movement of the light-emitting materials and the observer, we can compute the redshift and the blueshift. &#xD;
&#xD;
#Details, Theory, Coding and Results&#xD;
&#xD;
Now let&amp;#039;s assume that we are stationary observers viewing from 6 times the Schwarzchild radius.&#xD;
&#xD;
##Ray Tracing&#xD;
The first problem to solve is tracing the light beam. Light bends around black holes following the geodesics, and the most apparent consequence of this would be that the accretion disk we see would not be on a plane, but rather curved and bent. Fortunately for us, because Schwartzchild black holes are spherically symmetric, we can reduce the problem to 2D. The parametric equation of geodesics around a Schwarzschild black hole can be derived as follows:&#xD;
&#xD;
$$&#xD;
	\left\{&#xD;
	\begin{aligned}&#xD;
		t&amp;#039;&amp;#039;(\lambda)&amp;amp;=\frac{R_s r&amp;#039; t&amp;#039;}{R_s r-r^2}\\&#xD;
		r&amp;#039;&amp;#039;(\lambda)&amp;amp;=\frac{-R_s r^2 r&amp;#039;^2-2r^3\theta&amp;#039;^2(R_s-r)^2+R_s(R_s-r)^2t&amp;#039;^2}{2r^3(R_s-r)}\\&#xD;
		\theta&amp;#039;&amp;#039;(\lambda)&amp;amp;=-\frac{2r&amp;#039;\theta&amp;#039;}{r}&#xD;
	\end{aligned}&#xD;
	\right.&#xD;
$$&#xD;
&#xD;
&#xD;
Where $\lambda$ is the ray parameter.&#xD;
&#xD;
Now we construct a set of light which originates from the observer, and trace them backward:&#xD;
&#xD;
![Possible light paths][3]&#xD;
&#xD;
![Definition of variables][4]&#xD;
&#xD;
![How interpolation works][5]&#xD;
&#xD;
On each ray, we take some sample points and record the corresponding angle $\theta_0$, $\theta_1$, and time $\Delta T$. By interpolating them, we know about how a random object will look like in our eyes.&#xD;
&#xD;
    (*Initial definitions*)&#xD;
    Rs = 1;&#xD;
    R0 = 6 Rs;&#xD;
    Rmax = 6 Rs + 1.*^-6;&#xD;
    (*Tracking the light*)&#xD;
    parfunc = &#xD;
      ParametricNDSolveValue[{{tt&amp;#039;&amp;#039;[\[Tau]], &#xD;
          rr&amp;#039;&amp;#039;[\[Tau]], \[Theta]\[Theta]&amp;#039;&amp;#039;[\[Tau]]} == {(&#xD;
          Derivative[1][rr][\[Tau]] Derivative[1][tt][\[Tau]])/(&#xD;
          rr[\[Tau]] - rr[\[Tau]]^2), (&#xD;
           rr[\[Tau]]^2 Derivative[1][&#xD;
              rr][\[Tau]]^2 - (-1 + rr[\[Tau]])^2 Derivative[1][&#xD;
              tt][\[Tau]]^2)/(&#xD;
           2 (-1 + rr[\[Tau]]) rr[\[Tau]]^3) + (-1 + &#xD;
              rr[\[Tau]]) Derivative[1][\[Theta]\[Theta]][\[Tau]]^2, -((&#xD;
           2 Derivative[1][rr][\[Tau]] Derivative[&#xD;
             1][\[Theta]\[Theta]][\[Tau]])/rr[\[Tau]])}, {tt&amp;#039;[0], &#xD;
          rr&amp;#039;[0], \[Theta]\[Theta]&amp;#039;[&#xD;
           0]} == {1/(1 - Rs/R0), -Cos[\[Theta]0], &#xD;
          Sqrt[1/(1 - Rs/R0)]/R0 Sin[\[Theta]0]}, {tt[0], &#xD;
          rr[0], \[Theta]\[Theta][0]} == {0, R0, 0}, &#xD;
        WhenEvent[&#xD;
         1.01 Rs &amp;gt;= rr[\[Tau]] || &#xD;
          rr[\[Tau]] &amp;gt;= Rmax || \[Theta]\[Theta][\[Tau]] &amp;gt;= 3.1 Pi, &#xD;
         &amp;#034;StopIntegration&amp;#034;]}, {tt[\[Tau]], &#xD;
        rr[\[Tau]], \[Theta]\[Theta][\[Tau]]}, {\[Tau], 0, &#xD;
        1000}, {\[Theta]0}];&#xD;
    (*data used in interpolation*)&#xD;
    datp = Catenate@&#xD;
       Table[With[{pf = parfunc[\[Theta]]}, &#xD;
         With[{\[Tau]max = pf[[1, 0, 1, 1, 2]], df = D[Rest@pf, \[Tau]], &#xD;
           f = Rest@pf}, &#xD;
          Block[{\[Tau] = &#xD;
             Range[RandomReal[{0, \[Tau]max/500}], \[Tau]max, \[Tau]max/&#xD;
               500]}, Select[&#xD;
            Thread[(Thread@f -&amp;gt; &#xD;
               Thread@{\[Theta], &#xD;
                 ArcTan[-df[[1]], df[[2]] f[[1]] Sqrt[1 - Rs/f[[1]]]], &#xD;
                 pf[[1]]})], &#xD;
            2.4 Rs &amp;lt; #[[1, 1]] &amp;lt; 5.6 Rs &amp;amp;&amp;amp; -0.05 Pi &amp;lt; #[[1, 1]] &amp;lt; &#xD;
               3.08 Pi &amp;amp;]]]], {\[Theta], &#xD;
         Range[-2.5 Degree, 80 Degree, 1 Degree]~Join~&#xD;
          Range[20.2 Degree, 28.2 Degree, 0.5 Degree]~Join~&#xD;
          Range[23.025 Degree, 24.05 Degree, 0.05 Degree]~Join~&#xD;
          Range[23.2825 Degree, 23.4 Degree, 0.005 Degree]~Join~&#xD;
          Range[23.28525 Degree, 23.30025 Degree, 0.001 Degree]}];&#xD;
    datp = First /@ GatherBy[datp, Floor[#[[1]]/{0.01 Rs, 1 Degree}] &amp;amp;];&#xD;
    &#xD;
    (*Construct InterpolatingFunctions*)&#xD;
    ReceiveAngleFunction = &#xD;
      Interpolation[Thread[{datp[[;; , 1]], datp[[;; , 2, 1]]}], &#xD;
       InterpolationOrder -&amp;gt; 1];&#xD;
    EmitAngleFunction = &#xD;
     Interpolation[Thread[{datp[[;; , 1]], datp[[;; , 2, 2]]}], &#xD;
      InterpolationOrder -&amp;gt; 1];&#xD;
    DelayFunction = &#xD;
     Interpolation[Thread[{datp[[;; , 1]], datp[[;; , 2, 3]]}], &#xD;
      InterpolationOrder -&amp;gt; 1];&#xD;
    (*Angle vs time of observation*)&#xD;
    GenerateAngleFunctions[R1_, \[Theta]1_] := Block[{\[Phi]1},&#xD;
      With[{interpol = &#xD;
           Interpolation@&#xD;
            Table[{DelayFunction[R1, #] + &#xD;
               Sqrt[2 R1^3] \[Phi]1, \[Phi]1}, {\[Phi]1, 0., 2 Pi, &#xD;
              10. Degree}]},&#xD;
         With[{ts = interpol[[1, 1, 1]], tperiod = 2. Pi Sqrt[2 R1^3]}, &#xD;
          Function[t, interpol[t - Floor[t - ts, tperiod]]]]] &amp;amp; /@ ({#, &#xD;
           2 Pi - #, 2 Pi + #} &amp;amp;@ArcCos[Sin[\[Phi]1] Sin[\[Theta]1]])]&#xD;
&#xD;
If we only consider this effect, then we will have something like this:&#xD;
&#xD;
![Light bending included][6]&#xD;
&#xD;
The inner two rings correspond to the light that rotates around the black hole for more than half a round.&#xD;
&#xD;
And if we consider the propagation time of light, the right side will be a bit brighter.&#xD;
&#xD;
![Time correction included][7]&#xD;
&#xD;
This is because on the right, objects are moving away from you. So from your point of view, these particles will stay for a longer time on the right. (The reason is explained in the figure)&#xD;
&#xD;
![Illustration of how velocity influence timing][8]&#xD;
&#xD;
##&amp;#034;Brighter when Closer&amp;#034;&#xD;
The next question is about the &amp;#034;brighter when closer&amp;#034; rule. We all know that the further a bulb is, the dimmer it would appear to be. This is because the light from the bulb is approximately evenly distributed across solid angles, but as we move further, the solid angle corresponding to our eyes will be smaller. Mathematically, this is saying $I\propto S_0 \frac{d\Omega}{dS}$ where $S_0$ is the surface area of our eyes, $S$ is area, and $\Omega$ is the solid angle.&#xD;
&#xD;
![&amp;#034;Brighter when closer&amp;#034; rule in flat space][9]&#xD;
&#xD;
The same rules apply here in curved spacetime, except the light beams are weirder.&#xD;
&#xD;
![&amp;#034;Brighter when closer&amp;#034; rule in curved space][10]&#xD;
&#xD;
We know that $\frac{d\Omega}{dS}=(\frac{dx}{d\theta_x}\frac{dy}{d\theta_y})^{-1}$. While $\frac{dy}{d\theta_y}=\frac{R_0 \sin \alpha}{\sin \theta_1}$ can be derived using basic solid geometry, $\frac{dx}{d\theta_x}$ must be calculated numerically by tracing the light from the object to the observer. Similarly, we use interpolating function to generalize the result from a set of sample points to the whole space.&#xD;
&#xD;
    (*Reverse ray tracing*)&#xD;
    parfuncrev = &#xD;
      ParametricNDSolveValue[{{tt&amp;#039;&amp;#039;[\[Tau]], &#xD;
          rr&amp;#039;&amp;#039;[\[Tau]], \[Theta]\[Theta]&amp;#039;&amp;#039;[\[Tau]]} == {(&#xD;
          Derivative[1][rr][\[Tau]] Derivative[1][tt][\[Tau]])/(&#xD;
          rr[\[Tau]] - rr[\[Tau]]^2), (&#xD;
           rr[\[Tau]]^2 Derivative[1][&#xD;
              rr][\[Tau]]^2 - (-1 + rr[\[Tau]])^2 Derivative[1][&#xD;
              tt][\[Tau]]^2)/(&#xD;
           2 (-1 + rr[\[Tau]]) rr[\[Tau]]^3) + (-1 + &#xD;
              rr[\[Tau]]) Derivative[1][\[Theta]\[Theta]][\[Tau]]^2, -((&#xD;
           2 Derivative[1][rr][\[Tau]] Derivative[&#xD;
             1][\[Theta]\[Theta]][\[Tau]])/rr[\[Tau]])}, {tt&amp;#039;[0], &#xD;
          rr&amp;#039;[0], \[Theta]\[Theta]&amp;#039;[0]} == {1/(1 - Rs/R1), &#xD;
          Cos[\[Theta]0], -Sqrt[1/(1 - Rs/R1)]/R1 Sin[\[Theta]0]}, {tt[0],&#xD;
           rr[0], \[Theta]\[Theta][0]} == {0, R1, \[Theta]1}, &#xD;
        WhenEvent[\[Theta]\[Theta][\[Tau]] == 0, &#xD;
         &amp;#034;StopIntegration&amp;#034;]}, {tt[\[Tau]], &#xD;
        rr[\[Tau]], \[Theta]\[Theta][\[Tau]]}, {\[Tau], 0, &#xD;
        100}, {\[Theta]0, R1, \[Theta]1}];&#xD;
    (*data used in interpolation*)&#xD;
    \[CapitalDelta]\[Phi] = 1.*^-5;&#xD;
    intensity = &#xD;
      Catenate@Table[{{R, \[Theta]}, &#xD;
         R0^2 With[{\[Theta] = Abs[\[Theta]]}, &#xD;
           Abs[Sin[EmitAngleFunction[&#xD;
                R, \[Theta]]]/(R0 \&#xD;
    Sin[\[Theta]])]*(\[CapitalDelta]\[Phi]/(Sin[&#xD;
                 ReceiveAngleFunction[R, \[Theta]]]* &#xD;
                Subtract @@ (With[{f = &#xD;
                       parfuncrev[&#xD;
                        EmitAngleFunction[&#xD;
                        R, \[Theta]] + # \[CapitalDelta]\[Phi], &#xD;
                        R, \[Theta]][[2, 0]]}, f@f[[1, 1, -1]]] &amp;amp; /@ {-1, &#xD;
                    1})))]}, {R, 2.45 Rs, 5.55 Rs, &#xD;
         0.02 Rs}, {\[Theta], -3 Degree, 543 Degree, 2 Degree}];&#xD;
    &#xD;
    (*Construct InterpolatingFunction*)&#xD;
    IntensityFunction1 = Interpolation[intensity];&#xD;
&#xD;
![With intensity correction 1][11]&#xD;
&#xD;
The figure will be much more realistic in the aspect of intensity after we added this effect. The inner two rings are much dimmer because light bent dramatically is rare after all.&#xD;
&#xD;
##Doppler Effect and Headlight Effect&#xD;
Now its time for Doppler effect and headlight effect. These two effects are related to the movement of light-emitting objects and observers. Though the names of these effects can be forbidding, these effects are quite common in everyday life. Blueshift refers to the phenomenon that when a car is approaching you, the noise made by the car would be more acute and loud, and redshift means when the car is leaving you, the noise would quieter and be of lower frequency. &#xD;
&#xD;
![Doppler effect][12]&#xD;
&#xD;
The equation for the relativistic Doppler effect is:&#xD;
&#xD;
$$&#xD;
    f&amp;#039;=f\frac{\sqrt{1-\beta^2}}{1-\beta \cos \theta}&#xD;
$$&#xD;
&#xD;
where $\beta=\frac{v}{c}$ and $\theta$ is the angle between the velocity direction of the light-emitting object and the light emitted, as observed by an external observer. In this case, we should further add a coefficient of &#xD;
&#xD;
$$&#xD;
 f&amp;#039;&amp;#039;=f&amp;#039;\sqrt{\frac{1 - R_s/R_1}{1 - R_s/R_0}}&#xD;
$$&#xD;
&#xD;
due to general relativistic effects.&#xD;
&#xD;
Headlight effect means when you are driving a car on rainy days, no matter how the wind blows, the raindrops will always run towards the windshield. But if you stop your vehicle, you can see how the wind influences the dropping direction of rain.  &#xD;
&#xD;
![Headlight effect][13]&#xD;
&#xD;
The equation for angle transformation is:&#xD;
&#xD;
$$&#xD;
    \cos \theta&amp;#039;= \frac{\cos \theta +\beta}{1+\beta \cos \theta}&#xD;
$$&#xD;
&#xD;
and such, the intensity difference introduced by this can be written as:&#xD;
&#xD;
$$&#xD;
    \frac{dP&amp;#039;}{d\Omega}= \frac{dP}{d\Omega}\frac{\sin \theta}{\sin \theta&amp;#039;}\frac{d \theta}{d \theta&amp;#039;}=\frac{dP}{d\Omega}\frac{1 - \beta^2}{(1 -\beta \cos \theta)^2}&#xD;
$$&#xD;
&#xD;
Except for the difference in timing brought by the curved spacetime, these two effects are purely in the special relativity regime. The only thing involved in coding is tedious coordinate transformation. &#xD;
&#xD;
    (*Calculate moving speed*)&#xD;
    Calc\[Beta][{R1_, \[Theta]_, \[Phi]_}, {vr_, v\[Theta]_, v\[Phi]_}] :=&#xD;
      Sqrt[vr^2/(1 - &#xD;
           Rs/R1) + (R1 v\[Theta])^2 + (R1 Sin[\[Theta]] v\[Phi])^2]/&#xD;
      Sqrt[1 - Rs/R1]&#xD;
    (*Calculate inner product between moving direction and light direction*)&#xD;
    CalcCosAngle[{R1_, \[Theta]_, \[Phi]_}, {vr_, v\[Theta]_, v\[Phi]_}] :=&#xD;
      With[{v = {vr/Sqrt[1 - Rs/R1], R1 v\[Theta], &#xD;
         R1 Sin[\[Theta]] v\[Phi]}}, &#xD;
      MapThread[With[{\[Theta]0 = EmitAngleFunction[R1, #1]},&#xD;
         With[{vnormed = MapThread[Normalize@*List, v]}, &#xD;
          MapThread[&#xD;
           Dot, {vnormed, Thread@{Cos[\[Theta]0], #2 Sin[\[Theta]0], 0}}, &#xD;
           1]]] &amp;amp;, {{\[Theta], 2 Pi - \[Theta], 2 Pi + \[Theta]}, {-1, &#xD;
         1, -1}}]]&#xD;
    (*Frequency shift, Doppler effect + GR timing effects*)&#xD;
    FrequencyMult[R1_, \[Beta]_, cos_] := &#xD;
     Sqrt[(1 - Rs/R1)/(1 - Rs/R0)]*Sqrt[1 - \[Beta]^2]/(1 - \[Beta] cos)&#xD;
    (*Intensity shift due to headlight effect only*)&#xD;
    IntensityMult2[\[Beta]_, &#xD;
      cos_] := (Sqrt[1 - \[Beta]^2]/(1 - \[Beta] cos))^2&#xD;
&#xD;
Then we can put all these effects together and see how things works out!&#xD;
&#xD;
    &amp;lt;&amp;lt; PhysicalColor`&#xD;
    &#xD;
    IntensityFunctionScaling::usage = &amp;#034;Scale Intensity.&amp;#034;;&#xD;
    Protect@IntensityFunctionScaling;&#xD;
    &#xD;
    Options[RenderFunc] = {ColorFunction -&amp;gt; TemperatureColor, &#xD;
       ColorFunctionScaling -&amp;gt; (# &amp;amp;), IntensityFunctionScaling -&amp;gt; (# &amp;amp;), &#xD;
       &amp;#034;StaticObserver&amp;#034; -&amp;gt; True};&#xD;
    &#xD;
    RenderFunc[R1_, {\[Theta]1_, t1_, \[Gamma]1_}, {T0_, I0_}, &#xD;
      OptionsPattern[]] :=&#xD;
     Function[t, Through[#[t]]] &amp;amp;@Module[{&#xD;
        (*Velocity of observer*)&#xD;
        vobs = N@Sqrt[(1 - Rs/R0) Rs/(2 R0)],&#xD;
        (*list of \[Phi]1 parameters*)&#xD;
        \[Phi]1l = Range[0., 2 Pi, 1 Degree],&#xD;
        (*Polar coordinates \[Theta] and \[Phi]*)&#xD;
        \[Theta]l0, \[Phi]l0,&#xD;
        (*velocity of object and its norm*)&#xD;
        vrl, v\[Theta]l, v\[Phi]l, vnorml&#xD;
        },&#xD;
       (*Polar coordinate \[Theta]*)&#xD;
       \[Theta]l0 = ArcCos[Sin[\[Phi]1l] Sin[\[Theta]1]];&#xD;
       &#xD;
       (*Original \[Phi]*)&#xD;
       \[Phi]l0 = &#xD;
        ArcTan[Cos[\[Phi]1l], Sin[\[Phi]1l] Cos[\[Theta]1]] + \[Gamma]1;&#xD;
       &#xD;
       (*velocity of object*)&#xD;
       vrl = ConstantArray[0, Length@\[Phi]1l];&#xD;
       v\[Theta]l = -(Cos[\[Phi]1l] Sin[\[Theta]1])/&#xD;
          Sqrt[1 - Sin[\[Theta]1]^2 Sin[\[Phi]1l]^2]*Sqrt[Rs/(2 R1^3)];&#xD;
       v\[Phi]l = &#xD;
        1/(Cos[\[Phi]1l]^2/Cos[\[Theta]1] + &#xD;
            Cos[\[Theta]1] Sin[\[Phi]1l]^2)*Sqrt[Rs/(2 R1^3)];&#xD;
       &#xD;
       (*velocity norm*)&#xD;
       vnorml = &#xD;
        Calc\[Beta][{R1, \[Theta]l0, 0}, {vrl, v\[Theta]l, v\[Phi]l}];&#xD;
       &#xD;
       MapThread[Module[{&#xD;
           (*Observed \[Phi]1 parameter - t*)&#xD;
           \[Phi]1t = #3,&#xD;
           (*actual \[Theta] of object*)&#xD;
           \[Theta]l = #1,&#xD;
           (*angle between velocy and ray*)&#xD;
           cosl = #4,&#xD;
           (*Observed values - \[Phi]1*)&#xD;
           (*Geometry*)&#xD;
           \[Theta]obsl, \[Phi]obsl = \[Phi]l0 + #2,&#xD;
           (*Frequency and intensity shift*)&#xD;
           freqobsl, intobsl,&#xD;
           (*helper function*)&#xD;
           helpf&#xD;
           },&#xD;
          \[Theta]obsl = ReceiveAngleFunction[R1, \[Theta]l];&#xD;
          &#xD;
          (*Frequency*)&#xD;
          freqobsl = FrequencyMult[R1, vnorml, cosl];&#xD;
          &#xD;
          (*Process with the non-static observer*)&#xD;
          If[OptionValue[&amp;#034;StaticObserver&amp;#034;] =!= True,&#xD;
           Module[{\[Theta]transl, \[Phi]transl, \[Delta] = ArcSin[vobs]},&#xD;
            (*Geometrics, static frame*)&#xD;
            \[Theta]transl = ArcCos[Sin[\[Theta]obsl] Cos[\[Phi]obsl]];&#xD;
            \[Phi]transl = &#xD;
             ArcTan[Sin[\[Theta]obsl] Sin[\[Phi]obsl], Cos[\[Theta]obsl]];&#xD;
            (*Frequency shift due to movement of observer, &#xD;
            intensity shift is calculated together later*)&#xD;
            freqobsl *= (1 + vobs Cos[\[Theta]transl])/Sqrt[1 - vobs^2];&#xD;
            (*Angle shift due to movement of observer*)&#xD;
            \[Theta]transl = &#xD;
             ArcCos[(vobs + Cos[\[Theta]transl])/(1 + &#xD;
                 vobs Cos[\[Theta]transl])];&#xD;
            (*Transform back*)&#xD;
            (*Here we change the center of viewing angle so that the \&#xD;
    black hole&amp;#039;s center is at {0,0}*)&#xD;
            \[Theta]obsl = &#xD;
             ArcCos[Sin[\[Delta]] Cos[\[Theta]transl] + &#xD;
               Cos[\[Delta]] Sin[\[Theta]transl] Sin[\[Phi]transl]];&#xD;
            \[Phi]obsl = &#xD;
             ArcTan[Cos[\[Delta]] Cos[\[Theta]transl] - &#xD;
               Sin[\[Delta]] Sin[\[Theta]transl] Sin[\[Phi]transl], &#xD;
              Sin[\[Theta]transl] Cos[\[Phi]transl]]&#xD;
            ]&#xD;
           ];&#xD;
          &#xD;
          \[Phi]obsl = &#xD;
           Catenate[&#xD;
            MapIndexed[#1 + 2 Pi #2[[1]] &amp;amp;, Split[\[Phi]obsl, Less]]];&#xD;
          &#xD;
          (*Intensity*)&#xD;
          intobsl = &#xD;
           freqobsl^2*IntensityFunction1[R1, \[Theta]l]*&#xD;
            IntensityMult2[vnorml, cosl]*&#xD;
            TemperatureIntensity[freqobsl T0]/TemperatureIntensity[T0]/&#xD;
             freqobsl^4;&#xD;
          &#xD;
          (*Helper function to construct interpolating functions*)&#xD;
          helpf[l_] := Interpolation[Thread[{\[Phi]1l, l}]];&#xD;
          &#xD;
          With[{&#xD;
            cf = OptionValue[ColorFunction],&#xD;
            (*Interpolating functions*)&#xD;
            t11 = t1,&#xD;
            \[Phi]1f = #3,&#xD;
            \[Theta]func = helpf[\[Theta]obsl],&#xD;
            \[Phi]func = helpf[\[Phi]obsl],&#xD;
            freqfunc = &#xD;
             helpf[OptionValue[ColorFunctionScaling][T0 freqobsl]],&#xD;
            intfunc = &#xD;
             helpf[OptionValue[IntensityFunctionScaling][I0 intobsl]]&#xD;
            },&#xD;
            &#xD;
           (*Final function*)&#xD;
           Function[t,&#xD;
            With[{\[Phi]11 = \[Phi]1f[t + t11]},&#xD;
             {Append[cf[freqfunc[\[Phi]11]], intfunc[\[Phi]11]],&#xD;
              &#xD;
              With[{\[Theta] = \[Theta]func[\[Phi]11], \[Phi] = \&#xD;
    \[Phi]func[\[Phi]11]},&#xD;
               (*Point[{Sin[\[Theta]]Cos[\[Phi]],Sin[\[Theta]]Sin[\[Phi]],&#xD;
               Cos[\[Theta]]}]*)&#xD;
               Point[Tan[\[Theta]] {Cos[\[Phi]], Sin[\[Phi]]}]]}&#xD;
             ]]&#xD;
           ]&#xD;
          ] &amp;amp;, {{\[Theta]l0, 2 Pi - \[Theta]l0, 2 Pi + \[Theta]l0}, {0, &#xD;
          Pi, 0}, GenerateAngleFunctions[R1, \[Theta]1], &#xD;
         CalcCosAngle[{R1, \[Theta]l0, 0}, {vrl, v\[Theta]l, v\[Phi]l}]}]]&#xD;
    (*My version of rasterize, which increase color precision in dimmer areas*)&#xD;
    HDRRasterize[gr_Graphics, convertfunc_, &#xD;
      opts : OptionsPattern[Rasterize]] :=&#xD;
     Module[{rasterl = &#xD;
        Join[ColorSeparate[ColorConvert[Rasterize[gr, opts], &amp;#034;HSB&amp;#034;]], &#xD;
         ColorSeparate[&#xD;
          ColorConvert[&#xD;
           Rasterize[&#xD;
            gr /. RGBColor[r_, g_, b_, op_] :&amp;gt; RGBColor[r, g, b, 16 op], &#xD;
            opts], &amp;#034;HSB&amp;#034;]]], mask, invmask},&#xD;
      mask = Binarize[rasterl[[3]], 1/16];&#xD;
      invmask = 1 - mask;&#xD;
      ColorCombine[{&#xD;
        mask*rasterl[[1]] + invmask*rasterl[[4]],&#xD;
        mask*rasterl[[2]] + invmask*rasterl[[5]],&#xD;
        mask*convertfunc[rasterl[[3]]] + &#xD;
         invmask*convertfunc[rasterl[[6]]/16.]}, &amp;#034;HSB&amp;#034;]&#xD;
      ]&#xD;
    (*Preliminary computation*)&#xD;
    npts = 5000;&#xD;
    rflist = MapThread[&#xD;
       Function[{R1, \[Theta]1, t1, \[Gamma]1, T0, I0}, &#xD;
        RenderFunc[R1, {\[Theta]1, t1, \[Gamma]1}, {T0, I0}, &#xD;
         &amp;#034;StaticObserver&amp;#034; -&amp;gt; False(*,&#xD;
         IntensityFunctionScaling\[Rule](.7(#/.5)^0.5&amp;amp;)*)]],&#xD;
       {RandomReal[{3, 4.5}, npts],&#xD;
        RandomReal[-{83, 86} Degree, npts],&#xD;
        RandomReal[{0, 10000}, npts],&#xD;
        RandomReal[15 Degree + {-2, 2} Degree, npts],&#xD;
        RandomReal[{4000, 10000}, npts],&#xD;
        RandomReal[{.03, .1}, npts]&#xD;
        }&#xD;
       ];&#xD;
    (*rendering!!!*)&#xD;
    g = Graphics[{(*AbsolutePointSize@.1,White,Point[{Sin[20Degree]Cos[#],&#xD;
        Sin[20Degree]Sin[#],Cos[20Degree]}&amp;amp;/@Range[0.,360.Degree,&#xD;
        60.Degree]],*)AbsoluteThickness@2, &#xD;
        Map[Line[#[[;; , 2, 1]], &#xD;
           VertexColors -&amp;gt; &#xD;
            MapThread[&#xD;
             Function[{col, len, mult}, &#xD;
              MapAt[mult^2*#*0.006/len &amp;amp;, col, 4]], {#[[;; , 1]], &#xD;
              Prepend[#, #[[1]]] &amp;amp;@&#xD;
               BlockMap[Norm[#[[2]] - #[[1]]] &amp;amp;, #[[;; , 2, 1]], 2, 1], &#xD;
              Subdivide[Length[#] - 1]}]] &amp;amp;, &#xD;
         Reverse@Transpose[&#xD;
           Through[rflist[#]] &amp;amp; /@ (Range[0, 3, .1]), {3, 2, 1}], {2}]}, &#xD;
       Background -&amp;gt; Black, ImageSize -&amp;gt; {500, Automatic}, &#xD;
       PlotRange -&amp;gt; {{-1.28, 1.28}, {-0.72, 0.72}}];&#xD;
&#xD;
    HDRRasterize[g, #^(1/2.2) &amp;amp;, ImageSize -&amp;gt; {1920, 1080}]&#xD;
&#xD;
![With all effects, static observer][14]&#xD;
&#xD;
Well, because objects at left are moving towards you, they will appear much brighter and blue-ish, while objects at right are much dimmer and red-ish.&#xD;
&#xD;
We can also consider the movement of the observer, which will make the image something like this:&#xD;
&#xD;
![With all effects, observer moving][15]&#xD;
&#xD;
Hooray!&#xD;
&#xD;
The notebook can be found in the attachment or at [my github repo](https://github.com/wjxway/Realistic_Blackhole_Accretion_Disk).&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=bh10.png&amp;amp;userId=1340903&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=T_001.png&amp;amp;userId=1340903&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Path_4.png&amp;amp;userId=1340903&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=illus2.png&amp;amp;userId=1340903&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=illus1.png&amp;amp;userId=1340903&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=LightBending.png&amp;amp;userId=1340903&#xD;
  [7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=WithTimeCorrection.png&amp;amp;userId=1340903&#xD;
  [8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=illus3.png&amp;amp;userId=1340903&#xD;
  [9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=IntensityIllus.png&amp;amp;userId=1340903&#xD;
  [10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=illus4.png&amp;amp;userId=1340903&#xD;
  [11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=WithIntensity1.png&amp;amp;userId=1340903&#xD;
  [12]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Doppler.jpg&amp;amp;userId=1340903&#xD;
  [13]: https://community.wolfram.com//c/portal/getImageAttachment?filename=FrontLight.jpg&amp;amp;userId=1340903&#xD;
  [14]: https://community.wolfram.com//c/portal/getImageAttachment?filename=WithAllEffects.png&amp;amp;userId=1340903&#xD;
  [15]: https://community.wolfram.com//c/portal/getImageAttachment?filename=WithObserverMoving.png&amp;amp;userId=1340903</description>
    <dc:creator>Jingxian Wang</dc:creator>
    <dc:date>2020-07-02T11:26:03Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/3458262">
    <title>The uncontrolled re-entry of a large Soviet-era Venus probe KOSMOS-482 on May 10, 2025</title>
    <link>https://community.wolfram.com/groups/-/m/t/3458262</link>
    <description>![The uncontrolled re-entry of a large Soviet-era Venus probe KOSMOS-482 on May 10, 2025][1]&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][2]&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Video-2025-05-09T12-02-59-ezgif.com-optimize.gif&amp;amp;userId=20103&#xD;
  [2]: https://www.wolframcloud.com/obj/1c63983c-ad3c-4244-b174-bfa84310904f</description>
    <dc:creator>Gosia Konwerska</dc:creator>
    <dc:date>2025-05-09T18:37:28Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/418720">
    <title>Calculus of the perfectly centered break of a perfectly aligned pool ball rack</title>
    <link>https://community.wolfram.com/groups/-/m/t/418720</link>
    <description>## This is it. The perfectly centered billiards break. Behold:&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
&amp;lt;h2&amp;gt;Setup&amp;lt;/h2&amp;gt;&#xD;
&#xD;
This break was computed in *Mathematica* using a numerical differential equations model.  Here are a few details of the model:&#xD;
&#xD;
* All balls are assumed to be perfectly [elastic][3] and almost perfectly rigid.&#xD;
* Each ball has a mass of 1 unit and a radius of 1 unit.&#xD;
* The cue ball has a initial speed of 10 units/sec.&#xD;
* The force between two balls is given by the formula $$F \;=\; \begin{cases}0 &amp;amp; \text{if }d \geq 2, \\ 10^{11}(2-d)^{3/2} &amp;amp; \text{if }d &amp;lt; 2, \end{cases}$$ where $d$ is the distance between the centers of the balls.  Note that the balls overlap if and only if $d &amp;lt; 2$.  The power of $3/2$ was [suggested by Yoav Kallus][4] on Math Overflow, because it follows [Hertz&amp;#039;s theory of non-adhesive elastic contact](https://en.wikipedia.org/wiki/Contact_mechanics#Hertzian_theory_of_non-adhesive_elastic_contact).&#xD;
&#xD;
The initial speed of the cue ball is immaterial -- slowing down the cue ball is the same as slowing down time. The force constant $10^{11}$ has no real effect as long as it&amp;#039;s large enough, although it does change the speed at which the initial collision takes place.&#xD;
&#xD;
&amp;lt;h2&amp;gt;The Collision&amp;lt;/h2&amp;gt;&#xD;
&#xD;
For this model, the entire collision takes place in the first 0.2 milliseconds, and none of the balls overlap by more than 0.025% of their radius during the collision.  (These figures are model dependent -- real billiard balls may collide faster or slower than this.)&#xD;
&#xD;
The following animation shows the forces between the balls during the collision, with the force proportional to the area of each yellow circle.  Note that the balls themselves hardly move at all *during* the collision, although they do accelerate quite a bit.&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
&amp;lt;h2&amp;gt;The Trajectories&amp;lt;/h2&amp;gt;&#xD;
&#xD;
The following picture shows the trajectories of the billiard balls after the collision.&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
After the collision, some of the balls are travelling considerably faster than others.  The following table shows the magnitude and direction of the velocity of each ball, where $0^\circ$ indicates straight up.&#xD;
&#xD;
&#xD;
$\begin{array}{|c|c|c|c|c|c|c|c|c|c|c|}&#xD;
\hline&#xD;
\text{ball} &amp;amp; \text{cue} &amp;amp; 1 &amp;amp; 2,3 &amp;amp; 4,6 &amp;amp; 5 &amp;amp; 7,10 &amp;amp; 8,9 &amp;amp; 11,15 &amp;amp; 12,14 &amp;amp; 13 \\&#xD;
\hline&#xD;
\text{angle} &amp;amp; 0^\circ &amp;amp; 0^\circ &amp;amp; 40.1^\circ &amp;amp; 43.9^\circ &amp;amp; 0^\circ &amp;amp; 82.1^\circ &amp;amp; 161.8^\circ &amp;amp; 150^\circ &amp;amp; 178.2^\circ &amp;amp; 180^\circ \\&#xD;
\hline&#xD;
\text{speed} &amp;amp; 1.79 &amp;amp; 1.20 &amp;amp; 1.57 &amp;amp; 1.42 &amp;amp; 0.12 &amp;amp; 1.31 &amp;amp; 0.25 &amp;amp; 5.60 &amp;amp; 2.57 &amp;amp; 2.63 \\&#xD;
\hline&#xD;
\end{array}&#xD;
$&#xD;
&#xD;
&#xD;
For comparison, remember that the initial speed of the cue ball was 10 units/sec.  Thus, balls 11 and 15 (the back corner balls) shoot out at more than half the speed of the original cue ball, whereas ball 5 slowly rolls upwards at less than 2% of the speed of the original cue ball.&#xD;
&#xD;
By the way, if you add up the sum of the squares of the speeds of the balls, you get 100, since kinetic energy is conserved.&#xD;
&#xD;
&#xD;
&amp;lt;h2&amp;gt;Linear and Quadratic Responses&amp;lt;/h2&amp;gt;&#xD;
&#xD;
The results of this model are dependent on the power of $3/2$ in the force law -- other force laws give other breaks.  For example, we could try making the force a linear function of the overlap distance (in analogy with springs and [Hooke&amp;#039;s law][7]), or we could try making the force proportional to the  *square* of the overlap distance.  The results are noticeably different&#xD;
&#xD;
![enter image description here][8] ![enter image description here][9]&#xD;
&#xD;
&#xD;
&amp;lt;h2&amp;gt;Stiff Response&amp;lt;/h2&amp;gt;&#xD;
&#xD;
Glenn the Udderboat points out that &amp;#034;stiff&amp;#034; balls might be best approximated by a force response involving a higher power of the distance (although this isn&amp;#039;t the [usual definition][10] of &amp;#034;stiffness&amp;#034;).  Unfortunately, the calculation time in *Mathematica* becomes longer when the power is increased, presumably because it needs to use a smaller time step to be sufficiently accurate.&#xD;
&#xD;
Here is a simulation involving a reasonably &amp;#034;stiff&amp;#034; force law&#xD;
$$F \;=\; \begin{cases}0 &amp;amp; \text{if }d \geq 2, \\ 10^{54}(2-d)^{10} &amp;amp; \text{if }d&amp;lt;2. \end{cases}$$&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
As you can see, the result is very similar to my first thought:&#xD;
&#xD;
&amp;gt; The two balls in the back corners shoot away along rays parallel to the two sides of the triangle.  Here is a picture showing the forces, with each force vector emanating from the point of contact.&#xD;
&#xD;
&amp;gt; ![enter image description here][12]&#xD;
&#xD;
This seems like good evidence that above 1st-thought behavior is indeed the limiting behavior in the case where the stiffness goes to infinity. As you might expect, most of the energy in this case is transferred very quickly at the beginning of the collision.  Almost all of the energy has moves to the back corner balls in the first 0.02 milliseconds.  Here is an animation of the forces:&#xD;
&#xD;
&#xD;
![enter image description here][13]&#xD;
&#xD;
After that, the corner balls and the cue ball shoot out, and the remaining balls continue to collide gently for the next millisecond or so.&#xD;
&#xD;
While the simplicity of this behavior is appealing, I would guess that &amp;#034;real&amp;#034; billard balls do not have such a stiff force response.  Of the models listed here, the intial Hertz-based model is probably the most accurate.  Qualitatively, it certainly seems the closest to an &amp;#034;actual&amp;#034; break.&#xD;
&#xD;
&amp;lt;h2&amp;gt; Full Code &amp;lt;/h2&amp;gt;&#xD;
&#xD;
&amp;amp;[Wolfram Notebook][14]&#xD;
&#xD;
----------&#xD;
&#xD;
I wrote this post originally for [Math Stack Exchange][15].&#xD;
&#xD;
&#xD;
  [1]: http://math.bard.edu/belk/code.htm&#xD;
  [2]: http://i.stack.imgur.com/Y9ixR.gif&#xD;
  [3]: https://en.wikipedia.org/wiki/Elasticity_%28physics%29&#xD;
  [4]: http://mathoverflow.net/questions/156263/perfectly-centered-break-of-a-perfectly-aligned-pool-ball-rack/156407?noredirect=1#comment400402_156407&#xD;
  [5]: http://i.stack.imgur.com/WY37i.gif&#xD;
  [6]: http://i.stack.imgur.com/wHVJA.png&#xD;
  [7]: https://en.wikipedia.org/wiki/Hooke%27s_law&#xD;
  [8]: http://i.stack.imgur.com/a1l3b.gif&#xD;
  [9]: http://i.stack.imgur.com/xM76n.gif&#xD;
  [10]: https://en.wikipedia.org/wiki/Stiffness&#xD;
  [11]: http://i.stack.imgur.com/nMJyT.gif&#xD;
  [12]: http://i.stack.imgur.com/GKGT9.png&#xD;
  [13]: http://i.stack.imgur.com/VuUWT.gif&#xD;
  [14]: https://www.wolframcloud.com/obj/8c6b7e81-4a5c-4e3a-bb13-a3d47e728e64&#xD;
  [15]: http://math.stackexchange.com/a/659318/28293</description>
    <dc:creator>Jim Belk</dc:creator>
    <dc:date>2015-01-08T18:02:10Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/787142">
    <title>Crystallica: A package to plot crystal structures</title>
    <link>https://community.wolfram.com/groups/-/m/t/787142</link>
    <description>## General information and download links ##&#xD;
&#xD;
If you&amp;#039;re interested in crystal structures, you can now download the Crystallica application from the Wolfram Library Archive, and then you can do things like this:&#xD;
&#xD;
    Needs[&amp;#034;Crystallica`&amp;#034;];&#xD;
    CrystalPlot[&#xD;
    {{5.4,0,0},{0,5.4,0},{0,0,5.4}},&#xD;
    {{0,0,0},{0,0,.5},{0,.5,0},{.5,0,0},{.24,.24,.24},{.24,.76,.76},{.76,.24,.76},{.76,.76,.24}},&#xD;
    {1,2,2,2,3,3,3,3},&#xD;
    AtomCol-&amp;gt;{&amp;#034;Firebrick&amp;#034;,&amp;#034;YellowGreen&amp;#034;,White},AtomRad-&amp;gt;.4,&#xD;
    BondStyle-&amp;gt;2,BondDist-&amp;gt;3,&#xD;
    CellLineStyle-&amp;gt;False,AddQ-&amp;gt;True,Lighting-&amp;gt;{{&amp;#034;Directional&amp;#034;,White,ImageScaled[{0,0,1}]}},Background-&amp;gt;Black]&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
Here are the download links for Crystallica and two other packages you may need:&#xD;
&#xD;
[Crystallica][2] - contains the functions `CrystalPlot` and `CrystalChange`&#xD;
&#xD;
[CifImport][3] - contains an import function for CIF files&#xD;
&#xD;
[VaspImport][4] - contains an import function for files related to [VASP][5]&#xD;
&#xD;
Once you&amp;#039;ve installed Crystallica (by saving the entire Crystallica folder - not the zip archive - to `$USerBaseDirectory/Applications` and re-starting the Kernel), you can enter Crystallica into the Documentation Center and you&amp;#039;ll find lots of useful examples. Most of the examples in this post are taken from the Documentation. For the other two packages, just install them and evaluate this:&#xD;
&#xD;
    ?CifImport&#xD;
    ?VaspImport&#xD;
&#xD;
I&amp;#039;ll first show you a few things the `CrystalPlot` function can do when you already have crystal structure data inside Mathematica, wherever it may have come from. Then we&amp;#039;ll take a look at how to get the data into Mathematica in the first place, which is where `CifImport` and `VaspImport` will come into play - but we&amp;#039;ll get data from other sources as well. I&amp;#039;ll cover the different import solutions in separate replies to this thread, because I have a feeling that I&amp;#039;ll be rambling on and on and on...&#xD;
&#xD;
## Simple plot ##&#xD;
&#xD;
Traditional ball-and-stick plots are usually just fine, so the simplest thing you can do is this:&#xD;
&#xD;
    CrystalPlot[&#xD;
    {{4.5,0,0},{0,4.5,0},{0,0,3}},&#xD;
    {{0,0,0},{.5,.5,.5},{.2,.8,.5},{.3,.3,0},{.7,.7,0},{.8,.2,.5}},&#xD;
    {1,1,2,2,2,2}]&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
As you can see, `CrystalPlot` expects three arguments. The first one contains the lattice vectors, which are simply the three vectors that create the parallelepiped that constitutes the cell. The second argument contains the atomic coordinates, but they&amp;#039;re given in the basis of the lattice vectors (which is quite useful in crystallography). The third argument is a list of integers that gives the atom types, with one entry for each atom. If you want to plot a molecule instead, you can call `CrystalPlot` with just two arguments: A list of atom coordinates in cartesian space, and a list of atom types. Everything else you see in the plot - the atoms, bonds, colours, arrows etc. - represents the default settings of various layout options.&#xD;
&#xD;
## Advanced atoms and bonds ##&#xD;
&#xD;
Let&amp;#039;s take a look at some more advanced options just for fun. For instance, atoms and bonds can look any way you need them to, because you can specify your own functions for them. You can also fine-tune where to put bonds and what to do with their thickness and colour in a physically (or chemically) meaningful way, but I won&amp;#039;t show that here. So here are some customized atoms and bonds:&#xD;
&#xD;
    Row[Table[&#xD;
    CrystalPlot[{{4,0,0},{0,4,0},{0,0,4}},{{0,0,0},{.4,.4,.4},{.8,.8,.8}},{1,2,3},&#xD;
    AtomRad-&amp;gt;{.4,1.2,.7},AtomFunction-&amp;gt;style,ImageSize-&amp;gt;400],&#xD;
    {style,{&#xD;
    (Ball[#1,#2]&amp;amp;),&#xD;
    (Scale[Sphere[#1,#2],{1,1,.5}]&amp;amp;),&#xD;
    ({EdgeForm[Thick],Opacity[.7],Cuboid[#1-.5*#2,#1+.5*#2]}&amp;amp;)&#xD;
    }}]]&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
    Row[Table[&#xD;
    CrystalPlot[{{0,0,0},{5,0,0},{2.5,4,0}},{1,2,3},BondDist-&amp;gt;6,BondStyle-&amp;gt;style,ImageSize-&amp;gt;400],&#xD;
    {style,{&#xD;
    1,&#xD;
    Function[{bonds,partcol},Table[{If[ii&amp;lt;.5,partcol[#,1],partcol[#,2]],Sphere[bonds[[#,1]]+ii*(bonds[[#,2]]-bonds[[#,1]]),.15]},{ii,0,1,1/9}]&amp;amp;/@Range[Length[bonds]]],&#xD;
    Function[{bonds,partcol},Module[{spiral,points,rad=.05},&#xD;
    spiral[atoms_]:=Module[{scale=.5,dist=atoms[[2]]-atoms[[1]],curls=60,normal,rot,scaled},&#xD;
    normal=Table[{scale*Cos[ii],scale*Sin[ii],.1*ii},{ii,0,curls,\[Pi]/10}];&#xD;
    scaled={#[[1]],#[[2]],10*Norm[dist]/curls*#[[3]]}&amp;amp;/@normal;&#xD;
    rot=scaled.Quiet[RotationMatrix[{dist,{0,0,1}}]];&#xD;
    Join[{atoms[[1]]},#+atoms[[1]]&amp;amp;/@(rot[[25;;-25]]),{atoms[[2]]}]];&#xD;
    points=spiral/@bonds;&#xD;
    {partcol[#,1],Tube[BSplineCurve[points[[#,;;Round[Length[points[[#]]]/2]]],rad]],partcol[#,2],Tube[BSplineCurve[points[[#,Round[Length[points[[#]]]/2];;]],rad]]}&amp;amp;/@Range[Length[bonds]]&#xD;
    ]]&#xD;
    }}]]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
## Lattice planes ##&#xD;
&#xD;
Crystallica can also add lattice planes to the plot. You can specify them using [h,k,l] Miller indices and distance to the origin.&#xD;
&#xD;
    CrystalPlot[{{3,0,0},{0,3,0},{0,0,3}},{{0,0,0}},{1},&#xD;
    AddQ-&amp;gt;True,AtomRad-&amp;gt;.3,AtomCol-&amp;gt;&amp;#034;CadmiumYellow&amp;#034;,Sysdim-&amp;gt;2,CellLineStyle-&amp;gt;2,&#xD;
    LatticePlanes-&amp;gt;Table[{{1,1,1},dist},{dist,1,5}],ContourStyle-&amp;gt;{&amp;#034;TerreVerte&amp;#034;,Opacity[.7]},BoundaryStyle-&amp;gt;Thick]&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
## Coordination polyhedra ##&#xD;
&#xD;
You can automatically search for and plot coordination polyhedra. This is not limited to the commonly occurring tetrahedra and octahedra - you can actually look for polyhedra with arbitrary numbers of corners. There are also options to fine-tune both the searching and the rendering.&#xD;
&#xD;
    plot[corners_,mixed_]:=CrystalPlot[{{0,0,0},{0,0,1.8},{-.9,-1.5,-.6},{-.9,1.5,-.6},{1.7,0,-.6},{.8,.8,.8}},{1,2,2,2,2,3},&#xD;
    BondStyle-&amp;gt;False,ImageSize-&amp;gt;250,&#xD;
    PolyMode[corners]-&amp;gt;{&amp;#034;Show&amp;#034;-&amp;gt;All,&amp;#034;AllowMixed&amp;#034;-&amp;gt;mixed},PolyStyle[corners]-&amp;gt;Directive[Opacity[.5],EdgeForm[Thick]]];&#xD;
    Grid[{{&#xD;
    &amp;#034;&amp;#034;,&#xD;
    &amp;#034;Search for polyhedra with \n4 corners&amp;#034;,&#xD;
    &amp;#034;Search for polyhedra with \n5 corners&amp;#034;&#xD;
    },{&#xD;
    &amp;#034;Allow \nmixed corners&amp;#034;,&#xD;
    plot[4,True],&#xD;
    plot[5,True]&#xD;
    },{&#xD;
    &amp;#034;Don&amp;#039;t allow \nmixed corners&amp;#034;,&#xD;
    plot[4,False],&#xD;
    plot[5,False]&#xD;
    }},Dividers-&amp;gt;All]&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
    CrystalPlot[{{2.5,-4.3,0},{2.5,4.3,0},{0,0,5.5}},&#xD;
    {{.5,0,0},{0,.5,.7},{.5,.5,.3},{.2,.4,.5},{.6,.8,.2},{.2,.8,.8},{.8,.6,.5},{.4,.2,.2},{.8,.2,.8}},{1,1,1,2,2,2,2,2,2},&#xD;
    PolyMode[4]-&amp;gt;True,PolyStyle[4]-&amp;gt;EdgeForm[None],AddQ-&amp;gt;True,&#xD;
    Sysdim-&amp;gt;2,AtomRad-&amp;gt;0,CellLineStyle-&amp;gt;False,AtomCol-&amp;gt;{&amp;#034;SlateGray&amp;#034;,&amp;#034;Firebrick&amp;#034;},&#xD;
    ViewAngle-&amp;gt;.4,ViewPoint-&amp;gt;{3.2,0,1.1},ViewVertical-&amp;gt;{.5,0,1.2}]&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
## Other things ##&#xD;
&#xD;
Visualization aside, you can also build supercells, change cell shapes, or add, remove and sort atoms... but that&amp;#039;s a bit boring to read, so I&amp;#039;ll refer you to the Documentation page of the `CrystalChange` function instead.&#xD;
&#xD;
If you&amp;#039;re interested, we can use this thread to talk about any questions you may have, or you can share your use of the package (if you decide to use it). I&amp;#039;m not offering full support here, but I&amp;#039;ll be floating around, and I&amp;#039;d like to hear your feedback. We don&amp;#039;t have any intentions to be involved in further development. But if you have a good idea and some time, then by all means, work on it for yourself, or host it on your favourite code collaboration site.&#xD;
&#xD;
Bianca Eifert and Christian Heiliger&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=teaser.png&amp;amp;userId=69107&#xD;
  [2]: http://library.wolfram.com/infocenter/MathSource/9372/&#xD;
  [3]: http://library.wolfram.com/infocenter/MathSource/9373/&#xD;
  [4]: http://library.wolfram.com/infocenter/MathSource/9375/&#xD;
  [5]: http://vasp.at/&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=9692simple.png&amp;amp;userId=69107&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=atoms.png&amp;amp;userId=69107&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=bonds.png&amp;amp;userId=69107&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=planes.png&amp;amp;userId=69107&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=polys.png&amp;amp;userId=69107&#xD;
  [11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=polys2.png&amp;amp;userId=69107&#xD;
  [12]: http://rruff.geo.arizona.edu/AMS/CIF_text_files/13532_cif.txt&#xD;
  [13]: http://cms.mpi.univie.ac.at/vasp/vasp/POSCAR_file.html&#xD;
  [14]: http://wiki.jmol.org/index.php/File:Caffeine.mol</description>
    <dc:creator>Bianca Eifert</dc:creator>
    <dc:date>2016-02-05T18:43:18Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2085563">
    <title>[GiF] Optimizing your Swing Ride</title>
    <link>https://community.wolfram.com/groups/-/m/t/2085563</link>
    <description>![enter image description here][1]&#xD;
&#xD;
In a previous Wolfram Demonstration [Pendulum with Varying Length or How to Improve Your Next Swing Ride][2], I modelled a swing and rider system as a pendulum with varying length. Inspired by the article &amp;#034;[Pumping a Playground Swing][3]&amp;#034; by Post et al.  I looked at an alternative strategy to &amp;#034;optimize my swing ride&amp;#034;.&#xD;
The swing-rider system can be modeled as a double pendulum. The regular, *unforced double pendulum* maintains a constant level of energy. Kinetic-and potential energy are merely converted into one another and their sum remains constant. In the case of a swing however, we have a *forced double pendulum* as the rider wants to go higher and &amp;#034;pump&amp;#034; his way up. This can only be achieved by increasing the total energy in the (swing and rider) system. &amp;#034;Energy insertion&amp;#034; can be done by someone pushing the rider or  by a properly synchronized change in the position  of the center of mass (CM) of the rider.&#xD;
In the mentioned demonstration, the CM change was limited to an up and down crouching of the rider. Here, I will analyse a more  general, circular or elliptic position change of the rider&amp;#039;s CM.&#xD;
&#xD;
**Geometry**&#xD;
&#xD;
Let us first look at the geometry of the swing-rider system: The swinging kid at P can introduce energy into the double pendulum by forcibly moving his center of gravity in an elliptic movement around a point Z on the rigid swing rods OS. \[Theta] is the angle of the swing movement and \[Phi] is the angle of the crouching movement (rotation). We need a &amp;#034;crouching function&amp;#034; linking the angles \[Phi] and \[Theta]: \[Phi] = \[Omega] \[Theta]+\[Phi]0. \[Omega] is the crouching frequency and \[Phi]0 is the crouching&amp;#039;s initial angular offset.&#xD;
&#xD;
    Animate[&#xD;
     With[{L = 10, r = 2., \[Omega] = 3., \[Phi]0 = 0, a = .62, b = 2},&#xD;
      Module[{pivot, \[Phi], trace, seatCenter, hipPivot, hip},&#xD;
       pivot = {0, 0}; \[Phi] = \[Omega] \[Theta] + \[Phi]0;&#xD;
       seatCenter = {L Sin[\[Theta]], -L Cos[\[Theta]]}; &#xD;
       hipPivot = (L - r) {Sin[\[Theta]], -Cos[\[Theta]]};&#xD;
       hip = {(L - r - a Cos[\[Phi]]) Sin[\[Theta]] + &#xD;
          b Cos[\[Theta]] Sin[\[Phi]], &#xD;
         Cos[\[Theta]] (-L + r + a Cos[\[Phi]]) + &#xD;
          b Sin[\[Theta]] Sin[\[Phi]]};&#xD;
       trace = Rotate[Circle[hipPivot, {b, a}], \[Theta]];&#xD;
       Graphics[{Line[{pivot, seatCenter}], Blue, Line[{hipPivot, hip}], &#xD;
         PointSize[.015], &#xD;
         Point[{pivot, hip, hipPivot, seatCenter}], {Red, trace}, {Dashed,&#xD;
           Line[{hip, pivot}]},&#xD;
         {Black, Text[Style[&amp;#034;O&amp;#034;, 12], pivot, {-1, -1}], &#xD;
          Text[Style[&amp;#034;Z&amp;#034;, 12], hipPivot, {1, 1}], &#xD;
          Text[Style[&amp;#034;P&amp;#034;, 12], hip, {-1, -1}], &#xD;
          Text[Style[&amp;#034;S&amp;#034;, 12], seatCenter, {-1, 1}]}}]]], {\[Theta], 0, &#xD;
      2 Pi}]&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
**Dynamic Model**&#xD;
&#xD;
We add the driver&amp;#039;s mass mk at P and consider the crouching as a periodic driving force. We use Newton&amp;#039;s laws to derive the equation of motion:&#xD;
&#xD;
    (*hip (CM) coordinate*)&#xD;
    xh[t_] := &#xD;
      b Cos[\[Theta][t]] Sin[\[Phi]0 + t \[Omega]] + (L - r - &#xD;
          a Cos[\[Phi]0 + t \[Omega]]) Sin[\[Theta][t]];&#xD;
    yh[t_] := (-L + r + a Cos[\[Phi]0 + t \[Omega]]) Cos[\[Theta][t]] + &#xD;
       b Sin[\[Phi]0 + t \[Omega]] Sin[\[Theta][t]];&#xD;
    (*effective swing length*)l = Sqrt[xh[t]^2 + yh[t]^2];&#xD;
    (*equilibrium of forces*) &#xD;
    deqns = {mk xh&amp;#039;&amp;#039;[t] == s[t] xh[t]/l, &#xD;
       mk yh&amp;#039;&amp;#039;[t] == s[t] yh[t]/l - mk g};&#xD;
    deqn = Eliminate[deqns, s[t]] // FullSimplify&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
This is an animation showing a solution of the differential equation. The evolution of the energy levels shows how the forced position changes in the rider&amp;#039;s CM is increasing the total energy in the system. Trying to reach a large energy increase in a short time is the goal of every swing rider. Here, a maximum energy level with a high swing is reached after a mere 1.5 full swings.&#xD;
&#xD;
    Animate[Module[{a = 1.75, &#xD;
       b = 1.5, \[Omega] = 1.9, \[Phi]0 = &#xD;
        0, \[Theta]0 = \[Pi]/4, \[Theta]00 = 0, V, T, mk = 50, g = 9.81, &#xD;
       L = 10, l, xh, yh, \[Theta]sol, seat, hip, hipPivot, trace, &#xD;
       tMax = 16, r = .75},&#xD;
      pivot = {0, 0};&#xD;
      (*crouch function*)\[Phi][t_] := \[Omega] t + \[Phi]0;&#xD;
      xh[t_] := &#xD;
       b Cos[\[Theta][t]] Sin[\[Phi]0 + t \[Omega]] + (L - r - &#xD;
           a Cos[\[Phi]0 + t \[Omega]]) Sin[\[Theta][t]];&#xD;
      yh[t_] := (-L + r + a Cos[\[Phi]0 + t \[Omega]]) Cos[\[Theta][t]] + &#xD;
        b Sin[\[Phi]0 + t \[Omega]] Sin[\[Theta][t]];&#xD;
      sol = First@&#xD;
        NDSolve[{deqn, \[Theta][0] == \[Theta]0, \[Theta]&amp;#039;[&#xD;
            0] == \[Theta]00}, \[Theta], {t, 0, tMax}];&#xD;
      hip = {xh[t], yh[t]} /. sol /. t -&amp;gt; time;&#xD;
      seat = L {Sin[\[Theta][time]], -Cos[\[Theta][time]]} /. sol;&#xD;
      hipPivot = (L - r) {Sin[\[Theta][time]], -Cos[\[Theta][time]]} /. &#xD;
        sol;&#xD;
      trace = Rotate[Circle[hipPivot, {b, a}], \[Theta][time]] /. sol;&#xD;
      (*kinetic energy*)&#xD;
      T[t_] := Evaluate[.5 mk (xh&amp;#039;[t]^2 + yh&amp;#039;[t]^2)] /. &#xD;
        sol;(*potential energy*)V[t_] := mk g yh[t] /. sol;&#xD;
      Column[{&#xD;
        Plot[Evaluate[{V[t], T[t] + V[t]}], {t, 0, tMax}, &#xD;
         Filling -&amp;gt; {2 -&amp;gt; {1}, 1 -&amp;gt; Bottom}, PlotLabel -&amp;gt; &amp;#034;Energy&amp;#034;, &#xD;
         PlotLegends -&amp;gt; Placed[{&amp;#034;Potential&amp;#034;, &amp;#034;Total&amp;#034;}, Bottom], &#xD;
         AxesLabel -&amp;gt; {&amp;#034;t&amp;#034;, &amp;#034;&amp;#034;}, &#xD;
         Epilog -&amp;gt; {AbsoluteThickness[.75], &#xD;
           Line[{{time, -10000}, {time, 10000}}]}],&#xD;
        Graphics[{(*support*){FaceForm[Yellow], EdgeForm[Black], &#xD;
           Triangle[{pivot, 10 {-.035, .045}, 10 {.035, .045}}], Red, &#xD;
           Disk[pivot, .01]},&#xD;
          (*floor*), {Brown, AbsoluteThickness[4], &#xD;
           Line[{{-10, -L - a}, {10, -L - a}}]}, &#xD;
          Point[{pivot, seat, hipPivot}], &#xD;
          Line[{pivot, hip}], {Directive[Blue, AbsoluteThickness[.5]], &#xD;
           trace}, {DotDashed, Line[{pivot, seat}]}, {Blue, &#xD;
           Line[{hipPivot, hip}]}, {Red, AbsolutePointSize[7], Point@hip, &#xD;
           White, Disk[hip, .025]}, &#xD;
          ParametricPlot[&#xD;
            Evaluate[{xh[t], yh[t]} /. sol], {t, 0, time + .001}, &#xD;
            PlotStyle -&amp;gt; Directive[Red, AbsoluteThickness[.75]]][[1]]}, &#xD;
         PlotRange -&amp;gt; 12, Axes -&amp;gt; True]}]], {time, 0, 15.5, .25}]&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
**Adding a rider**&#xD;
&#xD;
I designed a simplified rider figure with the hip position at the center of gravity and fixed points where the foot is on the seat and the grip of the hand is on the front rod. This figure can then simply be fitted into the previous code to make a working and more realistic  model.&#xD;
&#xD;
    kidNSwing[hip : {hx_, hy_}] :=&#xD;
     &#xD;
     With[{pivot = {0, 0}, L = 10, seat = .75, head = .45, grip = 2.5, &#xD;
       leg = 1.55, thigh = 1.4, trunk = 1.5, arm1 = 1.25, arm2 = 1.2}, &#xD;
      Module[{(*joints*)ptF, ptB, ptT, ptS, ptK, ptP, ptN, ptE, ptH, &#xD;
        ptD},&#xD;
       ptT = {-.2, -L}; ptS = {0, -L + .085}; ptF = {-seat, -L}; &#xD;
       ptB = {seat, -L}; ptK = findTop[ptS, hip, leg, thigh];&#xD;
       ptH = AngleVector[{(L - grip), -1.6458}];&#xD;
       ptN = First@&#xD;
         Nearest[{x, y} /. &#xD;
           Solve[{x, y} \[Element] Line[{ptS, pivot}] &amp;amp;&amp;amp; &#xD;
             EuclideanDistance[{x, y}, hip] == trunk + .1, {x, y}], pivot];&#xD;
       ptE = findTop[ptN, ptH, arm2, arm2];&#xD;
       ptD = First@&#xD;
         Nearest[{x, y} /. &#xD;
           Solve[{x, y} \[Element] Line[{ptN, pivot}] &amp;amp;&amp;amp; &#xD;
             EuclideanDistance[{x, y}, hip] == trunk + head + .175, {x, &#xD;
             y}], pivot];&#xD;
       {(*seat*){AbsoluteThickness[6], Gray, Line[{ptF, ptB}]},&#xD;
        (*rods*){AbsoluteThickness[.9], &#xD;
         Line[{ptF, {0, 0}, ptB}]}, {PointSize[.01], Point[hip]},&#xD;
        (*trunk &amp;amp; limbs*) {FaceForm[Lighter[Red, .8]], &#xD;
         EdgeForm[AbsoluteThickness[1]],&#xD;
         StadiumShape[#, .125] &amp;amp; /@ &#xD;
          Partition[{ptT, ptS, ptK, hip, ptN, ptE, ptH}, 2, 1] },&#xD;
        (*joints*){Disk[#, .12] &amp;amp; /@ {ptT, ptS, ptK,(*hip,*)ptN, ptE, &#xD;
           ptH}, White, &#xD;
         Disk[#, .065] &amp;amp; /@ {hip, ptT, ptS, ptK,(*hip,*)ptN, ptE, ptH}},&#xD;
        (*head*){Darker[Gray, .35], &#xD;
         Disk[ptD, head, {176 \[Degree], -154 \[Degree]}],(*eye*)White, &#xD;
         Disk[ptD, .075]}}]] &#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
**Full model to Optimize your Swing ride**&#xD;
&#xD;
The equation of motion is then introduced in a Manipulate. This lets the user experiment with a simple model of the swing and rider system to explore the conditions for an optimized swing ride . The parameters of the hip (CM) displacement and the initial conditions (angular position and speed) can be adjusted. The energy level graph on top lets the user see where the maximum energy level occurs and try do move this as much as possible to the start of the ride.&#xD;
&#xD;
    Manipulate[With[{mk = 50, g = 9.81, pivot = {0, 0}, L = 10},&#xD;
      Module[{deqn, crouch, xh, yh, sol, \[Phi], V, T, hipPivot, hip, &#xD;
        trace}, time = Min[tMax, time];&#xD;
       \[Phi][t_] := \[Omega] t + \[Phi]0; &#xD;
       crouch[t_] := {b Sin[\[Phi][t]], -L + r + a Cos[\[Phi][t]]};&#xD;
       xh[t_] := &#xD;
        b Cos[\[Theta][t]] Sin[\[Phi]0 + t \[Omega]] + (L - r - &#xD;
            a Cos[\[Phi]0 + t \[Omega]]) Sin[\[Theta][t]];&#xD;
       yh[t_] := (-L + r + a Cos[\[Phi]0 + t \[Omega]]) Cos[\[Theta][t]] +&#xD;
          b Sin[\[Phi]0 + t \[Omega]] Sin[\[Theta][t]];&#xD;
       deqn = &#xD;
        2 b ((-L + r) \[Omega]^2 + g Cos[\[Theta][t]]) Sin[\[Phi]0 + &#xD;
             t \[Omega]] + &#xD;
          4 \[Omega] (a (L - r) + (-a^2 + b^2) Cos[\[Phi]0 + &#xD;
                t \[Omega]]) Sin[\[Phi]0 + t \[Omega]] Derivative[&#xD;
            1][\[Theta]][&#xD;
            t] + (a^2 + b^2 + 2 (L - r)^2 + &#xD;
             4 a (-L + r) Cos[\[Phi]0 + t \[Omega]] + (a - b) (a + b) Cos[&#xD;
               2 (\[Phi]0 + t \[Omega])]) (\[Theta]^\[Prime]\[Prime])[&#xD;
            t] == 2 g (-L + r + a Cos[\[Phi]0 + t \[Omega]]) Sin[\[Theta][&#xD;
            t]];&#xD;
       sol = First@&#xD;
         NDSolve[{deqn, \[Theta][0] == \[Theta]0, \[Theta]&amp;#039;[&#xD;
             0] == \[Theta]00}, \[Theta], {t, 0, tMax}];&#xD;
       hip[t_] := {xh[t], yh[t]} /. sol;&#xD;
       hipPivot = (L - r) {Sin[\[Theta][time]], -Cos[\[Theta][time]]} /. &#xD;
         sol;&#xD;
       trace[t_] := Rotate[Circle[hipPivot, {b, a}], \[Theta][t]];&#xD;
       T[t_] := Evaluate[.5 mk (xh&amp;#039;[t]^2 + yh&amp;#039;[t]^2)] /. sol; &#xD;
       V[t_] := mk g yh[t] /. sol;&#xD;
       Column[{&#xD;
         Plot[Evaluate[{V[t], T[t] + V[t]}], {t, 0, tMax}, &#xD;
          Filling -&amp;gt; {2 -&amp;gt; {1}, 1 -&amp;gt; Bottom}, PlotLabel -&amp;gt; &amp;#034;Energy&amp;#034;, &#xD;
          PlotLegends -&amp;gt; Placed[{&amp;#034;Potential&amp;#034;, &amp;#034;Total&amp;#034;}, Bottom], &#xD;
          AxesLabel -&amp;gt; {&amp;#034;t&amp;#034;, &amp;#034;&amp;#034;}, AxesStyle -&amp;gt; 7, &#xD;
          Epilog -&amp;gt; {AbsoluteThickness[.75], &#xD;
            Line[{{time, -1*^6}, {time, 1*^6}}]}, ImageSize -&amp;gt; 400, &#xD;
          AspectRatio -&amp;gt; .3],&#xD;
         Graphics[{&#xD;
           {FaceForm[Yellow], EdgeForm[Black], &#xD;
            Triangle[{pivot, {-.35, .45}, {.35, .45}}], Red, &#xD;
            Disk[pivot, .15]},&#xD;
           (*floor*), {Brown, AbsoluteThickness[4], &#xD;
            Line[{{-20, -L - 1}, {20, -L - 1}}]},&#xD;
           ParametricPlot[&#xD;
             hip[t] /. sol, {t, 0, If[sdt, tMax, time + .01]}, &#xD;
             PerformanceGoal -&amp;gt; &amp;#034;Quality&amp;#034;, &#xD;
             PlotStyle -&amp;gt; Directive[AbsoluteThickness[.45], Red], &#xD;
             PlotPoints -&amp;gt; 10][[1]],&#xD;
           Rotate[kidNSwing[crouch[time]], \[Theta][time], pivot] /. sol,&#xD;
           If[&#xD;
            sht, {Directive[Dashed, Blue, AbsoluteThickness[1.5]], &#xD;
             trace[time] /. sol}, Nothing]},&#xD;
          Background -&amp;gt; Lighter[Gray, 0.8],&#xD;
          Axes -&amp;gt; True, Frame -&amp;gt; True, FrameTicks -&amp;gt; None, &#xD;
          PlotRange -&amp;gt; 1.1 {{-L, L}, {-L - .1, L}}, &#xD;
          ImageSize -&amp;gt; 400]}]]],&#xD;
     Style[&amp;#034;animation&amp;#034;, Bold, 10],&#xD;
     {{time, 0.}, 0., tMax, .001, ImageSize -&amp;gt; Tiny, &#xD;
      Appearance -&amp;gt; &amp;#034;Labeled&amp;#034;}, Delimiter,&#xD;
     Style[&amp;#034;swinging&amp;#034;, Bold, 10],&#xD;
     &amp;#034;initial angular position kid&amp;#034;, {{\[Theta]0, 1.31}, -1.57, &#xD;
      1.57, .001, ImageSize -&amp;gt; Tiny, Appearance -&amp;gt; &amp;#034;Labeled&amp;#034;},&#xD;
     &amp;#034;initial angular speed&amp;#034;,&#xD;
     {{\[Theta]00, 0}, -6, 6, .0001, ImageSize -&amp;gt; Tiny, &#xD;
      Appearance -&amp;gt; &amp;#034;Labeled&amp;#034;}, Delimiter,&#xD;
     Style[&amp;#034;crouching&amp;#034;, Bold, 10],&#xD;
     &amp;#034;major axis a (in line with swing rods)&amp;#034;, {{a, .75}, 0., 2, .001, &#xD;
      ImageSize -&amp;gt; Tiny, Appearance -&amp;gt; &amp;#034;Labeled&amp;#034;},&#xD;
     &amp;#034;minor axis b (perpendicular to swing rods)&amp;#034;, {{b, .274}, 0., &#xD;
      2, .001, ImageSize -&amp;gt; Tiny, Appearance -&amp;gt; &amp;#034;Labeled&amp;#034;},&#xD;
     &amp;#034;frequency&amp;#034;,&#xD;
     {{\[Omega], 1.904}, -5, 5, .001, ImageSize -&amp;gt; Tiny, &#xD;
      Appearance -&amp;gt; &amp;#034;Labeled&amp;#034;},&#xD;
     &amp;#034;angular offset&amp;#034;,&#xD;
     {{\[Phi]0, 0}, -1.57, 1.57, .0001, ImageSize -&amp;gt; Tiny, &#xD;
      Appearance -&amp;gt; &amp;#034;Labeled&amp;#034;}, Delimiter,&#xD;
     &amp;#034;hip vertical offset&amp;#034;,&#xD;
     {{r, 1.6722}, 0, 2.5, .0001, ImageSize -&amp;gt; Tiny, &#xD;
      Appearance -&amp;gt; &amp;#034;Labeled&amp;#034;}, Delimiter,&#xD;
     Row[{&amp;#034;show full dynamic trace&amp;#034;, &#xD;
       Control[{{sdt, False, &amp;#034;&amp;#034;}, {True, False}}]}],&#xD;
     Row[{&amp;#034;show static trace&amp;#034;, &#xD;
       Control[{{sht, False, &amp;#034;&amp;#034;}, {True, False}}]}],&#xD;
     {{tMax, 30, &amp;#034;total time&amp;#034;}, None}, TrackedSymbols :&amp;gt; True, &#xD;
     ControlPlacement -&amp;gt; Left]&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
After some experimenting, one can easily derive some conclusions:&#xD;
&#xD;
1. the most important effect is to synchronize the crouching (\[Phi]) with the swinging (\[Theta]). Best results are achieved if the crouching frequency (\[Omega]) is double the swing frequency.&#xD;
&#xD;
2. up and down crouching (a is the crouching path&amp;#039;s semimajor axis in line with swing rods) has more effect than forward- backward leaning (b is the crouching path&amp;#039;s semi-minor axis perpendicular to swing rods)&#xD;
&#xD;
**Some Favorite Rides**&#xD;
&#xD;
1. A start from absolute standstill and zero position. Only the hip movement is in action here and is enough to add energy to the system.&#xD;
&#xD;
        &amp;#034;zero start-1&amp;#034; :&amp;gt; {a = 0.75, b = 0.75, &#xD;
          r = 1.6722, \[Theta]00 = 0, \[Theta]0 = 0, \[Phi]0 = &#xD;
           0.253, \[Omega] = 1}&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
2. This example also has zero initial speed and position but the crouching is synchronized in a nearly optimal way (\[Omega]= approximately 2), resulting in a spectacular swing over the top (we have rigid rods, no ropes or chains!).&#xD;
&#xD;
        &amp;#034;zero start-2&amp;#034; :&amp;gt; {a = 1.2, b = 0, &#xD;
          r = 1.6722, \[Theta]00 = 0, \[Theta]0 = 0.785, \[Phi]0 = &#xD;
           0.4664, \[Omega] = 1.994}&#xD;
&#xD;
![enter image description here][10]&#xD;
&#xD;
3. Other relations of crouching to swinging can result in some nice periodic rides.&#xD;
&#xD;
        &amp;#034;oval track&amp;#034; :&amp;gt; {a = 0.75, b = 0, &#xD;
          r = 0.8, \[Theta]00 = 0.0714, \[Theta]0 = &#xD;
           1.265, \[Phi]0 = -0.2527, \[Omega] = 3.74}&#xD;
&#xD;
&#xD;
![enter image description here][11]&#xD;
&#xD;
Experiment freely with the previous Manipulate and get as much fun as I did with this simple model of something we are all familiar with.&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=zerostart-6.gif&amp;amp;userId=68637&#xD;
  [2]: https://demonstrations.wolfram.com/PendulumWithVaryingLengthOrHowToImproveYourNextSwingRide/&#xD;
  [3]: https://pdfs.semanticscholar.org/9b19/8d284aee700cc35c2faae5683ff5e6fba66d.pdf&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=5490dynamicgeometry.gif&amp;amp;userId=68637&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1981eqnofmotion.png&amp;amp;userId=68637&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=2550modelwokid.gif&amp;amp;userId=68637&#xD;
  [7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=8117kidNswingcombi.gif&amp;amp;userId=68637&#xD;
  [8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ezgif.com-resize.png&amp;amp;userId=68637&#xD;
  [9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=8451zerostart-1.gif&amp;amp;userId=68637&#xD;
  [10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=zerostart-4.gif&amp;amp;userId=68637&#xD;
  [11]: https://community.wolfram.com//c/portal/getImageAttachment?filename=zerostart-5.gif&amp;amp;userId=68637</description>
    <dc:creator>Erik Mahieu</dc:creator>
    <dc:date>2020-09-29T12:38:26Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/790989">
    <title>Gravity wave visualization: celebrating LIGO first direct detection of gravitational waves</title>
    <link>https://community.wolfram.com/groups/-/m/t/790989</link>
    <description>![enter image description here][1]&#xD;
&#xD;
With all of the rumors and excitement about the gravity wave press release tomorrow, I was reminded of this code I&amp;#039;ve had lying around for years for creating a gravity wave visualization (seen above) for illustrative purposes. You can find also a [video here][2]. It was inspired by an interaction I had years ago (unfortunately I can&amp;#039;t find the interaction in my email) with someone on the [LISA][3] project wanting to use Mathematica to re-create a visualization they had. This code was the result of that interaction. &#xD;
&#xD;
First, the primary goal was to generate a &amp;#034;space-time&amp;#034; surface and mesh that had a double-armed spiral wave on it. The following code generates that. Its dependent on a rotation angle Theta which is not specified here:&#xD;
&#xD;
    Plot3D[(60 Cos[&#xD;
       2 ArcTan[y/(x + 0.00001)] - \[Theta] + 0.544331 Sqrt[x^2 + y^2]])/(&#xD;
     20 + Sqrt[x^2 + y^2]), {x, -45, 45}, {y, -45, 45}, PlotPoints -&amp;gt; 100,&#xD;
      Mesh -&amp;gt; 20, MeshStyle -&amp;gt; {RGBColor[.5, .5, .5, .5]}, Boxed -&amp;gt; False,&#xD;
      BoxRatios -&amp;gt; Automatic, Axes -&amp;gt; False, &#xD;
     PlotStyle -&amp;gt; {RGBColor[.3, .3, .8]}, ImageSize -&amp;gt; {1024, 768}, &#xD;
     Lighting -&amp;gt; {{&amp;#034;Directional&amp;#034;, White, ImageScaled[{0, 0, 2.}]}}, &#xD;
     ViewPoint -&amp;gt; {-0.011, -3.043, 1.479}, Background -&amp;gt; Black, &#xD;
     BoundaryStyle -&amp;gt; RGBColor[.5, .5, .5, .5]]&#xD;
&#xD;
I wanted to overlay 2 stars or black holes on top of the surface. Combining the above with  this overlay and giving a value to the angle Theta we get:&#xD;
&#xD;
    With[{\[Theta] = 0}, &#xD;
     Show[Plot3D[(&#xD;
       60 Cos[2 ArcTan[y/(x + 0.00001)] - \[Theta] + &#xD;
          0.544331 Sqrt[x^2 + y^2]])/(&#xD;
       20 + Sqrt[x^2 + y^2]), {x, -45, 45}, {y, -45, 45}, &#xD;
       PlotPoints -&amp;gt; 100, Mesh -&amp;gt; 20, &#xD;
       MeshStyle -&amp;gt; {RGBColor[.5, .5, .5, .5]}, Boxed -&amp;gt; False, &#xD;
       BoxRatios -&amp;gt; Automatic, Axes -&amp;gt; False, &#xD;
       PlotStyle -&amp;gt; {RGBColor[.3, .3, .8]}, ImageSize -&amp;gt; {1024, 768}, &#xD;
       Lighting -&amp;gt; {{&amp;#034;Directional&amp;#034;, White, ImageScaled[{0, 0, 2.}]}}, &#xD;
       ViewPoint -&amp;gt; {-0.011, -3.043, 1.479}, Background -&amp;gt; Black, &#xD;
       BoundaryStyle -&amp;gt; RGBColor[.5, .5, .5, .5]], &#xD;
      Graphics3D[{Directive[Hue[.58, 0, 1], &#xD;
         Lighting -&amp;gt; &#xD;
          Join[{{&amp;#034;Ambient&amp;#034;, Black}}, &#xD;
           Table[{&amp;#034;Directional&amp;#034;, Hue[.58, .5, 1], &#xD;
             ImageScaled[{Sin[x], Cos[x], -.5}]}, {x, 0, 2 Pi - 2 Pi/8, &#xD;
             2 Pi/8}]]], &#xD;
        Sphere[{2 Cos[\[Theta] - \[Pi]/2], 2 Sin[\[Theta] - \[Pi]/2], 3}, &#xD;
         1], Sphere[{Cos[\[Theta] + \[Pi]/2], Sin[\[Theta] + \[Pi]/2], 3},&#xD;
          1]}], PlotRange -&amp;gt; All]]&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
Next, I wanted to animate this to give the effect that the spiral arms are rotating outwards. That&amp;#039;s done by incrementing the angle Theta and generating a list of frames that can then be exported.&#xD;
&#xD;
    anim = Table[&#xD;
      Rasterize[&#xD;
       Show[Plot3D[(&#xD;
         60 Cos[2 ArcTan[y/(x + 0.00001)] - \[Theta] + &#xD;
            0.544331 Sqrt[x^2 + y^2]])/(&#xD;
         20 + Sqrt[x^2 + y^2]), {x, -45, 45}, {y, -45, 45}, &#xD;
         PlotPoints -&amp;gt; 100, Mesh -&amp;gt; 20, &#xD;
         MeshStyle -&amp;gt; {RGBColor[.5, .5, .5, .5]}, Boxed -&amp;gt; False, &#xD;
         BoxRatios -&amp;gt; Automatic, Axes -&amp;gt; False, &#xD;
         PlotStyle -&amp;gt; {RGBColor[.3, .3, .8]}, ImageSize -&amp;gt; {800, 450}, &#xD;
         Lighting -&amp;gt; {{White, ImageScaled[{0, 0, 2.}]}}, &#xD;
         ViewPoint -&amp;gt; {-0.011, -3.043, 1.479}, &#xD;
         Background -&amp;gt; RGBColor[0, 0, 0], BoundaryStyle -&amp;gt; Gray], &#xD;
        Graphics3D[{Directive[Hue[.58, 0, 1], &#xD;
           Lighting -&amp;gt; &#xD;
            Join[{{&amp;#034;Ambient&amp;#034;, Black}}, &#xD;
             Table[{&amp;#034;Directional&amp;#034;, Hue[.58, .5, 1], &#xD;
               ImageScaled[{Sin[x], Cos[x], -.5}]}, {x, 0, 2 Pi - 2 Pi/8, &#xD;
               2 Pi/8}]]], &#xD;
          Sphere[{2 Cos[\[Theta] - \[Pi]/2], 2 Sin[\[Theta] - \[Pi]/2], &#xD;
            3}, 1], Sphere[{Cos[\[Theta] + \[Pi]/2], &#xD;
            Sin[\[Theta] + \[Pi]/2], 3}, 1]}], &#xD;
        PlotRange -&amp;gt; All]], {\[Theta], 0, 2 \[Pi], .1}];&#xD;
&#xD;
And then to export it to an animated GIF: &#xD;
&#xD;
    Export[&amp;#034;GravityWave.gif&amp;#034;, anim]&#xD;
&#xD;
The result is the animation at the top of this post.&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ezgif.com-optimize%283%29.gif&amp;amp;userId=20103&#xD;
  [2]: https://www.youtube.com/watch?v=WiNKulqt0SE&#xD;
  [3]: http://lisa.nasa.gov/&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=gravitywave60.png&amp;amp;userId=25355&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=GravityWave.gif&amp;amp;userId=25355</description>
    <dc:creator>Jeffrey Bryant</dc:creator>
    <dc:date>2016-02-10T19:35:05Z</dc:date>
  </item>
</rdf:RDF>

