There's always something deeply satisfying about watching a #blackhole pop into the universe
James Berrow
@spacejames.bsky.social
C++/OpenCL/Binary Black Hole collisions. Space and astrophysics, with a side dish of cats https://20k.github.io
You know, somehow I *don't* think that this is how orbits work It took a while to track this one down, but its related to using trilinear interpolation, instead of a higher order interpolation scheme like tricubic
After much umming and erring, I finally figured out an easy way to build a galaxy with a z component that didn't involve like 8 integrals. Time to see if it'll actually simulate correctly!
This is how galaxies work, right? Right? Probably needs a bit more work
Ok well the omegacat II data release does have the minor problem in that their data header is wrong oops! 220-221 I2 --- nitschai_id ? ID in oMEGACat I MUSE spectroscopic catalog (Nitschai et al. 2023) 223-224 I2 --- gaia_id ? Gaia Source Identifier
Trying to simulate everything in omegacat II is (unsurprisingly!) a lot of work. I was (somewhat naively) hoping that there would simply be 3d positions and velocities available for everything
There's some part of my brain which goes: We've had 1 million stars, but what about 10 million? It turned out to be easier than I expected to optimise - I just had to sort the particles to optimise the memory layout I'm not even sure what to do with this many stars, and yet *what if 100 million*
One way of modelling hawking radiation is as an infalling negative energy. The simulation hates it, but its possible to chuck negative mass particles into a black hole and (partially) evaporate it Evaporating it more than this has a tendency to cause big explosions, super tricky to model #astro
The coolest thing about doing relativistic N body over newtonian N body? You can build black holes out of the particles! Its even the correct mass too
Some performance optimisations later, and 1M particles is running pretty well now. I tend to leave these test cases going for a while just because they look cool I think its finally time to go simulate some real things and see how well this works!
2 million particles! I left this one running for a while, just because I thought it was pretty darn cool
The best part about GPU programming is that once you have 2 of something working, you can just start hitting 0 on your keyboard and see what happens. First test of 200k particles for fully relativistic N-body #astro
Finally got the sanity test on the relativistic particle dynamics to work correctly (!) - turns out one of the papers I'm looking at got their equations all wrong which has made this a very good time
Oh boy, started working on particles and my favourite bug has turned up - where they just randomly drift off into space because of floating point problems
20k.github.io/c++/2025/05/... I've finished writing up how to implement #neutronstar collisions (with code!), and follow them through to collapsing into a black hole. Turned out quite well! There's also a small side venture on how to put a cat onto a neutron star, which is v important #astrocode
Numerical Relativity 105: Smashing neutron stars together like its 2002 · James' Space Blog
Ramblings on C++, OpenCL, and GPU programming
20k.github.io
Herbie (herbie.uwplse.org) has got to be one of the coolest tools for improving floating point equations. I don't think I've ever seen it call out one of my equations for being quite *this* terrible before though! Though, for some reason herbie has developed a passionate hatred for squaring things
Super duper long running inspiral of some low mass neutron stars. Interesting to watch a whole bunch of material get jettisoned, as well as the resulting accretion disk getting eaten. Some problems with mass loss here due to the numerics sadly
Neutron star mergers with colour might be my new favourite thing, it adds a tonne of visual depth to how everything looks #astro
I really don't have a good reason for spending so much time putting my cat on neutron stars
Finally got around to something I've been wanting to do for yonks, which is arbitrary colour distributions for neutron stars. Now you can watch them spin, and see how they mix internally! The spin conservation is also way *way* better than I ever expected, so that's exciting too #astro
20k.github.io/c++/2025/04/... Ever felt like building a #neutronstar, for a numerical relativistic simulation? Here's how! This is a programmer's guide (with code) on how to wrangle a specific set of initial conditions, so in the future we can smash some neutron stars together #astrocode
Numerical Relativity 104: How to build a neutron star - from scratch · James' Space Blog
Ramblings on C++, OpenCL, and GPU programming
20k.github.io
Neutron stars: One thing I think is interesting is that there's no unique way to determine the density at the centre of a neutron star, just from its mass. Here's a plot central matter densities (ie follow the curve from the top left, rightwards, this is increasing density), showing multiple options
I've had my crash course in fluid dynamics now and implemented a flux conservative high resolution shock capturing scheme. Super interesting to see just how much better the results are vs a traditional discretisation if you're a nooby pde solver like me! Still some minor mass gain to sort out
Fluid dynamics is even worse than NR! I have no idea how people working on hydrodynamics stay sane. On the plus size, I've ironed out a dozen bugs with these neutron star collisions now, so some aspects of this are looking a lot less sketchy now
Chasing down a nasty error: Left is a standard substitution of the christoffel symbol, right is with that substitution disabled. Top left is a measure of the Γᶦ error: Left clearly has higher error, yet much better results, as the right sim fails!
Most hydrodynamic simulations have a pervasive thin atmosphere in the simulation, and I'm starting to see why. The issue is, at the edge of the star in non atmospheric hydro, there's a true discontinuity which can severely affect inspiral based on minor numerical changes
Neutron star inspirals are pretty awesome: I rotated the background so you can see the gravitational lensing better. Testing out some different initial gauge conditions, which seems to have made a surprisingly large difference to energy conservation! #astro
So many orbits, so few numerical problems (!). If anyone just so happens to have a physical neutron star test case that includes the linear ADM momentum on hand, I can offer you pictures of my cat in exchange. Surprisingly hard to find explicit numbers for test cases here
It looks like the next step to get circular neutron star inspirals is (..finally) working nicely. Its good enough that I think I can declare the underlying hydrodynamics functional! Turns out there was a lot of gauge-condition-itus, as well as some constraint-damping-itus, as per normal. #astro
Pinned down why my neutron stars blow up after an orbit (its always the gauge conditions), and now its looking a lot better! Getting circular inspirals is going to be a lot more work