Explore GR & Newtonian Orbits in HTML/JS

  • Java
  • Thread starter m4r35n357
  • Start date
  • Tags
    Gr
In summary, this person built a JavaScript/HTML5 black hole simulator. It uses an "effective potential" approach and starts up with a reasonable approximation to the orbit of Mercury.
  • #1
m4r35n357
654
148
OK, just a bit of fun . . . hope no-one is too offended ;)

Inspired by the Newtonian orbit example here: http://www.travisglines.com/tag/runge-kutta, I thought I'd see how much GR I could do in JavaScript/HTML5 canvas. So, I got a side-by-side Newton/Schwarzschild demo going, code here: https://www.box.com/s/a514bd0a108e7717ab09. I stopped when I got bored, and I'm not into HTML, so I didn't make any controls for it; there are two scenarios commented in the JS code which you will need to edit to taste. By default it displays a borderline unstable decaying circular orbit against the Newtonian "equivalent", using the effective potential equations from MTW chapter 25 (Euler integration seems be more accurate than the RK4 on the original site, which has horrible precession for a Newton orbit).

Feel free to take/use/ignore with impunity, I'm sort of leaning towards trying a Boyer-Lindquist version, but not decided yet.

Of course, if you are looking for accuracy just go with GROrbits!
 
Technology news on Phys.org
  • #2
OK I went quite a bit further than I had originally planned, and so we now have a JavaScript/HTML5 canvas model of a spinning black hole in the equatorial plane, again up against Isaac's vision.
It uses an "effective potential" approach, with Euler integration and my own "turnaround" code. If you see precession in the Newton trace, you need to reduce the timestep.
It starts up with a reasonable approximation to the orbit of Mercury, you have to "zoom in" quite a lot to see the effects of GR (hopefully the input controls make sense).
I checked the geometrized figures against GROrbits, but to add a touch of reality I have attempted to "denormalize" everything to more everyday units; I might have made errors at this stage, please let me know if anyone finds any . . .
Anyway, Voila!

https://www.box.com/s/vfznxq5ymhg5zjyoeqds
 
  • #4
pervect said:
You might take a peek at http://www.fourmilab.ch/gravitation/orbits/, if you haven't already.
Ha, I had no idea that was yours! In fact that applet and later GROrbits were the inspiration for what I have done ;) I built them both in Eclipse and had a good rummage in the code, and wondered how far the basic engine could be stripped down, for learning purposes (mine or anyone else's).
My claim to notoriety is mainly down to the tiny code size (there is a commented out Schwarzschild model that can be deleted, also I haven't tried minifying . . .), also it can run and be debugged in any of the open source browsers (hint: not tested on any version of IE).
I do hope we can all coexist in harmony ;)
 
  • #5


I find your exploration of GR and Newtonian orbits in HTML/JS fascinating and impressive. It's always exciting to see science being applied and demonstrated through technology. While your project may have started as a bit of fun, it has the potential to spark interest and understanding in others about the complexities of gravity and how it affects the motion of objects in space. I appreciate your disclaimer about not being an expert in HTML and the need for further controls, but I believe your work is still valuable and can serve as a starting point for others to build upon. I also appreciate your mention of GROrbits for those seeking more accuracy. Overall, I think your project is a great example of how science and technology can come together to create engaging and educational experiences. Keep up the good work!
 

Related to Explore GR & Newtonian Orbits in HTML/JS

1. What is the purpose of "Explore GR & Newtonian Orbits in HTML/JS"?

The purpose of this project is to provide an interactive simulation of General Relativity and Newtonian orbits using HTML and JavaScript. It allows users to visualize and understand the effects of gravity on objects in space.

2. How does the simulation work?

The simulation uses mathematical equations to calculate the trajectories of objects in space based on their mass and velocity. It takes into account the principles of General Relativity and the laws of motion established by Isaac Newton.

3. Can this simulation be used for educational purposes?

Yes, this simulation can be used for educational purposes to help students understand the concepts of General Relativity and Newtonian orbits. It can also be used for self-study or as a visualization tool for those interested in physics and astronomy.

4. Is this simulation accurate?

While the simulation is based on scientific principles, it is not meant to be a completely accurate representation of the universe. It is a simplified model that can help users gain a basic understanding of how gravity affects objects in space.

5. Can the simulation be customized?

Yes, the simulation can be customized by changing the values of variables such as mass, velocity, and distance. This allows users to see how different factors affect the behavior of objects in space.

Similar threads

  • Programming and Computer Science
Replies
4
Views
3K
  • Special and General Relativity
Replies
7
Views
4K
  • Special and General Relativity
Replies
2
Views
3K
Back
Top