HTML/CSS Explore GR & Newtonian Orbits in HTML/JS

  • Thread starter Thread starter m4r35n357
  • Start date Start date
  • Tags Tags
    Gr
AI Thread Summary
The discussion explores the implementation of General Relativity (GR) and Newtonian orbits using JavaScript and HTML5 canvas, inspired by existing orbit simulations. A side-by-side demo showcases a decaying circular orbit compared to its Newtonian equivalent, utilizing effective potential equations and Euler integration for accuracy. The creator expresses interest in further developing the model, potentially incorporating a Boyer-Lindquist version, while noting the importance of adjusting the timestep for accurate precession visualization. The project aims to provide a user-friendly experience with everyday units, although the creator acknowledges possible errors in the denormalization process. Overall, the thread highlights a fun exploration of gravitational physics through coding, inviting feedback and collaboration.
m4r35n357
Messages
657
Reaction score
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
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
 
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 ;)
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.

Similar threads

Replies
4
Views
3K
Replies
8
Views
6K
Back
Top