Sign in

James Berrow

@spacejames.bsky.social
119 followers 72 following 129 posts

C++/OpenCL/Binary Black Hole collisions. Space and astrophysics, with a side dish of cats 20k.github.io

PostsRepliesMedia
James Berrow @spacejames.bsky.social · 08/07/2026
Somehow, we have to get Nigel Farage pinned down for a televised debate against Count Binface. They're the leading two candidates
020
James Berrow @spacejames.bsky.social · 17/07/2025
There's always something deeply satisfying about watching a #blackhole pop into the universe
010
James Berrow @spacejames.bsky.social · 11/06/2025
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
000
James Berrow @spacejames.bsky.social · 03/06/2025
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!
010
James Berrow @spacejames.bsky.social · 29/05/2025
This is how galaxies work, right? Right? Probably needs a bit more work
000
James Berrow @spacejames.bsky.social · 28/05/2025
I sunk some time into this recently! Sadly the naive approach of trying to directly use gaia parallax didn't pan out - I was a bit optimistic about its accuracy. Looks like a more sensible approach is to fit star distance based on proper velocities + radial profile I'd guess, so take 2!
010
James Berrow @spacejames.bsky.social · 27/05/2025
Now I have my favourite thing ever, which is a hardcoded table that looks like this: std::vector<int> data_lengths{ 7,12,12,10,10,11,12,11,11,7,7,8,8,1,3,3,7,11,12,11,11,3,8,6,19,6,12,5,12,5,11,9,10,9,6,2,1}; Still, hard to be anything other than happy the data exists for free and easily available
000
James Berrow @spacejames.bsky.social · 27/05/2025
Those byte offsets and type sizes (eg 220-221 + I2) should be much larger, which renders all the offsets later in the file broken as well. The joys of data processing
100
James Berrow @spacejames.bsky.social · 27/05/2025
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
110
James Berrow @spacejames.bsky.social · 26/05/2025
On one hand, being on bsky instead of twitter has hurt me professionally On the other hand, one of my friend's entire family tree was murdered by nazis, and they're the sole surviving branch of a giant tree of thousands of people Its not an especially difficult choice. Here's a cat:
Its a cat. She's called wesley. She's a very good cat, despite her love of sneezing in my face, and her ability to become airborne immediately in any environment just by walking in the room. Every time I open an amazon parcel, I find bits of her fur in it. I worry that one day I'll wake up, and I'll simply have become a pile of her fur which has sprung to life and begun to go about my daily tasks
010
James Berrow @spacejames.bsky.social · 26/05/2025
"Industry built on crime would collapse if the law was enforced"
020
James Berrow @spacejames.bsky.social · 25/05/2025
I'm going to guess I might be able to guess the mass from the star's magnitude, seems fraught with errors though
000
James Berrow @spacejames.bsky.social · 25/05/2025
It looks like: 1. Distances for many stars comes from gaia 2. The z component of the velocity comes from omegacat I 3. I'll have to build an approximate model to fit the other stars roughly based on their proper motion + position Absolutely no idea how to determine mass though
100
James Berrow @spacejames.bsky.social · 25/05/2025
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
100
James Berrow @spacejames.bsky.social · 24/05/2025
More technically its a measure of the constraint error. This *can* be a useful measure of how inaccurate the simulation is (though its tricky to interpret it like that), but its a very good metric of whether or not the simulation is likely to stop functioning altogether
010
James Berrow @spacejames.bsky.social · 24/05/2025
The nuclear option would be to decouple the particle step rate from the grid step rate, which could probably push it up into ~1 billion with some tweaks. Do I need a billion stars? ..maybe
000
James Berrow @spacejames.bsky.social · 24/05/2025
Each star at the moment is discretised into a volume of 4x4x4 grid cells. While 1 grid cell is too few (and introduces systematic errors), you can in theory shrink the size to 2x2x2. That solves 50% of the next performance step up - the particle stepping would be the next big problem
100
James Berrow @spacejames.bsky.social · 24/05/2025
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*
110
James Berrow @spacejames.bsky.social · 24/05/2025
Top left is a measure of how unhappy the sim is. If it looks like a disco rave ball, that means things are going poorly
110
James Berrow @spacejames.bsky.social · 24/05/2025
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
2253
James Berrow @spacejames.bsky.social · 23/05/2025
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
020
James Berrow @spacejames.bsky.social · 23/05/2025
I've always wanted to build a fully relativistic galaxy simulation. This is based on some particle dynamics I put together a few years ago that I found a few major mistakes in (as well as relying on a paper with bad equations), so fingers crossed that it all Magically Works™
030
James Berrow @spacejames.bsky.social · 23/05/2025
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!
141
James Berrow @spacejames.bsky.social · 22/05/2025
I clicked on *one* bike fork on amazon recently, and for 2 months I got nothing but bike fork ads. Apparently there was a 0% chance I wanted anything but a bike fork, which was now the sole object of desire in my life People say that targeted ads are amazing, but seems remarkably poor marketing
010
James Berrow @spacejames.bsky.social · 22/05/2025
Yeah that's the intent! This kind of setup is working with 'collisionless particles', so this can represent any object with gravity which doesn't (meaningfully) interact with its surroundings
010
James Berrow @spacejames.bsky.social · 22/05/2025
This is a test case of a cloud of 200k stars collapsing. The initial velocity distribution and mass distribution isn't anything real though, I'm more just checking that this all works correctly There's enough particles now to be able to put together a decent galaxy sim, or perhaps even a cluster!
110
James Berrow @spacejames.bsky.social · 21/05/2025
2 million particles! I left this one running for a while, just because I thought it was pretty darn cool
040
James Berrow @spacejames.bsky.social · 21/05/2025
Now I could fix this, *or* I could just keep hitting zero on my keyboard ...
020
James Berrow @spacejames.bsky.social · 21/05/2025
The rendering really was not built for this so there's a lot of artifacting. The initial conditions are also very basic - but heavily complicated by trying to avoid this test case from collapsing into a black hole
100
James Berrow @spacejames.bsky.social · 21/05/2025
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
2141
James Berrow @spacejames.bsky.social · 20/05/2025
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
020
James Berrow @spacejames.bsky.social · 18/05/2025
How can completely symmetric initial conditions result in an asymmetric outcome you ask? The perpetual joy of floating point
100
James Berrow @spacejames.bsky.social · 18/05/2025
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
130
James Berrow @spacejames.bsky.social · 10/05/2025
Its incredibly depressing watching this all implode. My plan for a while was to see if I could fnagle my way into a PhD in the US somewhere, but its wild seeing everything go up in flames so quickly with no regard for the damage that's happening
110
James Berrow @spacejames.bsky.social · 08/05/2025
Someone noticed that a large number of video embeds was causing problems: I've cut down on this significantly, and it should be working much better now
000
James Berrow @spacejames.bsky.social · 07/05/2025
This is really super critical science
000
James Berrow @spacejames.bsky.social · 07/05/2025
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
20k.github.io
Numerical Relativity 105: Smashing neutron stars together like its 2002 · James' Space Blog
Ramblings on C++, OpenCL, and GPU programming
270
James Berrow @spacejames.bsky.social · 03/05/2025
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
000
James Berrow @spacejames.bsky.social · 30/04/2025
Eg galaxies can lense each other very visibly. Its tricky to spot without an appropriate background (including in real astrophysics). I used to run these sims against a flatter backdrop where the effect wasn't visible at all
100
James Berrow @spacejames.bsky.social · 30/04/2025
They do! Neutron stars are very dense objects, so you end up with gravitational lensing, and a lot of relativistic effects that might be more familiar from black holes. In terms of compactness they're not that far away from being black holes You actually get gravitational lensing in other cases too
100
James Berrow @spacejames.bsky.social · 30/04/2025
This is the first decent spinning test case I've had as well, Χ (dimensionless spin) = 0.25
000
James Berrow @spacejames.bsky.social · 30/04/2025
This is a colour version of the above, but shorter lived as I was experimenting with some tighter numerical bounds - that didn't pan out (and the sim blew up). Very tempted to try something crazy like the projective reals, or unums or something
110
James Berrow @spacejames.bsky.social · 30/04/2025
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
110
James Berrow @spacejames.bsky.social · 29/04/2025
Neutron star mergers with colour might be my new favourite thing, it adds a tonne of visual depth to how everything looks #astro
2192
James Berrow @spacejames.bsky.social · 29/04/2025
I really don't have a good reason for spending so much time putting my cat on neutron stars
020
James Berrow @spacejames.bsky.social · 29/04/2025
Its an image I used for an old article:
Its a very long stretched picture of a cat, with a second cat randomly slapped on in the middle because it was the correct positioning for an old article. There are stars, and a rainbow, and everything is purple. The subtext is that the author is insane
010
James Berrow @spacejames.bsky.social · 29/04/2025
you can never have too many cats
120
James Berrow @spacejames.bsky.social · 29/04/2025
mrow
110
James Berrow @spacejames.bsky.social · 29/04/2025
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
1203
James Berrow @spacejames.bsky.social · 15/04/2025
Oh! That's me! If anyone has any questions or feedback, I'm very happy to answer anything about this The #1 Q I get is: Is that really my cat? A: Yes, and she truly *loves* that bag to an absolutely unreasonable degree
010