Skip to content

Commit f66317c

Browse files
committed
unit business
1 parent e74a369 commit f66317c

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

src/constants.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const electron_charge_cgs = 4.80320425e-10 # statcoulomb or cm^3/2 * g^1/2 / s
88
const amu_cgs = 1.6605402e-24 #g
99
const bohr_radius_cgs = 5.29177210903e-9 # cm 2018 CODATA recommended value
1010

11-
const bohr_magneton_eV = 5.7883818e-9 # eV / Gauss
11+
const bohr_magneton_cgs = 9.2740100783e-21 # erg G
1212

1313
const solar_mass_cgs = 1.9884e33 #g
1414
const G_cgs = 6.67430e-8

src/line_absorption.jl

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function line_absorption!(α, linelist, lande_g_factors, magnetic_field, λs::Wa
6565
ρ_crit = Vector{eltype(α)}(undef, size(temps))
6666
inverse_densities = Vector{eltype(α)}(undef, size(temps))
6767
ΔE_zeeman = Vector{eltype(α)}(undef, size(temps))
68-
Δλ = Vector{eltype(α)}(undef, size(temps))
68+
Δλ_zeeman = Vector{eltype(α)}(undef, size(temps))
6969

7070
for line in linelist_chunk
7171
m = get_mass(line.species)
@@ -100,18 +100,28 @@ function line_absorption!(α, linelist, lande_g_factors, magnetic_field, λs::Wa
100100
lorentz_line_window = maximum(inverse_densities)
101101

102102
# TODO don't just use odd g
103-
if ismissing(line.lande_g_odd)
104-
Δλ .= 0.0
103+
# TODO understand why lande is separated into odd and even
104+
lande_g = 0.0
105+
# TODO this is wrong
106+
if .!ismissing(line.lande_g_odd)
107+
lande_g += line.lande_g_odd
108+
end
109+
if .!ismissing(line.lande_g_even)
110+
lande_g += line.lande_g_even
111+
end
112+
if lande_g == 0.0
113+
Δλ_zeeman .= 0.0
105114
else
106-
ΔE_zeeman .= bohr_magneton_eV * line.lande_g_odd * magnetic_field
115+
ΔE_zeeman .= bohr_magneton_cgs * lande_g * magnetic_field
107116
# TODO upper or lower E
108-
Δλ .= @. line.wl^2 / (c_cgs * hplanck_eV) * ΔE_zeeman
109-
@show maximum(Δλ) * 1e8
117+
Δλ_zeeman .= @. line.wl^2 / (c_cgs * hplanck_cgs) * ΔE_zeeman
118+
∂λ_∂E = -line.wl^2 / (c_cgs * hplanck_cgs)
119+
Δλ_zeeman = ∂λ_∂E .* ΔE_zeeman
110120
end
111121

112122
window_size = sqrt(lorentz_line_window^2 + doppler_line_window^2) +
113-
maximum(Δλ) - minimum(Δλ) # make sure it's big enough to include all Zeeman shifts
114-
for shift in (-Δλ, Δλ) # TODO selection rules
123+
maximum(Δλ_zeeman) - minimum(Δλ_zeeman) # make sure it's big enough to include all Zeeman shifts
124+
for shift in (-Δλ_zeeman, Δλ_zeeman) # TODO selection rules
115125
λ = @. line.wl + shift
116126

117127
# calculate the window center from the nominal line center, not the shifted line

src/synthesize.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ function synthesize(atm::ModelAtmosphere, linelist, A_X::AbstractVector{<:Real},
149149
@warn "if you are synthesizing at wavelengths longer than 15000 Å (e.g. for APOGEE), setting use_MHD_for_hydrogen_lines=false is recommended for the most accurate synthetic spectra. This behavior may become the default in Korg 1.0."
150150
end
151151

152+
if I_scheme == "linear_flux_only" && mu_values != 20
153+
@warn "mu_values was set to a non-default value ($mu_values), which will have no effect when I_scheme is set to \"linear_flux_only\"."
154+
end
155+
152156
# Add wavelength bounds check (Rayleigh scattering limitation)
153157
# we should really have an upper bound as well
154158
min_allowed_wavelength = 1300.0 * 1e-8 # cm

0 commit comments

Comments
 (0)