Astron. Astrophys. 359, 1042-1058 (2000)

## 3. Numerical method

In this section we describe the complete numerical method. It is more stable and more accurate than the one used in Paper I and allows to take into account H, He, C, N and O simultaneously in all calculations. The stability of the methods used requires that the Courant condition is fulfilled. If is the geometrical distance between two grid points, v the velocity and the time step-width, then the relation must be valid. Therefore we use a primary grid (described in Sect. 3.1) for the construction of the stratification and for each element a variable secondary grid (Sect. 3.2) for the diffusion and mass loss calculations. The spacing of the secondary grids are such that the Courant condition holds.

At each point of the fixed gas pressure scale we would like to calculate the time-derivative of the mass fraction of an element l. The mass-fraction is defined as

is the atomic weight, the proton mass and the density. The mass fraction may change because of the effects of diffusion and wind. The corresponding variation of the particle density will be denoted as . Mass loss and diffusion do not change , because the wind velocity is derived from the equation of continuity (see Sect. 2) and diffusion does not lead to a net mass flow. However, the stellar structure changes with time. For example, if the gravity increases the mass-depth at a given gas pressure decreases. So mass elements move to larger values on the scale. In the presence of concentration gradients, this leads to variations of the composition at the various points on the scale. We denote the corresponding time-variation of the mass-fraction with . Alltogether we then have

For the particle density and the total velocity v of an element, in the following we omit the indices l:

is obtained from the equation of continuity for radial symmetry:

This equation has to be evaluated numerically for each element. Under certain conditions, which are fulfilled preferably in the outer regions, we use a modified upwind scheme described in Sect. 3.3. Otherwise the monotonic transport scheme described in Sect. 3.4 is used.

The variation of the mass fraction due to the stellar evolution is written as

m is the mass depth, is the time variation of the mass depth at a given point on the scale. The numerical evaluation of Eq. (9) is described in Sect. 3.5. The boundary conditions and the time integration are described in Sects. 3.6 and 3.7. Then we will briefly comment on the stability of the method.

In the following subsections some conventions are used. The indices i and j, which denote the points of the primary and the secondary grid, respectively, are defined such that they are 1 at the outer boundary and increase to the stellar interior. The geometrical depth variable r, however, is the distance from the stellar center and thus increases in opposite direction. The velocities and flows have a positive sign if they are directed to the stellar surface.

### 3.1. The primary grid

For the calculation of the stratification a grid is constructed as described in Unglaub & Bues (1997). For the gas pressure at the outer and inner boundaries we chose and , respectively. The grid spacing is

The points denoted as in Unglaub & Bues (1997) define the primary grid of the present calculations. At each grid point the diffusion and wind velocities are calculated.

### 3.2. The secondary grid

Let and be the diffusion and wind velocities for a given element at the points of the primary grid and the distance of point i from the stellar center. With we denote the chosen time step-width. It is not necessarily identical with the actual time step-width which may be smaller (see Sect. 3.7). These points of the primary grid which are simultaneously points of the secondary grid are found from the following condition:

The expression represents the relation between the indices j of the secondary grid and the indices i of the primary grid. The outer boundary of the primary grid is per definition a point of the secondary grid, so that . The left inequality is our numerical representation of the Courant condition. The time which the flow needs to proceed from point j to must be smaller than . In other words, the distance the flow proceeds during a time step must be smaller than the distance between two grid points. In addition we demand that at least in the outer regions is of the same order of magnitude as . This is the meaning of the second inequality. This additional condition improves the accuracy in the regions where the modified upwind scheme is used.

The points j represent zone centers. At these points the time derivations of the number densities will be evaluated. The inner and outer boundaries of the zone j will be denoted with and , respectively. To evaluate the various quantities like velocity or radius at the zone boundaries, let us consider the following expression:

If is an integer, then the quantities at this point of the primary grid are taken. Let, however, be , where k is an integer. In this case the mean values of the quantities at the points k and of the primary grid are used. So the point is exactly at the geometrical center of the points j and only if the primary and secondary grids are identical.

### 3.3. The modified upwind scheme

At a grid point j the modified upwind scheme is used if the following two conditions are fulfilled. denotes the flow of the considered species of particles.

The first condition means, that the flows at point j as well as at the two neighbouring points must have a positive sign: they are directed to the stellar surface. The second condition means that near point j the primary and secondary grid are not identical. Both conditions are fulfilled preferably in the outer regions, where the wind velocity is large in comparison to the diffusion velocities and where during one time step the flow covers a distance which is larger than the distance between two points of the primary grid.

Now we denote with the number of particles per unit time which cross a surface . Then is the number of particles per unit time, which enter the zone j via its inner boundary and is the corresponding number which leave the zone via the outer boundary. We use the numerical representations

