Page 1 of 1

Default behaviour of `x_ref`

Posted: Wed Aug 22, 2018 3:35 am
by warrick
Hi,

I was just discussing the normalisation of the mode inertiae and I suddenly can't see that the code (version 5.2) reproduces what the documentation says. From the docs,

Code: Select all

x_ref : reference fractional radius for photosphere, normalizations etc. (default 1 or outer grid point, whichever is smaller)
I searched in the code for x_ref:

Code: Select all

$ cd $GYRE_DIR
$ grep x_ref src/*/*.fpp
src/common/gyre_osc_par.fpp:     real(WP)                :: x_ref
src/common/gyre_osc_par.fpp:    real(WP)                              :: x_ref
src/common/gyre_osc_par.fpp:    namelist /osc/ x_ref, rotation_method, inner_bound, outer_bound, &
src/common/gyre_osc_par.fpp:       x_ref = HUGE(0._WP)
src/common/gyre_osc_par.fpp:       os_p(i) = osc_par_t(x_ref=x_ref, &
src/common/gyre_osc_par.fpp:    call bcast(os_p%x_ref, root_rank)
src/mode/gyre_mode.fpp:    real(WP)    :: x_ref
src/mode/gyre_mode.fpp:    x_ref = MIN(MAX(os_p%x_ref, gr%pt(1)%x), gr%pt(gr%n_k)%x)
src/mode/gyre_mode.fpp:    md%k_ref = MINLOC(ABS(gr%pt%x - x_ref), DIM=1)
src/mode/gyre_mode.fpp:    ! Calculate the effective temperature perturbation at x_ref
src/mode/gyre_mode.fpp:    ! Calculate the effective gravity perturbation at x_ref (assumed
src/mode/gyre_mode.fpp:         $WARN(Amplitude at x_ref is zero; not normalizing inertia)
src/output/gyre_output.fpp:       $OUTPUT_MODES(r,x_ref,gr%pt(md(i_md)%k_ref)%x)
src/output/gyre_output.fpp:         case ('x_ref')
src/output/gyre_output.fpp:            call wr%write('x_ref', pt(md%k_ref)%x)
src/search/gyre_c_search.fpp:  !   real(WP)      :: x_ref
src/search/gyre_c_search.fpp:  !   x_ref = x(n)
src/search/gyre_c_search.fpp:  !   call bp%recon(cmplx(omega), x, x_ref, y, y_ref, discrim)
src/search/gyre_c_search.fpp:  !               x, y, x_ref, y_ref)
Between these two lines, it seems the default behaviour will always be to take the outermost meshpoint of the model:

Code: Select all

src/common/gyre_osc_par.fpp:       x_ref = HUGE(0._WP)
src/mode/gyre_wave.fpp:    x_ref = MIN(MAX(os_p%x_ref, gr%pt(1)%x), gr%pt(gr%n_k)%x)
I imagine the behaviour described in the documentation would occur if the first line were just

Code: Select all

       x_ref = 1._WP
I also tried searching more thoroughly (with find) for source files but didn't find anything else with x_ref in it.

I have no opinion on what the default behaviour should be, just that the documentation should match.

Cheers,
Warrick

Re: Default behaviour of `x_ref`

Posted: Wed Aug 22, 2018 10:02 am
by rhtownsend
warrick wrote:
Wed Aug 22, 2018 3:35 am
Hi,

I was just discussing the normalisation of the mode inertiae and I suddenly can't see that the code (version 5.2) reproduces what the documentation says. From the docs,

Code: Select all

x_ref : reference fractional radius for photosphere, normalizations etc. (default 1 or outer grid point, whichever is smaller)
I searched in the code for x_ref:

Code: Select all

$ cd $GYRE_DIR
$ grep x_ref src/*/*.fpp
src/common/gyre_osc_par.fpp:     real(WP)                :: x_ref
src/common/gyre_osc_par.fpp:    real(WP)                              :: x_ref
src/common/gyre_osc_par.fpp:    namelist /osc/ x_ref, rotation_method, inner_bound, outer_bound, &
src/common/gyre_osc_par.fpp:       x_ref = HUGE(0._WP)
src/common/gyre_osc_par.fpp:       os_p(i) = osc_par_t(x_ref=x_ref, &
src/common/gyre_osc_par.fpp:    call bcast(os_p%x_ref, root_rank)
src/mode/gyre_mode.fpp:    real(WP)    :: x_ref
src/mode/gyre_mode.fpp:    x_ref = MIN(MAX(os_p%x_ref, gr%pt(1)%x), gr%pt(gr%n_k)%x)
src/mode/gyre_mode.fpp:    md%k_ref = MINLOC(ABS(gr%pt%x - x_ref), DIM=1)
src/mode/gyre_mode.fpp:    ! Calculate the effective temperature perturbation at x_ref
src/mode/gyre_mode.fpp:    ! Calculate the effective gravity perturbation at x_ref (assumed
src/mode/gyre_mode.fpp:         $WARN(Amplitude at x_ref is zero; not normalizing inertia)
src/output/gyre_output.fpp:       $OUTPUT_MODES(r,x_ref,gr%pt(md(i_md)%k_ref)%x)
src/output/gyre_output.fpp:         case ('x_ref')
src/output/gyre_output.fpp:            call wr%write('x_ref', pt(md%k_ref)%x)
src/search/gyre_c_search.fpp:  !   real(WP)      :: x_ref
src/search/gyre_c_search.fpp:  !   x_ref = x(n)
src/search/gyre_c_search.fpp:  !   call bp%recon(cmplx(omega), x, x_ref, y, y_ref, discrim)
src/search/gyre_c_search.fpp:  !               x, y, x_ref, y_ref)
Between these two lines, it seems the default behaviour will always be to take the outermost meshpoint of the model:

Code: Select all

src/common/gyre_osc_par.fpp:       x_ref = HUGE(0._WP)
src/mode/gyre_wave.fpp:    x_ref = MIN(MAX(os_p%x_ref, gr%pt(1)%x), gr%pt(gr%n_k)%x)
I imagine the behaviour described in the documentation would occur if the first line were just

Code: Select all

       x_ref = 1._WP
I also tried searching more thoroughly (with find) for source files but didn't find anything else with x_ref in it.

I have no opinion on what the default behaviour should be, just that the documentation should match.

Cheers,
Warrick
Nice catch. I'll fix this in the next release.

cheers,

Rich