geodynamics / Rayleigh

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

guarded against dividing by N^2=0 #490

Closed illorenzo7 closed 9 months ago

illorenzo7 commented 9 months ago

For reference_type = 5, when the buoyancy frequency N^2 was rescaled, this was causing problems with division by 0. I guard against this now with if-statements.

feathern commented 9 months ago

This looks good, but I have a quick question. Why is there duplicated code starting on line 760 (the same three lines are repeated), but then inside of the if statement, there is no duplication. Was the original duplication in error, or did it serve a purpose. Specifically, I'm talking about:

        Call Integrate_in_radius(nsquared,norm)
        norm = four_pi*norm/shell_volume
        nsquared = nsquared/norm
illorenzo7 commented 9 months ago

Hmm, it looks like my original code had the duplication, which was a mistake on my part, as far as I can tell. I must have removed the duplicate block when I surrounded it by the if-statement. I don't think removing the duplicate block should affect anything.

illorenzo7 commented 9 months ago

Thanks @feathern ! Good catch, I forgot I put those debugging statements there.