The EXOMOL project provides the partition function for the individual
isotopologues. Since synspec works in terms of the total number densities and
partition functions for molecules without a distinction in isotopologues, we
average the individual partition function as follows, for example for a
diatomic molecule AB,

$U({\rm AB})_{\rm av}=\sum_{i}\sum_{j}U({}^{i\\!}{\rm A}{}^{j\\!}{\rm
B})\,f^{i}_{A}f^{j}_{B},$ (28)

where $U({\rm AB})_{\rm av}$ is the averaged partition function for species
AB, $U({}^{i\\!}{\rm A}{}^{j\\!}{\rm B})$ are the partition functions for the
individual isotopologues, and $f^{i}_{A}$ is the fractional abundance of the
isotope ${}^{i\\!}{\rm A}$ of atom A. The summation extend over all physically
possible values of $i$ and $j$.

IRWTAB

\- a switch to select the table of fitting coefficients to evaluate the
molecular partition functions;
$\bullet\,=0$ – the original Irwin’s table is used. Since the improved table
is obviously preferable, we keep this option for possible comparisons with old
versions.
$\bullet\,\not=0$ – an improved table, based on Barklem & Collet (2016) data
for diatomic molecules, is used.
DEFAULT: IRWTAB=1

IPFEXO

\- a switch to include the EXOMOL partition functions for the above specified
molecules:
$\bullet\,=0$ – the EXOMOL partition function are not considered;
$\bullet\,\not=0$ – the EXOMOL partition functions are considered, and
override other values when available.
DEFAULT: IPFEXO=1

To get more insight into the results, and for comparing to results from other
studies, we have introduced four new output files, fort.51, fort.52, fort.53,
and fort.54. We have also introduced a new global option in synspec that only
solves the chemical equilibrium and generates the files fort.51 – fort.54
without computing detailed opacities or the emergent radiation intensity. This
option is switched on by the keyword parameter IFEOS.

IFEOS

– a switch to activate the “EOS-only” option.
$\bullet\,=0$ – the standard option to compute either a synthetic spectrum or
an opacity table, depending on the input parameters;
$\bullet\,>0$ – an “EOS-only” option, in which synspec works as in the mode of
evaluating the opacity table for a set of temperature/density pairs, but
instead of computing the opacities, it just solves the global chemical
equilibrium to obtain number densities of all atomic and molecular species.
$\bullet\,<0$ – the EOS quantities and output files are produced for an
otherwise standard run (synthetic spectrum or opacity tables), and the
quantities are printed for a loop in depth indices ID=1,ND, and a step of
abs(IFEOS). For the opacity tables, there is formally only one depth, so in
order to print the EOS quantities one sets IFEOS$=-1$. For synthetic spectra,
setting for instance IFEOS=-30 activates printing the EOS quantities at depths
1, 31, 61, etc.

In the EOS-only option the input is similar to that for the opacity table
option, but simplified because many parameters used for evaluating the
opacities are not needed here. Here is a description of the input files:

  * •

Standard input (usually named fort.5) – remains the same as for all other
applications of synspec.

  * •

fort.2 – only the first three lines are functional, the rest may be deleted
(but no harm is done if these are kept).

  * •

fort.55 – not needed.

  * •

Line lists – not needed.

The output files list some interesting quantities for all temperature/density
pairs. Here is their description:

#### File fort.51

It includes a header that is almost self-explanatory. But to avoid confusion,
here is a detailed explanation. Each record contains:

$T\ \ \ \ \ \ \ \ \ \ $ | – | temperature [K]
---|---|---
$\rho$ | – | density [g cm-3]
$w_{\rm mol}$ | – | mean molecular weight – see Eq. (33)
$N$ | – | the total particle number density [cm-3]
$N_{\rm e}$ | – | electron density [cm-3]
$n(\rm{H}_{\rm tot})$ | – | number density of hydrogen nuclei [cm-3]
$N(\rm{H})\quad$ | – | number density of neutral hydrogen [cm-3]
$N({\rm H}^{-})$ | – | number density of the negative ion of hydrogen [cm-3]
$N({\rm H}_{2})$ | – | number density of the hydrogen molecule [cm-3]
$N({\rm H}_{2}^{-})$ | – | number density of the negative ion of hydrogen molecule [cm-3]
$N({\rm H}_{2}^{+})$ | – | number density of the positive ion of hydrogen molecule [cm-3]

#### File fort.52

The first three entries are the same as in fort.51, then $N_{\rm e}/N$,
$N(\rm{H}_{\rm tot})$ , $N(\rm{H})$, and $n({\rm H}_{2})$, which is the number
density of hydrogen nuclei sequestered in H2. The next four entries, $a$(He),
$a$(C), $a$(N), and $a$(O) represent a check of the total number densities of
nuclei of He, C, N, O, in all important species they are constituents of,
divided by the chemical abundance. These numbers should be equal or very close
to 1. Finally, there are three columns entitled molfr(C), molfr(N), molfr(O),
that represent a molecular fractions, i.e., thr fraction of C, N, and O
nuclei, respectively, sequestered in molecules.

#### File fort.53

This file summarizes the number densities of the 20 most important molecular
species, namely those for which we have data in the line lists. The printed
quantities are $\log_{10}(N/U)$ [cm-3], because these are the quantities that
enter the calculation of line opacities. The individual column are:
temperature [K]. $\log_{10}\rho$ [g cm-3], and then 20 values of
$\log_{10}(N/U)$ for the following molecules: H2, H2O, OH, CH, CO, CN, C2, NH,
SiH, SiO, TiO, VO, MgH, CaH, NaH, MgO, AlO, CaO, CrH, and FeH. This file gives
useful guidance for reducing the number of lines in the molecular line lists.

#### File fort.54

The file is quite analogous to fort.53; the only difference is that instead of
$\log_{10}(N/U)$ one has $\log_{10}[N/n(H)]$, that is the ratio of the
molecular number density to the number density of hydrogen nuclei, for the
same molecular species as in fort.53.

###  3.4 Additional opacities

Changes in the treatment of additional opacities are analogous to the
corresponding changes in tlusty. Table 2 summarizes the additional opacity
sources, the keyword parameters that control them, their default values, and
the conditions when synspec resets them. The table is analogous to Table 1
that describes the corresponding switches and actions for tlusty. As is easily
seen, the only difference from their treatment in tlusty is that in synspec
the switches for additional Rayleigh scattering are reset to zero when an
opacity table is constructed.

We underline that tlusty will examine the header of any opacity table produced
by synspec and removes automatically any “additional” opacity source that has
already been included.

###  3.5 Rejection of weak lines from the line list

We stress at the outset that the rejection of lines considered here is quite
different from reducing the number of lines in the line list (mentioned
earlier, and described in detail in Appendix G). The latter reduces the line
list itself, which then becomes smaller and easier and faster to deal with.
But since a given line list (reduced or full) may be used for quite different
physical conditions, one still has to reject lines that are weak in those
particular conditions in order to make the overall procedure efficient; that
is, fast, yet sufficiently accurate.

As explained in Paper I, § 5.3.1, the standard procedure of rejecting lines
from the line list that are deemed to be too weak to contribute to the total
opacity is controlled by two input parameters specified in the file fort.55:
IDSTD and RELOP. The parameter IDSTD specifies the index of the depth point
that is viewed as the characteristic depth, that is a depth where roughly
$T\approx T_{\rm eff}$, so that the Rosseland optical depth at this point is
close to 1. In terms of depth indices, IDSTD is approximately equal to (2/3)
ND, unless the depth points of the input model atmosphere are set in a non-
standard way. Obviously, in the opacity-table mode, IDSTD=1 since ND is also
=1.

Table 2: Additional opacities in synspec – keywords and their values Opacity source | Keyword | Default | Set automatically to 0 if
---|---|---|---
H- b-f and f-f | IOPHMI | 1 | H- is already an explicit ion
H${}_{2}^{+}$ b-f and f-f | IOPH2P | 1 | IFMOL=0 or $T>$ TMOLIM
H${}_{2}^{-}$ f-f | IOPH2M | 1 | IFMOL=0 or $T>$ TMOLIM
He- b-f and f-f | IOPHEM | 1 |
CIA H2-H2 | IOH2H2 | 1 | IFMOL=0 or $T>$ TMOLIM
CIA H2-He | IOH2HE | 1 | IFMOL=0 or $T>$ TMOLIM
CIA H2-H | IOH2H | 1 | IFMOL=0 or $T>$ TMOLIM
CH opacity | IOPCH | 1 | IFMOL=0 or $T>$ TMOLIM
OH opacity | IOPOH | 1 | IFMOL=0 or $T>$ TMOLIM
H Rayleigh scat. | IRSCT | 1 | IMODE$=-3$ (opacity table)
He Rayleigh scat. | IRSCHE | 1 | IMODE$=-3$ (opacity table)
H2 Rayleigh scat. | IRSCH2 | 1 | IFMOL=0 or $T>$ TMOLIM
|  |  | or IMODE$=-3$ (opacity table)

The rejection parameter RELOP is the critical one. Its meaning is that a line
is rejected if the ratio of the line-center opacity to the continuum opacity
at the characteristic depth is less than RELOP. Such an approach was used in
all previous versions of synspec, and it worked quite well for hot and
moderately warm atmospheres. However, for solar-type and cooler stars the
local conditions at the characteristic depth may well be conducive to forming
only a limited number of molecular species, while many others are formed in
cooler regions of the atmosphere. Therefore, many molecular lines would be
erroneously rejected if the rejection criterion is based only on comparing
opacities at the characteristic depth.191919One can always compensate by
setting the parameter RELOP to a very low value, say $10^{-15}$ or even lower,
but such an approach is inefficient and time-consuming because one would also
select a number of lines that are weak everywhere and should be rightfully
rejected.

We have therefore upgraded the previous treatment, essentially allowing for
comparing line and continuum opacities at more depth points. The criterion for
including a line (i.e., not rejecting it) is that the ratio of the line-center
opacity to the continuum opacity at any of the selected depth points exceeds
the value of the parameter RELOP. The set of depth points at which the
opacities are compared is specified by the parameter IDSTD, which now has the
following meaning:

$\bullet$ IDSTD$>0$ – a classical treatment. In this case IDSTD specifies the
index of the characteristic depth, and the opacity is compared at only this
one depth point.

$\bullet$ IDSTD$=0$ – The set of “characteristic depth points” is composed of
three depths, with indices 1, (ND-10)/2+1, and ND-9, i.e. id=1,ND,NDSTEP with
NDSTEP=(ND-10)/2. This is the recommended option.

$\bullet$ IDSTD$<0$ – The characteristic depths are set again as
id=1,ND,NDSTEP, but now with NDSTEP=$-$IDSTD. This option allows for selecting
more depths for comparing the opacities; selecting IDSTD$=\\!\\!-1$ would lead
to comparing opacities at all depth points. While this option would represent
an overkill for classical atmospheres, it may be useful in special
circumstances, for example for models with a chromospheric temperature rise,
atmospheres with shocks, etc.

###  3.6 Updated treatment of NLTE levels

This modification provides a better identification of the lower and upper
levels of lines specified through the line list, and the explicit (NLTE)
levels specified through the atomic data input files for tlusty and synspec.
To this end, one needs:

  1. 1.

an extended line list that contains more quantum numbers for the individual
levels, and

  2. 2.

upgraded atomic data files that specify, for each explicit level, appropriate
lower and upper limits of quantum numbers. The notion of “limits” is invoked
because an individual “level”, as considered in an atomic data file may in
fact be a superposition of several genuine levels. For a genuine level, the
upper and lower limits coincide.

In the standard case, synspec associates the energy levels only by means of
their energies (see Paper I, Appendix C). If additional information is present
(as it is the case when an extended atomic line list is used), then the
program uses not only the energy, but also the quantum numbers $S$ and $L$, as
well as the level parity – see below. This can be very useful for complex
model atoms with many levels, or with significant uncertainties in their
energies.

In the following, we will describe these modifications in detail.

####  3.6.1 Modification of the atomic line list

These modifications were described in § 3.1.1. We stress that synspec
automatically detects whether a line list is in the standard format or whether
it has the 6 new parameters. If they are present, one can still force synspec
to ignore the new information for all ions by setting the parameter INLIST (in
the input file fort.55) to 10 or larger. For more details, refer to § 3.1.3.
One can also force synspec to ignore this information for a particular ion by
setting the parameter NONSTD in the standard input file to 10, or, more
precisely, if a non-zero value of NONSTD was intended, setting NONSTD to the
desired NONSTD+10. For details, refer to Paper III, § 4.3.

####  3.6.2 Modification of the atomic data file

The entry for each explicit level contains, in addition to the standard 7
parameters (ENION, G, NQUANT, TYPLEV, IFWOP, FRODF, IMODL – see Paper III, §
11.1), the following 8 new parameters:

ENION1, ENION2

– lower and upper limit for the level energy (analogously to ENION, they can
be in any units – erg, eV, cm-1, or as frequency, s-1);

SQUANT1, SQUANT2

– lower and upper limit of the $2S+1$ values;

LQUANT1, LQUANT2

– lower and upper limit of the $L$ values;

PQUANT1, PQUANT2

– lower and upper limit of the parities.

In analogy to reading the line list, synspec detects whether the additional
information is present in an atomic data file, and if not, it proceeds in the
standard way.

####  3.6.3 Additional input parameters

There are several additional keyword parameters meant for global control of
the use of the energy and quantum number limits:

ERANGE

– resets the energy limits in the case when they are set too close to the
actual energy of the level. Namely, if
(ENION1-ENION)/ENION$<10^{-6}$ then ENION1 is reset to
ENION1=ENION (1+ERANGE); and analogously for ENION2.
DEFAULT: ERANGE=0.1 (i.e., 10%)

ISPICK

– if set to 0, then the $S$ quantum number is not used for associating the
levels from the line list to the explicit levels
DEFAULT: ISPICK=1 (i.e., the S value is being used)

ILPICK

– analogous switch for the $L$ quantum number
DEFAULT: ILPICK=1 (i.e., the L value is being used)

IPPICK

– analogous switch for the parity
DEFAULT: IPPICK=1 (i.e., the parity is being used).

####  3.6.4 Input NLTE level populations

In the previous versions of synspec, the NLTE level populations of all levels
of all explicit species were transmitted to synspec as an input file, fort.8.
This file is typically generated by a previous run of tlusty202020Such an
input file could have also been generated by appropriately modifying output of
NLTE level populations generated by another code. While such procedure may be
useful in some cases, it might be cumbersome. It may prove to be more
straightforward to rerun tlusty with appropriate atomic data files. as an
output file fort.7.

In some applications, in particular in the context of cool stars, it may be
useful to have as input not the absolute values of NLTE level populations (in
cm-3), but rather the absolute $b^{\ast}$-factors, defined as ratios of NLTE
and (absolute) LTE populations, as described in § 2.10.2.

$b_{i}^{\ast}\equiv n_{i}/n_{i}^{\ast\ast}$ (29)

where $n_{i}$ is a NLTE population of level $i$, and $n_{i}^{\ast\ast}$ the
absolute LTE population, obtained by solving the Saha-Boltzmann equations for
all levels of all considered ionization stages of the element.

The computation of a spectrum from an input NLTE model using the standard
method (absolute NLTE populations) or input $b^{\ast}$ factors will obviously
give the same results. However, using a file that contains the
$b^{\ast}$-factors allows the user to estimate reasonably well the NLTE level
populations for a slightly different LTE structure without actually computing
a new NLTE model.

