## Appendix A: the codeOur code is applicable to a wide range of astrophysical problems
involving (sub) millimetre and infrared
( Fig. A.1 gives an overview of the structure of our code, which consists of two parts. The first runs the Monte Carlo simulation solving the radiative transfer and molecular excitation. The second part uses this solution to calculate the emission that would be observed from this source above the atmosphere and with perfect spatial and velocity resolution, given a source distance and, for cylindrically symmetric models, inclination. This latter part can also be used to calculate the continuum radiation emitted by the source. Its output format is that used by the MIRIAD package [Multichannel Image Reconstruction, Image Analysis, and Display; Sault et al. (1995)]. This package, designed to analyse interferometric spectral line data, includes many processing options such as convolution with a single-dish beam and modeling of aperture-synthesis visibilities, as well as a wide variety of imaging capabilities. MIRIAD also allows easy conversion to the ubiquitous FITS format and portability to other software packages.
Both parts of the code are controlled by UNIX C-shell scripts that extract information from the provided input and compile an executable code. In this way, the size of several arrays containing the source model, the collisional rate coefficients, etc., can be adjusted to the required size, minimizing memory requirements. The source code is written in FORTRAN-77. Following the flow chart of Fig. A.1, the following steps describe the Monte Carlo part of the code in more detail. -
The code starts by reading a list of keywords, detailing the required signal-to-noise ratio on the level populations, the initial number of photons in each cell (), and pointers to the source model, the systematic velocity field (if any), the description of the dust emissivity, and the molecular energy levels and collisional rate coefficients. The velocity field can be defined simply through the source model with each grid cell moving at a constant speed, or it can be a constantly varying function over each cell. The source model can be a series of concentric shells covering a region from the origin to a maximum radius, or a series of stacked cylinders fully covering a region out to a maximum radius and height. Collisional rate coefficients are available for many astrophysically interesting species and common collision partners such as H _{2}in the and in the levels, e^{-}, and He. Our code currently allows for two simultaneous collision partners, e.g., H_{2}and e^{-}, each with its own density and temperature. For molecular ions such as HCO^{+}, excitation due to collisions with electrons can be significant compared to collisions with H_{2}at fractional ionization (). Often, listed rate coefficients are equivalent rates per H_{2}molecule including contributions from He at cosmic abundance. The results of our code, and any non-LTE calculation, sensitively depend on the quality of the rate coefficients. Recently, Black (2000) discussed the need for good rate coefficients and the effects of other implicit assumptions of radiative transfer codes. -
In the first stage of the calculation, the radiation field is based on rays per cell, each starting at a random position equally distributed over the cell volume, pointing in a random direction, and at a random frequency within 4.3 times the local line width around the local systematic velocity vector. The value of 4.3 corresponds to the width where the line profile has dropped to less than 1% of its peak. In this stage, in each iteration the *same*series of random numbers is used, so that there are no random fluctuations in the coverage of the radiation field. -
For each ray, the distance *ds*from the ray's origin to the nearest boundary of the cell along its randomly chosen direction is calculated. The incident radiation along the ray then follows from integrating Eq. (2) in a stepwise manner from cell edge to cell edge, attenuating the contribution from each cell by all intervening cells, with the cosmic microwave background as a boundary condition. The only quantity that changes when stepping through a cell is the direction, and possibly the magnitude, of the systematic velocity vector, which enters Eq. 2 through the line profile function . Changes of within cells are tracked by subdividing the integration into small steps as needed. -
Armed with the set of for each ray, the radiation field in the cell follows from Eq. (14). A consistent solution of this equation and the level populations (Eq. 10) quickly follows from iteration to a relative accuracy of in the populations. Limitations on masering are discussed in Sect. 3.4. -
The first stage of the code repeats items 2-4 until the largest relative fractional difference between the populations in all cells of three subsequent solutions is ten times better than ultimately required. Since the angular sampling is the same in each iteration, these differences are free of random noise but might not adequately sample all directions and frequencies. -
The second stage of the code proceeds along similar lines as the first stage, but with a *different*set of random numbers in each iteration. The only other difference is, that each time the maximum fractional error in the populations in a cell exceeds the requested accuracy, the number of rays in that cell is doubled. This stage lasts until all cells comply with the required accuracy, after which the solutions are written out to a file.
The second part of the program calculates the emission distribution on the sky for a given source distance and inclination by simple ray tracing. The output from the Monte Carlo code forms the input for this ray-tracing code. Since it uses much of the same code as the Monte Carlo part, geometry and radiative transfer being the same, it is not further discussed here. ## Appendix B: comparison with other codesThis section describes two cases to test our code against well-documented calculations with Monte Carlo codes from the literature. For further tests, we refer the reader to the web-page collecting a number of standard test cases, which has resulted from the 1999 workshop on Radiative Transfer in Molecular Lines at the Lorentz Center of Leiden University (http://www.strw.leidenuniv.nl/~radtrans ). ## B.1. Bernes' CO cloudIn his seminal paper on Monte Carlo methods for radiative transfer
and molecular excitation, Bernes (1979) presents a constant-density,
constant-temperature, optically thick cloud model. The density of the
cloud, cm
## B.2. Model for B 335 by Choi et al.Another critical element of any radiative transfer code is its
ability to correctly deal with systematic velocity fields. The
inside-out collapse model as outlined in Sect. 2 is well suited
for such a test, because of its wide range in velocities from zero to
many times the turbulent line width combined with significant optical
depth. As a test case, we calculate the populations and the emergent
spectrum of several CS and H Fig. B.2 compares the resulting excitation temperature
distribution with the results of Choi et al. The agreement is very
good for CS, where we used the same collisional rate coefficients
(Table 1). For H
Fig. B.2 also plots the excitation temperatures obtained for the same model but using the cylindrically symmetric code. Both codes clearly give consistent answers; the small `wiggles' in the excitation temperatures as function of radius in the output of the cylindrically symmetric calculation can be attributed to geometrical defects when trying to fit a sphere in a series of stacked cylinders. © European Southern Observatory (ESO) 2000 Online publication: October 24, 2000 |