Forum Springer Astron. Astrophys.
Forum Whats New Search Orders

Astron. Astrophys. 345, 787-812 (1999)

Previous Section Next Section Title Page Table of Contents

3. Numerical methods

The initial models are evolved using a composite N-body and hydro code developed by the Geneva Observatory galactic dynamic group, originally provided by D. Friedli but considerably modified in the present application. At each time step, the gravitational forces on all particles (gas included) are derived by the particle-double mesh method detailed in Sect. 3.1, the pressure and viscous forces on the gas particles by the Lagrangian smoothed particle hydrodynamics (SPH) technique described in Sect. 3.2, and finally the phase space coordinates of each particle are updated by integration of the equations of motion according to the algorithm presented in Sect. 3.3.

3.1. Gravitation with PM2

To compute the gravitational forces on the particles, we have resorted as in Paper I to the particle-mesh (PM) technique with polar-cylindrical grid geometry and variable homogeneous ellipsoidal kernel for the softening of the short range forces (Pfenniger & Friedli 1993). However, instead of using a single grid with constant vertical resolution, inappropriate to model efficiently the high density contrast between a thin disc and an extended dark halo, we have introduced a double embedded grid structure. The higher resolution grid (A) has [FORMULA] cells, with a maximum radial extent [FORMULA] and a vertical spacing [FORMULA], i.e. [FORMULA]. The lower resolution grid (B) has half the number of cells in each dimension of the plane, skipping every second R- and [FORMULA]-grid point of the finer grid, and the same number of cells vertically but with a spacing of [FORMULA], i.e. [FORMULA]. Hence grid B has the same radial extent than grid A, but is larger in the vertical dimension. Both grids have constant vertical spacing, thus allowing to keep the advantage of the Fast Fourier Transform algorithm in this dimension. Here [FORMULA] designates the number of active cells in z, corresponding to half the value required by the doubling-up method (Hockney & Eastwood 1981). The vertical grid parameters are chosen to satisfy:


ensuring that (i) there are grid points of each grid in the plane [FORMULA], (ii) the horizontal planes [FORMULA] delimiting vertically grid A also contain points of grid B, and (iii) grid B has at least four cells within grid A in the z dimension. Fig. 3 gives an example of double grid fulfilling all these conditions.

[FIGURE] Fig. 3. Example of a double grid with [FORMULA], [FORMULA], [FORMULA] and [FORMULA]. The solid points and dotted lines are the points and meshes of grid A, and the circles and solid lines those of grid B.

In this particle-double mesh (or PM2) method, the mass assignment to the grid cells is repeated twice (once for each grid), and the total potential involves the evaluation of three sub-potentials: [FORMULA] and [FORMULA] generated by the mass inside grids A and B respectively, as well as [FORMULA] generated by the mass within grid B but outside grid A. The potential [FORMULA] is computed on grid A, at high resolution, and the other potentials on grid B. The total potential then amounts to [FORMULA] in the region of grid A, which requires an interpolation of [FORMULA] to grid A, and simply to [FORMULA] outside this region. The increase of CPU time owing to the triple potential evaluation is amply compensated by the reduction by a factor [FORMULA] of the effective number of cells relative to a single grid with the same resolution as grid A and the same size as grid B. The transition planes between the two grids are associated with numerical discontinuities in the force components, although quite small in practice (see Fig. 4). To smooth them out, the forces in the first and last cells of grid B within grid A are taken as a linear combination so that the forces at [FORMULA] coincide with the forces of grid B and those at [FORMULA] with the forces of grid A.

[FIGURE] Fig. 4. Typical z-behaviour of model dynamical properties calculated with the high resolution double grid, i.e. [FORMULA], [FORMULA], [FORMULA], [FORMULA], [FORMULA] kpc and [FORMULA] pc (the mass distribution and the grid refer to model l10t2000). From top to bottom and in linear scales: mass density ([FORMULA]), potential ([FORMULA]) and the three force components ([FORMULA], [FORMULA] and [FORMULA]). The full lines are the results from grid A (based on [FORMULA]), and the dashed lines those from grid B (based on [FORMULA]). The vertical dotted lines indicate the limits [FORMULA] of grid A. The forces considerably differ from one grid to the other near the plane [FORMULA], but almost confound in the transition zone.

The grid parameters adopted in our simulations are given in Table 1 and the resulting gravitational resolution achieved with the high resolution double grid is depicted in Fig. 5.

[FIGURE] Fig. 5. Various spatial resolutions of the high resolution simulations presented in this paper, as a function of galactocentric radius. The solid, short dashed and long dashed lines respectively represent the vertical, azimuthal and radial semi-axes of the gravitational homogeneous ellipsoidal kernel associated with grid A, and the points are the smoothing lengths of a random selection of 10% SPH particles in model l10t2000. The gas smoothing length is close to the vertical gravitational resolution.