This option is triggered by a new keyword parameter IBFAC, which acts as
follows:

IBFAC

– a switch defining the meaning of input NLTE populations on the input file
fort.8
$\bullet\,=0$ – the input file contains the absolute level populations (in
addition to the temperature, electron density, mass density, and, for models
with molecules, the total particle number density) – the standard option;
$\bullet\,=1$ – the input file fort.8 contains the $b^{\ast}$-factors instead
of absolute NLTE populations. When using this option, the user has to make
sure that the file fort.8 indeed contains the absolute $b^{\ast}$-factors, not
the usual $b$-factors. The file is generated by tlusty as fort.22 – see §
2.10.2.
$\bullet\,=2$ – In this case, one deals with an LTE model atmosphere with the
additional input of $b^{\ast}$-factors, with the aim to provide an approximate
NLTE line formation for LTE models, as further explained in § 3.8.3. In that
case the file fort.8 is an input LTE model atmosphere, while the
$b^{\ast}$-factors file is to be copied or linked to a file named bfactors.
DEFAULT: IBFAC=0 (i.e., the standard option)

###  3.7 Subtle points of computing line and continuum opacity

As explained in Paper I, computing a synthetic spectrum for an LTE model
atmosphere involves taking an information about bound-free transitions
(continua) from the input file(s) used for the construction if the
corresponding model atmosphere (if a tlusty model is used). If the input model
atmosphere is a Kurucz model, the analogous input files should be used. More
precisely, synspec takes into account bound-free transitions from all explicit
levels, as specified by the standard input file, with the corresponding cross-
sections taken from the relevant atomic data files whose names are given in
the standard input. The LTE level populations of all explicit levels are
evaluated by the standard Saha-Boltzmann expressions using the corresponding
data (level energies and statistical weights) given by the input atomic data
files.

This procedure is unambiguous for evaluating the continuum opacity. However,
there is a subtlety in evaluating the line opacity. For lines of non-explicit
species, the line opacity uses level populations of the lower and the upper
levels with level energies and statistical weights taken from the line list.
The way lines of explicit species are treated depends on the input model
atmosphere:

  * •

If the input model atmosphere is an LTE model, the input parameter INLTE
(input provided in the file fort.55) is reset to 0, so that the line opacity
is evaluated using data (level energies, oscillator strengths, broadening
parameters) from the line list.

  * •

If an input model is NLTE, the relevant parameters for the lower and upper
level are taken from the tlusty atomic data files. A problem may arise if a
“level” referred to in an atomic data file is in fact a representation of
several actual energy states lumped together. In that case, synspec first
associates a level referred to in the line list to that referred to in an
atomic data file, as described in the previous section, properly scales the
level populations by the statistical weights, but still uses the energy from
the tlusty atomic data file to evaluate the corresponding level populations.
Since the latter level energy may represent an averaged energy of a group of
actual levels, the LTE population computed in this way may be different from
the LTE level population computed using actual level parameters from the line
list. We stress that similar problems may occur even for single (explicit)
levels, simply because there is no a priori guarantee that the level energies
in the line list are exactly equal to those given in the atomic data file.

The most significant problem may arise if an input model is nominally NLTE,
and uses model atoms that are reasonably sufficient for some species (say H,
Mg for a solar-type star), but uses very simple model atoms for metals,
essentially with only very few low-lying levels, with the aim just to capture
the most important contributions to the UV continuum opacity. While this
approach would indeed reasonably describe the continuum opacity, it could lead
to significant inaccuracies in the line opacity of these species, as explained
above.

####  3.7.1 Semi-explicit species

To avoid these potential problems, we introduced a hybrid option of “semi-
explicit” species. These are those which are considered as explicit for
evaluating the continuum opacity (that is, with their level population and
bound-free cross-section evaluated using data from the tlusty atomic data
files), while considered as non-explicit when evaluating the line opacity
(that is, using data solely from the line list), and disregarding (potentially
inaccurate) NLTE populations of their levels.

This option is invoked by setting the parameter MODE, which is a part of the
second block of the standard input file, described in detail in Paper III, §
4.2, namely MODE=4. For convenience, we will provide a more detailed
description of this parameter below.

####  3.7.2 Quasi-explicit species

We have introduced another, somewhat related but distinct, option of “quasi-
explicit” species. Their utility comes from the following observation. Let us
assume that the input model atmosphere was built using very detailed model
atoms for, say, H, Mg, and Ca – these are true explicit species, and C, N, O,
Na, and Si with simple model atoms – these may be treated by synspec as semi-
explicit. No other species were explicit in the input model.212121We stress
that this is just an example used to explain the concept of the quasi-implicit
species; not an endorsement to construct a model atmosphere in this way.
However, we have realized, again as an example, that continua of Al, P, S, Fe,
and Ni may provide an important contribution to the total continuum opacity.
Since these species were not explicit in the input model atmosphere, their
continuum opacity would not be considered by synspec at all. In order to
remedy this problem, we have introduced the concept of quasi-explicit species.
The user will provide atomic data files for them, which may be relatively
simple, just to capture the bound-free opacity from the most important levels.
The populations of such levels will be computed in LTE, and their bound-free
opacity will be included with the cross-sections determined by the input
parameters from the corresponding atomic data files.

A more realistic example is computing a synthetic spectrum for models that
were computed in the Opacity Table/NLTE (OT/NLTE) mode, for instance models
g55res or g55ryb considered as test cases in § 6.2.2. In these models, only H,
Mg, and Ca are treated explicitly, while the rest of the opacity is provided
by a pre-calculate opacity table. When computing a synthetic spectrum using
the input for model, say g55res, the only bound-free opacities that would be
taken into account would be those of H, Mg, and Ca. The opacity table was
constructed (see § 7.2.1) using as explicit the following species: He, C, N,
O, Ne, Al, Si, S, and Fe. (the opacity of H, Mg, and Ca was excluded for the
use in hybrid models). In order to include the bound-free opacities of all
species when computing a spectrum for a hybrid model, He, C, N, O, Ne, Al, Si,
S, and Fe have therefore to be considered by synspec as quasi-explicit
species. For more details, see § 7.2.3.

To avoid confusion, we stress that while an opacity table is being constructed
by synspec (in its opacity-table mode – see above), it is not being used by
synspec for computing synthetic spectra. The obvious reason is that the
opacity table is meant for use in tlusty, and thus does not necessarily have
the wavelength resolution appropriate for truly detailed spectrum synthesis.
In contrast, synspec is designed precisely to provide a detailed spectrum (or
opacities, in the opacity-table mode), with all opacities computed from
scratch.

####  3.7.3 Summary of treating chemical species

Here we provide a description of the second block of the standard input file,
described in detail in Paper III, § 4.2, which specifies the selection of
chemical elements to be included in the calculations of model atmospheres or
spectra, and provides the basic parameters for these species. The block first
contains one or two numbers, NATOMS and IABSET. NATOMS represents the highest
atomic number of the elements considered, and IABSET, if set, specifies which
set of the standard solar abundances is adopted. If it is not set, the program
will default to 0. For details, refer to § 2.2.1, and Appendix A.
Subsequently, there are NATOMS input records, each containing three numbers:

MODE

– a specification of the mode of treatment for the element:
$\bullet\,=0$ – the element is not considered at all;
$\bullet\,=1$ – the element is treated implicitly, that is it does not
contribute to the continuum opacity (but in the case of synspec it does
contribute to the line opacity);
$\bullet\,=2$ – the element is considered fully explicitly; i.e. selected
energy levels of the selected ionization stages are considered explicitly. In
the case of synspec, these populations are either read from the input model
atmosphere (in the case of NLTE models), or are computed by synspec (in the
case of LTE models), using data provided by the atomic data files.
$\bullet\,=4$ – this is a new option, specific to synspec, setting the element
to the semi-explicit mode, as described above.
$\bullet\,=5$ – this is another new option, specific to synspec, setting the
element to the quasi-explicit mode, described above.

ABN

– a specification of the chemical abundances of the individual species, in
relation to the adopted standard solar abundance set, with the following
convention:
$\bullet\,=0$ – the standard solar abundance is assumed
$\bullet\,<0$ – a non-solar abundance is assumed, abs(ABN) has now the meaning
of the abundance expressed as a multiple of the standard solar abundance (i.e.
$-0.1$ means 1/10 of the standard solar abundance, $-5$ means 5 times standard
solar abundance, etc.);
$\bullet\,>0$ – a non-solar abundance is assumed, expressed as $N({\rm
elem})/N({\rm ref})$, i.e. relative by number to the reference species. The
reference atom is H by default, but the reference species can be changed by
means of the optional parameter IATREF (see § 7.4.4. of Paper III)
$\bullet\,>10^{6}$ – non-homogeneous (depth-dependent) abundance is assumed.
In this case, the immediately following $N\\!D$ lines should be added that
contain the individual values of the abundance (relative to hydrogen by
number), for all depth points $d=1,\ldots,N\\!D$.

MODPF

– originally meant as a switch to set the mode of evaluation of the partition
functions. However, the parameter MODPF is outdated because the evaluation of
the partition functions (for atoms and ions) is now driven by the keyword
parameter IIRWIN -see § 2.6.

###  3.8 Summary of treating line and continuum opacities by synspec

The previously described treatment of lines and continua might seem
complicated and confusing, so we will summarize here various options and
possibilities. The basic difference is whether the input model is LTE or NLTE.
We will describe these two basic types of generating spectra in turn, with an
additional possibility of using, in a given run, input data and model
parameters for both an LTE as well as a NLTE model.

####  3.8.1 Input LTE model atmosphere; with no additional input

If the input model atmosphere is a tlusty-generated model, synspec takes from
the input model atmosphere only 3 or 4 basic parameters (3 for models without
molecules, 4 for models with molecules), namely $T$, $n_{\rm e}$, $\rho$, and,
for models with molecules, $N$.

If the input model atmosphere is a Kurucz model, then synspec takes from the
input $T$, $n_{\rm e}$, and $P_{\rm g}$, the gas pressure. From these state
parameters synspec computes $N$ and $\rho$. If molecules are absent (IFMOL=0),
the procedure is trivial: $N=P_{\rm g}/kT$ and $\rho=\mu m_{H}(N-n_{\rm e})$,
while if molecules are included, one has to solve the equation of state as
described in § 3.3.

The basic building blocks of the spectrum synthesis are then treated as
follows:

Atomic level populations:

are generally determined by solving the Saha-Boltzmann relations.

Continuum opacity:

is computed as a bound-free opacity for all explicit levels, a free-free
opacity for all explicit ions, and various “additional” opacities, as
described earlier. To this end, the standard input file may be identical to
the standard input file for tlusty to generate the current model, or may be
quite independent of it – if one uses for instance a Kurucz model atmosphere.
In any case, it is important that the standard input specifies as explicit
atoms/ions those that are expected to provide a non-negligible source of
continuum opacity. Examples of such files are given in Paper III, and here in
§ 7.2.1 and 7.2.3.

Line opacity:

is quite independent of the standard input, and on the choice of explicit
atoms and ions. All elements are allowed to contribute to the line opacity,
unless they are specifically excluded (MODE=0 in the standard input). In other
words, line opacity is computed for any non-excluded chemical elements,
regardless of the MODE, that is for MODE $\not=0$

####  3.8.2 Input NLTE model atmosphere

The situation here is more tricky. But generally, since the point of computing
NLTE model atmospheres is to provide NLTE level populations of selected energy
levels of particular atoms and ions, these level populations are to be
communicated to synspec. They may, or many not be actually used by synspec.
Usually they are, but we have explained the reasons why they may not be used
for the line opacity in § 3.7.1. The important point is that the model input
(unit 8) now contains, in addition to the 3 or 4 parameters as in the case of
LTE, also the level populations of the energy levels treated explicitly by
tlusty. Therefore, the standard input to synspec has to conform to the
standard input for tlusty that generated the given model; in the sense that
all species that were explicit in the tlusty input have to be explicit (or
semi-explicit) here, with MODE=2 or 4, and with the same number of explicit
levels. Otherwise, synspec will get confused. The previous versions of synspec
were much simpler in this respect – one just used exactly the same standard
input for both codes. This can be done in the present version as well, but now
synspec54 can offer a larger flexibility, and several additional useful
options, at the expense of a slight increase in complexity for setting the
standard input.

Important note: When we talk here about “input NLTE level populations”, we
mean either the traditional number densities (the standard approach), or
“absolute” $b^{\ast}$-factors – see § 3.6.4. Which one is included in the
model input is determined by the keyword IBFAC, but the approach to evaluate
the line and continuum opacity is the same in both cases.

The basic building blocks of the spectrum synthesis are now treated as
follows:

Atomic level populations:

Generally, populations of the explicit levels are taken from the model input,
and others are computed in LTE.

Continuum opacity:

As mentioned several times before, a treatment of the continuum opacity was
extended with respect to previous versions:

  * •

As before, the bound-free and free-free opacity are automatically included for
all explicit levels and atoms.

  * •

Since this may be insufficient, we introduced the the “quasi-explicit
species”, and these have to be specified in the standard input, with MODE=5.
This is not for classical NLTE models, where one was supposed to take into
account all important opacity sources by means of selecting appropriately the
explicit atoms and levels, but rather for hybrid Opacity Table/NLTE (OT/NLTE)
models where most of the opacity sources are included through the opacity
table. The concept is discussed in § 3.7.2, and an actual example is given in
§ 7.2.3. The populations of quasi-explicit species are computed in LTE, but
their bound-free and free-free cross-section are calculeted exactly as for
truly explicit species.

Line opacity:

In this case, the evaluation of line opacity may depend on the parameters from
the standard input, and obviously on the input NLTE level populations. The
line opacity can be taken in two different ways:

  * •

For explicit atoms (MODE=2), synspec takes into account the NLTE level
populations in the input model by associating the level parameters given in
the line list and those in the tlusty. standard input. The subtleties of this
approach are discussed in Paper I, and here in § 3.6.

  * •

Some species, being taken as explicit in tlusty, may be set to the “semi-
explicit” mode for synspec, simply by changing the MODE from 2 to 4. As a
consequence, their NLTE populations are taken into account for the bound-free
opacity, but the level populations for the line opacity are computed in LTE.
The rationale for this approach is explained above in § 3.7.1.

####  3.8.3 LTE model atmosphere, with additional (NLTE) input

This is a new option that provides a reasonable approximation of NLTE line
formation for otherwise LTE models. To this end, one uses two previously
computed model atmospheres: one is a usual LTE model (tlusty or Kurucz), and
another one is a NLTE tlusty model. The LTE model provides the atmospheric
structure ($T$, $n_{\rm e}$, $\rho$, possibly $N$), while the NLTE model
provides NLTE level populations. In this case, the level populations have to
be supplied as $b^{\ast}$-factors. From them, synspec computes actual NLTE
populations using the internal LTE populations based on the input LTE
structure. Here are the basic ingredients:

Standard input:

