geodynamics / Rayleigh

Rayleigh: Pseudo-spectral MHD
GNU General Public License v3.0
59 stars 48 forks source link

Set f_14 depending on convention; don't reset c's and f's for diffusion types = 3 #505

Closed illorenzo7 closed 3 months ago

illorenzo7 commented 3 months ago

This pull request lumps in the setting of f_14 with c_11 to coincide with different conventions depending on reference_type. It also "protects" various c's and f's from being reset when the user specifies a diffusion using a custom reference (and therefore, set the c and f directly).

This change should not alter the functionality of the code at all (and it should not alter the internal "reference" object), but it should change the output of the equation_coefficients file in certain circumstances.

feathern commented 3 months ago

Sorry that it took me a minute to get to this. I think there's a (maybe) potential bug in that the user can selected reference_type=2 and also use 'with_custom_reference" to specify a background dsdr. It seems like the logic added here will unset the function and constant associated with dsdr.

illorenzo7 commented 3 months ago

@feathern Darn, you're right. In fact, I think it was already a bug, because c_11 was already reset to zero in the case you were mentioning.

I think the cleanest fix would be to make a new flag (say "with_custom_dsdr") that gets set to True if the user sets dsdr via the "with custom" framework. Then only go through the whole block setting c_11 and f_14 if that flag is false. (Otherwise, both c_11 and f_14 were already set).

What do you think?

illorenzo7 commented 3 months ago

@feathern. OK, from some limited testing, I think there were a number of bugs after introducing c_11 (beginning I believe with request #489). The first you already pointed out. The second is that c_11 was never set to 1 if the user didn't set it, remaining zero even after "with_custom_functions = 14" or similar was specified in main_input. Both these bugs should now be fixed. I also added some warning statements if the user modifies reference_types 1 or 2 which physically assume dsdr = 0.