Table 1. List and characteristics of the simulations presented in this paper. [FORMULA], [FORMULA], [FORMULA] and [FORMULA] are the grid parameters as defined in Sect. 3.1. Both low and high resolution double grids have [FORMULA], [FORMULA] kpc, [FORMULA] kpc and [FORMULA] kpc. # is the number of particles, [FORMULA] the sound speed of the gas, [FORMULA] the gas switch-on time and [FORMULA] the time to which the simulation is performed. The points refer to the former lines.

3.2. Gas hydrodynamics with SPH

The pressure and viscous forces acting on the gas particles are derived by three-dimensional SPH. We will not repeat here the principle of this very popular Lagrangian method for solving Euler's equation of motion (see Benz 1990; Monaghan 1992 and Steinmetz 1996 for reviews), but just give the necessary specifications about this part of our code.

The relevant form of the Euler equation writes:


where [FORMULA] is the velocity field, [FORMULA] the spatial mass density and [FORMULA] the pressure of the gas. [FORMULA] is the viscosity term and [FORMULA] the gravitational force as obtained by the PM2 method.

The internal properties of a classical fluid are fully described by three macroscopic independent variables of state, like for example the density and the pressure appearing explicitly in Eq. (2), and the internal energy per unit mass [FORMULA]. The density is evaluated directly at each particle position [FORMULA] via:


where [FORMULA] is the number of gas particles, [FORMULA] the individual mass of the particles, [FORMULA] the kernel function and h the smoothing length. In SPH, this equation is equivalent to the continuity equation expressing the conservation of total mass.

A first relation between the variables of state is given by the equation of state assuming a perfect gas, i.e. [FORMULA], where [FORMULA] is the adiabatic index of the gas, which from statistical mechanics is given by [FORMULA], with f being the number of freedom degrees of the gas constituents ([FORMULA] for atomic hydrogen and [FORMULA] for molecular hydrogen). A second relation comes from the energy conservation equation, which in its general form involves cooling and heating functions. Since these functions are poorly constrained by theory, we have simply resorted to the isothermal assumption, i.e. the internal energy of the gas is at any time and everywhere the same. This assumption, partly justified by the homogeneous velocity dispersion of the warm gas component in external galaxies (e.g. van der Kruit & Shostak 1984), means that cooling and heating exactly cancel each other and that the energy released by the shocks is instantaneously radiated away. Hence, introducing the (constant) sound speed [FORMULA] to substitute the internal energy, the equation of state for particle i reduces to:


which is degenerated in sound speed and adiabatic index, depending only on the ratio [FORMULA]. With this last equation, Benz's (1990) SPH version of the pressure term in Euler's equation simply becomes:


The empirical artificial viscosity is calculated exactly as in Benz (1990). It consists of a superposition of the "bulk" and the von Neumann-Richtmyer viscosities, with the standard parameters set to [FORMULA] and [FORMULA], and takes into account Balsara's (1995) correction to avoid energy dissipation in pure shearing flows.

We have used the spherical spline kernel because of its finite spatial extension:


where [FORMULA]. To increase the hydro resolution in high density regions like shocks, the particles are assigned individual smoothing lengths [FORMULA] such that their number of neighbouring particles [FORMULA] always remains close to a fixed number [FORMULA]. Two particles i and j are defined as mutual neighbours if [FORMULA] and [FORMULA], where [FORMULA] is the symmetrised smoothing length which should enter the kernel evaluations in Eqs. (3) and (5) to ensure momentum conservation.

At each time step, the smoothing lengths are updated considering the general three-dimensional scaling law:


where [FORMULA] and [FORMULA] are constants, and [FORMULA] is added to account for particle i. Following Benz (1990), differentiating this formula and substituting the continuity equation yields:


Benz did only consider the variation of [FORMULA] ensuring the constancy of the neighbour numbers, and hence did not include the term in [FORMULA]. However, in practice, numerical fluctuations of the [FORMULA]'s can carry these number outside a reasonable range around [FORMULA]. To overcome this problem, we simply damp the systematic departure of the [FORMULA]'s from [FORMULA] setting:


in Eq. (8) and integrate the resulting equation along with the equations of motion (see Sect. 3.3). The parameter [FORMULA] controls the damping rate per time step ([FORMULA]) and should be significantly greater than 1 to avoid abrupt discontinuities in the non-gravitational forces. In all simulations we have adopted [FORMULA] and [FORMULA]. Fig. 5 shows the typical SPH resolution achieved in evolved models and Fig. 6 an example of the neighbour number distribution. The standard deviation of this distribution usually amounts to only about 1.5 neighbours. The velocity divergence in Eq. (8), which is also needed for the viscous forces, is estimated as in Benz (1990).

