Skip to content

Commit 875389a

Browse files
authored
Merge pull request #774 from MESAHub/rotation_update
2 parents 1c5db18 + 4e55cfc commit 875389a

File tree

8 files changed

+228
-439
lines changed

8 files changed

+228
-439
lines changed

docs/source/changelog.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ New Features
2121

2222
A pseudo drag term ``v_drag`` has been reintroduced for ``u_flag`` to damp spurious shocks.
2323

24+
``hydro_rotation`` now contains the more accurate deformation fits from Fabry+2022, A&A 661, A123
25+
2426
.. _Bug Fixes main:
2527

2628
Bug Fixes
2729
---------
2830

2931
fixed small bug in star/private/create_initial_model.f90 that will have a small effect on creating initial models
30-
32+
fixed bug in ``star/private/hydro_rotation.f90`` where the sigmoid function to cap ``w_div_w_crit`` was incorrectly implemented. This only influences models with `w_div_wc_flag = .true.`
3133

3234
.. note:: Before releasing a new version of MESA, move `Changes in main` to a new section below with the version number as the title, and add a new `Changes in main` section at the top of the file (see ```changelog_template.rst```).
3335

star/defaults/controls.defaults

Lines changed: 19 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,7 @@
23132313
! convection model ``TDC`` with an overshooting model, or combining ``TDC``
23142314
! with other models for chemical composition gradients
23152315
! (predictive mixing or convective premixing), rotation, etc. (MESA VI)
2316-
2316+
23172317
! ::
23182318

23192319
MLT_option = 'TDC'
@@ -4060,57 +4060,21 @@
40604060

40614061
! ::
40624062

4063-
w_div_wcrit_max = 0.90d0
4063+
w_div_wcrit_max = 0.89d0
40644064

40654065

40664066
! w_div_wcrit_max2
40674067
! ~~~~~~~~~~~~~~~~
40684068

40694069
! When w_div_wc_flag is true, rather than a hard limit on w_div_wcrit
4070-
! we use w_div_wcrit_max2<w_div_wcrit_max to provide a smooth transition.
4071-
! In the limit of j_rot->infinity, the resulting w_div_wc will match
4072-
! w_div_wcrit_max, while nothing is done when w_div_wcrit_max<w_div_wcrit_max2
4073-
4074-
! ::
4075-
4076-
w_div_wcrit_max2 = 0.89d0
4077-
4078-
4079-
! FP_min
4080-
! ~~~~~~
4081-
! FT_min
4082-
! ~~~~~~
4083-
4084-
! Lower limits for rotational distortion corrections factors FP and FT.
4085-
! Used for the calculation when fitted_fp_ft_i_rot = .false., otherwise the
4086-
! limits are set using w_div_wcrit_max
4087-
4088-
! ::
4089-
4090-
FP_min = 0.75d0
4091-
FT_min = 0.95d0
4092-
4093-
4094-
! FP_error_limit
4095-
! ~~~~~~~~~~~~~~
4096-
4097-
! If calculate an fp < this, treat it as an error.
4098-
! Used for the calculation when fitted_fp_ft_i_rot = .false.
4070+
! we use two limiting values w_div_wcrit_max < w_div_wcrit_max2 to provide a smooth transition.
4071+
! Nothing is done when w_div_wc < w_div_wcrit_max, if w_div_wcrit_max < w_div_wc < w_div_wcrit_max2,
4072+
! we apply a sigmoid, and in the limit of j_rot -> infinity, the resulting w_div_wc will match
4073+
! w_div_wcrit_max2 (being on the top of the sigmoid)
40994074

41004075
! ::
41014076

4102-
FP_error_limit = 0d0
4103-
4104-
4105-
! FT_error_limit
4106-
! ~~~~~~~~~~~~~~
4107-
4108-
! If calculate an ft < this, treat it as an error.
4109-
! Used for the calculation when fitted_fp_ft_i_rot = .false.
4110-
4111-
! ::
4112-
4113-
FT_error_limit = 0d0
4077+
w_div_wcrit_max2 = 0.90d0
41144078

