          Astron. Astrophys. 344, 282-288 (1999)

## 3. Monte Carlo procedures

In this section, the Monte Carlo methods used to obtain the temperature distribution in an extended, spherically symmetric, non-grey stellar atmosphere are described. These methods represent a continuation and extension of previous work on stellar winds (Abbott & Lucy 1985; Lucy & Abbott 1993), supernovae (Lucy 1987; Mazzali & Lucy 1993), and photoionized nebulae (Och et al. 1998).

### 3.1. Energy packets and radiative equilibrium

In Monte Carlo treatments of radiative transfer, we can take the calculation's "quanta" to be photons, thereby simulating exactly the physical processes occurring as matter and radiation interact. However, we also have the freedom to take the quanta to be packets of photons of the same frequency so that is the energy content of a packet containing n photons. This is often advantageous. For example, taking all packets to have the same energy implies that packets in the infrared have large numbers of photons that one thereby avoids following individually (Abbott & Lucy 1985).

In this investigation, photons are also grouped into packets of constant energy but now with the motivation of rigorously imposing the constraint of zero flux divergence on the Monte Carlo radiation fields derived for an iterative sequence of approximate temperature distributions. Thus, when a packet of radiant energy suffers a pure absorption event, it is re-emitted with frequency in accordance with the emissivity of the medium and with energy This simple but powerful device constrains the radiation field to be divergence-free at each and every iteration, and this has the following consequence: For a not-yet-converged temperature stratification, this Monte Carlo radiation field will in general be a closer approximation to the final radiative equilibrium solution than would be that derived by actually solving the equation of radiative transfer. Accordingly, successively bringing matter into thermal equilibrium with a sequence of such divergence-free radiation fields should result in rapid convergence, with acceptable results if sampling errors are small enough.

As the above remarks imply, with the adopted procedure, the derived Monte Carlo radiation fields only represent solutions of the equation of radiative transfer when the temperature distribution has converged to the radiative equilibrium solution, for only then does Eq. (1), which implies a balance between the rates of absorption and emission of energy, correspond to physical reality. Apart from sampling errors, the divergence-free radiation fields at early iterations differ from the final solution only in consequence of the temperature dependence of the absorption and scattering coefficients. Accordingly, for grey atmospheres "convergence" is immediate, since successive temperature iterates then differ only because of different sampling errors.

### 3.2. Initiation

In order to carry out the Monte Carlo calculation, the extended atmosphere is approximated by J spherical shells, with the jth shell having inner and outer radii and , and these radii are such that is constant. Within each shell, the density , the temperature T, and the scattering and absorption coefficients , are constant. This crude, low-accuracy discretization is common practice in Monte Carlo treatments of radiative transfer because it simplifies the sampling of flight paths. The shell densities are obtained from Castor's code; the other variables are derived iteratively as the radiative equilibrium solution is found.

At the lower boundary , the outwardly-directed radiation field is taken to be - i.e. isotropic in the outward hemisphere with black body intensity at unknown "boundary" temperature . Using the current estimate of , energy packets are selected according to this boundary condition as follows:

(1) The mid-probability points of K equal probability bins for black body emission are determined from the equation with k = 1, 2, ..., K. Note that this calculation can be done in terms of the frequency variable , and so need not be repeated when changes.

(2) An integer k is chosen randomly from the interval and the frequency of the emitted packet set = .

(3) The initial direction cosine is taken to be where here and below z denotes a random number from the interval .

In practice, it is beneficial to depart from step (2) by introducing stratified sampling for the frequency distribution of packets emitted at the lower boundary. Thus, in fact, we constrain Poisson noise by selecting equal numbers of packets from each of the K frequency bins.

The frequency sampling at the lower boundary can be checked by computing the mean value of . For black body emission, this should = 3.83223.

### 3.3. Trajectories

Having thus launched a packet across the lower boundary, we must now compute its trajectory as it scatters off free electrons and undergoes absorptions followed by re-emissions due to bound-free and free-free processes. This trajectory ends when the packet escapes to infinity or re-enters the core by crossing the lower boundary. Notice that because of Eq. (1), packets do not disappear within the atmosphere. Nor, in this scheme, are packets spontaneously created within the atmosphere.

Within each uniform shell, the random flight path of a packet between events is which corresponds to the physical displacement given by If this displacement would carry the packet out of its current shell, then the packet is moved along its linear flight path to the boundary with the next shell, at which point a new is selected and its further progress followed in the next shell. On the other hand, if this displacement leaves the packet within the current shell, then at the end-point of the displacement the packet is either scattered or undergoes absorption followed by re-emission. We take this physical event to be a scattering if and to be an absorption otherwise.

Note that the selection of a new when a packet crosses a boundary does not result in bias: a photon always has = 1 as the expected path length to its next interaction no matter what distance it has already travelled.

After a physical event, the packet's frequency and direction cosine must be re-assigned. If the event was a scattering, the frequency is unchanged - i.e., assumption of coherent electron scattering. If the event was an absorption, the re-emitted packet is assigned frequency given by the equation where is the emissivity. In either case, the new direction cosine is selected according to the rule corresponding to isotropic scattering or emission.

