Skip to content

Commit 1d059d5

Browse files
rjfarmerDebraheemevbauer
authored
Reintroduce velocity drag (#541)
Reincorporated velocity drag into energy and momentum equations, and added controls to toggle Added a new test suite make_pre_ccsn_13BVN for testing velocity drag, for v_flag (#535) --------- Co-authored-by: Rob Farmer <[email protected]> Co-authored-by: EbF <[email protected]> Co-authored-by: Evan Bauer <[email protected]> Co-authored-by: Ebraheem Farag <[email protected]>
1 parent 0acf73d commit 1d059d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4462
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../star/test_suite/make_pre_ccsn_13bvn/README.rst

star/defaults/controls.defaults

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8136,10 +8136,29 @@
81368136
! ::
81378137

81388138
use_dPrad_dm_form_of_T_gradient_eqn = .false.
8139-
use_gradT_actual_vs_gradT_MLT_for_T_gradient_eqn = .false.
8140-
8139+
use_gradT_actual_vs_gradT_MLT_for_T_gradient_eqn = .false.
81418140

81428141

8142+
! drag_coefficient
8143+
! ~~~~~~~~~~~~~~~~
8144+
! min_q_for_drag
8145+
! ~~~~~~~~~~~~~~
8146+
8147+
! only when v_flag. adjusts both v and energy transfer from kinetic to thermal.
8148+
! only for v(k) when q(k) > min_q_for_drag.
8149+
! kill off fraction of v = drag_coefficient (i.e. set to 1 to keep v near 0)
8150+
! useful for preventing the development radial pulsations during advanced
8151+
! burning in massive stars and AGB stars.
8152+
8153+
! Under certain circumstances we will not have drag in the surface k=1 zone
8154+
! To force the drag term to be on in the outer zone you must enable one of the
8155+
! following surface boundary conditions:
8156+
! ``use_momentum_outer_BC``, ``use_zero_Pgas_outer_BC``, or ``use_fixed_Psurf_outer_BC``
8157+
8158+
! ::
8159+
8160+
drag_coefficient = 0d0
8161+
min_q_for_drag = 0d0
81438162

81448163

81458164
! for hydro comparison tests (e.g., Sedov)

star/private/alloc.f90

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,12 @@ subroutine star_info_arrays(s, c_in, action_in, ierr)
985985
action == do_copy_pointers_and_resize) &
986986
s% alpha_mlt(1:nz) = s% mixing_length_alpha
987987

988+
call do1(s% dvdt_drag, c% dvdt_drag)
989+
if (failed('dvdt_drag')) exit
990+
991+
call do1(s% FdotV_drag_energy, c% FdotV_drag_energy)
992+
if (failed('FdotV_drag_energy')) exit
993+
988994
call do1(s% vc, c% vc)
989995
if (failed('vc')) exit
990996

star/private/ctrls_io.f90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ module ctrls_io
350350
P_theta_for_velocity_time_centering, L_theta_for_velocity_time_centering, &
351351
steps_before_use_TDC, use_P_d_1_div_rho_form_of_work_when_time_centering_velocity, compare_TDC_to_MLT, &
352352
velocity_logT_lower_bound, max_dt_yrs_for_velocity_logT_lower_bound, velocity_q_upper_bound, &
353+
drag_coefficient, min_q_for_drag, &
353354
retry_for_v_above_clight, &
354355

355356
! hydro solver
@@ -1856,6 +1857,9 @@ subroutine store_controls(s, ierr)
18561857
s% RTI_m_full_boost = RTI_m_full_boost
18571858
s% RTI_m_no_boost = RTI_m_no_boost
18581859

1860+
s% drag_coefficient = drag_coefficient
1861+
s% min_q_for_drag = min_q_for_drag
1862+
18591863
s% velocity_logT_lower_bound = velocity_logT_lower_bound
18601864
s% max_dt_yrs_for_velocity_logT_lower_bound = max_dt_yrs_for_velocity_logT_lower_bound
18611865
s% velocity_q_upper_bound = velocity_q_upper_bound
@@ -3520,6 +3524,10 @@ subroutine set_controls_for_writing(s, ierr)
35203524
RTI_m_full_boost = s% RTI_m_full_boost
35213525
RTI_m_no_boost = s% RTI_m_no_boost
35223526

3527+
3528+
drag_coefficient = s% drag_coefficient
3529+
min_q_for_drag = s% min_q_for_drag
3530+
35233531
velocity_logT_lower_bound = s% velocity_logT_lower_bound
35243532
max_dt_yrs_for_velocity_logT_lower_bound = s% max_dt_yrs_for_velocity_logT_lower_bound
35253533
velocity_q_upper_bound = s% velocity_q_upper_bound

star/private/hydro_energy.f90

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ subroutine setup_sources_and_others(ierr) ! sources_ad, others_ad
224224
!use hydro_rsp2, only: compute_Eq_cell
225225
integer, intent(out) :: ierr
226226
type(auto_diff_real_star_order1) :: &
227-
eps_nuc_ad, non_nuc_neu_ad, extra_heat_ad, Eq_ad, RTI_diffusion_ad
227+
eps_nuc_ad, non_nuc_neu_ad, extra_heat_ad, Eq_ad, RTI_diffusion_ad, &
228+
v_00, v_p1, drag_force, drag_energy
228229
include 'formats'
229230
ierr = 0
230231

@@ -272,7 +273,26 @@ subroutine setup_sources_and_others(ierr) ! sources_ad, others_ad
272273

273274
call setup_RTI_diffusion(RTI_diffusion_ad)
274275

275-
sources_ad = eps_nuc_ad - non_nuc_neu_ad + extra_heat_ad + Eq_ad + RTI_diffusion_ad
276+
drag_energy = 0d0
277+
s% FdotV_drag_energy(k) = 0
278+
if (k .ne. s% nz) then
279+
if (s% q(k) > s% min_q_for_drag .and. s% drag_coefficient > 0) then
280+
v_00 = wrap_v_00(s,k)
281+
drag_force = s% drag_coefficient*v_00/s% dt
282+
drag_energy = 0.5d0*v_00*drag_force
283+
s% FdotV_drag_energy(k) = drag_energy%val
284+
! drag energy for outer half-cell. the 0.5d0 is for dm/2
285+
end if
286+
if (s% q(k+1) > s% min_q_for_drag .and. s% drag_coefficient > 0) then
287+
v_p1 = wrap_v_p1(s,k)
288+
drag_force = s% drag_coefficient*v_p1/s% dt
289+
drag_energy = drag_energy + 0.5d0*v_p1*drag_force
290+
s% FdotV_drag_energy(k) = drag_energy%val
291+
! drag energy for inner half-cell. the 0.5d0 is for dm/2
292+
end if
293+
end if
294+
295+
sources_ad = eps_nuc_ad - non_nuc_neu_ad + extra_heat_ad + Eq_ad + RTI_diffusion_ad + drag_energy
276296

277297
sources_ad%val = sources_ad%val + s% irradiation_heat(k)
278298

star/private/hydro_eqns.f90

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,14 @@ subroutine PT_eqns_surf(s, nvar, do_du_dt, do_dv_dt, do_equL, ierr)
745745
i_P_eqn = s% i_dv_dt
746746
end if
747747

748+
749+
if(s% drag_coefficient > 0) then
750+
! We dont call expected_non_HSE_term with k==1 unless we call set_momentum_BC
751+
! so lets initilize this to zero, then if we dont call set_momentum_BC we have a
752+
! sensible value here.
753+
s% dvdt_drag(1) = 0
754+
end if
755+
748756
need_P_surf = .false.
749757
if (s% use_compression_outer_BC) then
750758
call set_compression_BC(ierr)

star/private/hydro_momentum.f90

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ subroutine expected_non_HSE_term( &
387387
other_ad, accel_ad,Uq_ad
388388
real(dp), intent(out) :: other
389389
integer, intent(out) :: ierr
390-
type(auto_diff_real_star_order1) :: extra_ad, v_00
390+
type(auto_diff_real_star_order1) :: extra_ad, v_00, &
391+
drag
391392
real(dp) :: accel, d_accel_dv, fraction_on
392393
logical :: test_partials, local_v_flag
393394

@@ -401,6 +402,8 @@ subroutine expected_non_HSE_term( &
401402
end if
402403

403404
accel_ad = 0d0
405+
drag = 0d0
406+
s% dvdt_drag(k) = 0d0
404407
if (s% v_flag) then
405408

406409
if (s% i_lnT == 0) then
@@ -423,6 +426,12 @@ subroutine expected_non_HSE_term( &
423426
end if
424427
accel_ad%val = accel
425428
accel_ad%d1Array(i_v_00) = d_accel_dv
429+
430+
if (s% q(k) > s% min_q_for_drag .and. s% drag_coefficient > 0) then
431+
v_00 = wrap_v_00(s,k)
432+
drag = -s% drag_coefficient*v_00/s% dt
433+
s% dvdt_drag(k) = drag%val
434+
end if
426435

427436
end if ! v_flag
428437

@@ -432,7 +441,7 @@ subroutine expected_non_HSE_term( &
432441
if (ierr /= 0) return
433442
end if
434443

435-
other_ad = extra_ad - accel_ad + Uq_ad
444+
other_ad = extra_ad - accel_ad + drag + Uq_ad
436445
other = other_ad%val
437446

438447
!test_partials = (k == s% solver_test_partials_k)

star/test_suite/do1_test_source

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ do_one c13_pocket "all values are within tolerance" "final.mod" auto
1212
do_one split_burn_big_net "stop because have dropped below central lower limit for si28" "final.mod" skip
1313
do_one 12M_pre_ms_to_core_collapse "all values are within tolerance" "final.mod" auto
1414
do_one 20M_pre_ms_to_core_collapse "all values are within tolerance" "final.mod" auto
15+
do_one make_pre_ccsn_13bvn "termination code: fe_core_infall_limit" "final.mod" auto
1516
do_one zams_to_cc_80 "all values are within tolerance" "final.mod" auto
1617
do_one pisn "termination code: Star is unbound" "final.mod" skip
1718
do_one 15M_dynamo "all values are within tolerances" "final.mod" auto

star/test_suite/each_test_run

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ function check_restart {
9292
fi
9393

9494
# check that final model matches
95+
if [[ ! -f ./ck ]]; then
96+
failure_msg "$1 restart failed: No ck script"
97+
return 1
98+
fi
99+
95100

96101
if ! ./ck
97102
then
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.. _make_pre_ccsn_13bvn:
2+
3+
*******************
4+
make_pre_ccsn_13bvn
5+
*******************
6+
7+
This test suite evolves a solar metalicity 12 |MSun| model from the pre-ms to helium depletion, strips the hydrogen envelope, and then evolves to core collapse.
8+
This test suite is made to be similar (almost identical) to the 13BVN model from MESA IV. (This is a sensitive test_suite)
9+
10+
Physical checks
11+
===============
12+
13+
Tests the functionality of velocity drag for v_flag for damping large surfaces velocities from He shell (N-alpha) flashes during advanced burning.
14+
Tests energy conservation for regions where v_drag is applied.
15+
Tests the use of OP_split_burn as split burn <4d9 leads to large temperature swings and single zone burning in the core, and split burn >4.5d9 needs smaller timesteps.
16+
This case illustrates strong coupling between burning and hydro: OP_split_burn lower and higher thresholds can only be exceeded with very tight timesteps.
17+
18+
Inlists
19+
=======
20+
21+
This test case has five parts.
22+
23+
* Part 1 (``inlist_to_zams``) creates a 12 |Msun|, Z=2*10^-2 metallicity, pre-main sequence model and evolves it the zero age main sequence.
24+
25+
* Part 2 (``inlist_before_remove``) takes the model to core helium depletion.
26+
27+
* Part 3 (``inlist_remove``) removes the hydrogen envelope, leaving a stripped, evolved helium core.
28+
29+
* Part 4 (``inlist_after_remove``) replaces the remaining hydrogen in the envelope with helium.
30+
31+
* Part 5 (``inlist_to_pre_si_burn``) evolves the model until log_center_T = 9.45d0, just before Si-core burning.
32+
33+
* Part 6 (``inlist_to_cc``) evolves the model until core collapse (300 km/s infall).
34+
35+
36+
Last-Updated: 24May2023 by EbF
37+

0 commit comments

Comments
 (0)