41154079

41164080
! D_mix_rotation_max_logT_full_on
@@ -4142,17 +4106,17 @@
41424106
! For numerical stability, turn off rotational part of ``D_mix`` at very low tau.
41434107

41444108
! ::
4145-
4109+
41464110
D_mix_rotation_min_tau_full_off = 0d0
4147-
4111+
41484112
! D_mix_rotation_max_tau_full_on
41494113
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41504114

41514115
! Use rotational components of ``D_mix`` for locations where tau >= this.
41524116
! For numerical stability, turn off rotational part of ``D_mix`` at very low tau.
41534117

41544118
! ::
4155-
4119+
41564120
D_mix_rotation_min_tau_full_on = 0d0
41574121

41584122

@@ -4673,8 +4637,8 @@
46734637
! do_starspots
46744638
! ~~~~~~~~~~~~
46754639

4676-
! If ``.true.``, switch on impedance of the surface flux due to magnetic pressure from starspots,
4677-
! parameterized in the style of an atmospheric boundary modification. First described by
4640+
! If ``.true.``, switch on impedance of the surface flux due to magnetic pressure from starspots,
4641+
! parameterized in the style of an atmospheric boundary modification. First described by
46784642
! `Somers et al. (2015; ApJ) <https://ui.adsabs.harvard.edu/abs/2015ApJ...807..174S>`__.
46794643
! Detailed discussion of this functionality can be found in |MESA VI|.
46804644

@@ -4695,8 +4659,8 @@
46954659
! xspot
46964660
! ~~~~~
46974661

4698-
! Temperature contrast between the spotted and unspotted regions.
4699-
! Valid values are between 1.0 (no contribution from magnetic pressure) and 0.5
4662+
! Temperature contrast between the spotted and unspotted regions.
4663+
! Valid values are between 1.0 (no contribution from magnetic pressure) and 0.5
47004664
! (half of the total pressure is due to magnetic pressure)
47014665

47024666
! ::
@@ -8263,11 +8227,11 @@
82638227

82648228
use_dPrad_dm_form_of_T_gradient_eqn = .false.
82658229
use_gradT_actual_vs_gradT_MLT_for_T_gradient_eqn = .false.
8266-
8267-
8230+
8231+
82688232
! Hydrodynamic drag
82698233
! =================
8270-
8234+
82718235
! drag_coefficient
82728236
! ~~~~~~~~~~~~~~~~
82738237
! min_q_for_drag
@@ -8299,7 +8263,7 @@
82998263
drag_coefficient = 0d0
83008264
min_q_for_drag = 0d0
83018265

8302-
8266+
83038267
! v_drag_factor
83048268
! ~~~~~~~~~~~~~
83058269
! v_drag
@@ -8312,7 +8276,7 @@
83128276

83138277
! Only when u_flag = .true.. Adds a pseudo drag term of the form
83148278
! -v_drag_factor*(v-v_drag)^2/r, can be used damp velocities in outer layers
8315-
! of a star, useful for smoothing out spurious shocks colliding in ejected layers.
8279+
! of a star, useful for smoothing out spurious shocks colliding in ejected layers.
83168280
! Effect is full on for q>q_for_v_drag_full_on and full off for
83178281
! q < q_for_v_drag_full_off.
83188282

