D How to calculate a NLTE model with TMAP

A pre-requiste to understand the following scripts is basic knowledge of unix commands. Lists of the most important can be found easily in the WWW.
In addition, knowledge of the emacs text editor is required.
The meaning of the input cards (traditional name adopted from the formerly used FORTRAN punch cards) for ATOMS2, SETF2, LTE2, PRO2, LINE1, and LINE1_PROF, can be found in this User’s Guide.

D.1 Basics

First, this is a short explanation of the directory structure:

${HOME}/adaten is the directory for the atomic data checked by ATOMS2.
${HOME}/bimod is the directory for the executable binaries of LTE2 and PRO2.
${HOME}/fgrids is the directory for the frequency grids that were produced with SETF2.
${HOME}/jobs is the directory for all the .job files (ATOMS2, SETF2, LTE2, and PRO2).
${HOME}/models is the directory for the calculated models from LTE2 and PRO2 are.

For our scripts, we use the following definitions / shell variables (typically set in the ~/.alias file):

setenv AA ${HOME}/adaten

setenv BI ${HOME}/bimod

setenv FF ${HOME}/fgrids

setenv JO ${HOME}/jobs

setenv MO ${HOME}/models

D.2 Creation of atomic data files with ATOMS2

D.3 Creation of a frequency grid with SETF2

D.4 Adaption of the Parameter files

D.5 Calculation of a start model with LTE2

D.6 Calculation of a NLTE model with PRO2

D.7 Strategy to calculate a NLTE model with PRO2

To avoid extremely long calculation times, a reasonable way is to calculate first a model using relatively small model atoms and subsequently, after its convergence, perform a so-called line-formation calculation with much more detailed model atmos on a fixed temperature (and density) structure of the model atmosphere. This yields the NLTE occupation numbers of all considered levels. Figure 1 shows the scheme of this startegy.

Some models calculate without any problem using the LTE2 start model and an atomic data file that contains all lines. This can be tested first. In case that this approach fails, try to follow the steps summarized in Table 5. There is, however, no recipe to guarantee numerical stable models.


PICT

Figure 1: Calculation flow.



Table 5: Steps to calculate a NLTE model with PRO2







line temperatureATOMSFGRID

step

comment



transitions correction
calculated for








1 no no LTE2 LTE2

very fast due to minimum NF, should work in all cases at least with a
REDUCE LOG CVEC -1
during the very first iterations

2 no yes LTE2 LTE2

very fast

3 no yes LTE2 PRO2

fast, using now the final frequency grid

4 yes yes PRO2 PRO2

initial test with
ITMAX=1
NEWMAX=0
LP-PLOT OPTICALLY THICK/THIN,ITERATION:LAST,FILE ONLY
whether the atmosphere is optically thin at the outer boundary (at least two depth points) and optically thick at the inner boundary (at least two depth points) - if this is not fulfilled, recalculate the LTE2 models with slightly extended tmin and/or tmax (be aware that the following PRO2 calculation will change the atmospheric structure and the occupation numbers of the atomic levels and, thus, all line strengths - check this t = 1 limit in the atmosphere by default after all PRO2 jobs (together with temperature structure and spectral energy distribution)

5 yes yes PRO2 PRO2

test whether all lines can be considered in the temperature correction directly from the outset
a) if numerical instabilities are encountered, try first
REDUCE LOG CVEC -1 or REDUCE LOG CVEC -2
b) if step a is not successful, use the STEP UP F-VALUES method, start with unproblematic ions like H i and He ii, followed by those that have low ionization fractions, and finally those that are dominating in the line-forming region

6 yes yes PRO2 PRO2

in the final model, neither a REDUCE LOG CVEC nor a UNSOELD-LUCY TEMPERATURE CORRECTIONa is allowed









a The UNSOELD-LUCY TEMPERATURE CORRECTION may be used in interplay with the standard PRO2 temperature correction because it yields the temperature of the inner atmosphere quickly and thus stabilizes the numerics. In the outer atmosphere, starting from the line-forming region, the UNSOELD-LUCY TEMPERATURE CORRECTION is not giving a reliable temperature stratification.


D.8 An Example: A model with hydrogen and helium

