Sunday, 2 February 2014

Diatomic partition functions in IDL

Recently I posted a set of IDL routines for the atomic partition functions (PF) based on various polynomial fits that are available in the literature. Here I do the same for the diatomic molecules.

The routines for the diatomic PF use an internal catalog of 325 diatomic molecules. The ionized molecules are separate entries. The catalog is stored as an IDL structure in catalogue_of_diatomics.sav. The structure has the following tags for every molecule:

Name
Chemical formula, e.g. 'H2', 'CO', 'H2+'
NcNumber of constituents, always 2 for diatomics
NucNumber of uniq constituents, e.g. 2 for CO, 1 for H2
ConstituentsConstituent atoms, e.g. ['H', 'H'], ['C', 'O']
ChargeCharge, e.g. -1, 0, +1
CodeKurucz's code for molecules, e.g. CO '0608.00'
D0Dissociation energy in eV
DataList of internally available data sets for this molecule
TypeType of data: pf for partition function, kp for chemical equilibrium constant, eint for internal energy (one entry for each dataset)
ReferencesList of ADS references (for each dataset)

Wednesday, 25 December 2013

Atomic partition functions in IDL

Many books on radiative transfer and spectroscopy introduce the partition function ($U$, PF) as a statistical weight or probability that an atom is in the ionization stage $r$ at the temperature $T$. It is defined as the sum over all excitation states ($i$) of their statistical weights ($g_i$) multiplied by an
exponential factor (cf. Rutten, 2003, p.30, Eq.289):
$$U_r \equiv \sum_i g_i \mathrm{e}^{-\frac{\chi_{r, i}}{kT}},$$ where $\chi_{r, i}$ is the excitation potential of the state $i$ in the ionization stage $r$, $k$ is the Boltzmann constant) and $T$ is the temperature.

The trouble with PF is that there is an infinite number of the energy levels. No matter how small their contribution becomes (the exponential factor is decreasing with the excitation potential), PF computed after this definition goes to infinity. Farther, that means that the probability of an atom to occupy any finite state would be zero. Since this is clearly unphysical, thus there is a need to define a reliable procedure to cut off the partition function. There are many approached described in literature. However, they are usually rather non-trivial and, therefore, computing partition function even for a limited range of temperature and for a specific atomic element can be a very tedious job. The results of these computations are often published as the coefficients of the best polynomial fits for a range of temperature values. The IDL procedure that you can find below is written to load these tables from several different sources (see below) and to interpolate them for given a temperature, an atomic specie and an ionization stage.

Saturday, 12 October 2013

Use of "some useful atomic data"

To illustrate how the routines in the previous post can be used, I made a couple of plots.

Fig.1 The logarithmic solar abundances relative to hydrogen A (A(H) = 12) after Asplund et al (2009, 2009ARA&A..47..481A) versus the atomic number Z. The data are loaded using load_abundances.pro function.

Saturday, 5 October 2013

Some useful atomic data in IDL

Here I list a couple of my IDL routines that load some useful atomic data (atomic numbers up to 92 are supported).


List of elements

This routine returns symbols and names of atomic elements for a given atomic number Z.

load_list_of_elements.pro

Example:
IDL> sym = LOAD_LIST_OF_ELEMENTS([6, 7, 8], element = names)
IDL> PRINT, sym
C N O
IDL> PRINT, names
Carbon Nitrogen Oxygen


Atomic weights (aka relative atomic masses)

This routine loads the atomic weights for a given atomic number Z. The data comes from
  http://www.nist.gov/pml/data/comp.cfm

The original source is Wieser & Berglund (2009, Pure Appl. Chem., Vol.81, No.11, p.2131-2156), published as an IUPAC Tecnical Report available at:
   http://pac.iupac.org/publications/pac/pdf/2009/pdf/8111x2131.pdf

load_atomic_weights.pro

Example:
IDL> a = LOAD_ATOMIC_WEIGHTS([1, 2, 6, 7, 8])
IDL> PRINT, a
1.00790      4.00260      12.0107      14.0067      15.9994


Sunday, 29 September 2013

Cubic spline interpolation: Periodic splines

If the unknown function is periodic, then the periodicity may be used to specify the boundary conditions. Before (in the case of the natural splines) we had $n+1$ value of x and y and as a result we obtained values of the cubic polynomial at $n$ intervals.

Now our function is periodic with period $p$, thus $S(x) = S(x+p)$. In practice, we have an additional data point $x_{n+1}$, such that
$$x_{n+1} = x_0 + p,$$
and
$$y_{n+1} = y_0.$$

The total number of data points is $n+2$ and the total number of segments (and cubic splines) between them is $n+1$.

Thursday, 26 September 2013

Cubic spline interpolation: Natural splines

Last year I published a post on the data interpolation and smoothing using the cubic splines using IDL. (Soon I'll do an update of that post as well.) Here I go a step back and show how the classical spline interpolation works. As before, the derivation follows the book of D.S.G.Pollock (highly recommended to any student interested in the analysis of time-series). I'll first go through some theory general for all the cubic splines, than through the derivation of the natural cubic splines and at the end I'll show some examples. In the next post I'll describe the solution of the clamped cubic splines and do the same examples using that variation of the method.



Wednesday, 21 August 2013

Three-diagonal periodic system

Three-diagonal periodic system of linear equations can be solved in a similar way as the pure three-diagonal system. The difference is that now we have additional two coefficients in the matrix of the system ($a_0\ne0$, $c_n \ne0$). This form of a system is common when the boundary conditions are periodic (e.g. periodic cubic splines). The solution is again based on the Gaussian elimination, but because of the additional matrix elements, it requires some more steps. The system is strictly diagonal dominant. It can be proved that it has a unique solution.

There is n+1 equation. Our goal is to solve it for n+1 value of $x_i$. The matrix of the system (size $n+1\times n+1$) is of the following form (additional coefficients are shown in bold font):

\begin{equation}\left(\begin{matrix} b_0 & c_0 & 0   & \dots & 0   & 0  & \mathbf{a_0} \\
a_1 & b_1 & c_1 & \dots & 0   & 0  & 0\\
\vdots & \vdots & \vdots & \ddots & \vdots   & \vdots  & \vdots  \\
0 & 0 & 0 & \dots & a_{n-1} & b_{n-1} & c_{n-1}  \\
\mathbf{c_n} & 0 & 0 & \dots & 0 & a_{n} & b_n \end{matrix}\right)
\left(\begin{matrix} x_0 \\ x_1 \\ \vdots \\ x_{n-1}  \\x_{n}\end{matrix}\right) = \left(\begin{matrix} d_0 \\ d_1 \\ \vdots \\ d_{n-1}  \\d_{n}\end{matrix}\right)
\label{eq:matrix}\nonumber\end{equation}

or in the form of the individual equations ($n+1$ equation with $n+1$ unknown $x_i$):

\begin{eqnarray}
b_0 x_0 + c_0 x_1 + a_0 x_n &=& d_0,\nonumber\\
a_1 x_0 + b_1 x_1 + c_1 x_2 &=& d_1,\nonumber\\
\dots &=& \dots, \nonumber\\
a_i x_{i-1}+ b_i x_i + c_i x_{i+1} &=& d_i,\nonumber\\
\dots &=& \dots ,\nonumber\\
a_{n-1} x_{n-2} +b_{n-1} x_{n-1} + c_{n-1} x_{n} &=& d_{n-1},\nonumber\\
c_n x_{0} + a_{n} x_{n-1} +b_{n} x_{n} &=& d_{n}.\nonumber
\end{eqnarray}