The obvious method would be to evaluate the values n, v and r at the zone boundary. This is numerically unstable, however. In the usual upwind scheme only the particle density n is evaluated upstream, whereas the velocities are evaluated at the zone boundaries. This would be very unconvenient for our purposes, because in the outer regions n and v may vary by order of magnitudes between the grid points. The particle flows, however, are similar at the various grid points, at least if the composition gradient is not too large. For this reason we evaluate all quantities upstream. The time derivative of the particle density of an element at point j is obtained from

The expression in the denominator on the right would be the volume of the zone j, if were used. However, we use

This is more consistent with our upwind evaluation of r in Eqs. (15) and (16).

### 3.4. The monotonic transport scheme

The monotonic tranport scheme (abbreviated mono scheme) is used, if the conditions (13) and (14) are not fulfilled. This is the case especially in the inner regions, where the primary and the secondary grid tend to be identical. The basic ideas from which the mono scheme is derived are described in Hawley et al. (1984). It is an improved upwind scheme, which combines stability with accuracy. In deep regions, during one time step the flow covers a distance which is small in comparison to the distance between two points of the primary grid, so that . Especially in such cases the mono scheme is more accurate than the upwind scheme.

According to the mono scheme the flow at the zone boundary , for example, is evaluated as follows:

is the geometrical distance between the points j and as defined in Eq. (18). In a similar way the flow at the outer zone boundary is obtained. The mono scheme requires the knowledge of the time step. However, we fix after the time derivatives for the various elements have been calculated. Therefore we must use the , which is equal or larger than (see Sect. 3.7). The spatial derivative at a point j is evaluated similar as in Hawley et al. (1984):

For the mono scheme is identical with the upwind scheme. With the flows and at the inner and outer zone boundaries, respectively, the number of particles crossing the boundaries per unit time are obtained according to:

Then the time derivative of the particle density of an element at point j is

### 3.5. The evaluation of

To evaluate the variation of the mass fraction of an element l, which is due to changes of the mass depth at a given point, according to Eq. (9) we need numerical representations of and . Here m is the mass depth and X is the mass fraction of an element (the index l is omitted). At a point j we use the obvious representation:

An exception is the point which represents the inner boundary. Here is used:

The variation of the mass depth during the considered time step is obtained by linear extrapolation from the preceding time step with

is the width of the preceding time step. The nominator on the right represents the difference between the actual mass depth at point j and the corresponding mass depth in the preceding model.

### 3.6. Boundary conditions

The outermost points of the primary and secondary grid are identical. The point represents the center of the outermost zone. The outer boundary of this zone is beyond of our computation domain. The gas pressure at is for all our computations. Therefore the density will be low enough, so that for the considered mass loss rates the wind velocity is usually large in comparison to the diffusion velocities. As shown in Paper I this tends to smooth out concentration gradients. This justifies the assumption of homogeneous composition in the region between the two outermost grid points:

This choice avoids numerical problems at the outermost point. At the lower boundary () at , we assume that diffusion and mass loss do not change the mass fractions. Only if the mass depth at decreases, the composition is allowed to vary. In this case mass elements located within our computation domain at move to the lower boundary. So we obtain the inner boundary condition:

### 3.7. The time step

In Sect. 3.2 we have introduced the chosen time step width . This value is used to define the secondary grids for the various elements and to obtain the time derivatives of the particle densities according to the monotonic transport scheme. For all calculations presented in this paper is used. The drawback of the numerical method is, that during many time steps the composition fluctuates around some slowly changing mean value. To restrict these fluctuations, during one time step we do not allow the mass fractions to vary by more than . For each element l at each grid point j we define

is the time, for which the mass fraction would change by . The actual time step width used in the computations is the minimum value of and all :

In most cases and are identical. Exceptions may occur, if one of the elements has an extremely low abundance or during the calculations for helium-rich white dwarfs with traces of hydrogen. Then may be smaller than . The new mass fractions of the element l at the points j of the secondary grid are obtained according to

The new mass fractions of these points i of the primary grid, which are not points of the secondary grid, are obtained from interpolation. Then a new model is constructed. The various velocities and particle densities and the secondary grids are updated after each time step. Other quantities like opacities, radiative accelerations per particle and mass loss rates are updated only if the mass fraction of at least one element has changed by at least at one of the grid points.

### 3.8. The stability of the method

The method is by far more stable than the one used in Paper I. There the stable upwind scheme has been used only for the part of the flow which is due to the wind, whereas the diffusion flows have been evaluated at the zone boundaries. Then unstabilities occurred in cases of very large diffusion velocities. This may happen for extremely low abundances, where the radiative acceleration may be much larger than the gravitational one. Therefore in the present method stable schemes are used for the total flow. If the velocities increase the grid is adapted by increasing the distances between the points. We use a separate grid for each element. So if one element requires a coarse grid (because of large velocities), the grids for the other elements can be kept more refined, which means a better accuracy. However, numerical instabilities may still occur under certain circumstances. This is for the case of helium-rich white dwarfs with small admixtures of hydrogen ( by number).

© European Southern Observatory (ESO) 2000

Online publication: July 13, 2000