geodynamics / Rayleigh

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

Implementation of Finite-Difference formulation #474

Closed rpvin closed 1 year ago

rpvin commented 1 year ago

Added all the necessary changes required to run the benchmarks on uniform FD grids when dr_input is not specified. When dr_input is specified using Fortran-based syntax in the main_input file, Rayleigh can be run with a non-uniform grid. Currently, when the chebyshev flag is set to false, finite-difference is activated.

feathern commented 1 year ago

Is this ready for a review, or is this still work-in-progress?

rpvin commented 1 year ago

Hi Nick,

I'd like to wait until Philipp is done with the anelastic, MHD Benchmark run. He should be done by next week and I will let you know when it's ready for review.

Cheers, Rathish.

On Sat, 17 Jun 2023, 07:49 Nick Featherstone, @.***> wrote:

Is this ready for a review, or is this still work-in-progress?

— Reply to this email directly, view it on GitHub https://github.com/geodynamics/Rayleigh/pull/474#issuecomment-1595764984, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4B2HVUSQ5QI733SZB5NRY3XLWYVZANCNFSM6AAAAAAZJPR75I . You are receiving this because you authored the thread.Message ID: @.***>

tukss commented 1 year ago

These are the results of a long, anelastic finite difference run with MHD. It ran for 6.1e8 s. The results look pretty good to me.

 ///////////////////////////////////////////////////////////////////////////
               RAYLEIGH ACCURACY BENCHMARK SUMMARY               

   Benchmark:  Jones et al. 2001  (Steady Dynamo Case)

   Radial Resolution      N_R =          128
   Angular Resolution N_theta =          192

   Averaging Interval (seconds) :   1.800000E+05

   Beginning Iteration :      3085100
   Ending Iteration    :      3086000
   Number of Samples   :           10
 ----------------------------------------------------------------------------
   Observable      |    Measured    | Suggested   | % Difference |  Std. Dev.
 ----------------------------------------------------------------------------
   Kinetic Energy  :  8.119345E+36  8.036230E+36  1.034251E+00  1.587161E+32
   Zonal KE        :  1.187032E+36  1.153180E+36  2.935532E+00  6.838595E+31
   Meridional KE   :  1.029017E+33  1.015870E+33  1.294139E+00  2.528745E+28
   Magnetic Energy :  6.019203E+36  6.133330E+36 -1.860765E+00  2.446445E+32
   Zonal ME        :  4.520376E+36  4.620460E+36 -2.166101E+00  2.100449E+32
   Meridional ME   :  3.147325E+35  3.249270E+35 -3.137471E+00  2.154197E+31
   Entropy         :  6.111929E+05  6.089300E+05  3.716264E-01  1.827545E-01
   Vphi            : -2.998166E+03 -2.942200E+03  1.902197E+00  3.806120E-02
   Btheta          :  2.602995E+02  2.729200E+02 -4.624238E+00  5.981200E-03
   Drift Frequency :  4.296363E-06  4.307600E-06 -2.608559E-01  2.182600E-11
rpvin commented 1 year ago

Hi,

I think it's good to go for a review then :).

Cheers, Rathish

On Mon, 19 Jun 2023, 14:23 Philipp Edelmann, @.***> wrote:

These are the results of a long, anelastic finite difference run with MHD. It ran for 6.1e8 s. The results look pretty good to me.

/////////////////////////////////////////////////////////////////////////// RAYLEIGH ACCURACY BENCHMARK SUMMARY

Benchmark: Jones et al. 2001 (Steady Dynamo Case)

Radial Resolution N_R = 128 Angular Resolution N_theta = 192

Averaging Interval (seconds) : 1.800000E+05

Beginning Iteration : 3085100 Ending Iteration : 3086000 Number of Samples : 10

Observable | Measured | Suggested | % Difference | Std. Dev.

Kinetic Energy : 8.119345E+36 8.036230E+36 1.034251E+00 1.587161E+32 Zonal KE : 1.187032E+36 1.153180E+36 2.935532E+00 6.838595E+31 Meridional KE : 1.029017E+33 1.015870E+33 1.294139E+00 2.528745E+28 Magnetic Energy : 6.019203E+36 6.133330E+36 -1.860765E+00 2.446445E+32 Zonal ME : 4.520376E+36 4.620460E+36 -2.166101E+00 2.100449E+32 Meridional ME : 3.147325E+35 3.249270E+35 -3.137471E+00 2.154197E+31 Entropy : 6.111929E+05 6.089300E+05 3.716264E-01 1.827545E-01 Vphi : -2.998166E+03 -2.942200E+03 1.902197E+00 3.806120E-02 Btheta : 2.602995E+02 2.729200E+02 -4.624238E+00 5.981200E-03 Drift Frequency : 4.296363E-06 4.307600E-06 -2.608559E-01 2.182600E-11

— Reply to this email directly, view it on GitHub https://github.com/geodynamics/Rayleigh/pull/474#issuecomment-1597186847, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4B2HVUVEC4SY6FVNJNE2KDXMBHERANCNFSM6AAAAAAZJPR75I . You are receiving this because you authored the thread.Message ID: @.***>

feathern commented 1 year ago

The results look good to me as well. The drift frequency is particularly hard to get correct if something is off. Did that run use the strict_L_conservation flag? Since this will be need a pretty lengthy read through, it will probably be next week before I can do a careful code review.