[FIGURE] Fig. 6. Typical distribution of the number of neighbouring SPH particles, obtained by adjusting at each time step the smoothing lengths according to Eqs. (8) and (9). The data refer to model l10t2000.

The initial smoothing lengths of the gas particles, confined near the plane [FORMULA], are derived from the two-dimensional scaling relation:


where [FORMULA] is the surface mass density profile of the gas component and [FORMULA] its switch-on time (see Sect. 5). This method unfortunately leads to a large spread in the initial neighbour numbers. To adjust the [FORMULA]'s without evolving too much the system, the simulations with live gas are therefore started with a time step much smaller than in the subsequent stabilised regime, i.e. [FORMULA] Myr for the large simulations (l-series) and [FORMULA] Myr for the smaller ones (s-series).

3.3. Integrator

To integrate the equations of motion, we have applied a semi-adaptative second order accurate algorithm where the (Cartesian) phase space coordinates, contrary to the standard leap-frog scheme, are evaluated at synchronous times. At each time step the positions [FORMULA] and velocities [FORMULA] of the particles are modified according to (e.g. Hut et al. 1995):


where the [FORMULA]'s are the accelerations and [FORMULA] is the time step, and where the last equation is used to update the smoothing lengths of the SPH particles. The indices n and [FORMULA] refer to the values at time [FORMULA] and [FORMULA] respectively.

The first equation handling the positions is not exactly reversible in time. However, we have repeated simulation m00 of Paper I replacing successively the leap-frog integrator by this algorithm and a second order Runge-Kutta-Fehlberg algorithm (RKF; Fehlberg 1968) as in Friedli's original code, and found that, for the same constant time step [FORMULA] Myr, the conservation of the total energy (and of the total angular momentum) is similar for the present algorithm and for the leap-frog, but much worse for the RKF ([FORMULA] larger by a factor [FORMULA], see Fig. 7). Also, the bar begins to form much sooner with the RKF integrator, at [FORMULA] Myr instead of [FORMULA] Myr with the other two integrators, which is a sign of higher numerical noise amplification.

[FIGURE] Fig. 7. Variation of the total energy (top ) and of the total angular momentum about the rotation axis (bottom ) for simulations started from the same initial conditions but evolved using three different second order integrators with the same constant time step; [FORMULA] and [FORMULA]. The steeper part of the curves are associated with the epoch of bar formation.

For the gaseous particles, the pressure and viscous forces contributing to [FORMULA] both involve velocities which are not known a priori, and similarly [FORMULA] depends on [FORMULA] (through Eq. (8)). Therefore the non-gravitational part of [FORMULA] and [FORMULA] are calculated with the first order predictors:


which fortunately preserve the second order accuracy of [FORMULA], [FORMULA] and [FORMULA].

To temporally resolve the high density shocks in the gas component, we use an adaptative time step procedure inspired from Friedli (1992). After step n, the next time step [FORMULA] is estimated from the maximum relative contribution per unit time of the second order terms to the integrated quantities:




and where [FORMULA] and [FORMULA] are destinated to prevent divergences and a drastic drop of the time step. The value of [FORMULA] is fixed to 0.01 pc in the large simulations and to 0.02 pc in the smaller ones, corresponding approximatively to the smallest dimension of the PM2 cells. Ideally, to guarantee a relative uncertainty of the same order or smaller than a given tolerance [FORMULA], it suffice to take [FORMULA]. However, a more advisable prescription is:




and [FORMULA]. The square root over [FORMULA] softens the variations of the time step and [FORMULA] puts an upper limit on its growth. Moreover the time step is maintained in the range [FORMULA], with [FORMULA] Myr and [FORMULA] Myr. The upper boundary is a fraction of the time needed by the stars to cross the central high resolution PM2 cell in the steep nuclear potential. This time-stepping criterion is applied only to the gas, i.e. the loop on i in Eq. (16) is restricted to the gas particles, and [FORMULA] is in general controlled by the smoothing lengths.

If [FORMULA] and [FORMULA], the tolerance is considered as not respected in the last integration step. In this case, the old values of the integrated quantities are restored and integrated again with a time step [FORMULA]. This rejection procedure unfortunately requires to store the old positions of all particles.

In the simulations with live gas, the tolerance has been set to [FORMULA], and in the simulations with fixed gas component, a constant time step [FORMULA] has been applied.

Previous Section Next Section Title Page Table of Contents

© European Southern Observatory (ESO) 1999

Online publication: April 28, 1999