Skip to content

Commit f30f0b0

Browse files
DebraheemVincentVanlaer
authored andcommitted
colors: use Fe/H instead of zbase (#939)
1 parent d8e8149 commit f30f0b0

5 files changed

Lines changed: 86 additions & 13 deletions

File tree

colors/defaults/colors.defaults

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,65 @@
6969
sed_per_model = .false.
7070

7171

72+
! ``stellar_atm``
73+
! ~~~~~~~~~~~~~~~
74+
75+
! Path to the directory containing the stellar atmosphere lookup table and
76+
! spectra used by the colors module. This directory should contain a
77+
! ``lookup_table.csv`` file and the corresponding SED files. The default
78+
! uses the ``Kurucz2003all`` ATLAS9 atmosphere grid shipped with MESA.
79+
80+
! ::
81+
82+
stellar_atm = '/data/colors_data/stellar_models/Kurucz2003all/'
83+
84+
85+
! ``z_over_x_ref``
86+
! ~~~~~~~~~~~~~~~~
87+
88+
! ``z_over_x_ref`` is the reference metal-to-hydrogen ratio used to map
89+
! the photospheric composition onto the atmosphere-table metallicity axis:
90+
! [Fe/H] = log10((Z/X)/z_over_x_ref).
91+
92+
! The default matches the GS98 solar mixture used by the default
93+
! Kurucz2003all ATLAS9 atmosphere grid and equals
94+
! 0.0169/(1 - 0.0169 - 0.2485) = 2.30057173972d-2.
95+
96+
! If the photospheric metallicity, expressed as Z/X, falls outside the
97+
! metallicity range available in the tabulated atmosphere lookup table,
98+
! then MESA uses the nearest metallicity in the table for the atmosphere
99+
! interpolation. If the photospheric hydrogen mass fraction or metal mass
100+
! fraction is not positive, then MESA cannot form
101+
! log10((Z/X)/z_over_x_ref), so it uses the lowest metallicity in the
102+
! table instead. This is a fallback safeguard and not a dedicated treatment
103+
! for H-free atmospheres.
104+
105+
! For the shipped Kurucz2003all table in this checkout, the
106+
! metallicity range is [Fe/H] = -2.5 to [Fe/H] = 4.0. With the
107+
! default ``z_over_x_ref``, the lower edge corresponds to
108+
! Z/X ~ 7.275d-5.
109+
110+
! ::
111+
112+
z_over_x_ref = 2.30057173972d-2
113+
114+
72115
! Extra inlist controls
73116
! ---------------------
74117

75118
! One can split a colors inlist into pieces using the following parameters.
76119
! It works recursively, so the extras can read extras too.
77120

78-
! ``read_extra_colors_inlist(1..5)``
79-
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80-
! ``extra_colors_inlist_name(1..5)``
81-
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121+
! ``read_extra_colors_inlist(1..5)``
122+
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123+
! ``extra_colors_inlist_name(1..5)``
124+
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82125

83-
! If ``read_extra_colors_inlist(i)`` is true, then read ``&colors`` from the file ``extra_colors_inlist_name(i)``.
84-
! ::
126+
! If ``read_extra_colors_inlist(i)`` is true, then read ``&colors``
127+
! from the file ``extra_colors_inlist_name(i)``.
128+
!
129+
130+
! ::
85131

86132
read_extra_colors_inlist(:) = .false.
87133
extra_colors_inlist_name(:) = 'undefined'

colors/private/colors_ctrls_io.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module colors_ctrls_io
3838
character(len=256) :: mag_system
3939

4040
real(dp) :: distance
41+
real(dp) :: z_over_x_ref
4142
logical :: make_csv
4243
logical :: sed_per_model
4344
logical :: use_colors
@@ -47,6 +48,7 @@ module colors_ctrls_io
4748
vega_sed, &
4849
stellar_atm, &
4950
distance, &
51+
z_over_x_ref, &
5052
make_csv, &
5153
sed_per_model, &
5254
mag_system, &
@@ -155,6 +157,7 @@ subroutine store_controls(rq, ierr)
155157
rq%vega_sed = vega_sed
156158
rq%stellar_atm = stellar_atm
157159
rq%distance = distance
160+
rq%z_over_x_ref = z_over_x_ref
158161
rq%make_csv = make_csv
159162
rq%sed_per_model = sed_per_model
160163
rq%colors_results_directory = colors_results_directory
@@ -192,6 +195,7 @@ subroutine set_controls_for_writing(rq)
192195
vega_sed = rq%vega_sed
193196
stellar_atm = rq%stellar_atm
194197
distance = rq%distance
198+
z_over_x_ref = rq%z_over_x_ref
195199
make_csv = rq%make_csv
196200
sed_per_model = rq%sed_per_model
197201
colors_results_directory = rq%colors_results_directory

colors/private/colors_history.f90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ subroutine data_for_colors_history_columns( &
112112
filter_name = trim(remove_dat(color_filter_names(i)))
113113
names(i + filter_offset) = filter_name
114114

115-
if (t_eff >= 0 .and. metallicity >= 0) then
116-
! pick the precomputed zero-point for the requested mag system
115+
! Negative [M/H] values are valid for metal-poor atmosphere grids.
116+
! so we do not apply a limit on the "metallicity" parameter.
117+
if (t_eff >= 0) then
118+
! Select precomputed zero-point based on magnitude system
117119
select case (trim(cs%mag_system))
118120
case ('VEGA', 'Vega', 'vega')
119121
zero_point = cs%filters(i)%vega_zero_point
@@ -152,4 +154,4 @@ subroutine data_for_colors_history_columns( &
152154

153155
end subroutine data_for_colors_history_columns
154156

155-
end module colors_history
157+
end module colors_history

colors/public/colors_def.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module colors_def
4949
character(len=256) :: mag_system
5050
real(dp) :: metallicity
5151
real(dp) :: distance
52+
real(dp) :: z_over_x_ref
5253
logical :: make_csv
5354
logical :: sed_per_model
5455
logical :: use_colors
@@ -315,4 +316,4 @@ subroutine do_free_colors_tables
315316

316317
end subroutine do_free_colors_tables
317318

318-
end module colors_def
319+
end module colors_def

star/private/history.f90

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ subroutine do_history_info(s, write_flag, ierr)
7070
num_extra_cols, num_binary_cols, num_extra_binary_cols, num_colors_cols,num_extra_header_items, n
7171
integer, parameter :: num_epsnuc_out = 12
7272
real(dp) :: &
73-
epsnuc_out(num_epsnuc_out), csound_surf, v_surf, envelope_fraction_left
73+
epsnuc_out(num_epsnuc_out), csound_surf, v_surf, envelope_fraction_left, m_div_h, &
74+
min_m_div_h, max_m_div_h
7475
integer :: mixing_regions, mix_relr_regions, burning_regions, burn_relr_regions
7576
integer, pointer :: mixing_type(:), mix_relr_type(:), burning_type(:), burn_relr_type(:)
7677
character (len = maxlen_history_column_name), pointer, dimension(:) :: &
@@ -268,9 +269,28 @@ subroutine do_history_info(s, write_flag, ierr)
268269
colors_col_names(1:num_colors_cols) = 'unknown'
269270
colors_col_vals(1:num_colors_cols) = -1d99
270271

271-
call data_for_colors_history_columns(s%T(1), safe_log10(s%grav(1)), s%R(1), s%kap_rq%Zbase, &
272-
s% model_number, s% colors_handle, num_colors_cols, colors_col_names, colors_col_vals, ierr)
272+
! Here we compute [Fe/H], and thencall colors to compute history columns.
273+
if (colors_settings% z_over_x_ref <= 0d0) then
274+
write(*, *) 'colors error: z_over_x_ref must be positive'
275+
ierr = -1
276+
call dealloc
277+
return
278+
end if
279+
280+
min_m_div_h = minval(colors_settings% lu_meta)
281+
max_m_div_h = maxval(colors_settings% lu_meta)
282+
283+
! Map the current photospheric Z/X onto the atmosphere table metallicity axis.
284+
if (s% X(s% photosphere_cell_k) > 0d0 .and. s% Z(s% photosphere_cell_k) > 0d0) then
285+
m_div_h = log10((s% Z(s% photosphere_cell_k)/s% X(s% photosphere_cell_k)) / &
286+
colors_settings% z_over_x_ref)
287+
m_div_h = max(min_m_div_h, min(max_m_div_h, m_div_h))
288+
else
289+
m_div_h = min_m_div_h
290+
end if
273291

292+
call data_for_colors_history_columns(s%T(1), log10(s%grav(1)), s%R(1), m_div_h, &
293+
s% colors_handle, num_colors_cols, colors_col_names, colors_col_vals, ierr)
274294
if (ierr /= 0) then
275295
call dealloc
276296
return

0 commit comments

Comments
 (0)