feathern commented 1 year ago

Oh. One additional request. Can you possibly run this with 200 radial points (uniform grid) and see what the results look like? I seem to recall that that's the number we used with ASH several years ago, and I think most of the numbers were spot on at that resolution.

tukss commented 1 year ago

Did that run use the strict_L_conservation flag?

Yes, that flag was switched on.

tukss commented 1 year ago

Oh. One additional request. Can you possibly run this with 200 radial points (uniform grid) and see what the results look like? I seem to recall that that's the number we used with ASH several years ago, and I think most of the numbers were spot on at that resolution.

This is what I'm getting for 200 radial points. Looks like we're really close to the expected result.

 ///////////////////////////////////////////////////////////////////////////
               RAYLEIGH ACCURACY BENCHMARK SUMMARY               

   Benchmark:  Jones et al. 2001  (Steady Dynamo Case)

   Radial Resolution      N_R =          200
   Angular Resolution N_theta =          192

   Averaging Interval (seconds) :   1.980000E+06

   Beginning Iteration :      4200100
   Ending Iteration    :      4210000
   Number of Samples   :          100
 ----------------------------------------------------------------------------
   Observable      |    Measured    | Suggested   | % Difference |  Std. Dev.
 ----------------------------------------------------------------------------
   Kinetic Energy  :  8.037441E+36  8.036230E+36  1.507482E-02  5.035889E+29
   Zonal KE        :  1.152928E+36  1.153180E+36 -2.189514E-02  2.117157E+29
   Meridional KE   :  1.015979E+33  1.015870E+33  1.077104E-02  8.544276E+25
   Magnetic Energy :  6.137821E+36  6.133330E+36  7.322252E-02  7.714003E+29
   Zonal ME        :  4.623474E+36  4.620460E+36  6.522686E-02  6.648745E+29
   Meridional ME   :  3.253103E+35  3.249270E+35  1.179795E-01  6.914827E+28
   Entropy         :  6.089087E+05  6.089300E+05 -3.502790E-03  1.616939E-01
   Vphi            : -2.938927E+03 -2.942200E+03 -1.112285E-01  3.003451E-02
   Btheta          :  2.725399E+02  2.729200E+02 -1.392809E-01  1.544048E-03
   Drift Frequency :  4.307537E-06  4.307600E-06 -1.461858E-03  1.173114E-12
feathern commented 1 year ago

Awesome. OK, I will do a code review next week once I'm freed from proposal purgatory this Friday!

rpvin commented 1 year ago

Hi Nick,

I have fixed the indent now. Do I need to resend the PR?

I have attached the main_input file used for the Jones MHD benchmark. Two main input parameters that are used for this formulation are “chebyshev=false" and “dr_input”. FD is activated automatically when chebyshev is set to false. When dr_input in problemsize_namelist is not specified, a uniform grid is automatically calculated, so Delta_r in the code is set to a constant value. When dr_input is specified, the number of dr_input values must match n_r. Fortran syntax such as 200*some_dr_value can be used with comma separation.

That should be all of them. Please let me know if you need any more information.

Cheers, Rathish

On Tue, Jun 27, 2023 at 5:31 PM Nick Featherstone @.***> wrote:

@.**** requested changes on this pull request.

This looks good. I have three small requested changes: 1.) Can you fix the indent on line 54 of Sphere_Spectral_Space.F90? 2.) Could you provide the FD input file that you used to pass the Jone MHD benchmark? 3.) Can you provide a summary of the various new input parameter names and what they do? Once I have that info and an example input file, I can write a short blurb in the documentation about the 4th-order FD method and submit that as a separate PR..

— Reply to this email directly, view it on GitHub https://github.com/geodynamics/Rayleigh/pull/474#pullrequestreview-1501407319, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4B2HVSO7OZ5OWWWHOWA3TLXNMDGBANCNFSM6AAAAAAZJPR75I . You are receiving this because you authored the thread.Message ID: @.***>

-- Cheers, Rathish Previn Ratnasingam PhD Applied Mathematics (Newcastle University) MSc Theoretical Physics(University of Edinburgh) BSc Physics(Imperial College London)

feathern commented 1 year ago

Hey Rathish. I'm still not seeing the input files. If you place them Rayleigh/input_examples on your branch and commit/push, they should appear here without the need to initiate another PR.

rpvin commented 1 year ago

Hi Nick,

Just did this and checked. It should be labelled as main_input_mhd_jones_FD.

Cheers, Rathish

On Wed, Jun 28, 2023 at 2:56 PM Nick Featherstone @.***> wrote:

Hey Rathish. I'm still not seeing the input files. If you place them Rayleigh/input_examples on your branch and commit/push, they should appear here without the need to initiate another PR.

— Reply to this email directly, view it on GitHub https://github.com/geodynamics/Rayleigh/pull/474#issuecomment-1611462938, or unsubscribe https://github.com/notifications/unsubscribe-auth/A4B2HVW2DGK6HRFBFMON4NDXNQZ2XANCNFSM6AAAAAAZJPR75I . You are receiving this because you authored the thread.Message ID: @.***>

-- Cheers, Rathish Previn Ratnasingam PhD Applied Mathematics (Newcastle University) MSc Theoretical Physics(University of Edinburgh) BSc Physics(Imperial College London)

feathern commented 1 year ago

Wonderful! Merging now. Thanks for the hard work on this!