From f5faa2ef095f035110f83e17da0b35d3a34d6b97 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sat, 17 Feb 2024 19:52:53 -0700 Subject: bump --- docs/posts/2023-04-30-n-body-simulation.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'docs/posts/2023-04-30-n-body-simulation.html') diff --git a/docs/posts/2023-04-30-n-body-simulation.html b/docs/posts/2023-04-30-n-body-simulation.html index 6583004..1174d27 100644 --- a/docs/posts/2023-04-30-n-body-simulation.html +++ b/docs/posts/2023-04-30-n-body-simulation.html @@ -26,7 +26,7 @@ - + @@ -35,6 +35,7 @@ home | about/links | posts | +3D designs | RSS Feed | -- cgit v1.2.3 From f6d2141a480dd6b5b8ee0e48d43bb64773232791 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Tue, 26 Mar 2024 23:38:14 -0600 Subject: add header ids --- docs/posts/2023-04-30-n-body-simulation.html | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'docs/posts/2023-04-30-n-body-simulation.html') diff --git a/docs/posts/2023-04-30-n-body-simulation.html b/docs/posts/2023-04-30-n-body-simulation.html index 1174d27..9a7c7a2 100644 --- a/docs/posts/2023-04-30-n-body-simulation.html +++ b/docs/posts/2023-04-30-n-body-simulation.html @@ -6,13 +6,13 @@ - n-body solution generator + id="n-body-solution-generator">n-body solution generator - - + n-body solution generator" /> + n-body solution generator" /> @@ -44,7 +44,7 @@
-

n-body solution generator

+

n-body solution generator

