James Berrow
banner
spacejames.bsky.social
James Berrow
@spacejames.bsky.social
C++/OpenCL/Binary Black Hole collisions. Space and astrophysics, with a side dish of cats

https://20k.github.io
Pinned
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
There's always something deeply satisfying about watching a #blackhole pop into the universe
July 17, 2025 at 10:01 PM
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
June 11, 2025 at 5:01 PM
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!
June 3, 2025 at 6:17 AM
This is how galaxies work, right? Right? Probably needs a bit more work
May 29, 2025 at 10:48 PM
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
May 27, 2025 at 12:56 AM
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
May 25, 2025 at 7:14 PM
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*
May 24, 2025 at 5:43 AM
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
May 24, 2025 at 12:39 AM
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
May 23, 2025 at 3:31 AM
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!
May 23, 2025 at 1:41 AM
2 million particles! I left this one running for a while, just because I thought it was pretty darn cool
May 21, 2025 at 10:47 PM
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
May 21, 2025 at 6:15 PM
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
May 20, 2025 at 7:17 PM
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
May 18, 2025 at 7:34 PM
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
May 7, 2025 at 10:39 PM
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
May 3, 2025 at 3:21 AM
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
April 30, 2025 at 1:33 AM
Neutron star mergers with colour might be my new favourite thing, it adds a tonne of visual depth to how everything looks #astro
April 29, 2025 at 7:45 PM
I really don't have a good reason for spending so much time putting my cat on neutron stars
April 29, 2025 at 2:36 PM
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
April 29, 2025 at 4:02 AM
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
April 15, 2025 at 11:03 AM
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
April 8, 2025 at 10:53 PM
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
April 1, 2025 at 3:25 AM
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
March 26, 2025 at 3:51 PM
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!
March 17, 2025 at 1:08 PM