Research

Simulate gravity lensing

Bend light around a star or a black hole and watch the image change: an interactive gravity lab and calculator whose every number is checked by tests.

Recipe code: simulate-gravity-lensing

No Mariwave yet? Download it, and keep the recipe code to open this recipe once it is installed.

a black hole with a bright ring of bent light around it

What it is

An app you run and watch, opened in its own machine.

What it needs

A Mac with Apple silicon and macOS 27 or later, with Mariwave installed. It runs in its own signed machine on your Mac.

Source

Eyzaguirre-co-LLC/mari-examples/simulate-gravity-lensing at 2a7999b922601fc4b7fd635bee11ce286e964b2b

Picture

sha256 04151317da7ac700610eaef2badabc5ecfb24d9e97a824113eacee36e2f12875

What the agent reads

When you open this recipe, the agent in its machine reads these instructions first.

Lensing Lab in this machine

Three files make the page, with no dependencies and no build step:

  • index.html: two tabs, Lensing lab and Lensing calculator.
  • lensing-app.js: the canvas lab (scenes, state, draw loop, scale bar) and the calculator.
  • lensing-physics.js: the point-lens physics with no DOM access: deflection α = 4GM/c²b, Einstein angle, magnification, image positions and Shapiro delay.

Two test files check it: test-physics.js (numeric anchors such as the 1.75″ solar limb and the EHT ring) and test-render.js (a render under a DOM stub, including a hidden tab). They are in /session/work/simulate-gravity-lensing.

Run it

When this agent was opened on the example, Mariwave copied its own files to /session/work/simulate-gravity-lensing and wrote /session/work/web-server.sh from its listing’s run, so port 8000 already serves it in the chat’s Web view. The page loads lensing-app.js as an ES module, so it is served over HTTP, never opened as a file. curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8000/ answers 200; when it does not, /session/bridge.log says why, and the Web view’s switch starts the server again.

The lab has three scenes (Sgr A* at 4.3 million solar masses, a 10-solar-mass black hole, and the Sun grazing Sgr A*’s light toward Earth) and an alignment slider u = β/θE. The calculator takes any mass, impact parameter and distance, with presets from the 1919 eclipse to Sgr A*.

Test and change it

Change the files in place, run the tests with bun, and have the person reload the Web view:

cd /session/work/simulate-gravity-lensing
bun test ./test-physics.js
bun run test-render.js

A new physical quantity goes in lensing-physics.js with a check in test-physics.js derived from its formula or a published value; lensing-app.js imports it from there for the lab and the calculator.