Skip to content

Commit 214cab2

Browse files
author
Matthias Fabry
committed
reimplement logT switch + subtle fixes to dX checking
1 parent f130bd9 commit 214cab2

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

star/defaults/controls.defaults

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9534,9 +9534,9 @@
95349534

95359535
dX_decreases_only(:) = .true.
95369536

9537-
! Limit on magnitude of relative decrease in any cell nonH, nonHe abundance.
9537+
! Limit on magnitude of relative decrease in any cell abundance.
95389538
! ``dX_div_X`` here is abs(xa(j,k) - xa_old(j,k))/xa(j,k)
9539-
! for any cell k and any species j other except hydrogen or helium.
9539+
! for any cell k and any species j.
95409540
! Considers all cells except where have convective mixing.
95419541

95429542

star/private/timestep.f90

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -495,34 +495,38 @@ integer function check_dX(s, skip_hard_limit, dt, &
495495
bdy_dist_dm, max_dX_bdy_dist_dm, max_dX_div_X_bdy_dist_dm, cz_dist_limit
496496
integer :: i, j, k, cid, bdy, max_dX_j, max_dX_k, max_dX_div_X_j, max_dX_div_X_k
497497
real(dp) :: D_mix_cutoff
498-
real(dp), dimension(max_dX_limit_ctrls) :: dX_limit_min_X, dX_limit, dX_hard_limit, &
499-
dX_div_X_limit_min_X, dX_div_X_limit, dX_div_X_hard_limit, &
500-
dX_div_X_at_high_T_limit, dX_div_X_at_high_T_hard_limit, &
501-
dX_div_X_at_high_T_limit_lgT_min
498+
real(dp), dimension(max_dX_limit_ctrls) :: dX_limit, dX_hard_limit, &
499+
dX_div_X_limit, dX_div_X_hard_limit
502500
character (len=strlen) :: sp
503501

504502
include 'formats'
505503

506504
check_dX = keep_going
507505

508506
if (s% mix_factor == 0d0 .and. s% dxdt_nuc_factor == 0d0) return
509-
510-
dX_limit = s% dX_limit*s% time_delta_coeff
511-
dX_hard_limit = s% dX_hard_limit*s% time_delta_coeff
512-
513-
dX_div_X_limit = s% dX_div_X_limit*s% time_delta_coeff
514-
dX_div_X_hard_limit = s% dX_div_X_hard_limit*s% time_delta_coeff
515507

516508
do i=1, max_dx_limit_ctrls ! go over all potential species + XYZ
517-
if ( dX_limit_min_X(i) >= 1 .and. & ! as soon as all of these are >= 1
518-
dX_limit(i) >= 1 .and. & ! we'd have nothing to do
519-
dX_hard_limit(i) >= 1 .and. &
520-
dX_div_X_limit_min_X(i) >= 1 .and. &
521-
dX_div_X_limit(i) >= 1 .and. &
522-
dX_div_X_hard_limit(i) >= 1) then
509+
if (s% dX_limit(i) >= 1 .and. & ! as soon as all of these are >= 1
510+
s% dX_hard_limit(i) >= 1 .and. & ! we'd have nothing to do
511+
s% dX_div_X_limit(i) >= 1 .and. &
512+
s% dX_div_X_hard_limit(i) >= 1) then
523513
cycle ! go to next
524514
end if
525-
515+
516+
dX_limit = s% dX_limit(i) * s% time_delta_coeff
517+
dX_hard_limit = s% dX_hard_limit(i) * s% time_delta_coeff
518+
519+
if (s% log_max_temperature > s% dX_div_X_at_high_T_limit_lgT_min(i)) then
520+
dX_div_X_limit = s% dX_div_X_at_high_T_limit(i)
521+
dX_div_X_hard_limit = s% dX_div_X_at_high_T_hard_limit(i)
522+
else
523+
dX_div_X_limit = s% dX_div_X_limit(i)
524+
dX_div_X_hard_limit = s% dX_div_X_hard_limit(i)
525+
end if
526+
527+
dX_div_X_limit = dX_div_X_limit * s% time_delta_coeff
528+
dX_div_X_hard_limit = dX_div_X_hard_limit * s% time_delta_coeff
529+
526530
max_dX = -1; max_dX_j = -1; max_dX_k = -1
527531
max_dX_div_X = -1; max_dX_div_X_j = -1; max_dX_div_X_k = -1
528532
bdy = 0
@@ -578,7 +582,7 @@ integer function check_dX(s, skip_hard_limit, dt, &
578582

579583
if ((.not. s% dX_decreases_only(j)) .and. delta_X < 0) delta_X = -delta_X
580584

581-
if (X >= dX_limit_min_X(i)) then ! any check for dX_limit_* < 1 is useless since X <= 1 anyway
585+
if (X >= s% dX_limit_min_X(i)) then ! any check for dX_limit_* < 1 is useless since X <= 1 anyway
582586
if ((.not. skip_hard_limit) .and. delta_X > dX_hard_limit(i)) then
583587
check_dX = retry
584588
s% why_Tlim = Tlim_dX
@@ -601,7 +605,7 @@ integer function check_dX(s, skip_hard_limit, dt, &
601605
max_dX_bdy_dist_dm = bdy_dist_dm
602606
end if
603607
end if
604-
if (X >= dX_div_X_limit_min_X(i)) then
608+
if (X >= s% dX_div_X_limit_min_X(i)) then
605609
delta_X_div_X = delta_X/X
606610
if ((.not. skip_hard_limit) .and. delta_X_div_X > dX_div_X_hard_limit(i)) then
607611
check_dX = retry
@@ -656,8 +660,8 @@ integer function check_dX(s, skip_hard_limit, dt, &
656660
else
657661
s% Tlim_dX_div_X_species = max_dX_div_X_j
658662
s% Tlim_dX_div_X_cell = max_dX_div_X_k
659-
write(*, '(a30, i5, 99e20.10)') &
660-
'limit dt because of large dX_div_X ' // &
663+
write(*, '(a35, i5, 99e20.10)') &
664+
' limit dt because of large dX_div_X ' // &
661665
trim(chem_isos% name(s% chem_id(max_dX_div_X_j))) // &
662666
' k, max, lim, m ', &
663667
max_dX_div_X_k, max_dX_div_X, dX_div_X_limit(i), &

0 commit comments

Comments
 (0)