As with frequency sampling at the lower boundary, the operation indicated by Eq. (8) is in practice replaced by a pre-iteration calculation of equal probability emissivity bins, and so it is the label of the bin that is randomly selected in assigning a frequency to a re-emitted packet. Note that these bins change from shell to shell and must be recomputed after each temperature-correction step.

When these emissivity bins are calculated, the mean frequency of the emissivity function for each shell can also be calculated. These can then be used to check the mean frequencies of the packets re-emitted during the Monte Carlo calculation.

### 3.4. Monte Carlo estimators

In order to detect departures from radiative equilibrium, we must first calculate the rate at which matter absorbs energy from the radiation field, and this must be derived from the Monte Carlo model of the radiation field. Now, the exact expression for this quantity is and in radiative equilibrium this balances the rate at which matter emits energy, given by Evidently, to compute , we must first compute the mean intensity . Now, in constructing Monte Carlo estimators for moments of the radiation field, the natural starting point is the basic definition of specific intensity in terms of energy flow in a given direction across a reference surface. This is the approach adopted by Och et al. (1998), leading to an estimator for given in their Eq. (13). However, for problems without symmetries, there will in general be no unique or natural reference surfaces for the volume elements of the adopted discretization. Accordingly, with respect to and weighted integrals thereof, it is preferable to construct Monte Carlo estimators from the basic result that the energy density of the radiation field in ( ) is .

At a given instant, a packet contributes energy to the volume element containing it. Accordingly, if denotes the path length between successive events, where "events" includes crossings of boundaries between volume elements, then this segment of a packet's trajectory contributes to the time-averaged energy content of a volume element, where and is the duration of our Monte Carlo experiment. The estimator for the volume element's energy density that follows from this argument gives the following estimator for the monochromatic mean intensity where V is the volume and the summation is over all flight segments in V for packets with frequencies in ( ). The corresponding estimator for the integrated mean intensity is where the summation is now over all segments in V regardless of frequency.

If we now compare Eqs. (6) and (12), we see immediately that a Monte Carlo estimator for the absorption rate is This is the expression used below in an iterative scheme to find the radiative equilibrium ( ) solution.

It is worth noting that these estimators are such that all packets entering the volume element V contribute. With estimators based on a reference surface within V, some packets will enter and depart from V without crossing that surface and so do not contribute. This, together with the total freedom allowed in the shapes of the volume elements, strongly suggest the superiority of this approach.

A further point to emphasize is that packets contribute to our estimate of the absorption rate even if they pass through V without being absorbed. Indeed, Eq. (14) returns estimates of the absorption rates throughout a model atmosphere even when that atmosphere is so tenuous that all packets pass through without absorption. This is a point of difference with the investigation of Bjorkman & Wood (1997), where the absorption rate is computed only from the packets that are absorbed in the volume element. If the estimator is thus restricted to absorbed packets, the result is noisier, is indeterminate in the optically thin limit, and we have failed to use our knowledge of the exact formula given in Eq. (10).

### 3.5. Temperature corrections

If N packets are launched across the lower boundary in our Monte Carlo experiment and of these ultimately escape to infinity, then our estimate of the star's luminosity is Since the factor has hitherto remained free, we now fix it by setting , the desired luminosity of the model.

With thus determined, Eq. (14) now gives the absorption rate throughout the atmosphere in physical units, and in general this rate will not balance the emission rate given by Eq. (11) - i.e. . To obtain a modified temperature distribution that brings the atmosphere closer to radiative equilibrium, we note that can be written as where is the Planck-mean absorption coefficient and is the integral of the Planck function. This then suggests that the temperature distribution for the next iteration should be that given by with quantities on the right-hand side evaluated from the just-completed iteration. This is the adopted temperature-correction procedure, with only the slight modification that an undercorrection factor -0.8 is commonly used.

Readers familiar with temperature-correction procedures for non-grey atmospheres will recognize that Eq. (17) can be written as where is the intensity- or absorption-mean absorption coefficient. Thus, the adopted scheme is apparently identical to the notorious lambda-iteration procedure that has long been known to fail (see, e.g., Mihalas 1970). However, this failure relates to its use with conventional transfer techniques and can be traced to the fact that Eq. (18) gives a "correction" without using information about the required constant value of . Here the Monte Carlo radiation field itself carries this information and, in fact, at all iterations rigorously obeys the constraint . Thus the adopted procedure can be described as bringing the matter into equilibrium with a radiation field that already has the correct , and the procedure only fails to converge immediately because depends on T.

The boundary temperature , which determines the frequency distribution but not the luminosity of the radiation emitted at the lower boundary, must also be iteratively improved. Now, integration of Eq. (2) gives and we also have Accordingly, after completion of a Monte Carlo step, is obtained as noted earlier from Eq. (15). Eq. (20) then gives , which on substitution in Eq. (19) yields an improved value for . The implied correction is, however, applied with the same undercorrection factor used above when iteratively correcting .    © European Southern Observatory (ESO) 1999

Online publication: March 10, 1999 