MESAHub / mesa

Modules for Experiments in Stellar Astrophysics
http://mesastar.org
GNU Lesser General Public License v2.1
145 stars 39 forks source link

Thermohaline hackathon: FRG24 model with safety=3 fails due to ill-conditioned matrix #738

Open afraser3 opened 1 month ago

afraser3 commented 1 month ago

The FRG24 model as currently implemented in the thermohaline_hackathon and thermohaline_keep_on_hacking feature branches appears to work great with safety=0, but crashes in pesky edge cases with safety=3 (which implements the full model without the approximations used by safety=0 to speed up the model---see #633). The problem arises when evaluating the model in regions that are very weakly unstable, with density ratio R_0 approaching the diffusivity ratio 1/tau. There, the flow speed w_f is comparable to machine precision, and the resulting matrix whose eigenvalues are sought becomes extremely ill-conditioned, so that the eigenvalues it spits out are unreliable, and the routine doesn't know how to proceed. Fortunately, the model seems to work fine with safety=0, so the FRG24 model can still be used. Still, it would be nice to be able to run calculations with safety=3 in case users want to test the validity of the approximations employed when running with safety=0.

Opening this up as an issue so that @rhdtownsend, @JarRosenberg, and I can keep track of progress while we try to get to the bottom of this. Current leading candidates for addressing this problem involve (1) changing the nondimensionalization employed when writing out the matrix whose eigenvalues are needed, and (2) trying to employ matrix perturbation theory to get the eigenvalues in this problematic regime perturbatively rather than calculating them via brute force. We should also probably test other choices of safety to see if they run into similar problems.