Astron. Astrophys. 364, 587-596 (2000)

## 2. The Monte Carlo code

My code follows closely the procedure described in Bianchi et al. (1996). The simulation is made in the following way:

1. Emission: Random place and direction of an unpolarized (pseudo)photon is calculated from the brightness distribution of the disk.

2. A random optical depth is selected, and the photon path in the disk is integrated until this optical depth is reached.

3. Scatter the photon and return to step 2, until the photon exits the disk.

4. The photon Stokes parameters are added to those of the corresponding inclination bin.

The coordinates of the photon emission place in cylidrical coordinates, with in the disk plane, are calculated from three random numbers :

where and are the functions describing the emissivity distribution. From the form of Eq. (1) and Eq. (2), it is clear that and should be simple enough to allow direct calculation of and , or and should be tabulated. The limits of the integral in Eq. (2) are dependent on radius. To solve this problem efficiently, the limits are set by selected values of vertical optical depth, defined by

Now two values of vertical optical depth, , are selected. All photons are emitted between these. This parametrization is made to help distinguishing between different energy sources. It is important to restrict the emission to layers near the disk surface, as the optical depth from the disk plane is very large, of the order 10000, in the inner disk. Otherwise most of the computing effort would go to modelling the radiative transfer in the disk plane, which is irrelevant for the polarization of observed radiation. Also, the polarization of radiation from is saturated, i.e. it is consistent with the Chandrasekhar solution of semi-infinite slab (Wood et al. 1996).

Some of the scattered photons travel to the disk plane, reaching very large optical depth values. They scatter around in the deeper layers and most of them will never exit the disk. If these photons are not eliminated from the simulation, most of the time is spent for their radiative transfer, which is also irrelevant for observed polarization. Therefore all photons crossing the bottom of the radiating layer are discarded.

From these the vertical optical depth corresponding to random place between and can be calculated.

Substituting to Eq. (4), z can be solved. To simplify the calculations, I adopt exponential vertical structure, , so that Eq. (4) can be inverted analytically.

From the above equations, the three coordinates of a random emission place corresponding to some emissivity and density distribution can be solved. and were used. The inner disk radius, , was set to one, and the maximum radius, , was set to a value corresponding to the outer edge of the simulated disk model, and were set to constant values.

The direction angles of the emitted photon are calculated from and where are random numbers. After emission, the photon travels to a random optical depth , which is calculated from

When the optical depth and direction to which the photon travels, are known, the density distribution can be integrated until either is reached or the photon exits the disk. Formally this can be expressed as

If the photon is still in the disk, three more random numbers are required, two to obtain the scattering direction .

where is the degree of polarization before scattering, and is measured from the direction of incident ray polarization. The third random number is needed for calculating the new optical depth from Eq. (8). A total of random numbers are required for a photon scattering N times.

The Stokes parameters of each photon exiting to a specific inclination interval are summed to get the approximate solution for the radiative transfer. The mean error of the mean of the Stokes Q and U parameters can be calculated for each inclination bin from:

Where the summations with indices i and j include all photons in the bin, and N is the number of photons in the bin. Eq. (12) has one significant drawback: The double sum can not be computed, unless all the Stokes parameters of each photon are known. This reduces the efficiency of simulations severly. If N is large, the error can be approximated by expanding the square in Eq. (12), and setting the term with highest power of to zero. The small negative term left inside the square root is divided by two to prevent any artificial decrease of the error estimate. The new error estimate is:

This has also been used in (Wood et al. 1996) to estimate the errors of the simulation. The sums in Eq. (13) can be calculated during the simulation, as the double summation vanishes. The error of Stokes I is insignificant when compared to the errors of Q and U.

I tested the simulation code with several simple geometries. Results of simulations were also compared to those of (Coulson et al. 1960), who have calculated the polarization arising from a plane-parallel atmosphere with Rayleigh scattering using Chandrasekhar functions. My simulations reproduced these results without difficulty.

© European Southern Observatory (ESO) 2000

Online publication: January 29, 2001