star/private/ctrls_io.f90

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ module ctrls_io
277277
min_q_for_adjust_J_lost, min_J_div_delta_J, max_mdot_redo_cnt, mdot_revise_factor, &
278278
implicit_mdot_boost, min_years_dt_for_redo_mdot, surf_omega_div_omega_crit_limit, surf_omega_div_omega_crit_tol, &
279279
w_div_wcrit_max, w_div_wcrit_max2, &
280-
fp_min, ft_min, fp_error_limit, ft_error_limit, &
281280
D_mix_rotation_max_logT_full_on, D_mix_rotation_min_logT_full_off, &
282281
D_mix_rotation_min_tau_full_off, D_mix_rotation_min_tau_full_on, &
283282
set_uniform_am_nu_non_rot, uniform_am_nu_non_rot, &
@@ -1679,10 +1678,6 @@ subroutine store_controls(s, ierr)
16791678
s% surf_omega_div_omega_crit_tol = surf_omega_div_omega_crit_tol
16801679
s% w_div_wcrit_max = w_div_wcrit_max
16811680
s% w_div_wcrit_max2 = w_div_wcrit_max2
1682-
s% fp_min = fp_min
1683-
s% ft_min = ft_min
1684-
s% fp_error_limit = fp_error_limit
1685-
s% ft_error_limit = ft_error_limit
16861681

16871682
s% D_mix_rotation_max_logT_full_on = D_mix_rotation_max_logT_full_on
16881683
s% D_mix_rotation_min_logT_full_off = D_mix_rotation_min_logT_full_off
@@ -3365,10 +3360,6 @@ subroutine set_controls_for_writing(s, ierr)
33653360
surf_omega_div_omega_crit_tol = s% surf_omega_div_omega_crit_tol
33663361
w_div_wcrit_max = s% w_div_wcrit_max
33673362
w_div_wcrit_max2 = s% w_div_wcrit_max2
3368-
fp_min = s% fp_min
3369-
ft_min = s% ft_min
3370-
fp_error_limit = s% fp_error_limit
3371-
ft_error_limit = s% ft_error_limit
33723363

33733364
D_mix_rotation_max_logT_full_on = s% D_mix_rotation_max_logT_full_on
33743365
D_mix_rotation_min_logT_full_off = s% D_mix_rotation_min_logT_full_off

star/private/hydro_eqns.f90

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,9 @@ subroutine do1_w_div_wc_eqn(s, k, nvar, ierr)
601601
integer, intent(in) :: k, nvar
602602
integer, intent(out) :: ierr
603603
integer :: i_equ_w_div_wc, i_w_div_wc
604-
real(dp) :: wwc
605-
real(dp) :: jr_lim1, jr_lim2, A, C
604+
real(dp) :: wwc, wwc4, wwc6, wwc_log_term, dimless_rphi, dimless_rphi_given_wwc, w1, w2, jr_lim1, jr_lim2
606605
type(auto_diff_real_star_order1) :: &
607-
w_d_wc00, r00, jrot00, resid_ad, A_ad, C_ad, &
606+
w_d_wc00, w4_d_wc00, w6_d_wc00, r00, w_log_term_d_wc00, jrot00, resid_ad, A_ad, C_ad, &
608607
jrot_ratio, sigmoid_jrot_ratio
609608
logical :: test_partials
610609
include 'formats'
@@ -618,34 +617,42 @@ subroutine do1_w_div_wc_eqn(s, k, nvar, ierr)
618617
i_w_div_wc = s% i_w_div_wc
619618

620619
wwc = s% w_div_wcrit_max
621-
A = 1d0-0.1076d0*pow4(wwc)-0.2336d0*pow6(wwc)-0.5583d0*log(1d0-pow4(wwc))
622-
C = 1d0+17d0/60d0*pow2(wwc)-0.3436d0*pow4(wwc)-0.4055d0*pow6(wwc)-0.9277d0*log(1d0-pow4(wwc))
623-
jr_lim1 = two_thirds*wwc*C/A
620+
wwc4 = pow4(wwc)
621+
wwc6 = pow6(wwc)
622+
wwc_log_term = log(1d0 - pow(wwc, log_term_power))
623+
jr_lim1 = two_thirds * wwc * C(pow2(wwc), wwc4, wwc6, wwc_log_term) / A(wwc4, wwc6, wwc_log_term)
624624

