-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thermohaline hackathon: speeding up FRG24 implementation #633
base: thermohaline_hackathon
Are you sure you want to change the base?
Thermohaline hackathon: speeding up FRG24 implementation #633
Conversation
…plotter makes the same plot
…e .dat file, looks like the LPN limit has the same diffusivities out to 6 decimal places
As of this point, I've implemented the speedups that have zero error (change of basis / block diagonalization), and that have asymptotically small error (low Péclet number limit, which introduces errors of order tau, which is usually between 10^-3 to 10^-7). This should be just about 10 times faster than it was before, but I'm not sure how best to test that. Next step is to implement the low-Rm limit (Sec V of the PDF I linked above), and use HG19 as guardrails to keep the resulting error to acceptable levels. Also, general cleanup. |
…ences in turb_plotter.png if you squint (expect larger differences for the WD case)
… (with low-Rm limit) and trying to use HG19 for first block, but doesn't work right now; also implements "safety" integer for picking which of these new speedups to employ
I think this is working as intended. I've added a
Here is a .zip with the resulting In the notes I TeXed above I claimed that for safety=0 the appropriate thing to do is to let D_C be the min between HG19's D_C and the one calculated with this method. What I've implemented here is I'm instead letting w_f be the min between HG19's w_f and the one calculated here. I'm not sure which is more appropriate off the top of my head. |
… methods can be compared against the old in timing tests
For now, |
@@ -130,14 +131,23 @@ subroutine calc_frg24_w(pr, tau, r0, hb, db, ks, n, w, withTC, ierr, lamhat, l2h | |||
if (present(lamhat)) then | |||
! lamhat and l2hat already calculated, so can pass as arguments | |||
if(withTC) then | |||
w = wf_withTC(pr, tau, r0, hb, db, ks, n, .false., lamhat, l2hat) | |||
if (safety == 0) then | |||
! TODO: is it bad for this minimization to be occurring here AND in thermohaline.f90? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine. This calc_frg24_w
routine just exists to give a public interface for calling the velocities so we can use it in turb/plotter. Any actual stellar evolution goes through the get_D_thermohaline
routine that is calling the stuff in thermohaline.f90
independent of this, because right now mesa/star just wants a thermohaline composition diffusion coefficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this structure does end up causing a lot of duplicated code at this point. It would be better to have all that code live in a velocity routine in private/thermohaline.f90
, and leave this public interface as just a wrapper to call that private routine.
The FRG24 model for MHD thermohaline mixing, as currently implemented in the
thermohaline_hackathon
feature branch, is very slow (as pointed out by @evbauer in d453d85 in the context of #605). I've TeXed up some notes (TL;DR on page 2) on different ways to speed up the model---some with zero loss in accuracy, some with negligible loss in accuracy, and some with a loss in accuracy that is a factor of a few (but still more accurate than HG19 or the other models currently implemented). This draft PR covers these different speedups. Broadly speaking, they involve a change of basis that block-diagonalizes the matrix we're dealing with, asymptotic reductions of the equations, and reliance on HG19 where appropriate.Some speedups this doesn't cover, but are worth exploring down the road if needed: