Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
1daceee
[ci optional] Enabled Uq in TDC.
adamjermyn Mar 18, 2022
2aca86c
[ci optional] Enabled Uq in TDC.
adamjermyn Mar 18, 2022
3570a54
Merge branch 'tdc_uq' of github.com:MESAHub/mesa into tdc_uq
pmocz Oct 1, 2024
72cea14
compute_Chi_cell
pmocz Oct 1, 2024
91e5acd
update riemann
pmocz Oct 1, 2024
714ac8a
switch on energy viscous heating term
pmocz Oct 1, 2024
b2f51a8
add tdc coupling
pmocz Oct 1, 2024
29ff289
merge main into branch
Debraheem Feb 15, 2025
b1108cc
add eddy viscosity routine, clean up and reorganize.
Debraheem Feb 15, 2025
e200275
[ci skip] cleanup set_flags.f90
Debraheem Feb 15, 2025
d711db8
missing items from previous commit
Debraheem Feb 15, 2025
ee1d0d0
ad v_flag check and clean up
Debraheem Feb 15, 2025
d12dc92
Update star/private/hydro_rsp2.f90
Debraheem Feb 18, 2025
0a1fcc1
[ci skip]Update star/private/hydro_rsp2.f90
Debraheem Feb 18, 2025
0f987aa
[ci skip]Update star/private/hydro_rsp2.f90
Debraheem Feb 18, 2025
4e99e71
add dev test cases for radial pulsations
Debraheem Mar 17, 2025
86c0c55
[ci skip] updates to 20M RSG
Debraheem Apr 9, 2025
7034e0e
add tridiagonal density form of Uq and Eq for u_flag, update tests
Debraheem May 3, 2025
e3d5612
fixes, changes, new test cases
Debraheem Jun 11, 2025
93ae8ef
[ci skip] add some missing files
Debraheem Jun 11, 2025
cd8fe3f
[ci skip] tweaks
Debraheem Jun 11, 2025
932a098
more changes and clean up
Debraheem Jun 13, 2025
5d19031
[ci skip] fixes to evol
Debraheem Jun 14, 2025
49acc84
fix tdc pturb, add pturb to thermoy and mlt, add new test cases, add …
Debraheem Jun 26, 2025
921fad8
update turb test_output
Debraheem Jun 26, 2025
4857802
move tdc pulsations cases into new dev directory
Debraheem Jun 29, 2025
a47ae96
tweak cepheid comparison
Debraheem Jun 30, 2025
9eb0d57
Merge branch 'main' into tdc_uq
Debraheem Jun 30, 2025
e0ef22e
make rho_face wrapper public
Debraheem Jun 30, 2025
bef5a6a
more cleanup to cepheid testing
Debraheem Jun 30, 2025
b4ff301
remove mlt correction to tdc and clean up
Debraheem Jul 1, 2025
52b06c1
fix mlt_pturb profile bug, and other tweaks, introduce alpha_cygni test
Debraheem Jul 2, 2025
7614480
add tdc into total energy equ, new time centering controls, add mlt t…
Debraheem Jul 7, 2025
f9df692
[ci skip] update turb codeowners
Debraheem Jul 7, 2025
76a1ae7
remove L time centering from Lsurf BC
Debraheem Jul 7, 2025
23dbfde
[ci skip] inlist tweaks
Debraheem Jul 9, 2025
717c89e
add new rr_lyrae test case ,minor tweak to FL
Debraheem Jul 10, 2025
43df2f0
[ci skip] remove rr_lyrae movie
Debraheem Jul 10, 2025
343c31f
[ci skip] tweak
Debraheem Aug 7, 2025
1078da1
move Eq to face
Debraheem Aug 7, 2025
f63adb6
tweak surface cell
Debraheem Aug 7, 2025
bb7e47c
return to cell center Eq
Debraheem Aug 8, 2025
84e16bf
add rsp_cepheid mod
Debraheem Aug 11, 2025
9328619
[ci skip] fortitude check --fix
pmocz Aug 11, 2025
ac06a7d
move things out of rsp2 into its own tdc_pulse module
pmocz Aug 11, 2025
625f57a
fortitude check fixes
pmocz Aug 11, 2025
2ca27f2
adding alpha_TDC_c and alpha_TDC_s dev controls
pmocz Aug 11, 2025
bafeacc
[ci skip] typos
pmocz Aug 11, 2025
810de64
[ci skip] OMG TABS!!!
pmocz Aug 11, 2025
bbd30de
[ci skip] add some TCD_pulse remesh dev controls
pmocz Aug 11, 2025
fbd7e7e
update Eq_face and Hp_face calculations, no more staggered updates
Debraheem Aug 11, 2025
37bcdb0
[ci skip] fortitude check --fix
pmocz Aug 11, 2025
76dcd86
fix missing ptrb, add rotation to geff, clean tdc_pulse and support
Debraheem Aug 12, 2025
7b15b2a
add tdc eturb energy into energy conservation calculations ,fix missi…
Debraheem Aug 12, 2025
50a2b75
clean up
Debraheem Aug 12, 2025
4309501
fix energy accounting for eturb, still missing vc_old
Debraheem Aug 12, 2025
edc62a0
tweaks
Debraheem Aug 12, 2025
c3fcddc
[ci skip] fix enthalpy limter typo
pmocz Aug 12, 2025
eec9eaa
update renamed controls in star_data
Debraheem Aug 12, 2025
6bb59e4
fix ctrls typo
Debraheem Aug 12, 2025
7bd57a0
[ci skip] keep old Eq_cell commented, for now
Debraheem Aug 13, 2025
c4a84f2
changes to flux limiter
Debraheem Aug 15, 2025
7ea6306
fix conv_vel limiter for Y_face correction
Debraheem Sep 1, 2025
09f2721
[ci skip] rename some things and clean up
Debraheem Sep 2, 2025
c9154f1
implement working hydrodynamic mlt scale height
Debraheem Sep 2, 2025
420d36b
tweaks to mlt hydro scale height
Debraheem Sep 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion star/defaults/controls_dev.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@


! split burn
! ================
! ==========


! op_split_burn_min_T_for_variable_T_solver
Expand All @@ -174,3 +174,24 @@
! ::

op_split_burn_min_T_for_variable_T_solver = 1d99


! TDC
! ===


! alpha_TDC_DampM
! ~~~~~~~~~~~~~~~

! If alpha_TDC_DampM >0, then include eddy viscous damping in TDC alpha_TDC_DampM
! This control is analogous to `RSP_alfam`, where the default is `RSP_alfam` = 0.25d0.

! This control is only supported when v_flag = .true.
! If hydrostatic (v_flag = .false. , v = 0 ) there are no velocity gradients,
! and thus no shear to drive turbulence. Without shear, the eddy viscosity term becomes zero.

! ::

alpha_TDC_DampM = 0.25d0


4 changes: 3 additions & 1 deletion star/private/ctrls_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module ctrls_io
mixing_D_limit_for_log, trace_mass_location, min_tau_for_max_abs_v_location, &
min_q_for_inner_mach1_location, max_q_for_outer_mach1_location, &
conv_core_gap_dq_limit, &
alpha_TDC_DAMP, alpha_TDC_DAMPR, alpha_TDC_PtdVdt, &
alpha_TDC_DAMP, alpha_TDC_DAMPR, alpha_TDC_PtdVdt, alpha_TDC_DAMPM, &

! burn zone eps definitions for use in logs and profiles
burn_min1, burn_min2, &
Expand Down Expand Up @@ -2059,6 +2059,7 @@ subroutine store_controls(s, ierr)
s% alpha_TDC_DAMP = alpha_TDC_DAMP
s% alpha_TDC_DAMPR = alpha_TDC_DAMPR
s% alpha_TDC_PtdVdt = alpha_TDC_PtdVdt
s% alpha_TDC_DAMPM = alpha_TDC_DAMPM
s% compare_TDC_to_MLT = compare_TDC_to_MLT

s% RSP2_alfap = RSP2_alfap
Expand Down Expand Up @@ -3738,6 +3739,7 @@ subroutine set_controls_for_writing(s, ierr)
alpha_TDC_DAMP = s% alpha_TDC_DAMP
alpha_TDC_DAMPR = s% alpha_TDC_DAMPR
alpha_TDC_PtdVdt = s% alpha_TDC_PtdVdt
alpha_TDC_DAMPM = s% alpha_TDC_DAMPM
compare_TDC_to_MLT = s% compare_TDC_to_MLT

RSP2_alfap= s% RSP2_alfap
Expand Down
17 changes: 15 additions & 2 deletions star/private/hydro_energy.f90
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,10 @@ subroutine setup_dL_dm(ierr)
dL_dm_ad = (L00_ad - Lp1_ad)/dm
end subroutine setup_dL_dm

subroutine setup_sources_and_others(ierr) ! sources_ad, others_ad
!use hydro_rsp2, only: compute_Eq_cell

subroutine setup_sources_and_others(ierr) ! sources_ad, others_ad
use hydro_rsp2, only: compute_Eq_cell

integer, intent(out) :: ierr
type(auto_diff_real_star_order1) :: &
eps_nuc_ad, non_nuc_neu_ad, extra_heat_ad, Eq_ad, RTI_diffusion_ad, &
Expand Down Expand Up @@ -271,6 +273,17 @@ subroutine setup_sources_and_others(ierr) ! sources_ad, others_ad
if (ierr /= 0) return
end if

! we do not need this term for tdc, because Eq is included
! in the turbulent energy equation solved inside TDC. It's effects
! are seen in hydro_momentum
! if (s% alpha_TDC_DampM >0d0 .and. s% MLT_option == 'TDC') then
! Eq_ad = s% Eq_ad(k) !compute_Eq_cell(s, k, ierr)
!! if (k==91) then
!! write(*,*) 'test Eq, k', Eq_ad %val , k
!! end if
! if (ierr /= 0) return
! end if

call setup_RTI_diffusion(RTI_diffusion_ad)

drag_energy = 0d0
Expand Down
19 changes: 13 additions & 6 deletions star/private/hydro_momentum.f90
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ subroutine expected_non_HSE_term( &
extra_ad = s% extra_grav(k)
end if

Uq_ad = 0d0
accel_ad = 0d0
drag = 0d0
s% dvdt_drag(k) = 0d0
Expand Down Expand Up @@ -432,14 +433,20 @@ subroutine expected_non_HSE_term( &
s% dvdt_drag(k) = drag%val
end if

end if ! v_flag
if (s% RSP2_flag) then ! Uq(k) is turbulent viscosity drag at face k
Uq_ad = compute_Uq_face(s, k, ierr)
if (ierr /= 0) return
end if

Uq_ad = 0d0
if (s% RSP2_flag) then ! Uq(k) is turbulent viscosity drag at face k
Uq_ad = compute_Uq_face(s, k, ierr)
if (ierr /= 0) return
end if
! need to add check for v_flag.
if (s% alpha_TDC_DampM > 0 .and. s% MLT_option == 'TDC') then ! Uq(k) is turbulent viscosity drag at face k
Uq_ad = compute_Uq_face(s, k, ierr)
!write (*,*) Uq_ad %val, 'Uq_ad %val'
if (ierr /= 0) return
end if

end if ! v_flag

other_ad = extra_ad - accel_ad + drag + Uq_ad
other = other_ad%val

Expand Down
11 changes: 11 additions & 0 deletions star/private/hydro_riemann.f90
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,23 @@ subroutine do1_uface_and_Pface(s, k, ierr)
end if
end if


if (s% RSP2_flag) then ! include Uq in u_face
Uq_ad = compute_Uq_face(s, k, ierr)
if (ierr /= 0) return
s% u_face_ad(k) = s% u_face_ad(k) + Uq_ad
end if

if (s% alpha_TDC_DampM >0d0 .and. s% MLT_option == 'TDC') then ! include Uq in u_face
call mesa_error(__FILE__,__LINE__,'Uq is not currently supported by u_flag')
! Uq_ad = compute_Uq_face(s, k, ierr)
! if (k==63) then
! write(*,*) 'test Uq, k', Uq_ad %val, k
! end if
! if (ierr /= 0) return
! s% u_face_ad(k) = s% u_face_ad(k) + Uq_ad
end if

s% u_face_val(k) = s% u_face_ad(k)%val

if (s% P_face_start(k) < 0d0) then
Expand Down
112 changes: 104 additions & 8 deletions star/private/hydro_rsp2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ module hydro_rsp2
do1_rsp2_L_eqn, do1_turbulent_energy_eqn, do1_rsp2_Hp_eqn, &
compute_Eq_cell, compute_Uq_face, set_RSP2_vars, &
Hp_face_for_rsp2_val, Hp_face_for_rsp2_eqn, set_etrb_start_vars, &
RSP2_adjust_vars_before_call_solver, get_RSP2_alfa_beta_face_weights
RSP2_adjust_vars_before_call_solver, get_RSP2_alfa_beta_face_weights, &
set_viscosity_vars_TDC

real(dp), parameter :: &
x_ALFAP = 2.d0/3.d0, & ! Ptrb
Expand Down Expand Up @@ -113,6 +114,53 @@ subroutine set_RSP2_vars(s,ierr)
end subroutine set_RSP2_vars


! This routine is called to initialize eq and uq for TDC.
subroutine set_viscosity_vars_TDC(s,ierr)
type (star_info), pointer :: s
integer, intent(out) :: ierr
type(auto_diff_real_star_order1) :: x
integer :: k, op_err
include 'formats'
ierr = 0
op_err = 0

!$OMP PARALLEL DO PRIVATE(k,op_err) SCHEDULE(dynamic,2)
do k=1,s%nz
! Hp_face(k) <= 0 means it needs to be set. e.g., after read file
if (s% Hp_face(k) <= 0) then
! this scale height for face is already calculated in TDC
s% Hp_face(k) = s% scale_height(k) !get_scale_height_face_val(s,k)
end if
end do
!$OMP END PARALLEL DO
if (ierr /= 0) then
if (s% report_ierr) write(*,2) 'failed in set_viscosity_vars_TDC loop 1', s% model_number
return
end if
!$OMP PARALLEL DO PRIVATE(k,op_err) SCHEDULE(dynamic,2)
do k=1,s% nz
x = compute_Chi_cell(s, k, op_err)
if (op_err /= 0) ierr = op_err
x = compute_Eq_cell(s, k, op_err)
if (op_err /= 0) ierr = op_err
x = compute_Uq_face(s, k, op_err)
if (op_err /= 0) ierr = op_err
end do
!$OMP END PARALLEL DO
if (ierr /= 0) then
if (s% report_ierr) write(*,2) 'failed in set_viscosity_vars_TDC loop 2', s% model_number
return
end if
if (.not. s% v_flag) then ! set values 0 if not using v_flag.
do k = 1, s% nz
s% Eq(k) = 0d0; s% Eq_ad(k) = 0d0
s% Chi(k) = 0d0; s% Chi_ad(k) = 0d0
s% Uq(k) = 0d0
end do
end if
end subroutine set_viscosity_vars_TDC


subroutine do1_rsp2_L_eqn(s, k, nvar, ierr)
use star_utils, only: save_eqn_residual_info
type (star_info), pointer :: s
Expand Down Expand Up @@ -585,15 +633,25 @@ function compute_d_v_div_r(s, k, ierr) result(d_v_div_r) ! s^-1
integer, intent(in) :: k
type(auto_diff_real_star_order1) :: d_v_div_r
integer, intent(out) :: ierr
type(auto_diff_real_star_order1) :: v_00, v_p1, r_00, r_p1
type(auto_diff_real_star_order1) :: v_00, v_p1, r_00, r_p1, term1, term2
logical :: dbg
include 'formats'
ierr = 0
dbg = .false.
v_00 = wrap_v_00(s,k)
v_p1 = wrap_v_p1(s,k)
r_00 = wrap_r_00(s,k)
r_p1 = wrap_r_p1(s,k)
if (r_p1%val == 0d0) r_p1 = 1d0
d_v_div_r = v_00/r_00 - v_p1/r_p1 ! units s^-1
d_v_div_r = v_00/r_00 - v_p1/r_p1 ! units s^-1

! Debugging output to trace values
if (dbg .and. k == -63) then
write(*,*) 'test d_v_div_r, k:', k
write(*,*) 'v_00:', v_00%val, 'v_p1:', v_p1%val
write(*,*) 'r_00:', r_00%val, 'r_p1:', r_p1%val
write(*,*) 'd_v_div_r:', d_v_div_r %val
end if
end function compute_d_v_div_r


Expand Down Expand Up @@ -662,9 +720,21 @@ function compute_Chi_cell(s, k, ierr) result(Chi_cell)
type(auto_diff_real_star_order1) :: &
rho2, r6_cell, d_v_div_r, Hp_cell, w_00, d_00, r_00, r_p1
real(dp) :: f, ALFAM_ALFA
logical :: dbg
include 'formats'
ierr = 0
ALFAM_ALFA = s% RSP2_alfam*s% mixing_length_alpha
dbg = .false.

! check where we are getting alfam from.
if (s% MLT_option == 'TDC' .and. .not. s% RSP2_flag) then
ALFAM_ALFA = s% alpha_TDC_DampM * s% mixing_length_alpha
else if (s% RSP2_flag) then
ALFAM_ALFA = s% RSP2_alfam * s% mixing_length_alpha
else ! this is for safety, but probably is never called.
ALFAM_ALFA = 0d0
end if


if (ALFAM_ALFA == 0d0 .or. &
k <= s% RSP2_num_outermost_cells_forced_nonturbulent .or. &
k > s% nz - int(s% nz/s% RSP2_nz_div_IBOTOM)) then
Expand All @@ -678,7 +748,17 @@ function compute_Chi_cell(s, k, ierr) result(Chi_cell)
if (ierr /= 0) return
d_v_div_r = compute_d_v_div_r(s, k, ierr)
if (ierr /= 0) return
w_00 = wrap_w_00(s,k)

! don't need to check if mlt_vc > 0 here.
if (s% MLT_option == 'TDC' .and. .not. s% RSP2_flag) then
if (s% have_mlt_vc .and. s% okay_to_set_mlt_vc) then
w_00 = s% mlt_vc_old(k)/sqrt_2_div_3! same as info%A0 from TDC
else
w_00 = s% mlt_vc(k)/sqrt_2_div_3! same as info%A0 from TDC
end if
else ! normal RSP2
w_00 = wrap_w_00(s,k)
end if
d_00 = wrap_d_00(s,k)
f = (16d0/3d0)*pi*ALFAM_ALFA/s% dm(k)
rho2 = pow2(d_00)
Expand All @@ -693,6 +773,18 @@ function compute_Chi_cell(s, k, ierr) result(Chi_cell)
s% Chi(k) = Chi_cell%val
s% Chi_ad(k) = Chi_cell

if (dbg .and. k==-100) then
write(*,*) ' s% ALFAM_ALFA', ALFAM_ALFA
write(*,*) 'Hp_cell', Hp_cell %val
write(*,*) 'd_v_div_r', d_v_div_r %val
write(*,*) ' f', f
write(*,*) 'w_00',w_00 %val
write(*,*) 'd_00 ', d_00 %val
write(*,*) 'rho2 ', rho2 %val
write(*,*) 'r_00', r_00 %val
write(*,*) 'r_p1 ', r_p1 %val
write(*,*) 'r6_cell', r6_cell %val
end if
end function compute_Chi_cell


Expand Down Expand Up @@ -735,10 +827,14 @@ function compute_Uq_face(s, k, ierr) result(Uq_face) ! cm s^-2, acceleration
Uq_face = 0d0
else
r_00 = wrap_opt_time_center_r_00(s,k)
Chi_00 = s% Chi_ad(k) ! compute_Chi_cell(s,k,ierr)

! which do we adopt?
Chi_00 = compute_Chi_cell(s,k,ierr) ! s% Chi_ad(k) XXX
!Chi_00 = s% Chi_ad(k) ! compute_Chi_cell(s,k,ierr)

if (k > 1) then
!Chi_m1 = shift_m1(compute_Chi_cell(s,k-1,ierr))
Chi_m1 = shift_m1(s% Chi_ad(k-1))
Chi_m1 = shift_m1(compute_Chi_cell(s,k-1,ierr))
!Chi_m1 = shift_m1(s% Chi_ad(k-1)) XXX
if (ierr /= 0) return
else
Chi_m1 = 0d0
Expand Down
12 changes: 11 additions & 1 deletion star/private/hydro_vars.f90
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ subroutine set_hydro_vars( &
use hydro_rotation, only: set_rotation_info, compute_j_fluxes_and_extra_jdot
use brunt, only: do_brunt_B, do_brunt_N2
use mix_info, only: set_mixing_info
use hydro_rsp2, only: set_RSP2_vars
use hydro_rsp2, only: set_RSP2_vars, set_viscosity_vars_TDC

type (star_info), pointer :: s
integer, intent(in) :: nzlo, nzhi
Expand Down Expand Up @@ -596,6 +596,15 @@ subroutine set_hydro_vars( &
else
s% gradr_factor(nzlo:nzhi) = 1d0
end if

if (s% alpha_TDC_DampM > 0) then
call set_viscosity_vars_TDC(s,ierr)
if (ierr /= 0) then
if (len_trim(s% retry_message) == 0) s% retry_message = 'set_viscosity_vars_TDC failed'
if (s% report_ierr) write(*,*) 'ierr from set_viscosity_vars_TDC'
return
end if
end if

call set_mlt_vars(s, nzlo, nzhi, ierr)
if (failed('set_mlt_vars')) return
Expand Down Expand Up @@ -634,6 +643,7 @@ subroutine set_hydro_vars( &
end if
end if


if (s% doing_timing) &
call update_time(s, time0, total, s% time_set_hydro_vars)

Expand Down
4 changes: 2 additions & 2 deletions star/private/profile_getval.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1886,9 +1886,9 @@ subroutine getval_for_profile(s, c, k, val, int_flag, int_val)
case(p_Chi)
if (rsp_or_w) val = s% Chi(k)
case(p_Eq)
if (rsp_or_w) val = s% Eq(k)
val = s% Eq(k)
case(p_Uq)
if (rsp_or_w) val = s% Uq(k)
val = s% Uq(k)
case(p_Lr)
val = get_Lrad(s,k)
case(p_Lr_div_L)
Expand Down
3 changes: 2 additions & 1 deletion star/private/read_model.f90
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ subroutine finish_load_model(s, restart, ierr)
total_angular_momentum, reset_epsnuc_vectors, set_qs
use hydro_rotation, only: use_xh_to_update_i_rot_and_j_rot, &
set_i_rot_from_omega_and_j_rot, use_xh_to_update_i_rot, set_rotation_info
use hydro_RSP2, only: set_RSP2_vars
use hydro_RSP2, only: set_RSP2_vars, set_viscosity_vars_TDC
use RSP, only: RSP_setup_part1, RSP_setup_part2
use report, only: do_report
use alloc, only: fill_ad_with_zeros
Expand Down Expand Up @@ -165,6 +165,7 @@ subroutine finish_load_model(s, restart, ierr)
s% doing_finish_load_model = .true.
call set_vars(s, s% dt, ierr)
if (ierr == 0 .and. s% RSP2_flag) call set_RSP2_vars(s,ierr)
if (ierr == 0 .and. s% alpha_TDC_DampM > 0) call set_viscosity_vars_TDC(s,ierr)
s% doing_finish_load_model = .false.
if (ierr /= 0) then
write(*,*) 'finish_load_model: failed in set_vars'
Expand Down
1 change: 1 addition & 0 deletions star/private/set_flags.f90
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ subroutine set_u_flag(id, u_flag, ierr)
call set_v_flag(id, .false., ierr)
end if


contains

subroutine del(xs)
Expand Down
Loading
Loading