Although the LTE model is a primary input, the standard input to tlusty for
the current run must be set up in such a way that synspec understands the
indexing of the input $b^{\ast}$-factors in the second model, so that they can
be correctly associated associates to the energy levels they were meant to.
Since the standard input for LTE models is essentially arbitrary as far as the
choice of explicit species is concerned, the standard input here is
essentially the same as the current model were a NLTE one. In fact, the
present setup represents a NLTE spectrum synthesis; the only difference from a
purely NLTE model described in the previous section is that the atmospheric
structure ($T$, $\rho$, etc.) is taken from a different, LTE,
model.222222Furthermore, this input model can in principle be a NLTE model,
but such an option is not recommended since in this case one could easily
calculate a proper NLTE model and do a spectrum synthesis for it in a
traditional way. This option is meant to provide a tool for spectrum synthesis
for a large set of previously computed LTE model atmospheres without a
necessity of recomputing all in NLTE. The standard input may also specify some
species as quasi-explicit; that is, their level populations are computed in
LTE (they are not a part of input NLTE level populations), but their bound-
free opacity is taken into account (see § 3.7.2).

The important point is that this option is switched on by setting the
parameter IBFAC, and which is one of the keyword parameters (see § 3.6.4), to
IBFAC$=2$.

Model input files:

Unlike the other options, here we have two input model files, and both have to
be present:

  * •

Usual fort.8 file, which in this case represents the input LTE model
atmosphere. If this file contains level populations, they will be disregarded.

  * •

File bfactors, which represents the output file fort.22 ($b^{\ast}$-factors)
from a previous tlusty run. An example is given later in § 7.2.3.

Atomic level populations:

They are computed in two steps:

  * •

First, LTE level populations are calculated for all non-excluded species (MODE
$\not=0$), based on the standard input, as for a typical LTE model.

  * •

Second, for levels specified as explicit (MODE=2) or semi-explicit (MODE=4),
their $b^{\ast}$-factors were read from the secondary input (NLTE) model—file
bfactors, and their actual level populations are calculated based on these
$b^{\ast}$-factors and the LTE level populations computed for the input LTE
model structure – see above.

Continuum opacity:

is computed as for a regular NLTE model, that is, the bound-free and free-free
opacities are calculated for all explicit, semi-explicit, and quasi-explicit
species.

Line opacity:

Again, it is computed as for a traditional NLTE model, that is, using NLTE
populations for explicit species, while LTE populations are adopted for semi-
explicit and quasi-explicit species, as described above.

##  4 Graphical user interface programs

As mentioned in Paper I, there are several useful graphical interface programs
for analyzing results from tlusty, as well as for running and making graphs
with the results from synspec.

###  4.1 Plotting output from tlusty

ł;abelguitlus

We will first describe current graphical interface programs for tlusty,
available both in the IDL and the Python languages.

####  4.1.1 IDL

As mentioned in Paper I, the standard sc tlusty/synspec distribution contains
two IDL programs, pconv.pro and pmodels.pro.. Examples of their usage are
presented in Paper III, § 6.1, and also here in Chap. 5.

The program pconv plots the contents of the convergence log, in file fort.9,
together with the file fort.7 that supplies the column mass coordinate, and
fort.69 that provides the timing information. The program may be called simply
as

    IDL>  pconv

in which case it assumes that the input files have their generic names,
fort.9, fort.7, and fort.69. If the file names were already modified, with a
common core name, for instance hhe35lt (as in one of the test examples
described later), namely hhe35lt.9, hhe36lt.7, and hhe35lt.69,pconv should be
invoked as follows

    IDL>  pconv,’hhe35lt’

An example of a plot generated using this command is presented in Fig. 1 of
Paper I.