This post requires JavaScript to be viewed properly :(

@@ -61,7 +61,7 @@

To workaround memory issues, the simulations are only run on-demand when the user clicks the respective button. Scroll down to the bottom of the page to see the results.

-

The n-body problem

+

The n-body problem

The n-body problem is a classic puzzle in physics (and thus astrophysics) and mathematics that deals with predicting the motion of multiple celestial objects that interact with each other through gravitational forces.

@@ -71,7 +71,7 @@

As the number of objects increases, finding an exact solution becomes impossible, and we rely on analytical approximations.

-

Visualising a basic orbit

+

Visualising a basic orbit

If we want to create a n-body simulation in our browser, we need to figure out how we are going to visualise the motion of the objects. There are a few ways to do this, but the easiest is to use Plotly.js, a JavaScript library for creating interactive graphs. (An alternative is to use the HTML5 canvas element).

@@ -138,7 +138,7 @@ Next, the function dR takes the position r and velocity v of Earth as input and

Finally, we normalize the position data by dividing it by the astronomical unit (AU) to make it more visually meaningful. We also create a circle for reference, which represents a perfect circular orbit. The code ends with the data for the Sun's position, Earth's orbit, and the reference circle ready to be plotted.

-

Plotting the orbit

+

Plotting the orbit

Now that we have the data for the Sun's position, Earth's orbit, and the reference circle, we can plot them using Plotly.js.

@@ -212,7 +212,7 @@ Next, the function dR takes the position r and velocity v of Earth as input and -

Figure of 8 orbit

+

Figure of 8 orbit

The figure of 8 solution[2] in the three-body problem refers to a unique and special trajectory where three celestial bodies (e.g., planets, stars) move in a figure of 8 shaped pattern around their mutual center of mass. This is special because it represents a stable and periodic solution to the three-body problem, which is known for its complexity and lack of general solutions.

@@ -226,7 +226,7 @@ Next, the function dR takes the position r and velocity v of Earth as input and
  • It looks cool!

  • -

    Show me the code

    +

    Show me the code

    The code for this simulation is very similar to the Earth-Sun orbit simulation, except that we now have three bodies instead of two. We also use a different set of initial conditions to generate the figure of 8 orbit.

    @@ -318,7 +318,7 @@ Next, the function dR takes the position r and velocity v of Earth as input and

    Finally, a loop iterates over each time step, updating the positions and velocities of the celestial bodies using the step function. The updated coordinates are stored in the X, Y, VX, and VY arrays.

    -

    Animation?

    +

    Animation?

    Now that we have time-series data, we need to animate it. We can use Plotly's animate function, as this does not force a full re-render, saving us some precious GPU and CPU cycles when we are trying to run this in the browser itself

    @@ -438,9 +438,9 @@ Next, the function dR takes the position r and velocity v of Earth as input and -

    "General" N-Body Solver

    +

    "General" N-Body Solver

    -

    Show me the code!

    +

    Show me the code!

    function step(coords, masses, deltaT, nBodies = 3, G = 6.67408313131313e-11) {
    @@ -675,7 +675,7 @@ Next, the function dR takes the position r and velocity v of Earth as input and
     
    -

    Playground

    +

    Playground

    @@ -759,7 +759,7 @@ function plotRandomNBodySimulation() { -

    References

    +

    References

    1. Barrow-Green, June (2008), "The Three-Body Problem", in Gowers, Timothy; Barrow-Green, June; Leader, Imre (eds.), The Princeton Companion to Mathematics, Princeton University Press, pp. 726–728
    2. -- cgit v1.2.3 From 9e620084e57378952c1a7f8e0a772ebebd18932b Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Wed, 27 Mar 2024 20:35:09 -0600 Subject: quick fix --- docs/posts/2023-04-30-n-body-simulation.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/posts/2023-04-30-n-body-simulation.html') diff --git a/docs/posts/2023-04-30-n-body-simulation.html b/docs/posts/2023-04-30-n-body-simulation.html index 9a7c7a2..732854e 100644 --- a/docs/posts/2023-04-30-n-body-simulation.html +++ b/docs/posts/2023-04-30-n-body-simulation.html @@ -6,13 +6,13 @@ - id="n-body-solution-generator">n-body solution generator + n-body solution generator - n-body solution generator" /> - n-body solution generator" /> + + -- cgit v1.2.3 From 01ff93c9c16867216f2d249664803860e1d6d5eb Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Wed, 27 Mar 2024 22:49:40 -0600 Subject: generate new theme --- docs/posts/2023-04-30-n-body-simulation.html | 55 +++++++++++++++++++--------- 1 file changed, 37 insertions(+), 18 deletions(-) (limited to 'docs/posts/2023-04-30-n-body-simulation.html') diff --git a/docs/posts/2023-04-30-n-body-simulation.html b/docs/posts/2023-04-30-n-body-simulation.html index 732854e..b244949 100644 --- a/docs/posts/2023-04-30-n-body-simulation.html +++ b/docs/posts/2023-04-30-n-body-simulation.html @@ -2,14 +2,26 @@ - + + + + + n-body solution generator + + + + + + + - n-body solution generator - @@ -29,21 +41,27 @@ - -
      -
      + + +
      -
      - +

      n-body solution generator

      This post requires JavaScript to be viewed properly :(

      @@ -766,14 +784,15 @@ function plotRandomNBodySimulation() {
    3. Moore, Cristopher (1993), "Braids in classical dynamics", Physical Review Letters, 70 (24): 3675–3679
    +
    If you have scrolled this far, consider subscribing to my mailing list here. You can subscribe to either a specific type of post you are interested in, or subscribe to everything with the "Everything" list.
    -
    + -- cgit v1.2.3 From de19543d7fb44d343b052dc9b34ede78620c4a46 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Wed, 27 Mar 2024 23:36:55 -0600 Subject: Generate --- docs/posts/2023-04-30-n-body-simulation.html | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'docs/posts/2023-04-30-n-body-simulation.html') diff --git a/docs/posts/2023-04-30-n-body-simulation.html b/docs/posts/2023-04-30-n-body-simulation.html index b244949..878624a 100644 --- a/docs/posts/2023-04-30-n-body-simulation.html +++ b/docs/posts/2023-04-30-n-body-simulation.html @@ -46,7 +46,7 @@ + +
    -- cgit v1.2.3 From a982ceab0b45609991179b3020a00260eed6f798 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Wed, 27 Mar 2024 23:45:59 -0600 Subject: css --- docs/posts/2023-04-30-n-body-simulation.html | 1 + 1 file changed, 1 insertion(+) (limited to 'docs/posts/2023-04-30-n-body-simulation.html') diff --git a/docs/posts/2023-04-30-n-body-simulation.html b/docs/posts/2023-04-30-n-body-simulation.html index 878624a..1d65a07 100644 --- a/docs/posts/2023-04-30-n-body-simulation.html +++ b/docs/posts/2023-04-30-n-body-simulation.html @@ -5,6 +5,7 @@ + n-body solution generator -- cgit v1.2.3