In the following example, we will use Teff = 100000 K, log g = 7 and number fractions H=0.9 and He=0.1. The respective parts that have to be changed by a user in the following scripts are marked in red color. Necessary differences in the job files are indicated in blue. Basic H and He model atoms are provided by TMAD ( http://astro.uni-_tuebingen.de/~TMAD). These have to be combined then in one atomic data file in the directory ${AA}/H+He.

D.8.1 ATOMS2

D.8.2 SETF2

D.8.3 Parameter files

D.8.4 LTE2


#!/bin/sh
set +x ; .  ${HOME}/. jobstart
# do not edit the beginning of this  f i l e
########################
## own job  following ##
########################
#
------------
# common paths
------------
GRP=/home/rauch/group
---------
# user part
---------
#
#  d i r e c t o r i e s  etc.
#
code=lte2
 mod=H+He
type=’_lte ’
#
jobdir=${JO}/ l t e
f l x d i r=${JO}/ l t e
#
# model parameters
 H=0.900
HE=0.100
#
GGM=7.00
TTM=0100000
#
name=${TTM}_${GGM}
fn=${mod}
#
aa=${AA}/${fn}${type}. atoms2
f f=${FF}/${fn}_${TTM}${type}. setf2
#
MO=${MO}/${mod}/ l t e /${name}_${H}_${HE}
#
i f  test  !   -s ${ MO }
then
#
echo  ’2 1 ${H} ${HE} ’ > normH
echo  ’2 2 ${H} ${HE} ’ > normHE
#
 HN=‘/home/rauch/bimod/normalize${sys} < normH  2>/dev/ null  1>&1‘
HEN=‘/home/rauch/bimod/normalize${sys} < normHE 2>/dev/ null  1>&1‘
#
cat > LDATEN << eos
T EFF ${TTM}
LOG G ${GGM}
DAMP=0.1
ITMAX=100
EPS=1.0E-6
TAU SCALE  86 90 -2
PRINT INTEGRATED EDDINGTON FLUX,ITERATION:LAST
PRINT TEMPERATURE CORRECTIONS,ITERATION:LAST,ALL DEPTHS
PRINT MODEL ATOMS (OVERVIEW)
ABUNDANCE H  ${HN}
ABUNDANCE HE ${HEN}
eos
#
cp ${aa} ATOMS
cp ${ f f } FGRID
#
${BI}/${code}${sys} < LDATEN
#
i f  test  -s  MODELL
then
  cp MODELL ${MO}
  chmod 600 ${MO}
f i
f i
#
# do not edit the rest of this  f i l e
#####################
set +x ;  ${HOME}/. jobend ${TMPDIR}
8cAp1x22-12300078:

D.8.5 PRO2


#!/bin/sh
set +x ; .  ${HOME}/. jobstart
# do not edit the beginning of this  f i l e
########################
## own job  following ##
########################
#
------------
# common paths
------------
GRP=/home/rauch/group
---------
# user part
---------
#
#  d i r e c t o r i e s  etc.
#
code=pro2
 mod=H+He
#
type=’’
#
jobdir=${HOME}/ jobs /pro2
f l x d i r=${HOME}/ jobs /pro2
#
IONFRAC=HE
#
#--- model parameters
#
fn=${mod}
#
GGM=7.00
#
TTM=0100000
#
 H=0.900
HE=0.100
#
name=${TTM}_${GGM}
#
#
aa=${AA}/${fn}${type}. atoms2
f f=${FF}/${fn}_${TTM}${type}. setf2
#
name=${name}_${H}_${HE}
#
MI=${HOME}/models/${mod}/0100000_7 .00 _0 .900 _0 .100 _pro2
MO=${HOME}/models/${mod}/${name}_pro2
#
i f  test  -s ${MI}
then
#
# use already existing PRO2 model  i f  not converged yet
i f  test  -s ${ MO }
then
  MI=${MO}
f i
#
cat > DATEN << eos
COMMENT:  test 4 TMAP
.
.CHANGE ABUNDANCE H  ${H}    MASS FRACTION
.CHANGE ABUNDANCE HE ${HE}   MASS FRACTION
.
.CHANGE LOGG $GGM
.CHANGE EFFECTIVE TEMPERATURE $TT
.
LAMBDA=4
.
OCCUPATION PROBABILITY FORMALISM FOR H1
OCCUPATION PROBABILITY FORMALISM FOR HE1
OCCUPATION PROBABILITY FORMALISM FOR HE2
.
OPACITY PROJECT RBF DATA:  START AT EDGE
OPACITY PROJECT RBF DATA:  MISSING HYDROGENIC
.
.STEP UP F-VALUES:  MODEL-START:  H1    1.0E-03  1.5  1
.STEP UP F-VALUES:  MODEL-START:  HE1   1.0E-04  1.5  1
.STEP UP F-VALUES:  MODEL-START:  HE2   1.0E-03  1.5  1
.
ITMAX=20
.ERRSCH=1.0E-4
NEWMAX=4
.ERRNEW=1.E-8
.
RADIATIVE EQUILIBRIUM:  DIFFERENTIAL/INTEGRAL FORM
.INNER BOUNDARY:  LAMBDA-ITERATION
.LINEARIZE HYDROSTATIC EQUATION
.
NO NEGATIVE POPULATION NUMBERS (LTE)
.
.SWITCH OFF LINES
.
DEPTH DEPENDENT LINE PROFILES,  LINEARIZATION:  FIRST
.
KANTOROVICH=2,   SWITCH LIMITS  0-->1, 1-->2, 2-->1  :   0.1  0.01  0.5
.SOLVE STATISTICAL EQUATIONS ONLY   RE-SOLVE PARTICLE CONSERVATION
.
.NO TEMPERATURE CORRECTION
.UNSOELD-LUCY TEMPERATURE CORRECTION DAMP=0.1   0.1    0.1
.UNSOELD-LUCY PARAMETERS PRINT LIMIT  0.1  TAU-WTS  0.1   1.
.
.REDUCE LOG CVEC -1
.
.PRINT OPTIONS
PRINT MODEL ATOMS (OVERVIEW)
PRINT ABUNDANCES
PRINT MAX.  REL.  CORRECTIONS EVERY 1  ITERATIONS
PRINT INTEGRATED SURFACE FLUX,ITERATION:EACH
PRINT CP-TIME/ITERATION,EACH
PLOT  EMERGENT FLUX,ITERATION:LAST
PRINT OUTPUT MODEL,ITERATION:LAST,DEPTH INCREMENT:1    (STRUCTURE ONLY)
PRINT CORRECTIONS OF LAST LINEARIZATION,ITERATION:LAST,DEPTH INCREMENT:1
LP-PLOT OPTICALLY THICK/THIN,ITERATION:LAST, FILE ONLY
PLOT IONIZATION FRACTIONS ${IONFRAC}  -8.5  2.5  -10.0  0.5
.
MACHINE  ‘ hostname ‘
eos
#
l s  -l  ${MI}
cp ${MI} MODIN;  chmod 600 MODIN
l s  -l  ${aa}
cp ${aa} ATOMS
l s  -l  ${ f f }
cp ${ f f } FGRID
/home/rauch/data/get_OP > /dev/ null
#
l s  -l  ${BI}/${code}_${mod}${type}${sys}
${BI}/${code}_${mod}${type}${sys} < DATEN
#
i f  test  -s  MODOUT
then
  echo ”new NLTE  model ${MO} created”
# save input model before replacement
  cp ${MI} ${MI}_ ‘ date +%y-%m-%d}_%H:%M:%S ‘
  cp MODOUT ${MO}
  chmod 600 ${MO
   l s  -l  ${MO
   i f  test  -s  STOP
  then
    cp STOP ${MO}. converged
   f i
e l s e
  echo ”no new model ${MO} created” > ${MO}. f a i l e d
  touch ${MO}.failed@$HOSTNAME
  echo ”no new model ${MO} created”
   i f  test  -s  MODTMP
  then
    echo ”model found from  i t e r a t i o n  before  f a i l u r e ”
    cp ${MI} ${MI}_ ‘ date +%y-%m-%d_%H:%M:%S ‘
    cp MODTMP ${MO}_tmp
     l s  -l  ${MO}_tmp
   f i
f i
#
# save plot data  f i l e s
i f  test  -s  IONPLOT
then
  cp IONPLOT ${ jobdir }/${name}. ${IONFRAC}_ion
f i
i f  test  -s  PLLP
then
  cp PLLP ${ jobdir }/${name}. lp
f i
i f  test  -s  PLOTCORR
then
  cp PLOTCORR ${ jobdir }/${name}. corr
f i
i f  test  -s  PRFLUX
then
  cp PRFLUX ${ f l x d i r }/${name}. flux
f i
i f  test  -s  STRUCTURE
then
  cp STRUCTURE ${ jobdir }/${name}.T-structure
f i
#
f i
#
# do not edit the rest of this  f i l e
#####################
set +x ;  ${HOME}/. jobend ${TMPDIR}
8cAp2x22-124000183:

D.9 Naming the TMAP models

In the framework of the Virtual Observatory, TMAP models and SEDs that are calculated from them have to follow a general rule. The models’ names have to start with Teff (TTTTTTT) and log g (G.GG), followed by the element abundances in mass fractions. An example is

0100000_7.00_H:__9.0000E-01_HE:_1.0000E-01 .

This is suitable for a small number of elements, where the level name stays relatively short. Thus, the general form for a model name is then

TTTTTTT_G.GG_ABUND_<nnn> ,

where nnn is a three digit integer code. ABUND_nnn corresponds to a file with the same name (located e.g. in the model directory). It has the form

H |~|  |~| 9.0000E-01 |~| <source ...>
HE |~| 3.0000E-05 |~| <source ...>
C |~|  |~| 4.0000E-06 |~| <source ...>
N |~|  |~| 2.0000E-06 |~| <source ...>
O |~|  |~| 1.0000E-05 |~| <source ...>
NE |~| 2.0000E-03 |~| <source ...>
SI |~| 8.0000E-06 |~| <source ...>
FE |~| 1.0000E-03 |~| <source ...>
NI |~| 2.0000E-05 |~| <source ...>

Please use one line per element, starting with the TMAP element code. The abundances are in mass fraction. The entry for the source of the abundances is optional and format free. Avoid to use any string that will be erroneously identified as an element code by a UNIX grep command!

In the TMAP jobs, the following has to be inserted to set some shell variables (${moddir} is the model directory, ${abund_old} and ${abund_new} may be used for different abundances).

#
abund_old="ABUND_001"
abund_new="ABUND_001"
#
#
# abundances in mass fraction (see files)
#
# old abundances
oldabund=${moddir}/${abund_old}
#
Hold=‘grep "H |~|  |~| " ${oldabund} | awk ’{ print $2 }’‘
HEold=‘grep "HE |~| " ${oldabund} | awk ’{ print $2 }’‘
Cold=‘grep "C |~|  |~| " ${oldabund} | awk ’{ print $2 }’‘
Nold=‘grep "N |~|  |~| " ${oldabund} | awk ’{ print $2 }’‘
Oold=‘grep "O |~|  |~| " ${oldabund} | awk ’{ print $2 }’‘
NEold=‘grep "NE |~| " ${oldabund} | awk ’{ print $2 }’‘
SIold=‘grep "SI |~| " ${oldabund} | awk ’{ print $2 }’‘
FEold=‘grep "FE |~| " ${oldabund} | awk ’{ print $2 }’‘
NIold=‘grep "NI |~| " ${oldabund} | awk ’{ print $2 }’‘
#
#
# new abundances
newabund=${moddir}/${abund_new}
#
Hnew=‘grep "H |~|  |~| " ${newabund} | awk ’{ print $2 }’‘
HEnew=‘grep "HE |~| " ${newabund} | awk ’{ print $2 }’‘
Cnew=‘grep "C |~|  |~| " ${newabund} | awk ’{ print $2 }’‘
Nnew=‘grep "N |~|  |~| " ${newabund} | awk ’{ print $2 }’‘
Onew=‘grep "O |~|  |~| " ${newabund} | awk ’{ print $2 }’‘
NEnew=‘grep "NE |~| " ${newabund} | awk ’{ print $2 }’‘
SInew=‘grep "SI |~| " ${newabund} | awk ’{ print $2 }’‘
FEnew=‘grep "FE |~| " ${newabund} | awk ’{ print $2 }’‘
NInew=‘grep "NI |~| " ${newabund} | awk ’{ print $2 }’‘
#

In the input files of e.g. PRO2 respective cards have to use the XXnew variables (XX is the element):

CHANGE |~| ABUNDANCE |~| H |~|  |~| ${Hnew} |~|  |~| MASS FRACTION
CHANGE |~| ABUNDANCE |~| HE |~| ${HEnew} |~| MASS FRACTION
CHANGE |~| ABUNDANCE |~| C |~|  |~| ${Cnew} |~|  |~| MASS FRACTION
CHANGE |~| ABUNDANCE |~| N |~|  |~| ${Nnew} |~|  |~| MASS FRACTION
CHANGE |~| ABUNDANCE |~| O |~|  |~| ${Onew} |~|  |~| MASS FRACTION
CHANGE |~| ABUNDANCE |~| NE |~| ${NEnew} |~| MASS FRACTION
CHANGE |~| ABUNDANCE |~| SI |~| ${SInew} |~| MASS FRACTION
CHANGE |~| ABUNDANCE |~| FE |~| ${FEnew} |~| MASS FRACTION
CHANGE |~| ABUNDANCE |~| NI |~| ${NInew} |~| MASS FRACTION