The second basic program is pmodels.pro, It plots one state parameter at a
time for one or more tlusty model atmospheres, stored in unit 7. The first
positional parameter is a list of core names of models to be plotted, the 2nd
parameter is an index of the state parameter to be plotted (that is, the order
in which it appears on the unit 7 output, namely: $0=$ temperature, $1=$
electron density, $2=$mass density, etc. The 3rd positional parameter is 0 to
plot absolute values of the given state parameter; or 1 to plot the difference
of the state parameter relative to the first model. Finally, the 4th
positional parameter indicates that data should be overplot when it is set to
1. The program also accepts and passes along any intended keyword for the IDL
routine plot, its (their) action is, however, limited to the plot of the first
model. The plots show a state parameter as a function of $\log m$, $m$ being
the column mass. All state parameters, except temperature, are plotted as
logarithms.

For example, let hhe35lt.7 and hhe35nl.7 are two computed model atmospheres
(see § 5.2), To plot temperature for these two models, one issues the command

    IDL>  pmodels,[’hhe35lt’,’hhe35nl’]

To include temperature for another model, say hhe35nc’ on the same plot, one
issues

    IDL>  pmodels,[’hhe35nc’],0,0,1

An example of a plot generated by using these two commands is shown in Fig. 2
of Paper III

To plot a difference (in logarithms) of the mass density between the second
and the first model, one types

    IDL>  pmodels,[’hhe35lt’,’hhe35nl’],2,1

The program pmodels also works for the tlusty output files fort.12 and
fort.22,which store the $b$-factors and absolute $b^{\ast}$-factors,
respectively. For instance, to plot the $b$-factors of the ground state of
hydrogen for models hhe35nc and hhe35nl, one calls

    |DL>  pmodels,[’hhe35nc.12’,’hhe35nl.12’],3

where now one needs to put the full name of the files. Using just the core
names works only for the $\ast$.7 files.

####  4.1.2 Python

A new feature of the tlusty208 distribution is a development of the analogous
utility programs in PYTHON. The module tlusty.py contains the following
routines:

(1) pconv – for plotting the convergence log contained in the output from
tlusty, in this case from the files fort.9 and fort.69 only. The plot is quite
similar to that produced by the IDL program pconv.pro; the only difference is
that the relative changes are plotted as a function of depth index instead of
column mass.

(2) pmodel – extracting values of the column mass and a selected state
parameter from the tlusty output file fort.7 (condensed model), fort.12
($b$-factors for NLTE models), or fort.22 (absolute $b^{\ast}$-factors);

(3) pmodels – similar to pmodel, but with an option to plot selected state
parameter for one or more tlusty models, and a possibility of plotting
differences between individual models. This program is equivalent to the IDL
program pmodels.pro.

(4) pmods \- a plot of a range of state parameters for one or more tlusty
models.

(5) pflux \- a plot of the emergent spectrum, either from tlusty (unit 14 ),
or from synspec (units 7 or 17).

Here are some examples (in plain Python):

– To plot a convergence log of the last computed model:

    >>> import matplotlib.pyplot as plt
    >>> import numpy as np
    >>> import tlusty as tl
    >>> plt.ion()
    >>> tl.pconv()

$\bullet$ To plot a convergence log for a model hhe35lt

    >>> pconv(’hhe35lt’)

The resulting plot is shown in Fig.1.
$\bullet$ To extract log(column mass) and temperature for the same model

    >>> (m35,t35) = tl.pmodel(’hhe35lt’)

which can then be plotted or used for some other purpose.

Figure 1: Convergence log for the model hhe35lt. The upper three panels
exhibit the relative changes in temperature, and the lower three panels shows
the maximum relative change of all state parameters. The left panels show the
absolute values of the changes as a function of depth index, the middle panels
the same in the logarithmic scale, and the right panels the maximum of
relative changes at all depths as a function of iteration number. The title
contains the core name of the model, and the total computing time.

$\bullet$ To plot the temperature as a function of log(m) for the last
computed model,

    >>> tl.pmodels()

$\bullet$ And to plot the temperature for three models, hhe35lt, hhe35nc, and
hhe35nl, and then differences from the first model, do

    >>> tl.pmodels([’hhe35lt’,’hhe35nc’,’hhe35nl’])
    >>> tl.pmodels([’hhe35lt’,’hhe35nc’,’hhe35nl’],diff=True)

The actual results of these two commands are presented in Figs. 2 and 3. For a
better resolution, the first plot was obtained by adding two commands,

    >>> plt.xlim(-7,1)
    >>> plt.ylim(20000,40000)

Figure 2: Temperature [K] as a function of $\log m$ for three test H-He models
with $T_{\rm eff}=35,000$ K, $\log g=4$, namely hhe35lt – blue line, hhe35nc –
green line, and hhe35nl – red line. For details, refer to § 6.2. Figure 3:
Analogous to Fig. 2, but showing differences of temperature from the hhe35lt
model.

$\bullet$ To plot level populations for the first five levels of hydrogen for
the model hhe35nl,

    >>> tl.pmods(’hhe35nl’,np.arange(3,8))

The programs pmodel, pmodels, and pmods work also for tlusty output files
fort.12 and fort.22 that store the $b$-factors, and absolute
$b^{\ast}$-factors, respectively. One now needs to include the full file name,
not just the core name, e.g.,

    >>> tl.pmods([’hhe35nl.12’],np.arange(3,8))

The resulting plot is shown in Fig.4.

Figure 4: A plot of (traditional) $b$-factors for the first five levels of
hydrogen for the test H-He model hhe35nl.

$\bullet$ To plot the emergent spectrum for two models, say hhe35lt and
hhe35nl,

    >>> tl.pflux([’hhe35lt’,’hhe35nl’])

where, if no extension is specified, pflux assumes .14. One can also plot
relative differences (in percentage) of the second model from the first one,
$(F_{2}/F_{1}-1)\times 100$,

    >>> tl.pflux([’hhe35lt’,’hhe35nl’],rel=True)

###  4.2 Plotting output from synspec

Since the main output from synspec, the files fort.7 (synthetic spectrum), and
fort.17 (theoretical continuum), are simple files with two columns –
wavelength versus flux, plotting the results is trivial both in IDL as well as
PYTHON. However, since the input to synspec is relatively simple and
straightforward, we have created two packages that serve as a wrapper to
prepare the necessary input files, run the code, possibly perform rotational
and instrumental convolutions, and plot the results.

####  4.2.1 Synplot – an IDL wrapper

synplot is an IDL wrapper to perform all the tasks outlined above, plus
providing line identifications based on the output in fort.12. The program is
described in a separate document. However, it has been developed to work with
an older version of synspec. This original version of synplot, that works with
synspec39, together with the the source code of synspec39 and the users’s
guide, can be downloaded from

https://www.as.arizona.edu/$\widetilde{\,\,}\,$hubeny/pub/synplot2.1.tar.gz

There is a recent upgrade of synplot, developed by one of us (YO), which is
compatible with synspec54, and which works in IDL and GDL. The files are
available at

https://owncloud.iac.es/index.php/s/0CO8xQYTZXjJpxN

The individual files are as follows:

synplot.pro:

Is a wrapper for synspec, quite analogous to the original synplot mentioned
above. It creates all the necessary input files and links and perform a
calculation using synspec. The calculation can be a synthetic spectrum
(absolute flux, normalized, convolved, LTE, NLTE, with line identification,
etc.), or an opacity table. The name of the parameters follows the coding
using in this work. Calling synplot with no arguments prints the different
options of the routine. Similarly to the original synplot, it does not support
all functionalities of synspec, for instance it works with a specification of
line lists using fort.55, but not with the new input from fort.3.

loadopt.pro:

Loads an opacity table produced by synspec into IDL for testing and/or
modifications. The opacity table is loaded as a structure. The routine
printopt prints a preloaded opacity table, which has to be in text format.

plotspec:

The ”save” option in synplot, saves a series of files from a synspec
calculation. Those files are restored, and the spectrum is plotted with this
routine. This routine can also print labels for the lines, both atomic and
molecular, present in the synthetic spectrum. It can also label lines of a
particular element or a group of elements.

lineid

`_`annot.pro, `lineid_select.pro`: These are slight modifications of the
analogous routines present in the original synplot, used for an automatic
identification and labelling of predicted lines (written originally by D.
Lindler, NASA/GSFC).

convol.pro:

Performs a convolution of the spectrum with the rotational and/or instrumental
broadening.

####  4.2.2 Synple – a Python wrapper

Recently, one of us has developed a new Python code, synple.py. It is to some
extent analogous to synplot, although there are differences. In the present
version, it does not allow to use all functionalities of synspec, but again,
we plan to upgrade it soon.

Synple can take as input MARCS, Kurucz, Phoenix and Tlusty model atmospheres,
and is designed to be useful to researchers that are not experts in stellar
atmospheres and radiative transfer. It facilitates performing massive spectral
synthesis calculations for large grids, parallelizing the calculations over
multiple cores, using the python libraries multiprocessing or ray, and
multiple processors, setting up scripts to run Synspec on distributed-memory
computers.

The package can be downloaded from:

https://github.com/callendeprieto/synple

##  5 Downloading and installing the package

The procedure is similar to that described in detail in Paper I, Chap. 3,
albeit with some important differences. Here, we provide a brief description
as well, underlining possible differences from the 205 package.

Downloading the package proceeds in one or more steps, depending on the user’s
needs. The first file is the main one, which needs to be downloaded in any
case. In addition, there are several files that are optional, The reasons for
splitting the complete package into several files to download are the
following: (i) The additional files are large, which may cause problems in
downloading; (ii) long-time users may already have some or all of the
auxiliary files; and (iii) many applications do not require these files, so
for some users they would represent an unnecessary waste of computer memory
and downloading time.

The files can be downloaded form various sites. The original one, used before,
http://aegis.as.arizona.edu/$\ldots$, is no longer operational. The present
main site is the following:

https://www.as.arizona.edu/$\widetilde{\,\,}\,$hubeny/tlusty208-package

At this site, there are four files:

  1. 1.

The main file, tl208-s54.tar.gz; and three additional files:

  2. 2.

Line lists – linelist.tar.gz,

  3. 3.

Iron data – irondata.tar.gz, and

  4. 4.

Opacity tables – optables.tar.gz

We describe these files in turn.

###  5.1 Main file

The main file, which is sufficient for most purposes, is tl208-s54.tar.gz. It
can be downloaded interactively using any web browser; but we will use here
the wget command as an example, namely:

wget
https://www.as.arizona.edu/$\widetilde{\,\,}\,$hubeny/tlusty208-package/tl208-s54.tar.gz
Once it is obtained, one unpacks it, for instance as follows:

    tar xvfz tl208-s54.tar.gz

That action creates the directory ./tl208-s54, with several subdirectories.
Although the user can obviously choose any location for the files, we will use
in the following examples the directory tree that originates from the
tl208-s54.tar file extracted in a specific directory, created by the user. To
provide a useful guide for the implementation of the package, we encourage the
user to set up an environment variable, say TL208, that specifies such main
package directory. If the user sets such directory as, for instance,
$\widetilde{\,\,}$/tlusty208-package (just one layer below the home
directory), then it is useful to define TL208 as:
setenv TL208 $\widetilde{\,\,}$/tlusty208-package (in tcsh)
[or export TL208= $\widetilde{\,\,}$/tlusty208-package (in bash)].
We will use this convention in the following text.

Directory ./tl208-s54 also contains several shell scripts that work with the
directory tree thus generated. In the following text, we will refer to this
directory tree as the standard directory tree. If the user prefers, or has
already created, a different directory system, the provided script files have
to be modified accordingly. In any case, the test cases can be run either
individually, or all of them in one run.

The standard directory tree has the following structure: The main directory
./tl208-s54 contains the shell scripts RTlusty and RSynspec for running
tlusty, and synspec, respectively, and five subdirectories:

  * •

tlusty \- which contains the source file for the current version of tlusty,
called tlusty208.f, together with auxiliary files *.FOR;

  * •

synspec \- an analogous directory for synspec. It contains the source files,
plus the utility programs rotin and ngrid.

  * •

data \- a collection of needed atomic data. This is similar to the
subdirectory data contained in the tlusty205 distribution described in Paper
I, Chap. 3, but is more extended. It is described in more detail below.

  * •

tests \- The directory that provides the input and output files for various
test cases for running tlusty and synspec. It has two subdirectories:

    * –

tests/tlusty \- contains the shell script Runtest that runs all the tlusty
test cases, and five subdirectories for the test cases, described in § 6.2.
The test cases are analogous to the tests for tlusty205, except for the tests
of model construction using opacity tables, which are now different.

    * –

tests/synspec \- Analogously, the directory contains several subdirectories
for various test cases, described in § 7.2.

  * •

gui \- contains the graphical user interface programs described in § 4.

#### Contents of the “./tl208-s54/data” directory

The directory contains several kinds of files; some having just a historical
significance and being kept for comparison with older models.

  1. 1.

Original atomic data files. They are essentially the files that were used for
constructing grids of NLTE metal line-blanketed model atmospheres for O stars
(Lanz & Hubeny 2003) and B stars (Lanz & Hubeny 2007). The file names consist
of the name of the element and the ionization degree, possibly with an
information about the number of energy levels considered, and with the
extension “.dat”. For instance, `ne2_138lev.dat` is the data file for Ne II
with 138 energy levels included; this file was used in a detailed study of
neon by Cunha, Hubeny, & Lanz (2006).

  2. 2.

Extended atomic data files for selected neutral and once-ionized atoms, with
essentially all levels considered by the Opacity Project TopBASE dataset with
updated observed energies from NIST. The filenames consists simply of name of
the element and the ionization stage (1 corresponds to the neutral atoms),
with an extension “.t”. For instance, mg1.t contains the data file for Mg I,
with a 71-level model atom (Allende Prieto et al. 2003).

  3. 3.

Specific data files for photoionization cross-sections of iron-peak elements
(remember, the bound-free cross-section for other atoms/ions are contained in
the basic “*.dat” or “*.t” files.). These files have extension “.rap” (which
stands for resonance-averaged profiles; for details refer to Allende Prieto et
al. 2003) – for iron; or “.72” to “.76” – for nickel.

  4. 4.

Irwin-like partition function tables: `irwin_orig.dat` – the original Irwin
(1980) data; and `irwin_bc.dat` – a recent update based on results by Barklem
& Collet (2016).

  5. 5.

Subdirectory EXOMOL that contains 32 files for the partition functions of
molecules listed in § 3.3, namely AlO, C2, CH, CN, CO, CS, CaH, CaO, CrH, FeH,
H2, HCl, HF, MgH, MgO, N2, NH, NO, NS, NaH, OH, PH, SH, SiH, SiO, SiS, TiH,
TiO, VO; and H2O, H2S, and CO2.

  6. 6.

Tsuji-like molecular equilibrium data, that is, the fitting coefficients to
evaluate the equilibrium constants for all considered molecular species. The
file `tsuji.molec_orig` is the original Tsuji (1973) table; while the file
`tsuji.molec_bc2` is the improved table based on Barklem & Collet (2016)
results.

  7. 7.

Hydrogen line-broadening data: `tremblay_old.dat` and tremblay.dat; two
variants of the Tremblay & Bergeron (2009) broadening data; the latter file
contains data for more lines (first 20 lines of the Lyman and Balmer series,
first 19 lines of the Paschen, and the first 10 lines of the Bracket series),
in contrast to the old file, that contains data for only first 10 members of
the Lyman and Balmer series. There is also file lemke.dat that contains Lemke
(1997) line broadening data, and the file hydprf.dat with cross-sections by
Schoening & Butler (1989) that is kept for possible comparisons to older
models.

  8. 8.

Hydrogen quasi-molecular data, namely files laquasi.dat, lbquasi.dat, and
lgquasi.dat for the cross-sections of the L$\alpha$, L$\beta$, and L$\gamma$
satellites, respectively. For details, refer to Paper I, § 12.1.2.

  9. 9.

Helium line broadening data; files he1prf.dat, and he2prf.dat. For details and
references, refer to Paper I, Appendix A. Briefly, for He I, he1prf.dat
contains data for four triplet lines, $\lambda\lambda$ 4026, 4387, 4471, and
4921 Å, after Barnard et al. (1974) and Shamey (1969). For He II, file
he2prf.dat contains data for the lines 2–3, 3–4 to 3–10, and 4–5 to 4–15,
after Schoening & Butler (1989).

  10. 10.

Collision-induced absorption (CIA) data for the four CIA processes: H2–H2
collisions (`CIA_H2H2.dat`), H2–He collisions (`CIA_H2HE.dat`), H2–H
collisions (`CIA_H2H.dat`), and H–He collisions (`CIA_HHE.dat`). The
corresponding references are given in Table 1.

  11. 11.

File linelist.test that contains a sample atomic line list for performing
simple tests of synspec.

  12. 12.

Last, but not least, three important script files, called Linklist, Linkiron,
and Linkopta, which set the necessary symbolic links from the additional files
(see below) to the data directory, where they can be easily accessed by tlusty
and/or synspec.

###  5.2 Additional files

As explained above, extensive line lists, the data for iron lines used to
generate metal line-blanketed models, and the opacity tables for usage in
tlusty, are not a part the ./tl208-s54 directory.. For some purposes they may
not be needed, or some users may perhaps already have these or analogous
files. However, to run the tlusty and synspec test cases described in §§ 6.2
and 7.2 they are needed, and thus should be downloaded separately to the main
package directory, referenced through the environment variable TL208, as
described above.

In all three cases, upon extracting each file one gets a subdirectory that
contains the appropriate files. The users who already have these files, or
some of them, have to provide the corresponding links themselves.

####  5.2.1 Line lists

The tarball with the line lists, called linelists.tar.gz can be obtained from
the source listed above. It should then be extracted

    tar xvfz linelist.tar.gz

which generates a subdirectory ./linelist which contains the three line lists
described below, plus the programs list2bin, and redulis, and the script file
Bin. The two molecular line lists are already reduced, using the utility
program redulis described above with a rejection parameter $s_{\rm
reject}=-8.5$ – see Appendix G. More extended molecular line lists are
available upon request. The line lists that are distributed in the present
package are:

  * •

gfATO.dat, which is the atomic line list in the extended format (that is,
containing additional quantum numbers). It contains data for about $2.3\times
10^{6}$ lines between 18 Å and 100 microns. The list is based on Kurucz
data232323http://kurucz.harvard.edu/linelists.html, updated by NIST
data242424https://www.nist.gov/pml/atomic-spectra-database whenever available.

  * •

gfMOL.dat \- line list for 18 most important diatomic molecules, containing
about $6\times 10^{6}$ lines. As mentioned above, the data are based on Kurucz
datasets for molecular lines.

  * •

gfTiO.dat \- line list for TiO, containing data for about $8.3\times 10^{6}$
lines. This list is based on EXOMOL data. A more extended list extracted from
EXOMOL data, from which this list was obtained, contains information for about
$10^{8}$ lines. Again, more detailed versions available upon request, but we
believe that for most practical purposes the present list is sufficient.

Since it is recommendable to work with binary files instead of text files,
because synspec works significantly faster with them, the script Bin generates
the binary equivalents of the three lists. Before using the script Bin, one
needs to compile list2bin, for instance as

    gfortran -o list2bin.exe list2bin.f

Once this is done, one may go to the standard “data” directory, for example
./tl208-source/data, and use the script Linklist to provide links from the
directory where the line lists are located to the “data” directory. Before
running Linklist, one has to set up the environment variable LINELIST to the
directory where the line lists are located. For instance, if the file
linelist.tar.gz was downloaded to and extracted in the main package directory,
then one sets the environment variable and runs the script as
setenv LINELIST $TL208/linelist  (in tcsh),
[or export LINELIST=$/TL208/linelist  (in bash)]
Linklist
We stress that this is not necessary from the point of view of an operation of
synspec, but it is advantageous to set up the test cases in an unambiguous
way.

We also mention that the standard ”data” directory also contains a very short
sample line list and therefore some tests of synspec can be done without
above-mentioned extensive line lists. Additional line lists in the tlusty-
compatible format, as well as some atomic data files and various model
atmospheres, are also
available.252525https://owncloud.iac.es/index.php/s/6x5mRhXj7Ekyc9H

####  5.2.2 Iron data

The data are the same as those mentioned in Paper I, § 3.3. The users who
already have them do not need to download them again, only to link them to the
current standard ”data” directory. For the users who do not have them, and who
intend to compute NLTE metal line-blanketed model atmospheres for early-type
stars, as shown on the test case presented in Paper I, Chap. 6, in Paper III,
§ 6.3, and here in § 6.2, need to acquire these data, again from the source
mentioned above. The corresponding file is irondata.tar.gz, and its content is
similar but more extended than that of the old file gf26.tar.gz, It is
extracted it as before,

    tar xvfz irondata.tar.gz

As a results, a subdirectory ./irondata is created containing several files
that represent Kurucz data files for iron levels and transitions, the files
gf2600.gam to gf2608.gam, and gf26*.lin from which tlusty generates necessary
parameters for iron superlevels and superlines - see Paper II, § 3.6.
Analogously to the case of line lists, one should go to the standard “data”
directory, and set the links to these files. Unlike the case of line lists,
these links are now mandatory. The procedure is analogous: one needs to set
the environment variable IRON to the directory where the downloaded iron data
are located, and then run the script Linkiron. We stress that the users who do
not intend to compute NLTE metal line-blanketed model atmospheres do not need
to download and store the iron data.

We stress that besides these data for iron ions that are used to construct
superlevels and superlines (Hubeny & Lanz 1995; Hubeny & Mihalas 2014), the
standard “data” directory also contains data for Fe I and Fe II where the
usual treatment of levels and transitions is adopted.

####  5.2.3 Opacity tables

Upon extracting the optables.tar.gz tarball, one obtains a subdirectory called
./optables that contains two new opacity tables, `optab11_7f.dat` – the full
table for the opacity of all species, and `optab11_7hmc.dat` – the table that
excludes the opacity of H, Mg, and Ca. These files can also be obtained by
running one of the test cases for synspec – see § 7.2.1, but are included for
convenience, and also because their evaluation is relatively time-consuming
(taking about 27 and 31 minutes, respectively, on an iMac with a 3.4 GHz Intel
Core i5 CPU). Again, one then goes to the standard “data” directory, and uses
the script Linkopta to make symbolic links to these files in the standard
“data” directory. Again, in order to use the script Linkopta, one first needs
to set the environment variable OPTABLES to the directory where the opacity
tables are located.

The files are used in the test cases for running tlusty with the Opacity
Tables, as described in § 6.2.2.

###  5.3 Summary of implementation

Here we summarize all the steps necessary for a successful implementation of
tlusty and synspec. For simplicity we assume that the reader needs all the
available additional files. If not, the user should make the corresponding
changes.

  1. 1.

Create a convenient main package directory, and set up the environment
variable TL208 that specifies the name of the directory. For instance, if the
user sets such directory as $\widetilde{\,\,}$/tlusty208-package (just one
layer below the home directory), then TL208 is set up as:
setenv TL208 $\widetilde{\,\,}$/tlusty208-package (in tcsh),
or
export TL208= $\widetilde{\,\,}$/tlusty208-package (in bash).

  2. 2.

Go to this directory, (i.e. cd $TL208), and download the main file, plus the
additional files, there. This is done either interactively, going to

https://www.as.arizona.edu/`~`hubeny/tlusty208-synsp54

and get the files tl208-s54.tar.gz, linelist.tar.gz, irondata.tar.gz, and
optables.tar.gz
or, analogously, using command wget,
wget https://www.as.arizona.edu/`~`hubeny/tlusty208-synsp54/tl208-s54.tar.gz
and similarly the other files.

  3. 3.

Extract all the downloaded files
tar xvfz tl208-s54.tar.gz
tar xvfz linelist.tar.gz
tar xvfz irondata.tar.gz
tar xvfz optables.tar.gz

  4. 4.

Set up the environment variables corresponding to all downloaded files

in tcshell: | in bash:
---|---
setenv TLUSTY $TL208/tl208-s54 |  export TLUSTY=$TL208/tl208-s54
setenv LINELIST $T208/linelist |  export LINELIST=$TL208/linelist
setenv IRON $TL208/irondata |  export IRON=$TL208/irondata
setenv OPTABLES $TL208/optables |  export OPTABLES=$TL208/optables

  5. 5.

Go to the directory ./linelist and compile program list2bin, e.g. as
gfortran -o list2bin.exe list2bin.f

  6. 6.

Run the script ./Bin in the same directory.
To be on the safe side, do ls to verify the the “*.bin” files were indeed
created.

  7. 7.

Go now to the directory ../tl208-s54/data (using the environment variable
TLUSTY the command would simply be cd $TLUSTY/data) and run the three linking
scripts:

        ./Linklist
    ./Linkiron
    ./Linkopta

If the environment variables LINELIST, IRON, and OPTABLES were set properly, a
bunch of new files (actually links) will appear in this directory, (gf*, and
optab*).

  8. 8.

Go to the directory $TLUSTY/tlusty, and compile tlusty, e.g., as
gfortran -fno-automatic -O3 -o tlusty.exe tlusty208.f
or, if needed, as
gfortran -fno-automatic -mcmodel=large -o tlusty.exe tlusty208.f
For more details, see below.

  9. 9.

Go to the directory ../synspec, and compile synspec analogously:
gfortran -fno-automatic -O3 -o synspec.exe synspec54.f
or, similarly, as
gfortran -fno-automatic -mcmodel=large -o synspec.exe synspec.f
Again, for details, see below.

This essentially concludes the basic implementation. In order to perform the
tests, one can simply do:

  1. 1.

cd $TLUSTY/tests/tlusty, and run all tests by simply issuing command
Runtest
One then can go to the individual subdirectories and examine the results.

  2. 2.

Analogously, one then can run the synspec tests by
cd $TLUSTY/tests/synspec, issue the command Runtest there, and again examine
the results in all subdirectories.

A detailed explanation of the test cases is provided below.

##  6 Compiling, testing, and running TLUSTY

###  6.1 Source code files and compilation

The program is distributed as a single file that contains all subroutines,
plus several (8) small files referred to in the tlusty source file by INCLUDE
statements, which declare most variables and arrays. These can be changed to
recompile the code and decrease or increase its memory consumption, as
explained in Paper III, § 2.1. All files should reside in the same directory.

The compilation of the program is explained in more detail in Paper III, §
2.1, where the compiler instructions on different platforms are summarized.
Here we only illustrate the compilation using gfortran, which is available on
most Mac and LINUX platforms,

            gfortran -fno-automatic [-O3] -o tlusty.exe tlusty208.f

where the option "-fno-automatic" indicates the static allocation of memory.
The level-3 optimization ("-O3") should be switched on since it improves the
performance of the code considerably. For more details, and several examples
of compiling the program on different platforms, refer to Paper III, § 2.1.

Compared to the standard distribution of tlusty205, the present one is set up
to allow for model atmospheres with a large number of explicit levels
(MLEVEL=1134), frequency points (MFREQ=135000), and a relatively large number
of depth points (MDEPTH=100), which are the parameters in the current file
BASICS.FOR. As a consequence, the executable file takes about 2.75 GB.
Although it is large, this is now acceptable for most modern computers. As
explained in Papers I and III, if this presents a problem, users who do not
intend, for instance, to compute sophisticated NLTE metal line-blanketed model
atmospheres, similar to the grids OSTAR2002 and BSTAR2006 (Lanz & Hubeny 2003,
2007) can decrease MLEVEL, or possibly MFREQ, to appropriate values.

Even for computers with large enough memory, some compilers do limit the
individual COMMON blocks to a certain size, the part of the memory known as
the stack. In particular, the COMMON block CURDER, referred to in the file
MODELQ.FOR, contains four 2-dimensional arrays MLEVEL $\times$ MDEPTH, which,
for the present parameters, may be too large for certain compilers. In this
case one needs to compile the program as262626I.H. is indebted to Jano Budaj
for alerting him about this possibility.

    gfortran -fno-automatic -mcmodel=large -o tlusty.exe tlusty208.f

###  6.2 Test cases for tlusty

As mentioned earlier, the standard tlusty directory contains a subdirectory
$TLUSTY/tests/tlusty, which in turn contains five subdirectories for five
different test cases:

  * •

hhe – a simple H-He LTE and NLTE model atmosphere - see Paper III, § 6.2. This
test is analogous to that for tlusty205, yet the results are slightly
different due to changes in setting the default values of some keyword
parameters. In particular, the present case takes into account Rayleigh
scattering on neutral hydrogen and helium, while the tlusty205 test did not.

  * •

bstar – a NLTE metal line-blanketed model of a B stars, analogous to models in
the bstar2006 grid (Lanz & Hubeny 2007); just a formal solution without any
global iterations – see Paper III, § 6.3. Again, the results are slightly
different for the same reasons as for the H-He models.

  * •

cwd – an LTE and NLTE model of a moderately cool DA (pure-hydrogen) white
dwarf - see Paper III, § 6.5. The results are now appreciably different from
the analogous test performed for tlusty205 because of an improved evaluation
of the adiabatic gradient to describe the convective flux. Also, the keyword
parameter file was somewhat modified with respect to that used with tlusty205.

  * •

disk \- a simple H-He LTE and NLTE model of a vertical structure of an
accretion disk - see Paper III, § 6.6. Similarly to the H-He test case, the
results are here slightly different due to an automatic inclusion of the
Rayleigh scattering.

  * •

optab – tests involving an opacity table, with both a full table and a partial
table. The full table mode is demonstrated on an LTE line-blanketed model of a
G star. This test case is similar to that discussed in Paper III, § 6.4; only
here we use new, very simple, opacity tables, `optab11_7f.dat` and
`optab11_7hmc.dat`, which can be obtained by running one of the test cases for
synspec – see § 7.2.1. These test opacity tables are included as well in the
additional tarball, optables.tar.gz – see § 5.2.3. The directory also contains
input files for two new NLTE models, which will be described in more detail
below.

All subdirectories contain (i) input data for a run, (ii) an AAAREADME file
with a short description of the tests; (iii) a script file R1 to run all the
tests, and (iv) a subdirectory named ./results that contains several important
output files obtained by running the test cases on an iMac (macOS Mojave,
10.14.2, with 3.4 GHz Intel Core i5 CPU) done by one of us (I.H.), which are
included to enable a comparison with user’s runs for the purpose of checking
the implementation of the codes on the user’s platform.

Important notes:

  * •

In order to use the provided script Runtest, or the individual R1 scripts
located in the individual subdirectories, it is mandatory to set up the
environment variable TLUSTY to the main tlusty/synspec directory, as specified
above.

  * •

The script Runtest, located in the $TLUSTY/tests/tlusty directory, is devised
to run all the available tests in a row. One can also do that manually, i.e.
to go consecutively to the individual subdirectories and to use scripts R1, or
to use the basics script RTlusty.

  * •

The basic script for running tlusty, called RTlusty, performs most of the
tasks needed to run the code. It accepts up to two formal parameters:
– the core name of the model to be computed;
– the core name of the starting model. If it is missing, then the model is
assumed to be computed from scratch.
The file with the core name and extension .5, typically the standard input to
tlusty, must be present; otherwise the script stops. Similarly, if the core
name of the starting model is present then the file with this core name plus
extension .7 must be present as well.
The script then establishes a symbolic link to the ./data directory, runs
tlusty, and copies some of the output files to the core name plus the
corresponding extension. As explained in Papers I and III, these files are:
– [core name].6 – standard output
– [core name].7 – condensed model
– [core name].9 – convergence log
– [core name].14 – emergent flux $F_{\lambda}$
– [core name].69 – timing

  * •

In some cases (disk models; using opacity tables), one needs to have
additional input files, for instance file fort.1 that sets the disk mode, or
fort.15 that specifies the name of the opacity table. One can still use the
script RTlusty, but before running it the user has to make sure that the
additional input files are copied or linked properly. The user is encouraged
to look inside the script file Runtest that provides an actual demonstration
how to use the script RTlusty.

  * •

There is an analogous script RSynspec for running synspec, but this one is
most useful for computing synthetic spectra of hot and warm stars, where only
an atomic line list is used. Its usage is demonstrated on some of the test
cases in the directory $TLUSTY/tests/synspec.

####  6.2.1 Standard model atmospheres and disks

As explained above, the subdirectories hhe, cwd, and bstar contain three test
cases for typical model atmospheres, with increasing complexity, and the
subdirectory disk a very simple model of one annulus of an accretion disk.
These models are discussed in detail in Paper III, Chap. 6. There are also
individual AAAREADME files in each directory that summarize the basic
properties of the test models.

####  6.2.2 Tests involving an opacity table

There are three test cases here. One involves computing an LTE model
atmosphere from scratch using a full opacity table (g55l), and two NLTE models
that use this LTE model as a starting one, namely
– g55nres – a restricted NLTE model; that is a model in which the structure
(temperature, density, electron density) is held fixed, and one computes NLTE
level populations of H, Mg, and Ca levels, using a reduced opacity table that
excludes these elements. The model is computed using the standard Complete
Linearization/Accelerated Lambda Iteration (CL/ALI) method (see Paper II,
Paper III, and Hubeny & Lanz 1995);
– g55nryb – a similar model that computes a full NLTE model in which
departures form LTE are allowed for H, Mg, and Ca, but where also the model
structure is allowed to change as a response to NLTE effects in these species.

The background philosophy and adopted procedures to calculate these models
were explained in § 2.2.3. Here, we describe the contents of the standard
input file and the keyword parameter files in some detail. We also stress that
we use here relatively simple model atoms of Mg and Ca, in order to provide a
fast and inexpensive test run of tlusty. The resulting model is meant only as
a test of performance of the code, not as a model that can be used for actual
spectroscopic diagnostics work, For such purposes, the user is encouraged to
use more detailed model atoms, which are also available in the ./data
directory. Similar NLTE calculations, using much more detailed model atoms,
not only for Mg and Ca, but also for Na and K, were recently presented by
Osorio et al. (2020).

The LTE model, g55l, is generated using the standard input file g55l.5, with
the following content:

    --------------------------------------------------
    5500. 4.5        ! TEFF, LOG G
     T  T            ! LTE,  LTGRAY  (LTE model from scratch)
     ’g55l.param’    ! name of file containing non-standard flags
    *
    * frequencies
    *
      0                ! frequencies taken from the opacity table
    *
    * data for atoms
    *
     30      ! NATOMS  (all first 30 species taken into account in EOS)
    * mode abn modpf
        1   0.      0  ! H
        1   0.      0  ! He
        1   0.      0  ! Li
        1   0.      0  ! Be
        1   0.      0  ! B
        1   0.      0  ! C
        1   0.      0  ! N
        1   0.      0  ! O
        1   0.      0  ! F
        1   0.      0  ! Ne
        1   0.      0  ! Na
        1   0.      0  ! Mg
        1   0.      0  ! Al
        1   0.      0  ! Si
        1   0.      0  ! P
        1   0.      0  ! S
        1   0.      0  ! Cl
        1   0.      0  ! Ar
        1   0.      0  ! K
        1   0.      0  ! Ca
        1   0.      0  ! Sc
        1   0.      0  ! Ti
        1   0.      0  ! V
        1   0.      0  ! Cr
        1   0.      0  ! Mn
        1   0.      0  ! Fe
        1   0.      0  ! Co
        1   0.      0  ! Ni
        1   0.      0  ! Cu
        1   0.      0  ! Zn
    *
    * data for ions
    *
    * no explicit atoms, ions, levels
    *iat   iz   nlevs  ilast ilvlin  nonstd typion  filei
    *
       0    0     0     -1      0      0    ’    ’ ’ ’
    *
    ---------------------------------------------------

The first line specifies $T_{\rm eff}$ and $\log g$; the second line
stipulates that an LTE model is going to be calculated, with no starting
model, so that the present model is calculated from scratch. The third line
specifies the name of the keyword parameter file. The reader is reminded that
lines starting with an asterisk (*) represent comments. The next executive
line, 0, says that the frequency points are taken from the opacity table. The
next block of lines sets all first 30 chemical species to MODE=1, i.e. they
are taken into account for the equation of state, but not for opacities
(because all opacity is given through the opacity table). All abundances are
the standard solar ones. There are no explicit atoms, ions, or levels.

As specified in g55l.5, the name of the file containing keyword parameters is
g55l.param, that has the following content:

    ---------------------------------------------------
    IOPTAB=-1,IFRYB=1,IFMOL=1,IDLST=0,IFRAYL=1
    HMIX0=1,ITEK=50,IACC=50,IFRSET=30000
    TAUFIR=1.e-7,TAULAS=1.0e2,TAUDIV=0.01
    ---------------------------------------------------

which have the following meaning (see also Paper III, § 7.10.3):
$\bullet\,$ IOPTAB=$-1$ – sets the mode of evaluation of opacities to using
the pre-calculated full opacity table, but with solving the equation of state
and evaluating the thermodynamic parameters on the fly.
$\bullet\,$ IFRYB=1 – sets the global iteration method to the Rybicki scheme.
As mentioned above, this scheme works very well for LTE models of cool stars,
and in particular when convection is present.
$\bullet\,$ IFMOL=1 – stipulates that molecules are included in the equation
of state, as is of course mandatory for such low-temperature models.
$\bullet\,$ IDLST=0 – sets the proper treatment of the energy equation at the
lower boundary. This option has to be used in conjunction with IFRYB=1 or 2.
$\bullet\,$ IFRAYL=1 – switches on an on-the-fly evaluation of the H, He, and
H2 Rayleigh scattering opacity.
$\bullet\ $ HMIX0=1 – switches on the convection, with the mixing length equal
to 1 pressure scale height.
$\bullet\,$ ITEK=50, IACC=50 – inhibits both Kantorovich and Ng acceleration
(that is, they would start at 50th iteration, but the total default number of
global iterations is 30). This option is safer when dealing with convective
models.
$\bullet\,$ IFRSET=30000 – sets the number of frequency points selected from
the opacity table, which in this case has 100,000 frequencies. For details,
refer to § 2.4.
$\bullet\,$ TAUFIR=1.e-7,TAULAS=1.0e2 – sets the minimum and maximum Rosseland
optical depth when computing the starting LTE-gray model. In fact, TAUFIR does
not have to be set because 1.e-7 is the default anyway. The model can easily
be computed also with the default TAULAS (3.16e2), but one would go to
unnecessary large depths in the atmosphere, which are inconsequential for the
bulk of the atmospheric structure and the emergent radiation.
$\bullet\,$ TAUDIV=0.01 – sets the division point for treating the
radiative/convective equilibrium equation to 0.01. This setup is a usual
choice if a model is computed using the Rybicki scheme.
Other keyword parameters, that were set for an analogous model considered in
Paper III, § 6.4, are not necessary here because the default values of those
parameters are sufficient.

Both NLTE models, g55nres and g55nryb, treat the opacity of all species
besides H, Mg, and Ca, through an opacity table, while the level populations
of H, Mg, and Ca are treated in NLTE. As mentioned above, g55nres is a so-
called “restricted NLTE” model where the temperature, density, and electron
density are held fixed at the values for the input model (in this case g55l),
and one solves for NLTE level populations of H, Mg, and Ca.

The standard input files for these two models are almost identical, differing
only in the name of the keyword parameter file. For convenience, we show their
content below:

    --------------------------------------------------
    5500. 4.5        ! TEFF, LOG G
     F  F            ! LTE,  LTGRAY  (NLTE model)
     ’nres.param’    ! or ’nryb.param’ - keyword files
    *
    * frequencies
    *
     50                ! additional frequencies
    *
    * data for atoms
    *
     30      ! NATOMS  (all first 30 species taken into account in EOS
    *                   H, Mg, and Ca explicit)
    * mode abn modpf
        2   0.      0  ! H - expl
        1   0.      0  ! He
        1   0.      0  ! Li
        1   0.      0  ! Be
        1   0.      0  ! B
        1   0.      0  ! C
        1   0.      0  ! N
        1   0.      0  ! O
        1   0.      0  ! F
        1   0.      0  ! Ne
        1   0.      0  ! Na
        2   0.      0  ! Mg - expl
        1   0.      0  ! Al
        1   0.      0  ! Si
        1   0.      0  ! P
        1   0.      0  ! S
        1   0.      0  ! Cl
        1   0.      0  ! Ar
        1   0.      0  ! K
        2   0.      0  ! Ca - expl
        1   0.      0  ! Sc
        1   0.      0  ! Ti
        1   0.      0  ! V
        1   0.      0  ! Cr
        1   0.      0  ! Mn
        1   0.      0  ! Fe
        1   0.      0  ! Co
        1   0.      0  ! Ni
        1   0.      0  ! Cu
        1   0.      0  ! Zn
    *
    * data for ions
    *
    *iat   iz   nlevs  ilast ilvlin  nonstd typion  filei
    *
       1   -1     1      0     0     0    ’ H- ’ ’data/hmin.dat’
       1    0     9      0     0     0    ’ H 1’ ’data/h1.dat’
       1    1     1      1     0     0    ’ H 2’ ’ ’
      12    0     41     0     0     0    ’Mg 1’ ’data/mg1.t’
      12    1     25     0     0     0    ’Mg 2’ ’data/mg2.dat’
      12    2     1      1     0     0    ’Mg 3’ ’ ’
      20    0     15     0    90     0    ’Ca 1’ ’data/ca1.t’
      20    1     18     0    90     0    ’Ca 2’ ’data/ca2.t’
      20    2     1      1     0     0    ’Ca 3’ ’ ’
       0    0     0     -1     0     0    ’    ’ ’ ’
    *
    ---------------------------------------------------

The restricted NLTE model, g55nres has the keyword parameter file called
nres.param which has the following content:

    ---------------------------------------------------
    IOPTAB=1,IFRYB=0,IFMOL=1,IFIXMO=1
    IFRSET=30000
    NLAMBD=4
    ---------------------------------------------------

where
$\bullet\,$ IOPTAB=$1$ – sets the mode of model construction to the hybrid
NLTE/Opacity Table – see § 2.2.1.
$\bullet\,$ IFRYB=0 – sets the standard CL/ALI linearization scheme (not the
Rybickl scheme). This is a default, so in fact it need not be specified. We
include it here for the sake of clarity.
$\bullet\,$ IFMOL=1 – as before, sets the inclusion of molecules.
$\bullet\,$ IFIXMO=1 – is a shorthand to specifying INHE=0, INRE=0, INPC=0
that stipulates that the hydrostatic, radiative/convective, and charge
equilibrium equations are not solved, and thus the temperature, density and
electron density are held fixed at the starting values.
$\bullet\,$ IFRSET=30000 – as before, sets the number of frequencies selected
from the opacity table to 30,000.
$\bullet\,$ NLAMBD=4 – sets the number of “Lambda” iterations of the formal
solution to 4. This somewhat improves the overall convergence behavior.

Finally, model g55nryb computes s self-consistent model, where not only the
level populations of H, Mg, and Ca are treated in NLTE, but also the self-
consistent model structure (temperature, density, electron density) is solved
for. The corresponding keyword parameter file nryb.param has the following
structure:

    ---------------------------------------------------
    IOPTAB=1,IFRYB=2,IFMOL=1,IDLST=0
    ITEK=15,IACC=10,IFRSET=30000
    HMIX0=1,TAUDIV=0.01
    NLAMBD=8,CHMAX=1.e-5
    ---------------------------------------------------

The meaning of the parameters is obvious, or was explained before. Notice
that, as discussed at length in § 2.2.3, it is important to use a large number
of “Lambda” iterations, NLAMBD (set here to 8) and a relatively very low
convergence parameter CHMAX (set here to 1.e-5). Also, since NLTE effects in
H, Mg, and Ca do not not likely change the temperature structure
significantly, it is now safe to switch on the acceleration schemes - the
Kantorovich acceleration in the 15th iteration – ITEK=15, and the Ng
acceleration at the 10th iteration, ITEK=10. This could perhaps be done even
earlier, but we did not explore this issue any further since the computing
time is already reasonably low in the present setup.

##  7 Compiling, testing, and running SYNSPEC

###  7.1 Source code files and compilation

As for tlusty, the program is distributed as a single file that contains all
subroutines, plus several (6) small files referred to in the synspec source
file by INCLUDE statements which declare most of variables and arrays. These
can be used to recompile the code and adjust memory consumption, as explained
in Paper III, § 2.1. All files should reside in the same directory.

The compilation of the program is explained in more detail in Paper III, §
2.1, where the compiler instructions on different platforms are summarized.
Here we only show a compilation using gfortran, which is available on most Mac
and LINUX platforms,

            gfortran -fno-automatic [-O3] -o synspec.exe synspec54.f

or, for some computers and/or compilers with limited size for the COMMON
blocks,

    gfortran -fno-automatic -mcmodel=large -O3 -o synspec.exe synspec54.f

Here, the option "-fno-automatic" indicates the static allocation of memory.
The level-3 optimization ("-O3") should again be switched on since it improves
the performance of the code considerably. For more details, and several
examples of compiling the program on different platforms, refer to Paper III,
§ 2.1.

Analogously as for tlusty, some arrays are quite big and may cause problems
for some computers and/or compilers. The critical arrays are those containing
data for molecular lines. There are several arrays MLINM0$\times$MMLIST,
located in the “include” file LINDAT.FOR. Here, MLINM0 represents the maximum
number of lines extracted from a given molecular line list, at present set to
MLINM0=9000000 and MMLIST, the maximum number of molecular line lists,
presently set to MMLIST=3. The users who do not intend to work with molecular
lines, can safely change the parameter MLINM0=2 and MLINM=2, which leads to a
significant decrease of the memory taken by the executable file.

On the other hand, when working with larger molecular line lists, one should
set MLINM0 and MLINM to larger values. We have therefore provided the file
`LINDAT.FOR_big` which can be used for the original, large, lists, but to run
synspec with these parameters one needs a computer with at least 8GB of RAM.

###  7.2 Test cases for synspec

There are six test cases for synspec; three of them being analogous to those
used for version 51 and described in Paper I, and three new cases that
demonstrate the construction of a simple opacity table, using synspec for
computing spectra for models that were constructed using opacity tables, and
for computing pseudo-NLTE spectra.

The relevant files are stored in the subdirectory $TLUSTY/tests/synspec, which
has six subdirectories:

  * •

hhe – a sample synthetic spectrum for a simple H-He model, analogous to that
considered for synspec51 – see Paper I, § 5.7;

  * •

bstar – a sample synthetic spectrum for a NLTE metal line-blanketed model,
again analogous to that considered for synspec51 – see Paper I, § 5.7;

  * •

kurucz – sample synthetic spectra for two Kurucz models, similar, but extended
with respect to those considered for synspec51 – see Paper I, § 5.7;

  * •

hybrid – computing a synthetic spectrum for a hybrid Opacity Table/NLTE model
atmosphere, described in detail in § 7.2.3.

  * •

pseudonlt – a test of computing a pseudo-NLTE spectrum, where the input model
is a Kurucz model with $T_{\rm eff}=5500$ K, $\log g=4.5$, but the NLTE level
populations of H, Mg, and Ca, expressed through the absolute
$b^{\ast}$-factors, are taken from the previously computed model g55nres (one
of the test cases for tlusty). These $b^{\ast}$-factors are communicated to
synspec in an input file named bfactors, which is a copied from the output
file fort.22 generated when computing the model g55nres. The details are
explained in § 3.8.3,

  * •

optab – a test of constructing an opacity table, described in more detail in §
7.2.1.

Analogously to the test cases for tlusty, all subdirectories contain (i) input
data for a run, (ii) an AAAREADME file with a short description of the tests;
(iii) a script file R1 to run all the tests here, and (iv) a subdirectory
named ./results that contains several important output files obtained by
running the test cases on an iMac (macOS Mojave, 10.14.2, with 3.4 GHz Intel
Core i5 CPU) done by one of us (I.H.), included to enable a comparison with
user’s runs for checking the installation on the user’s platform.

The directory $TLUSTY/tests/synspec also contains a script file Runtest,
analogous to that for tlusty, that runs all the tests in the first five
subdirectories consecutively. The tests specified in the subdirectory optab
are not included in Runtest, They should be executed, if desired, separately.
The reason is that the runs are somewhat time-consuming, so they would make a
quick testing of the implementation of the code cumbersome.

####  7.2.1 Tests of constructing an opacity table

An example of a construction of a simple, yet realistic, opacity table, is
located in the directory $TLUSTY/tests/synspec/optab. This directory contains
the input files needed for generating an opacity table with 100,000 wavelength
points, set logarithmically equidistant between 900 and 110,000 Å, for 11
temperatures, spaced logarithmically between 3,000 and 15,000 K, and 7
densities, spaced between $10^{-12}$ and $10^{-6}$ g cm-3. This is specified
in the file `optab11_7f.2`, located in the directory. This file should be
copied to fort.2, as explained in detail in § 3.2.1. Additional input files
located in this directory are tab.5, a standard input file that in this case
specifies the continuum opacities, together with the corresponding keyword
parameter file tab.nst, and `optab11_7f.55`, which should be copied to fort.55
as explained in § 3.2. As specified in the file fort.2, the resulting opacity
table is called `optab11_7f.dat`. This file should be identical, or nearly
identical, to the file of the same name downloaded as part of the optables.tar
tarball. For convenience, we show the corresponding fort.2:

    -----------------------------------
    11   3000. 15000.
    1
    7  1.e-12 1.e-6
    100000  0  900  110000
    ’optab11_7f.dat’  0
    ------------------------------------

Here we used the label “f” in the name of the resulting file to signify the
“full” table (including opacities of all species).

In this case it is not advantageous to use the script file RSynspec, but
rather to run a test using the corresponding script file R1, located in the
directory as well. Its first part looks like this:

    ln -s -f $TLUSTY/data data
    ln -s -f $TLUSTY/data/gfATO.bin gfATO.bin
    ln -s -f $TLUSTY/data/gfMOL.bin gfMOL.bin
    ln -s -f $TLUSTY/data/gfTiO.bin gfTiO.bin
    cp optab11_7f.2 fort.2
    cp optab11_7f.3 fort.3
    cp optab11_7f.55 fort.55

    $TLUSTY/synspec/synspec.exe <tab.5 > optab11_7f.6
    cp fort.29 optab11_7f.29
    cp fort.69 optab11_7f.69
    cp fort.51 optab11_7f.51
    cp fort.52 optab11_7f.52
    cp fort.53 optab11_7f.53
    cp fort.54 optab11_7f.54

The input file `optab11_7f.3` have to be copied to fort.3, specifies the line
lists to be used. We use all line lists in binary format, which speeds up the
calculations considerably. The file looks like this:

    -----------------------------------
    ’gfATO.bin’     1
    ’gfMOL.bin’     1     8000.
    ’gfTiO.bin’     1     5000.
    ------------------------------------

We stress that in order to be able to use this script that uses the binary
line lists, one has to make sure that they are properly created and linked to
the “data” directory, as explained in Sec. 5.3, items 4 and 5, together with
item 3.

One can also use the original text data, using the input file fort.3 that
looks like:

    -----------------------------------
    ’gfATO.dat’     0
    ’gfMOL.dat’     0     8000.
    ’gfTiO.dat’     0     5000.
    ------------------------------------

in which case one needs to modify the corresponding symbolic links as follows

    ln -s -f $TLUSTY/data/gfATO.dat gfATO.dat
    ln -s -f $TLUSTY/data/gfMOL.dat gfMOL.dat
    ln -s -f $TLUSTY/data/gfTiO.dat gfTiO.dat

In principle, one can mix text and binary files, for instance

    -----------------------------------
    ’gfATO.dat’      0
    ’gfMOL.bin’      1     8000.
    ’gfTiO.bin’      1     5000.
    ------------------------------------

One can also use the old method that does not set up file fort.3. In that case
the commands are

    ln -s -f $TLUSTY/data data
    ln -s -f $TLUSTY/data/gfATO.dat fort.19
    ln -s -f $TLUSTY/data/gfMOL.dat fort.20
    ln -s -f $TLUSTY/data/gfTiO.dat fort.21
    $TLUSTY/synspec/synspec.exe <tab.5 >tmp.log

in which case the file fort.55 must contain the the association of the
molecular line lists with the input files unit 20 and 21. Assuming that both
line lists are of text format, the file fort.55 will look like this:

    -------------------------------------
          -3       1       0
           1       0       0       0
           0       0       0       0       0
           1       0       0       0       0
           0       0       0
        900.   -110000.    50.00  2000.0   1.00000e-4  0.05
           2       20      21
    -------------------------------------

In the case that all line lists are in binary format, the file fort.55 has to
be modified to

    -------------------------------------
          -3       1       0
           1       0       0       0
           0       0       0       0       0
           1       0       0       1       0
           0       0       0
        900.   -110000.    50.00  2000.0   1.00000e-4  0.05
           2       20      21
    -------------------------------------

Here, the only change is the 4th number on the 4th line, INLIST, which is now
set to 1. But one must also link the binary versions of the line lists,
gfATO.bin, gfMOL.bin, and gfTiO.bin, to fort.19, fort.20, and fort.21,
respectively.

We stress that any of these fort.55 examples can be when fort.3 is provided as
well, since in that case the quantity INLIST, and the information on the last
line of input, are overridden by the input from fort.3. If one stores the line
lists in a different directory than in the standard ”data” directory, or uses
different line lists altogether, one has to modify the links accordingly.

Finally, we emphasize that the above input files to generate an opacity table
serve as a simple example to test the performance of the code, but are NOT THE
RECOMMENDED approach to generate actual production-run tables. In this case,
one would need to consider, in addition to the species included in the
standard molecular line lists, data for H2O. To show how the input file fort.3
will look like, let us assume that that we have binary line list for water,
called gfH2O.bin, possibly with the Van der Walls broadening data from the
EXOMOL tables272727Such a table, which is not a part of the standard
distribution, is also available upon request.. The file fort.3 is then

    -----------------------------------
    ’gfATO.bin’    1
    ’gfMOL.bin’    1     8000.
    ’gfTiO.bin’    1     5000.
    ’gfH2O.bin’    1     4000.
    ------------------------------------

Here, we assume that the TiO lines do not contribute above 5000 K, and the H2O
lines are negligible above 4000 K, which seems to be a reasonable assumption.
The line lists for these species are not even read above these respective
temperatures when evaluating the opacity table, which leads to considerable
time savings.

We could also generate an analogous table where the opacity of H, Mg, and Ca
is removed, so that it can be used for constructing model atmospheres where H,
Mg, and Ca are treated in NLTE, while the opacity of all other species (atomic
as well as molecular) is computed assuming LTE. The input files for such table
are the same, except fort.2 which now becomes:

    -----------------------------------
    11   3000. 15000.
    1
    7  1.e-12 1.e-6
    100000  0  900  110000
    ’optab11_7hmc.dat’  0
     1 0
    12 0
    20 0
    ------------------------------------

This file is also located in the directory, with the name `optab11_7hmc.2`;
the script file R1 copies it to fort.2.

For convenience, we include here the standard input file tab.5. It will also
be useful for a better explanation how to construct a standard input for
computing synthetic spectra for the hybrid Opacity Table/NLTE models.

    ----------------------------------------------------------------
    6000. 4.0
     T  F              ! LTE,  LTGRAY
     ’tab.nst’         ! name of file containing non-standard flags
    *
    * frequencies
    *
     2000
    *
    * data for atoms
    *
     30            ! NATOMS
    * mode abn modpf
        2   0.      0  ! H
        2   0.      0  ! He
        1   0.      0  ! Li
        1   0.      0  ! Be
        1   0.      0  ! B
        2   0.      0  ! C
        2   0.      0  ! N
        2   0.      0  ! O
        1   0.      0  ! F
        2   0.      0  ! Ne
        1   0.      0  ! Na
        2   0.      0  ! Mg
        2   0.      0  ! Al
        2   0.      0  ! Si
        1   0.      0  ! P
        2   0.      0  ! S
        1   0.      0  ! Cl
        1   0.      0  ! Ar
        1   0.      0  ! K
        2   0.      0  ! Ca
        1   0.      0  ! Sc
        1   0.      0  ! Ti
        1   0.      0  ! V
        1   0.      0  ! Cr
        1   0.      0  ! Mn
        2   0.      0  ! Fe
        1   0.      0  ! Co
        1   0.      0  ! Ni
        1   0.      0  ! Cu
        1   0.      0  ! Zn
    *
    * data for ions
    *
    *iat   iz   nlevs  ilast ilvlin  nonstd typion  filei
    *
       1   -1     1      0      0      9    ’ H- ’ ’data/hmin.dat’
       1    0     9      0      0      0    ’ H 1’ ’data/h1.dat’
       1    1     1      1      0      0    ’ H 2’ ’ ’
       2    0    24      0      0      0    ’He 1’ ’data/he1.dat’
       2    1     1      1      0      0    ’He 2’ ’ ’
       6    0    40      0      0      0    ’ C 1’ ’data/c1.dat’
       6    1    22      0      0      0    ’ C 2’ ’data/c2.dat’
       6    2     1      1      0      0    ’ C 3’ ’ ’
       7    0    34      0      0      0    ’ N 1’ ’data/n1.dat’
       7    1    42      0      0      0    ’ N 2’ ’data/n2_32+10lev.dat’
       7    2     1      1      0      0    ’ N 3’ ’ ’
       8    0    33      0      0      0    ’ O 1’ ’data/o1_23+10lev.dat’
       8    1    48      0      0      0    ’ O 2’ ’data/o2_36+12lev.dat’
       8    2     1      1      0      0    ’ O 3’ ’ ’
      10    0    35      0      0      0    ’Ne 1’ ’data/ne1_23+12lev.dat’
      10    1    32      0      0      0    ’Ne 2’ ’data/ne2_23+9lev.dat’
      10    2     1      1      0      0    ’Ne 3’ ’ ’
      12    0    41      0      0      0    ’Mg 1’ ’data/mg1.t’
      12    1    25      0      0      0    ’Mg 2’ ’data/mg2.dat’
      12    2     1      1      0      0    ’Mg 3’ ’ ’
      13    0    10      0      0      0    ’Al 1’ ’data/al1.t’
      13    1    29      0      0      0    ’Al 2’ ’data/al2_20+9lev.dat’
      13    2     1      1      0      0    ’Al 3’ ’ ’
      14    0    45      0      0      0    ’Si 1’ ’data/si1.t’
      14    1    40      0      0      0    ’Si 2’ ’data/si2_36+4lev.dat’
      14    2     1      1      0      0    ’Si 3’ ’ ’
      16    0    41      0      0      0    ’ S 1’ ’data/s1.t’
      16    1    33      0      0      0    ’ S 2’ ’data/s2_23+10lev.dat’
      16    2     1      1      0      0    ’ S 3’ ’ ’
      20    0    15      0      0      0    ’Ca 1’ ’data/ca1.t’
      20    1    18      0      0      0    ’Ca 2’ ’data/ca2.t’
      20    2     1      1      0      0    ’Ca 3’ ’ ’
      26    0    30      0      0      0    ’Fe 1’ ’data/fe1.dat’
      26    1    36      0      0     -1    ’Fe 2’ ’data/fe2va.dat’
       0    0                                      ’data/gf2601.gam’
                                                   ’data/gf2601.lin’
                                                   ’data/fe2p_14+11lev.rap’
      26    2    50      0      0     -1    ’Fe 3’ ’data/fe3va.dat’
       0    0                                      ’data/gf2602.gam’
                                                   ’data/gf2602.lin’
                                                   ’data/fe3p_22+7lev.rap’
      26    3     1      1      0      0    ’Fe 4’ ’ ’
       0    0     0     -1      0      0    ’    ’ ’ ’
    *
    ----------------------------------------------------------------

As this file stipulates, the bound-free opacities of the following atoms/ions
are taken into account: H-, H I, He I, C I, C II, N I. N II, O I, O II, Ne I,
Ne II, Mg I, Mg II, Al I, Al II, Si I, Si II, S I, S II, Ca I, Ca II, Fe I, Fe
II, and Fe III.

The non-standard parameters file tab.nst contains just one record, namely
IFEOS=-1
that set the output of interesting equation-of-state parameters, as explained
in § 3.3.

####  7.2.2 Ordinary stellar synthetic spectra

There are three test cases for computing ordinary stellar synthetic spectra,
contained in subdirectories hhe, bstar, and kurucz, that we briefly describe
below.

$\bullet$ hhe – Contains a test of very simple synthetic spectrum for a NLTE
H-He model, called hhe35nl, generated as a test case of tlusty – see § 6.2.
The sample spectrum is computed only between 1400 and 1410 Å, using a test-
case line list linelist.test stored in the standard “data” directory. A
similar spectrum was calculated as a test case of synspec51 – see Paper I.

$\bullet$ bstar – This is a similar test, but for computing a synthetic
spectrum for a sophisticated NLTE metal line-blanketed modes atmosphere of a
B-star, with $T_{\rm eff}=20,000$ K, and $\log g=4$. This is one of the models
of the BSTAR2006 grid (Lanz & Hubeny 2007). Again, only a very short interval
of spectrum, between 1400 and 1410 Å, is computed as a test.

$\bullet$ kurucz – This directory contains two tests with computations of
synthetic spectra for a Kurucz model. The first one is a spectrum for an early
A-type star, $T_{\rm eff}=9,750$ K, and $\log g=4$, computed for the same
short interval between 1400 and 1410 Å. and using the test-case short atomic
line list.

The second test is a synthetic spectrum for a solar-type star ($T_{\rm
eff}=5,500$ K, $\log g=4.5$), between 2,500 and 7,500 Å. Unlike the previous
tests, this one uses the three full binary line lists gfATO.bin, gfMOL.bin,
and gfTiO.bin. Similarly to the tests of generating an opacity table, one can
specify these line list either through the parameters in the file fort.55, or
through fort.3; here we chose the latter. In this test we also demonstrate
setting thee parameter IFEOS to a negative value (IFEOS=-4), which switches on
the creation of the output files fort.51 – fort.54 that contain various
interesting parameters and quantities, related to the equation of state (see §
3.3), at every fourth depth point.

####  7.2.3 Synthetic spectrum for a hybrid Opacity Table/NLTE model
atmosphere

As explained in § 3.7.2, the standard input file to be used for computing a
synthetic spectrum for a hybrid Opacity Table/NLTE model (such as the test
model g55res considered in § 6.2.2), has to be a modified file tab.5, in which
all the originally explicit species except H. Mg, and Ca are considered as
quasi-explicit (MODE=5). For convenience, we show here the first part of the
modified tab.5 file, called tabsp.5:

    ----------------------------------------------------------------
    6000. 4.0
     F  F              ! LTE,  LTGRAY
     ’’            ! no keyword parameters
    *
    * frequencies
    *
     2000
    *
    * data for atoms
    *
     30                 ! NATOMS
    * mode abn modpf
        2   0.      0  ! H
        5   0.      0  ! He
        1   0.      0  ! Li
        1   0.      0  ! Be
        1   0.      0  ! B
        5   0.      0  ! C
        5   0.      0  ! N
        5   0.      0  ! O
        1   0.      0  ! F
        5   0.      0  ! Ne
        1   0.      0  ! Na
        2   0.      0  ! Mg
        5   0.      0  ! Al
        5   0.      0  ! Si
        1   0.      0  ! p
        5   0.      0  ! S
        1   0.      0  ! Cl
        1   0.      0  ! Ar
        1   0.      0  ! K
        2   0.      0  ! Ca
        1   0.      0  ! Sc
        1   0.      0  ! Ti
        1   0.      0  ! V
        1   0.      0  ! Cr
        1   0.      0  ! Mn
        5   0.      0  ! Fe
        1   0.      0  ! Co
        1   0.      0  ! Ni
        1   0.      0  ! Cu
        1   0.      0  ! Zn
    *
    ----------------------------------------------------------------

The rest of the file remains unchanged. As is clearly seen here, H, Mg, and Ca
are explicit (MODE=2), because their level populations are provided by the
input model atmosphere, and He, C, N, O, Ne, Al, Si, S, and Fe are quasi-
explicit (MODE=5), so that their bound-free opacity (obviously in LTE) will be
included (as it was in the original opacity table).

There are actually two test cases here, with the same input model atmosphere,
and the same standard input. The first computes a full synthetic spectrum
between 6700 and 6800 Å (with atomic and molecular lines), and the second
computes a theoretical continuum between 1500 and 7500 Å, to demonstrate the
influence of the bound-free opacity of metals.

##  8 Summary and outlook

We have presented and described new upgrades in the computer programs tlusty
and synspec, developed with the aim of providing powerful and flexible tools
for computing model stellar atmospheres and accretion disks, and analyzing
stellar spectra. We would like to stress that while we spent considerable
effort in testing the codes for many physical conditions, they are by no means
error-free. In fact, we could paraphrase the disclaimer Bob Kurucz often uses,
namely “These codes are guarantied to contain errors”. We strongly advice any
users against using these codes as black boxes, or taking results of these
codes without a careful inspection and checking for their physical soundness
and consistency. The authors would also highly appreciate receiving comments
about possible bugs, and/or suggestion for improvements or changes that would
increase the accuracy and versatility of the codes.

Looking critically at the Section “Outlook” of Paper III, one can see that
most of the projected future developments of tlusty have not yet materialized.
So, we still have plenty of work to do for a foreseeable future. We have
however developed several improvements in synspec that were not envisaged
previously. For both codes, the new developments described in this paper
concern mostly applications for cool stars.

Another significant improvement, on a purely coding level, is a transformation
of tlusty, version 205, to FORTRAN 90, by Simon Preval (University of
Leicester). That development, as well as the present one, proceeded in
parallel, and therefore the present versions of the codes still adhere to
FORTRAN 77. We now plan to make analogous changes in tlusty208 to transfer it
to FORTRAN 90, and to pursue all future development and improvements on this
language.

## Acknowledgements

We thank Dr. Paul Barklem for advice on atomic and molecular data, Nikola
Vitas for his help in testing the equation of state, and Jano Budaj and
Krzysztof Gesicki for pointing out some issues when compiling the programs on
various platforms. I.H. would like to acknowledge support that enabled his
visit to IAC in Tenerife from the Severo Ochoa program, awarded by the
Government of Spain to the IAC.

## Appendix A - Adopted sets of the standard solar abundances

In Tables 3-5, we summarize the actual values of the standard solar
abundances, used by tlusty and synspec, described in § 2.1. The individual
sets are labelled as set0, invoked by setting the parameter IABSET=0 (see §
2.1); set1 by IABSET=1, and set2 by IABSET=2.

Table 3: Adopted sets of the standard solar abundances: H – Zn

Element | Set0 abs | Set0 log | Set1 abs | Set1 log | Set2 abs | Set2 log
---|---|---|---|---|---|---
H | 1.00E+00 | 12.00 | 1.00E+00 | 12.00 | 1.00E+00 | 12.00
He | 8.51E-02 | 10.93 | 8.51E-02 | 10.93 | 1.00E-01 | 11.00
Li | 1.12E-11 | 1.05 | 1.82E-09 | 3.26 | 1.26E-11 | 1.10
Be | 2.40E-11 | 1.38 | 2.40E-11 | 1.38 | 2.51E-11 | 1.40
B | 5.01E-10 | 2.70 | 6.17E-10 | 2.79 | 5.00E-10 | 2.70
C | 2.45E-04 | 8.39 | 2.69E-04 | 8.43 | 3.31E-04 | 8.52
N | 6.03E-05 | 7.78 | 6.76E-05 | 7.83 | 8.32E-05 | 7.92
O | 4.57E-04 | 8.66 | 4.90E-04 | 8.69 | 6.76E-04 | 8.83
F | 3.63E-08 | 4.56 | 3.63E-08 | 4.56 | 3.16E-08 | 4.50
Ne | 6.92E-05 | 7.84 | 8.51E-05 | 7.93 | 1.20E-04 | 8.08
Na | 1.48E-06 | 6.17 | 1.74E-06 | 6.24 | 2.14E-06 | 6.33
Mg | 3.39E-05 | 7.53 | 3.98E-05 | 7.60 | 3.80E-05 | 7.58
Al | 2.34E-06 | 6.37 | 2.82E-06 | 6.45 | 2.95E-06 | 6.47
Si | 3.24E-05 | 7.51 | 3.24E-05 | 7.51 | 3.55E-05 | 7.55
P | 2.29E-07 | 5.36 | 2.57E-07 | 5.41 | 2.82E-07 | 5.45
S | 1.38E-05 | 7.14 | 1.32E-05 | 7.12 | 2.14E-05 | 7.33
Cl | 3.16E-07 | 5.50 | 3.16E-07 | 5.50 | 3.16E-07 | 5.50
Ar | 1.51E-06 | 6.18 | 2.51E-06 | 6.40 | 2.52E-06 | 6.40
K | 1.20E-07 | 5.08 | 1.20E-07 | 5.08 | 1.32E-07 | 5.12
Ca | 2.04E-06 | 6.31 | 2.19E-06 | 6.34 | 2.29E-06 | 6.36
Sc | 1.12E-09 | 3.05 | 1.41E-09 | 3.15 | 1.48E-09 | 3.17
Ti | 7.94E-08 | 4.90 | 8.91E-08 | 4.95 | 1.05E-07 | 5.02
V | 1.00E-08 | 4.00 | 8.51E-09 | 3.93 | 1.00E-08 | 4.00
Cr | 4.37E-07 | 5.64 | 4.37E-07 | 5.64 | 4.68E-07 | 5.67
Mn | 2.45E-07 | 5.39 | 2.69E-07 | 5.43 | 2.45E-07 | 5.39
Fe | 2.82E-05 | 7.45 | 3.16E-05 | 7.50 | 3.16E-05 | 7.50
Co | 8.32E-08 | 4.92 | 9.77E-08 | 4.99 | 8.32E-08 | 4.92
Ni | 1.70E-06 | 6.23 | 1.66E-06 | 6.22 | 1.78E-06 | 6.25
Cu | 1.62E-08 | 4.21 | 1.55E-08 | 4.19 | 1.62E-08 | 4.21
Zn | 3.98E-08 | 4.60 | 3.63E-08 | 4.56 | 3.98E-08 | 4.60

Set0: Asplund et al. (2005), essentially the same as Grevesse et al. (2007);
Set1: Asplund et al. (2009); Set2: Grevesse & Sauval (1998) (former default).
“Abs” stands for $N_{\rm el}/N_{\rm H}$, while “log” for $\log(N_{\rm
el}/N_{\rm H})+12$.

Table 4: Adopted sets of the standard solar abundances: Ga – Nd

Element | Set0 abs | Set0 log | Set1 abs | Set1 log | Set2 abs | Set2 log
---|---|---|---|---|---|---
Ga | 7.59E-10 | 2.88 | 1.10E-09 | 3.04 | 1.35E-09 | 3.13
Ge | 3.80E-09 | 3.58 | 4.47E-09 | 3.65 | 4.27E-09 | 3.63
As | 1.95E-10 | 2.29 | 2.00E-10 | 2.30 | 2.34E-10 | 2.37
Se | 2.14E-09 | 3.33 | 2.19E-09 | 3.34 | 2.24E-09 | 3.35
Br | 3.63E-10 | 2.56 | 3.47E-10 | 2.54 | 4.27E-10 | 2.63
Kr | 1.91E-09 | 3.28 | 1.78E-09 | 3.25 | 1.70E-09 | 3.23
Rb | 3.98E-10 | 2.60 | 2.29E-10 | 2.36 | 2.51E-10 | 2.40
Sr | 8.32E-10 | 2.92 | 7.41E-10 | 2.87 | 8.51E-10 | 2.93
Y | 1.62E-10 | 2.21 | 1.62E-10 | 2.21 | 1.66E-10 | 2.22
Zr | 3.89E-10 | 2.59 | 3.80E-10 | 2.58 | 4.07E-10 | 2.61
Nb | 2.63E-11 | 1.42 | 2.88E-11 | 1.46 | 2.51E-11 | 1.40
Mo | 8.32E-11 | 1.92 | 7.59E-11 | 1.88 | 9.12E-11 | 1.96
Tc | 1.02E-22 | -9.99 | 1.02E-22 | -9.99 | 1.00E-24 | -12.00
Ru | 6.92E-11 | 1.84 | 5.62E-11 | 1.75 | 6.61E-11 | 1.82
Rh | 1.32E-11 | 1.12 | 1.15E-11 | 1.06 | 1.23E-11 | 1.09
Pd | 4.90E-11 | 1.69 | 4.47E-11 | 1.65 | 5.01E-11 | 1.70
Ag | 8.71E-12 | 0.94 | 1.58E-11 | 1.20 | 1.74E-11 | 1.24
Cd | 5.89E-11 | 1.77 | 5.13E-11 | 1.71 | 5.75E-11 | 1.76
In | 3.98E-11 | 1.60 | 5.75E-12 | 0.76 | 6.61E-12 | 0.82
Sn | 1.00E-10 | 2.00 | 1.10E-10 | 2.04 | 1.38E-10 | 2.14
Sb | 1.00E-11 | 1.00 | 1.02E-11 | 1.01 | 1.10E-11 | 1.04
Te | 1.55E-10 | 2.19 | 1.51E-10 | 2.18 | 1.74E-10 | 2.24
I | 3.24E-11 | 1.51 | 3.55E-11 | 1.55 | 3.24E-11 | 1.51
Xe | 1.86E-10 | 2.27 | 1.74E-10 | 2.24 | 1.70E-10 | 2.23
Cs | 1.17E-11 | 1.07 | 1.20E-11 | 1.08 | 1.32E-11 | 1.12
Ba | 1.48E-10 | 2.17 | 1.51E-10 | 2.18 | 1.62E-10 | 2.21
La | 1.35E-11 | 1.13 | 1.26E-11 | 1.10 | 1.58E-11 | 1.20
Ce | 3.80E-11 | 1.58 | 3.80E-11 | 1.58 | 4.07E-11 | 1.61
Pr | 5.13E-12 | 0.71 | 5.25E-12 | 0.72 | 6.03E-12 | 0.78
Nd | 2.82E-11 | 1.45 | 2.63E-11 | 1.42 | 2.95E-11 | 1.47

Set0: Asplund et al. (2005), essentially the same as Grevesse et al. (2007);
Set1: Asplund et al. (2009); Set2: Grevesse & Sauval (1998) (former default).
“Abs” stands for $N_{\rm el}/N_{\rm H}$, while “log” for $\log(N_{\rm
el}/N_{\rm H})+12$.

Table 5: Adopted sets of the standard solar abundances: Pm – U

Element | Set0 abs | Set0 log | Set1 abs | Set1 log | Set2 abs | Set2 log
---|---|---|---|---|---|---
Pm | 1.02E-22 | -9.99 | 1.02E-22 | -9.99 | 1.00E-24 | -12.00
Sm | 1.02E-11 | 1.01 | 9.12E-12 | 0.96 | 9.33E-12 | 0.97
Eu | 3.31E-12 | 0.52 | 3.31E-12 | 0.52 | 3.47E-12 | 0.54
Gd | 1.32E-11 | 1.12 | 1.17E-11 | 1.07 | 1.17E-11 | 1.07
Tb | 1.91E-12 | 0.28 | 2.00E-12 | 0.30 | 2.14E-12 | 0.33
Dy | 1.38E-11 | 1.14 | 1.26E-11 | 1.10 | 1.41E-11 | 1.15
Ho | 3.24E-12 | 0.51 | 3.02E-12 | 0.48 | 3.16E-12 | 0.50
Er | 8.51E-12 | 0.93 | 8.32E-12 | 0.92 | 8.91E-12 | 0.95
Tm | 1.00E-12 | 0.00 | 1.26E-12 | 0.10 | 1.35E-12 | 0.13
Yb | 1.20E-11 | 1.08 | 8.32E-12 | 0.92 | 8.91E-12 | 0.95
Lu | 1.15E-12 | 0.06 | 1.26E-12 | 0.10 | 1.32E-12 | 0.12
Hf | 7.59E-12 | 0.88 | 7.08E-12 | 0.85 | 5.37E-12 | 0.73
Ta | 6.76E-13 | -0.17 | 7.59E-13 | -0.12 | 1.35E-12 | 0.13
W | 1.29E-11 | 1.11 | 4.47E-12 | 0.65 | 4.79E-12 | 0.68
Re | 1.70E-12 | 0.23 | 1.82E-12 | 0.26 | 1.86E-12 | 0.27
Os | 2.82E-11 | 1.45 | 2.51E-11 | 1.40 | 2.40E-11 | 1.38
Ir | 2.40E-11 | 1.38 | 2.40E-11 | 1.38 | 2.34E-11 | 1.37
Pt | 4.37E-11 | 1.64 | 4.17E-11 | 1.62 | 4.79E-11 | 1.68
Au | 1.02E-11 | 1.01 | 6.31E-12 | 0.80 | 6.76E-12 | 0.83
Hg | 1.35E-11 | 1.13 | 1.48E-11 | 1.17 | 1.23E-11 | 1.09
Tl | 7.94E-12 | 0.90 | 5.89E-12 | 0.77 | 6.61E-12 | 0.82
Pb | 1.00E-10 | 2.00 | 1.10E-10 | 2.04 | 1.12E-10 | 2.05
Bi | 4.47E-12 | 0.65 | 4.47E-12 | 0.65 | 5.13E-12 | 0.71
Po | 1.02E-22 | -9.99 | 1.02E-22 | -9.99 | 1.00E-24 | -12.00
At | 1.02E-22 | -9.99 | 1.02E-22 | -9.99 | 1.00E-24 | -12.00
Rn | 1.02E-22 | -9.99 | 1.02E-22 | -9.99 | 1.00E-24 | -12.00
Fr | 1.02E-22 | -9.99 | 1.02E-22 | -9.99 | 1.00E-24 | -12.00
Ra | 1.02E-22 | -9.99 | 1.02E-22 | -9.99 | 1.00E-24 | -12.00
Ac | 9.77E-03 | 9.99 | 1.02E-22 | -9.99 | 1.00E-24 | -12.00
Th | 1.15E-12 | 0.06 | 1.15E-12 | 0.06 | 1.20E-12 | 0.08
Pa | 1.02E-22 | -9.99 | 1.02E-22 | -9.99 | 1.00E-24 | -12.00
U | 3.02E-13 | -0.52 | 2.88E-13 | -0.54 | 3.24E-13 | -0.49

Set0: Asplund et al. (2005), essentially the same as Grevesse et al. (2007);
Set1: Asplund et al. (2009); Set2: Grevesse & Sauval (1998) (former default).
“Abs” stands for $N_{\rm el}/N_{\rm H}$, while “log” for $\log(N_{\rm
el}/N_{\rm H})+12$.

## Appendix B- Mean molecular weight and total particle density

In the context of tlusty, the equation of state is used as a relation between
gas pressure, $P_{g}$, and mass density, $\rho$. Since one assumes an ideal
gas behavior, $P_{g}=kNT$, with $k$ being the Boltzmann constant, $N$ the
total particle number density, and $T$ the temperature, the equation of state
is essentially a relation between $N$ and $\rho$. It is written as

$\rho=(N-n_{\rm e})\mu m_{H},$ (30)

where $\mu$ is the mean molecular weight, and $m_{H}$ the mass of hydrogen
atom. In version 205 of tlusty, the mean molecular weight was assumed to be
given by (see Paper II, Eq. 83),

$\mu=\frac{\sum_{I}A_{I}(m_{I}/m_{H})}{\sum_{I}A_{I}}.$ (31)

where $A_{I}$ is the abundance of species $I$, by number relative to hydrogen,
and $m_{I}$ the mass of an atom of species $I$. In the absence of molecules,
$\mu$ depends only on the assumed chemical abundances, and is therefore
independent of atmospheric structure, and thus remains constant during the run
of tlusty.

When molecules are present, Eq. (30) remains valid, but the mass density is
given by

$\rho=\sum_{i}n_{i}m_{i},$ (32)

where $i$ runs over all species, atomic and molecular, with $n_{i}$ being the
actual number density of particles $i$ and $m_{i}$ their mass. Consequently,
the mean molecular weight is no longer fixed, but igiven by Eq. (30) that is
now viewed as a definition relation for $\mu$,

$\mu=(\rho/m_{H})/(N-n_{\rm e}).$ (33)

Consequently, either $\mu$ or $N$ has to be part of the basic structural
quantities to be stored as model output. A natural choice, in view of $N$
being among the basic state parameters anyway, is to chose $N$ as the
additional output parameter.

## Appendix C - Thermodynamic parameters and convection

tlusty208 allows the evaluation of the adiabatic gradient either through the
internal energy and its derivatives, or through the specific entropy and its
derivatives. This is controlled by the keyword parameter IFENTR – see Paper
III, § 12.3.2, and in § 2.7 of this document. In version 205, the default
value of this parameter is IFENTR=0, which sets an evaluation of the adiabatic
gradient through the internal energy – Eqs. (346) – (348) of Paper II.
Equation (349) of Paper II for the adiabatic gradient expressed through the
specific entropy is incorrect, and Eq. (350) is formally correct, but not
advantageous for numerical evaluation.

In the present version 208, the default is switched to IFENTR=1, that is to
using a specific entropy as a basic quantity to evaluate the adiabatic
gradient (although one can still set IFENTR=0 to recover the previous
treatment). The reason is that in the case of entropy, one needs to evaluate
fewer partial derivatives numerically than in the case of internal energy,
which is presumably less prone to numerical inaccuracies.

The adiabatic gradient and the specific heat are given by

$\nabla_{\rm ad}=-\frac{(\partial S/\partial P)_{T}}{(\partial S/\partial
T)_{P}}\,\frac{P}{T},$ (34)

and

$c_{P}=T(\partial S/\partial T)_{P},$ (35)

where the specific entropy is given by

$S=\frac{k}{\rho}\sum_{i}N_{i}\left[\frac{3}{2}\ln(kTm_{i})+\ln(U_{i}/N_{i})+kT^{2}\frac{\partial\ln
U_{i}}{\partial\ln T}+s_{0}\right],$ (36)

where the summation extends over all components $i$ of the gas, that is, over
neutral and ionized atoms, molecules, and electrons. Here $k$ is the Boltzmann
constant, $\rho$ the mass density, $T$ the temperature, $m_{i}$ the mass of
the species $i$ expressed in units of the hydrogen atom mass, and $N_{i}$ and
$U_{i}$ are the number density and the partition function of species $i$,
respectively. The constant $s_{0}$ is given by

$s_{0}=(3/2)\ln(2\pi m_{H}/h^{2})=103.973$ (37)

where $m_{H}=1.67333\times 10^{-24}$ is the mass of hydrogen atom in grams,
and $h$ is the Planck constant.

## Appendix D - Improved upper boundary condition for the radiative transfer
equation

We have developed an improved upper boundary condition for the radiative
transfer equation. Actually, it was already mentioned in the original paper on
tlusty [Hubeny (1988), Eq. (3.8)], but in subsequent versions it was deemed
unimportant and disabled. It turned out that in the context of cool stars it
plays a role in determining the correct temperature at the surface.

The traditional boundary condition is based on the assumption that there is no
incoming radiation at the surface, or that there is a prescribed irradiation
from an external source, e.g., in the case of a close binary, or a planetary
atmosphere. Here we consider the case of no prescribed external irradiation.
so that the incoming radiation is

$I_{\nu}^{-}(\mu)=0,$ (38)

where $I_{\nu}^{-}$ denotes $I_{\nu}(\mu)$ at frequency $\nu$ for $\mu<0$;
$\mu$ is the cosine of the angle between the direction of photon propagation
and the normal to the surface. However, Eq. (38) is strictly valid only at
optical depth $\tau=0$, while in reality the region above the first depth
point, with column mass $m_{1}$, is not empty and can thus generate some
radiation coming from directions with $\mu<0$ at the uppermost depth point. It
can be approximated, assuming that the source function is constant above
$m_{1}$, as (dropping the frequency subscript)

$I^{-}(\tau_{1},\mu)=\int_{0}^{\tau_{1}}S(t)\,e^{-t/\mu}dt/\mu=S(\tau_{1})(1-e^{-\tau_{1}/\mu}).$
(39)

Assuming that the opacity is a linear function of $m$ for $m<m_{1}$, then

$\tau_{1}=(1/2)\chi(m_{1})m_{1}/\rho_{1},$ (40)

where $\chi$ is the absorption coefficient (per cm), and
$\rho_{1}\equiv\rho(m_{1})$ is the mass density at the uppermost point. The
discretized upper boundary condition for the Feautrier variable $j$ [where
$j(\mu)\equiv(1/2)[I(\mu)+I(-\mu)]$ for $\mu>0$ – for details, refer e.g., to
Hubeny & Mihalas (2014), § 11.6] can be written as

$j_{1}\left[\frac{2\mu^{2}}{\Delta\tau_{3/2}^{2}}+\frac{2\mu}{\Delta\tau_{3/2}}+1\right]-j_{2}\frac{2\mu^{2}}{\Delta\tau_{3/2}^{2}}=S_{1}\left[1+\frac{2\mu}{\Delta\tau_{3/2}}\left(1-e^{-\tau_{1}/\mu}\right)\right],$
(41)

where $S$ is the source function. Here, the last term in the square bracket on
the right-hand side is the additional term due to the contribution of the
upper layers to the radiation intensity at the uppermost point of the
atmosphere.

By integrating over $\mu$ one gets a zero-order moment equation, which is one
of the basic structural equations to describe an atmosphere,

$J_{1}\left[\frac{2f_{1}}{\Delta\tau_{3/2}^{2}}+\frac{2g_{1}}{\Delta\tau_{3/2}}+1\right]-J_{2}\frac{2f_{2}}{\Delta\tau_{3/2}^{2}}=S_{1}[1+2Q(\tau_{1})/\Delta\tau_{3/2}]$
(42)

where $f$ and $g$ are the variable Eddington factors, and

$Q(t)\equiv\int_{0}^{1}(1-e^{-t/\mu})\mu\,d\mu=\frac{1}{2}-E_{3}(t),$ (43)

where $E_{3}(t)$ is the third exponential integral.

The reason why this correction is particularly significant in the context of
cool star model atmospheres is that the monochromatic opacity can be vastly
different for different frequencies. For instance, the opacity in the Lyman
continuum and in the Lyman lines is many orders of magnitude larger than the
opacity elsewhere (since hydrogen is predominantly in the ground state), so
that even if one selects a relatively low smallest Rosseland optical depth
used to construct the initial LTE-gray model, the optical depth in the Lyman
lines and the Lyman continuum may be quite large. For instance, in our test
models for a solar type star (see § 6.2) we chose the Rosseland optical depth
at the first depth point, the keyword parameter TAUFIR, equal to $10^{-7}$,
yet the monochromatic optical depth close to the Lyman limit is about 700 (!),
and the optical depth for all frequencies up to the L$\alpha$ line is still
larger than or close to unity. It is thus clear that the contribution of
layers above $m_{1}$ cannot be neglected.

## Appendix E - Treatment of hydrostatic equilibrium within the Rybicki scheme

We stress that when using the Rybicki scheme as a global linearization
procedure, only the radiative transfer and the radiative/convective
equilibrium equations are solved simultaneously, and thus only the mean
intensities of radiation and the temperature follow directly from the
iteration process. Other structural equations are to be solved, and hence the
updated values of other structural parameters are to be determined,
separately.

We have already described our treatment of the kinetic equilibrium equations
in the case of computing NLTE models - see § 2.2.3. Here we briefly outline
our adopted treatment of the hydrostatic equilibrium equation, and the way of
updating the gas pressure and consequently the total particle number density.
The next step is to solve the equation of state to determine number densities
of all atoms, ions, molecules, and electrons.

While the equation of state is local, and thus its treatment is the same for
stellar atmospheres and disks, the hydrostatic equilibrium equation differs
for these two cases, so we will discuss stellar atmospheres and disks
separately.

### Stellar atmospheres

In this case the adopted procedure depends on whether the radiation pressure
is neglected (as may be the case for cool stars), or is taken into account. In
the case of negligible radiation pressure, there is in fact no procedure
necessary. The total pressure is equal to the gas pressure, and is given by

$P_{\rm gas}=P_{\rm tot}=mg,$ (44)

where $m$ is the column mass and $g$ the gravity acceleration, assumed
constant throughout the atmosphere for our 1-D plane-parallel models. Since
$m$ is taken as the basic geometrical coordinate, the hydrostatic equilibrium
is fulfilled identically. The total particle number density is then given,
assuming the ideal gas equation of state, by

$N=P/kT,$ (45)

where $k$ is the Boltzmann constant and $T$ the temperature.