625625
wwc = s% w_div_wcrit_max2
626-
A = 1d0-0.1076d0*pow4(wwc)-0.2336d0*pow6(wwc)-0.5583d0*log(1d0-pow4(wwc))
627-
C = 1d0+17d0/60d0*pow2(wwc)-0.3436d0*pow4(wwc)-0.4055d0*pow6(wwc)-0.9277d0*log(1d0-pow4(wwc))
628-
jr_lim2 = two_thirds*wwc*C/A
626+
wwc4 = pow4(wwc)
627+
wwc6 = pow6(wwc)
628+
wwc_log_term = log(1d0 - pow(wwc, log_term_power))
629+
jr_lim2 = two_thirds * wwc * C(pow2(wwc), wwc4, wwc6, wwc_log_term) / A(wwc4, wwc6, wwc_log_term)
629630

630631
w_d_wc00 = wrap_w_div_wc_00(s, k)
631-
A_ad = 1d0-0.1076d0*pow4(w_d_wc00)-0.2336d0*pow6(w_d_wc00)-0.5583d0*log(1d0-pow4(w_d_wc00))
632-
C_ad = 1d0+17d0/60d0*pow2(w_d_wc00)-0.3436d0*pow4(w_d_wc00)-0.4055d0*pow6(w_d_wc00)-0.9277d0*log(1d0-pow4(w_d_wc00))
632+
w4_d_wc00 = pow4(w_d_wc00)
633+
w6_d_wc00 = pow6(w_d_wc00)
634+
w_log_term_d_wc00 = log(1d0 - pow(w_d_wc00, log_term_power))
635+
A_ad = 1d0 + 0.3293d0 * w4_d_wc00 - 0.4926d0 * w6_d_wc00 - 0.5560d0 * w_log_term_d_wc00
636+
C_ad = 1d0 + 17d0 / 60d0 * pow2(w_d_wc00) + 0.4010d0 * w4_d_wc00 - 0.8606d0 * w6_d_wc00 &
637+
- 0.9305d0 * w_log_term_d_wc00
633638

634639
r00 = wrap_r_00(s, k)
635640
if (s% j_rot_flag) then
636641
jrot00 = wrap_jrot_00(s, k)
637-
jrot_ratio = jrot00/sqrt(s% cgrav(k)*s% m(k)*r00)
642+
jrot_ratio = jrot00 / sqrt(s% cgrav(k) * s% m(k) * r00)
638643
else
639-
jrot_ratio = s% j_rot(k)/sqrt(s% cgrav(k)*s% m(k)*r00)
644+
jrot_ratio = s% j_rot(k) / sqrt(s% cgrav(k) * s% m(k) * r00)
640645
end if
641646
if (abs(jrot_ratio% val) > jr_lim1) then
642-
sigmoid_jrot_ratio = 2*(jr_lim2-jr_lim1)/(1+exp(-2*(abs(jrot_ratio)-jr_lim1)/(jr_lim2-jr_lim1)))-jr_lim2+2*jr_lim1
647+
sigmoid_jrot_ratio = 2d0 * (jr_lim2-jr_lim1) &
648+
/ (1d0 + exp(-2d0 * (abs(jrot_ratio) - jr_lim1) / (jr_lim2 - jr_lim1))) &
649+
- jr_lim2 + 2 * jr_lim1
643650
if (jrot_ratio% val < 0d0) then
644651
sigmoid_jrot_ratio = -sigmoid_jrot_ratio
645652
end if
646-
resid_ad = (sigmoid_jrot_ratio - two_thirds*w_d_wc00*C_ad/A_ad)
653+
resid_ad = (sigmoid_jrot_ratio - two_thirds * w_d_wc00 * C_ad / A_ad)
647654
else
648-
resid_ad = (jrot_ratio - two_thirds*w_d_wc00*C_ad/A_ad)
655+
resid_ad = (jrot_ratio - two_thirds * w_d_wc00 * C_ad / A_ad)
649656
end if
650657

651658
s% equ(i_equ_w_div_wc, k) = resid_ad% val

0 commit comments

Comments
 (0)