Skip to content

Commit 77a8cfe

Browse files
committed
revert w_div_w_crit_roche update (#637)
1 parent 4678c04 commit 77a8cfe

File tree

7 files changed

+438
-227
lines changed

7 files changed

+438
-227
lines changed

docs/source/changelog.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ 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-
2624
.. _Bug Fixes main:
2725

2826
Bug Fixes
2927
---------
3028

3129
fixed small bug in star/private/create_initial_model.f90 that will have a small effect on creating initial models
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.`
30+
3331

3432
.. 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```).
3533

star/defaults/controls.defaults

Lines changed: 55 additions & 19 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,21 +4060,57 @@
40604060

40614061
! ::
40624062

4063-
w_div_wcrit_max = 0.89d0
4063+
w_div_wcrit_max = 0.90d0
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 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)
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.
40744099

40754100
! ::
40764101

4077-
w_div_wcrit_max2 = 0.90d0
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
40784114

40794115

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

41084144
! ::
4109-
4145+
41104146
D_mix_rotation_min_tau_full_off = 0d0
4111-
4147+
41124148
! D_mix_rotation_max_tau_full_on
41134149
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41144150

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

41184154
! ::
4119-
4155+
41204156
D_mix_rotation_min_tau_full_on = 0d0
41214157

41224158

@@ -4637,8 +4673,8 @@
46374673
! do_starspots
46384674
! ~~~~~~~~~~~~
46394675

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
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
46424678
! `Somers et al. (2015; ApJ) <https://ui.adsabs.harvard.edu/abs/2015ApJ...807..174S>`__.
46434679
! Detailed discussion of this functionality can be found in |MESA VI|.
46444680

@@ -4659,8 +4695,8 @@
46594695
! xspot
46604696
! ~~~~~
46614697

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

46664702
! ::
@@ -8227,11 +8263,11 @@
82278263

82288264
use_dPrad_dm_form_of_T_gradient_eqn = .false.
82298265
use_gradT_actual_vs_gradT_MLT_for_T_gradient_eqn = .false.
8230-
8231-
8266+
8267+
82328268
! Hydrodynamic drag
82338269
! =================
8234-
8270+
82358271
! drag_coefficient
82368272
! ~~~~~~~~~~~~~~~~
82378273
! min_q_for_drag
@@ -8263,7 +8299,7 @@
82638299
drag_coefficient = 0d0
82648300
min_q_for_drag = 0d0
82658301

8266-
8302+
82678303
! v_drag_factor
82688304
! ~~~~~~~~~~~~~
82698305
! v_drag
@@ -8276,7 +8312,7 @@
82768312

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

star/private/ctrls_io.f90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ 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, &
280281
D_mix_rotation_max_logT_full_on, D_mix_rotation_min_logT_full_off, &
281282
D_mix_rotation_min_tau_full_off, D_mix_rotation_min_tau_full_on, &
282283
set_uniform_am_nu_non_rot, uniform_am_nu_non_rot, &
@@ -1678,6 +1679,10 @@ subroutine store_controls(s, ierr)
16781679
s% surf_omega_div_omega_crit_tol = surf_omega_div_omega_crit_tol
16791680
s% w_div_wcrit_max = w_div_wcrit_max
16801681
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
16811686

16821687
s% D_mix_rotation_max_logT_full_on = D_mix_rotation_max_logT_full_on
16831688
s% D_mix_rotation_min_logT_full_off = D_mix_rotation_min_logT_full_off
@@ -3360,6 +3365,10 @@ subroutine set_controls_for_writing(s, ierr)
33603365
surf_omega_div_omega_crit_tol = s% surf_omega_div_omega_crit_tol
33613366
w_div_wcrit_max = s% w_div_wcrit_max
33623367
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
33633372

33643373
D_mix_rotation_max_logT_full_on = s% D_mix_rotation_max_logT_full_on
33653374
D_mix_rotation_min_logT_full_off = s% D_mix_rotation_min_logT_full_off

star/private/hydro_eqns.f90

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,10 @@ 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, wwc4, wwc6, wwc_log_term, dimless_rphi, dimless_rphi_given_wwc, w1, w2, jr_lim1, jr_lim2
604+
real(dp) :: wwc
605+
real(dp) :: jr_lim1, jr_lim2, A, C
605606
type(auto_diff_real_star_order1) :: &
606-
w_d_wc00, w4_d_wc00, w6_d_wc00, r00, w_log_term_d_wc00, jrot00, resid_ad, A_ad, C_ad, &
607+
w_d_wc00, r00, jrot00, resid_ad, A_ad, C_ad, &
607608
jrot_ratio, sigmoid_jrot_ratio
608609
logical :: test_partials
609610
include 'formats'
@@ -617,42 +618,34 @@ subroutine do1_w_div_wc_eqn(s, k, nvar, ierr)
617618
i_w_div_wc = s% i_w_div_wc
618619

619620
wwc = s% w_div_wcrit_max
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)
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
624624

625625
wwc = s% w_div_wcrit_max2
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)
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
630629

631630
w_d_wc00 = wrap_w_div_wc_00(s, k)
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
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))
638633

639634
r00 = wrap_r_00(s, k)
640635
if (s% j_rot_flag) then
641636
jrot00 = wrap_jrot_00(s, k)
642-
jrot_ratio = jrot00 / sqrt(s% cgrav(k) * s% m(k) * r00)
637+
jrot_ratio = jrot00/sqrt(s% cgrav(k)*s% m(k)*r00)
643638
else
644-
jrot_ratio = s% j_rot(k) / sqrt(s% cgrav(k) * s% m(k) * r00)
639+
jrot_ratio = s% j_rot(k)/sqrt(s% cgrav(k)*s% m(k)*r00)
645640
end if
646641
if (abs(jrot_ratio% val) > jr_lim1) then
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
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
650643
if (jrot_ratio% val < 0d0) then
651644
sigmoid_jrot_ratio = -sigmoid_jrot_ratio
652645
end if
653-
resid_ad = (sigmoid_jrot_ratio - two_thirds * w_d_wc00 * C_ad / A_ad)
646+
resid_ad = (sigmoid_jrot_ratio - two_thirds*w_d_wc00*C_ad/A_ad)
654647
else
655-
resid_ad = (jrot_ratio - two_thirds * w_d_wc00 * C_ad / A_ad)
648+
resid_ad = (jrot_ratio - two_thirds*w_d_wc00*C_ad/A_ad)
656649
end if
657650

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

0 commit comments

Comments
 (0)