Skip to content

Commit 844f35a

Browse files
Add other close gaps hook (#518)
* add other_close_gaps hook (#487) Co-authored-by: Simon Guichandut <[email protected]>
1 parent baebe41 commit 844f35a

File tree

10 files changed

+117
-4
lines changed

10 files changed

+117
-4
lines changed

docs/source/changelog.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ This was found to be important for smooth convective boundary
9292
evolution with convective premixing.
9393

9494

95+
Hooks
96+
~~~~~
97+
98+
A new other_close_gaps hook has been added. Provided by Simon Guichandut
99+
100+
95101
Changes in r22.11.1
96102
===================
97103

star/defaults/controls.defaults

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11341,6 +11341,7 @@
1134111341
use_other_eps_grav = .false.
1134211342
use_other_mesh_functions = .false.
1134311343
use_other_D_mix = .false.
11344+
use_other_close_gaps = .false.
1134411345

1134511346
! ::
1134611347

star/make/makefile_base

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ SRCS = \
118118
other_rate_get.f90 \
119119
other_net_derivs.f90 \
120120
other_split_burn.f90 \
121+
other_close_gaps.f90 \
121122
star_utils.f90 \
122123
ctrls_io.f90 \
123124
alloc.f90 \

star/other/other_close_gaps.f90

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
! ***********************************************************************
2+
!
3+
! Copyright (C) 2023 The MESA Team & Simon Guichandut
4+
!
5+
! MESA is free software; you can use it and/or modify
6+
! it under the combined terms and restrictions of the MESA MANIFESTO
7+
! and the GNU General Library Public License as published
8+
! by the Free Software Foundation; either version 2 of the License,
9+
! or (at your option) any later version.
10+
!
11+
! You should have received a copy of the MESA MANIFESTO along with
12+
! this software; if not, it is available at the mesa website:
13+
! http://mesa.sourceforge.net/
14+
!
15+
! MESA is distributed in the hope that it will be useful,
16+
! but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18+
! See the GNU Library General Public License for more details.
19+
!
20+
! You should have received a copy of the GNU Library General Public License
21+
! along with this software; if not, write to the Free Software
22+
! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23+
!
24+
! ***********************************************************************
25+
26+
module other_close_gaps
27+
28+
! consult star/other/README for general usage instructions
29+
! control name: use_other_close_gaps = .true.
30+
! procedure pointer: s% other_close_gaps => my_routine
31+
! This also requires the control remove_mixing_glitches = .true.
32+
33+
use star_def
34+
35+
implicit none
36+
37+
contains
38+
39+
40+
subroutine null_other_close_gaps(id, mix_type, min_gap, ierr)
41+
integer, intent(in) :: id
42+
integer, intent(in) :: mix_type
43+
real(dp), intent(in) :: min_gap
44+
integer, intent(out) :: ierr
45+
ierr = 0
46+
end subroutine null_other_close_gaps
47+
48+
49+
end module other_close_gaps
50+
51+
52+
53+

star/private/ctrls_io.f90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ module ctrls_io
520520
use_other_diffusion_coefficients, use_other_pgstar_plots, use_other_eval_fp_ft, use_other_eval_i_rot, use_other_torque, &
521521
use_other_torque_implicit, use_other_wind, use_other_accreting_state, use_other_after_struct_burn_mix, use_other_mesh_delta_coeff_factor, &
522522
use_other_before_struct_burn_mix, use_other_astero_freq_corr, use_other_timestep_limit, use_other_set_pgstar_controls, &
523-
use_other_screening, use_other_rate_get, use_other_net_derivs, use_other_split_burn, &
523+
use_other_screening, use_other_rate_get, use_other_net_derivs, use_other_split_burn, use_other_close_gaps, &
524524
x_ctrl, x_integer_ctrl, x_logical_ctrl, x_character_ctrl, &
525525

526526
! extra files
@@ -2397,6 +2397,7 @@ subroutine store_controls(s, ierr)
23972397
s% use_other_rate_get = use_other_rate_get
23982398
s% use_other_net_derivs = use_other_net_derivs
23992399
s% use_other_split_burn = use_other_split_burn
2400+
s% use_other_close_gaps = use_other_close_gaps
24002401

24012402
s% x_ctrl = x_ctrl
24022403
s% x_integer_ctrl = x_integer_ctrl
@@ -4059,6 +4060,7 @@ subroutine set_controls_for_writing(s, ierr)
40594060
use_other_rate_get = s% use_other_rate_get
40604061
use_other_net_derivs = s% use_other_net_derivs
40614062
use_other_split_burn = s% use_other_split_burn
4063+
use_other_close_gaps = s% use_other_close_gaps
40624064

40634065
x_ctrl = s% x_ctrl
40644066
x_integer_ctrl = s% x_integer_ctrl

star/private/mix_info.f90

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,21 +1077,33 @@ end subroutine remove_mixing_singletons
10771077
subroutine close_convection_gaps(s, ierr)
10781078
type (star_info), pointer :: s
10791079
integer, intent(out) :: ierr
1080-
call close_gaps(s, convective_mixing, s% min_convective_gap, ierr)
1080+
if (s% use_other_close_gaps) then
1081+
call s% other_close_gaps(s% id, convective_mixing, s% min_convective_gap, ierr)
1082+
else
1083+
call close_gaps(s, convective_mixing, s% min_convective_gap, ierr)
1084+
end if
10811085
end subroutine close_convection_gaps
10821086

10831087

10841088
subroutine close_thermohaline_gaps(s, ierr)
10851089
type (star_info), pointer :: s
10861090
integer, intent(out) :: ierr
1087-
call close_gaps(s, thermohaline_mixing, s% min_thermohaline_gap, ierr)
1091+
if (s% use_other_close_gaps) then
1092+
call s% other_close_gaps(s% id, thermohaline_mixing, s% min_thermohaline_gap, ierr)
1093+
else
1094+
call close_gaps(s, thermohaline_mixing, s% min_thermohaline_gap, ierr)
1095+
end if
10881096
end subroutine close_thermohaline_gaps
10891097

10901098

10911099
subroutine close_semiconvection_gaps(s, ierr)
10921100
type (star_info), pointer :: s
10931101
integer, intent(out) :: ierr
1094-
call close_gaps(s, semiconvective_mixing, s% min_semiconvection_gap, ierr)
1102+
if (s% use_other_close_gaps) then
1103+
call s% other_close_gaps(s% id, semiconvective_mixing, s% min_semiconvection_gap, ierr)
1104+
else
1105+
call close_gaps(s, semiconvective_mixing, s% min_semiconvection_gap, ierr)
1106+
end if
10951107
end subroutine close_semiconvection_gaps
10961108

10971109

star/test_suite/other_physics_hooks/src/run_star_extras.f90

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ subroutine extras_controls(id, ierr)
7777
s% use_other_rate_get = .true.
7878
s% other_rate_get => my_rate_get
7979

80+
s% use_other_close_gaps = .true.
81+
s% other_close_gaps => my_close_gaps
82+
8083
s% extras_startup => extras_startup
8184
s% extras_check_model => extras_check_model
8285
s% extras_finish_step => extras_finish_step
@@ -394,5 +397,27 @@ subroutine my_rate_get(ir, temp, tf, raw_rate, ierr)
394397
end subroutine my_rate_get
395398

396399

400+
subroutine my_close_gaps(id, mix_type, min_gap, ierr)
401+
integer, intent(in) :: id
402+
integer, intent(in) :: mix_type
403+
real(dp), intent(in) :: min_gap
404+
integer, intent(out) :: ierr
405+
integer :: k
406+
type (star_info), pointer :: s
407+
ierr = 0
408+
call star_ptr(id, s, ierr)
409+
if (ierr /= 0) return
410+
411+
do k=1, 10
412+
if (.false. .and. s% mixing_type(k) == mix_type) then
413+
write(*,*) k, s% D_mix(k), s% mixing_type(k)
414+
end if
415+
end do
416+
417+
418+
end subroutine my_close_gaps
419+
420+
421+
397422
end module run_star_extras
398423

star_data/private/star_controls.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,7 @@
13601360
logical :: use_other_rate_get
13611361
logical :: use_other_net_derivs
13621362
logical :: use_other_split_burn
1363+
logical :: use_other_close_gaps
13631364

13641365
real(dp) :: x_ctrl(num_x_ctrls)
13651366
integer :: x_integer_ctrl(num_x_ctrls)

star_data/public/star_data_def.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,15 @@
835835
end subroutine other_diffusion_interface
836836

837837

838+
subroutine other_close_gaps_interface(id, mix_type, min_gap, ierr)
839+
use const_def, only: dp
840+
integer, intent(in) :: id
841+
integer, intent(in) :: mix_type
842+
real(dp), intent(in) :: min_gap
843+
integer, intent(out) :: ierr
844+
end subroutine other_close_gaps_interface
845+
846+
838847
subroutine other_kap_get_interface( &
839848
id, k, handle, species, chem_id, net_iso, xa, &
840849
log10_rho, log10_T, &

star_data/public/star_data_procedures.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@
128128
procedure (other_surface_PT_interface), pointer, nopass :: &
129129
other_surface_PT => null()
130130

131+
procedure (other_close_gaps_interface), pointer, nopass :: &
132+
other_close_gaps => null()
133+
131134
procedure (other_kap_get_interface), pointer, nopass :: &
132135
other_kap_get => null()
133136
procedure (other_kap_get_op_mono_interface), pointer, nopass :: &

0 commit comments

Comments
 (0)