Fix jet initial velocities
Fixes #866 (closed).
Merge request reports
Activity
requested review from @matthieu
assigned to @matthieu
I can. If we're doing this, should we also check some of the improvements/bug fixes from the recent big update (!1727 (merged))? In particular, point 1. from that MR might be important for flamingo. This bug fix should prevent the same particle from getting double kicks in a single time step, as well as the same particle being kicked in subsequent time-steps if it is still present in the kernel when a new kick happens.
Edited by Filip Husko- Resolved by Matthieu Schaller
@dc-husk1 @matthieu The code looks fine, but in order to be sure that everything works as expected I suggest doing two unit tests:
-
Record the change in gas particles' actual kinetic energies immediately before and after the kick, and verify that these numbers agree with how much kinetic energy the particles are expected to receive.
-
Check that the velocity with which the gas particle is kicked in fact (which can be different from v_jet) becomes equal to the target jet velocity, v_jet, when the relative velocity between the BH and gas particles approaches zero. For this test, I'd record the actual velocity with which the gas particles are kicked and the relative velocity between them and the BH. Then I'd plot one against the other.
-
Here are the results of the test you recommended, @chaikin. I recorded the final and initial velocities (in the frame of the BH) for each kicking event, as well as the kinetic energies calculated using those same velocities. Below I show the plots of v_final vs. v_init and E_fin vs. E_init. The two plots are closely related since they are showing almost the same thing (because I use the velocities to calculate the energies).
We can see that in the buggy version, the final energy is not what is expected from energy conservation, but it is in the fixed version. From the velocity plot we can see that in some cases, the relative velocity (w.r.t. the BH) can be less than the target kick velocity (3160 km/s), probably in cases when the particles were moving towards the BH.
Edited by Filip HuskoYes, I can do two runs (1000 km/s and 2000 km/s for the fiducial and strong jet runs, respectively). Of course, the dynamics of the gas will be a bit different to FLAMINGO, but it should still be roughly representative.
We want this test to be done with the bug included, right? To see the spread in all the red dots?