Minor optimization in bisection_iter
This is a tiny line that I had on cosma but didn't commit before cosma had its downtime.
It returns the minimum energy, when the lower bound is smaller or equal to the minimum energy and there is still a net cooling (LambdaNet_cgs < 0).
Edit: Sorry, merge request went into SWIFTsim instead of the colibre version.
Merge request reports
Activity
405 406 * as the subgrid density will always be higher than the resolved density 406 407 */ 407 408 408 int iden_eq = iden; 409 float dden_eq = 0.; 409 int iden_eq = -1; @matthieu This initialisation is a bit dangerous. The problematic value is only caught with the SWIFT_DEBUG_CHECKS on. In all other cases, it leads to a segfault (@folkert reported this behaviour) as the interpolation routine tries to access a negative index and a negative delta. I think it would be saver to initialise these values with:
iden_eq = iden; dden_eq = dden;
This way it reverts back to the hydro density if it doesn't find a subgrid solution. This will usually only happen close to where the EOS meets the thermal equilibrium temperature and the hydro density would be the solution anyway.
Yes, it can happen close to the intersection of the thermal equilibrium temperature function and the EOS. We put particles on the subgrid properties if they are within, say 0.5 dex of the EOS. It's possible that the particle is therefore above the EOS but below the thermal equilibrium line. The code snippet only finds solutions when the EOS is above the thermal equilibrium line. That's not a big problem, as for these cases we can just use the hydro variables.
Maybe @folkert can quickly try it out and report back if it solves his segfault.