Basic Tutorial
In the simplest use case, a model flux spectrum and associated formation temperatures can be calculated given stellar parameters as input. For further details on specifying linelists, abundances, and other details of the model atmosphere, please see the Korg.jl documentation.
using Korg
using PyPlot
using FormationTemps; FT = FormationTemps
# get the linelist
linelist = Korg.read_linelist(joinpath(FT.datdir, "Sun_VALD.lin"))[16000:16100]
# set stellar parameters
Teff = 5777.0
logg = 4.44
A_X = Korg.asplund_2020_solar_abundances
Fe_H = 0.0
vsini = 2100.0
ζ_RT = 3400.0 # radial-tangential macroturbulent broadening
ξ = 850.0 # microturbulent broadenign
# create StellarProps composite type to hold everything
star_props = StellarProps(Teff=Teff, logg=logg, Fe_H=Fe_H,
vsini=vsini, v_macro=ζ_RT, v_micro=ξ)
# get the flux + formation temperature spectra
form_temp_result = FT.calc_formation_temp(star_props, linelist; Δλ=0.01)
# parse the result
wavs = form_temp_result.wavs
flux = form_temp_result.flux
temp = form_temp_result.form_temps
# plot the result
fig, ax1 = plt.subplots(figsize=(9.6,4.8))
ax1.plot(wavs, temp, c="k")
ax1.set_xlabel("Vacuum Wavelength [Å]")
ax1.set_ylabel("Formation Temperature [K]")
fname = joinpath(FT.moddir, "docs", "src", "static", "temp_example_jl.png")
fig.savefig(fname, bbox_inches="tight")
plt.show()
plt.clf(); plt.close()
The high-level convenience function calc_formation_temp provides a few optional arguments discussed below.
Convolution vs. Integration
convolve=false
At low spectral resolving power, convolutions can be used to approximate the effects of macroturbulent and rotational broadening. As shown in Section 2.1.4 of the paper presenting FormationTemps.jl, this approximation can fail at higher resolution. By default, calc_formation_temp performs an explicit disk integration to evaluate model spectra and formation temperatures. Though more accurate, this approach is slower. To use the convolution approximation, convolve=true can be supplied to calc_formation_temp. A plot comparing the convolution and integration fluxes and temperatures is shown below for a solar-like model star. As shown in the paper, the error incurred by the convolution approximation grows with $v \sin i$.

GPU Usage
use_gpu=true
By default, calc_formation_temp will use an NVIDIA GPU to accelerate the computation of spectra, if one is present and configured. The CUDA.jl documentation provides installation instructions, though it is fortunately fairly autonomous.
Several steps of the spectral synthesis are parallelized, including:
- calculation of the stellar grid (if
convolve=false) - the convolution step in the microturbulent broadening
- the solving of the radiative transport equation:
- solving for the monochromatic optical depth
- calculating the monochromatic intensity/flux contribution functions
- evaluation of the monochromatic intensity/flux from the contribution function