          Astron. Astrophys. 321, 485-491 (1997)

## 3. Numerical method

To solve the time-dependent diffusion problem an Eulerian differencing scheme is used, which is based on a finite difference approximation for the spatial part of the differential equations.

### 3.1. Spatial part of the equations

To evaluate the finite difference equations we introduce a primary and a secondary grid, designated as a and b, respectively (see Fig. 1). During the computations a fixed gas pressure scale is used. The mesh points of the a-grid are spaced such that the gas pressure differs by 7% between two mesh points of the a-grid. At the outer boundary ( ) values between 5000 Pa (for the case log g = 6.0) and 120000 Pa are taken. This results in 200 to 270 a-grid points for the various cases considered. For the b-grid with is If the chemical composition is known at each gridpoint (we start with constant composition at a time ) Eq. (4) can be integrated from the outer boundary (where according to the Eddington approximation) towards the stellar interior by use of a midpoint method, so that and  is the total momentum per unit volume and time which is transferred from photons to matter. At each mesh point of the a- and b-grid the Saha equations are solved and opacities and radiative forces are calculated. Fig. 1. Explanation of the variables used in the text

Now the left hand sides of Eqs. (1) as well as the are evaluated at the mesh points of the b-grid with , where the gradients of the partial pressures are represented by . If the left hand sides of Eq.(1) for the various elements are summed up the result must be zero because of momentum conservation. The numerical method as described in Eqs. (7) and (8) guarantees that this sum is exactly zero also for the equations in their discretisized form. This is important because test calculations for mixtures with helium and carbon only have shown that deviations from zero may lead to wrong diffusion velocities, if one of elements has a very low abundance. The system of Eqs. (1) and (2) is solved for the diffusion flow of each element. The boundary conditions are such that the diffusion flows are zero at the outer boundary and the chemical composition remains constant at the lower boundary Now the gradients of the diffusion flows at each mesh point of the a-grid are obtained by Note that the mesh-points of the b-grid are not exactly centered in space.

### 3.2. Time integration

In this subsection all quantities refer to the a-grid. The chemical composition is specified by the ratios of the number density of each element l relative to helium From the equation of continuity  is derived. The composition at a timestep is obtained from the at time t by The stepwidth is such that during one timestep does not change by more than one percent at any mesh point. After each timestep a new model is constructed by integration of the Eqs. (7) and (8). However, the opacities and the radiative forces per particle are updated only if the of one of the elements has changed by at least 5% in at least one of the volume elements. During the first timesteps steadily increases from a few weeks to not more than a few years. After some hundreds of years the outermost regions are already very close to a diffusive equilibrium state, because the diffusion time scales are much shorter there than in the inner regions. Then, however, the stepwidth scarcely increases any more. Although the diffusion flows have decreased by a factor of 100 to 1000 in the outermost volume elements, because of numerical reasons they do not vanish. This effect leads to oscillations of the around their equilibrium value and restricts the stepwidth according to Eq. (15). The stepwidth cannot be increased significantly by use of a factor of e.g. 0.1 instead of 0.01 in Eq. (15). This would only increase the amplitude of the oscillations. The mean change of the composition in these volume elements during several timesteps, however, is almost zero. Therefore it is not necessary to carry out the time consuming calculations of the opacities and the after each timestep. However, the computation is still as large that the method cannot be recommended for implementation into stellar evolution codes.    © European Southern Observatory (ESO) 1997

Online publication: June 30, 1998 