bgmeulem / Luminet

This repo provides material for recreating the famous paper by Jean-Pierre Luminet (1979), simulating the first image of a Schwarzschild black hole.
MIT License
86 stars 6 forks source link

Write solver in C/C++ and vectorize #4

Open bgmeulem opened 11 months ago

bgmeulem commented 11 months ago

A lot of points need to be sampled, and there are currently no significant matters taken for speedup. The biggest bottleneck is solving the elliptic integral in equation 13. While scipy solves this in C, it is an annoying overhead having the solver itself in Python. A lot of time is wasted on communicating back and forth the solutions. The code should either be vectorized, so that all solutions can be communicated at once, or I should write my math.py in C/C++ to speed up the biggest bottleneck of the code. Preferably both should be done.

Niohori commented 10 months ago

Hello, I'm currently porting your code to C++. It is still a work in progress and still trying to decode the finesses of the Python version. If you want and can help you, I can upload what I already have on Github.

bgmeulem commented 10 months ago

Hi Niohori

That's absolutely wonderful! By any means, feel free to make contributions.

The python code could use some cleaning and restructuring to make it more clear (there is some superfluous code, plotting methods I used during debugging, and hooks for future extensions that were never finished), but the main "juice" of it is solving equation 13 (currently done with a midpoint solver). If you have any questions about the code, do let me know! I won't be able to add to your contribution for the next week or so, but after that, I would love to join in on the C++ conversion.

Niohori commented 10 months ago

OK, I will upload in the coming days what I have on Github.

Niohori commented 10 months ago

FYI: I uploaded some code

bgmeulem commented 10 months ago

Lovely! Feel free to create a pull request. I'll run it over when I get the chance. I've skimmed through it and it looks great!