A Walkthrough of XSTAR

Spherical photoionized cloud

In this section we illustrate how to use XSTAR’s interface. Once XSTAR is installed and configured, at the unix prompt, type:

unix> xstar

By invoking XSTAR with this simple command, you will be prompted for a series of physical and control parameters for the simulation.

The input parameters that must always be specified are: The model (initial) temperature, density, spectrum shape, ionizing luminosity, column density, ionization parameter, and elemental abundance table. Definitions for these and the units assumed are described in detail in chapter User Input to XSTAR. All input parameters have default values, selected by pressing return at the prompt, thus it is possible to simply start XSTAR as above to invoke the default model.

In this example we model a spherical, constant density cloud with a source at its center. The cloud is optically thin. The source luminosity is \(10^{32}\,\text{erg}\,\text{s}^{-1}\). The ionization parameter at the inner edge of the cloud is \(\log(\xi)=5\). The ionizing spectrum is a power law with energy index \(-1\). We assume all elemental abundances are solar but exclude Li, Be, B. The total column denstity is \(10^{19}\,\text{cm}^{-1}\). In this example, we require thermal equilibrium by expicitely setting the hidden parameter niter to 99 and spherical symmetry by setting the covering fraction cfrac to 1.

Call XSTAR from the command line:

unix> xstar niter=99 cfrac=1
xstar version 2.59cj
temperature (/10**4K) (0.:1.e4) [400.] 1000.
density (cm**-3) (0.:1.e21) [1.e+4] 1E+6
spectrum type?[pow]
radiation temperature or alpha?[-1.]
luminosity (/10**38 erg/s) (0.:1.e10) [1.e-6]
column density (cm**-2) (0.:1.e25) [1.E17] 1E19
log(ionization parameter) (erg cm/s) (-10.:+10.) [5.]
abundance table[xdef]
model name[XSTAR Default] 'filled sphere'

Alternatively, XSTAR can called directly with command-line parameters to avoid prompting.

xstar cfrac=1 temperature=1000. density=1.E+6 spectrum='pow ' \
trad=-1. rlrad38=1.E-6 column=1.E+19 rlogxi=5. abundtbl='xdef' \
modelname='filled sphere' niter=99

The terminal output reports the progress of the XSTAR run. Each line represents a spatial zone. For each spatial zone, XSTAR prints the radius, stepsize, column density, ionization parameter, electron fraction, temperature, heating/cooling balance, optical depth in forward and reverse direction, and number of iterations required to reach thermal equilibrium.

xstar version 2.59cj

pass number=           1          -1
  log(r) delr/r log(N) log(xi) x_e   log(n) log(t) h-c(%) h-c(%) log(tau)
                                                              fwd    rev
  10.50 -36.00 -10.00   5.00   1.21   6.00   7.77  -0.00   0.00 -10.00 -10.00 15
  10.50 -36.00 -10.00   5.00   1.21   6.00   7.77  -0.00  -0.00 -10.00 -10.00  1
  10.62  -0.60  16.02   4.75   1.21   6.00   7.75   0.00  -0.00 -10.00 -10.00  5
  [...]
  12.98  -0.00  18.98   0.04   1.20   6.00   4.33   0.01   0.12  -2.39 -10.00 14
  13.00  -0.00  18.99   0.01   1.20   6.00   4.32  -0.01   0.12  -2.32 -10.00 13
  13.00  -0.00  19.00  -0.00   1.20   6.00   4.32  -0.01   0.12  -2.30 -10.00 13
 final print:           0
xstar: Prepping to write spectral data
xstar: Done writing spectral data
total time   1663.5743254758418

Upon completion, the following output files are produced:

unix> ls
xout_abund1.fits
xout_cont1.fits
xout_lines1.fits
xout_rrc1.fits
xout_spect1.fits
xout_step.log

A detailed description of the output files is given in XSTAR output. The ASCII file “xout_step.log” contains mostly diagnostic information. Information about ion fractions, line and continuum emission and absorption as well as spectral information is stored in several FITS files.

In this example we are interested in the total optical depth of the cloud as a function of energy. This information can be obtained from the spectral file “xout_spect1.fits”. The file structure can for example be inspected with the FTOOL fstruct:

unix> fstruct xout_spect1.fits


  No. Type     EXTNAME      BITPIX Dimensions(columns)      PCOUNT  GCOUNT

0  PRIMARY                 16     0                           0    1
1  BINTABLE PARAMETERS      8     66(5) 56                    0    1

   Column Name                Format     Dims       Units     TLMIN  TLMAX
   1 index                      1I
   2 parameter                  20A
   3 value                      1E
   4 type                       10A
   5 comment                    30A

2  TABLE    XSTAR_SPECTRA   8     69(5) 9999                  0    1

   Column Name                Format     Dims       Units     TLMIN  TLMAX
   1 energy                     E13.5               eV
   2 incident                   E13.5               erg/s/erg
   3 transmitted                E13.5               erg/s/erg
   4 emit_inward                E13.5               erg/s/erg
   5 emit_outward               E13.5               erg/s/erg

FITS files can be processed with various programming languages and tools. In this example we are interested in the transmitted spectrum. Here we use Python to plot the transmitted spectrum in \(300\,\text{eV}\text{--}800\,\text{eV}\) range.

>>> import matplotlib.pyplot as plt
>>> from astropy.io import fits
>>> import numpy as np
>>>
>>> hdul = fits.open('xout_spect1.fits')
>>> en = hdul[2].data['energy']
>>> trns = hdul[2].data['transmitted']
>>> hdul.close()
>>>
>>> plt.plot(en, trns)
>>> plt.xscale("log")
>>> plt.yscale("log")
>>> plt.xlim(300,800)
>>> plt.ylim(100, 400)
>>> plt.xlabel("Energy (eV)")
>>> plt.ylabel("Transmitted Flux")
>>> plt.show()
_images/wt-trans.png