Astron. Astrophys. 345, 787-812 (1999) 3. Numerical methodsThe 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 PM^{2}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 cells, with a maximum radial extent and a vertical spacing , i.e. . The lower resolution grid (B) has half the number of cells in each dimension of the plane, skipping every second R- and -grid point of the finer grid, and the same number of cells vertically but with a spacing of , i.e. . 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 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 , (ii) the horizontal planes 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.
In this particle-double mesh (or PM^{2}) 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: and generated by the mass inside grids A and B respectively, as well as generated by the mass within grid B but outside grid A. The potential is computed on grid A, at high resolution, and the other potentials on grid B. The total potential then amounts to in the region of grid A, which requires an interpolation of to grid A, and simply to outside this region. The increase of CPU time owing to the triple potential evaluation is amply compensated by the reduction by a factor 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 coincide with the forces of grid B and those at with the forces of grid A.
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.
Table 1. List and characteristics of the simulations presented in this paper. , , and are the grid parameters as defined in Sect. 3.1. Both low and high resolution double grids have , kpc, kpc and kpc. # is the number of particles, the sound speed of the gas, the gas switch-on time and the time to which the simulation is performed. The points refer to the former lines. 3.2. Gas hydrodynamics with SPHThe 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 is the velocity field, the spatial mass density and the pressure of the gas. is the viscosity term and the gravitational force as obtained by the PM^{2} 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 . The density is evaluated directly at each particle position via: where is the number of gas particles, the individual mass of the particles, 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. , where is the adiabatic index of the gas, which from statistical mechanics is given by , with f being the number of freedom degrees of the gas constituents ( for atomic hydrogen and 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 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 . 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 and , 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 . To increase the hydro resolution in high density regions like shocks, the particles are assigned individual smoothing lengths such that their number of neighbouring particles always remains close to a fixed number . Two particles i and j are defined as mutual neighbours if and , where 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 and are constants, and 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 ensuring the constancy of the neighbour numbers, and hence did not include the term in . However, in practice, numerical fluctuations of the 's can carry these number outside a reasonable range around . To overcome this problem, we simply damp the systematic departure of the 's from setting: in Eq. (8) and integrate the resulting equation along with the equations of motion (see Sect. 3.3). The parameter controls the damping rate per time step () and should be significantly greater than 1 to avoid abrupt discontinuities in the non-gravitational forces. In all simulations we have adopted and . 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).
The initial smoothing lengths of the gas particles, confined near the plane , are derived from the two-dimensional scaling relation: where is the surface mass density profile of the gas component and its switch-on time (see Sect. 5). This method unfortunately leads to a large spread in the initial neighbour numbers. To adjust the '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. Myr for the large simulations (l-series) and Myr for the smaller ones (s-series). 3.3. IntegratorTo 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 and velocities of the particles are modified according to (e.g. Hut et al. 1995): where the 's are the accelerations and is the time step, and where the last equation is used to update the smoothing lengths of the SPH particles. The indices n and refer to the values at time and 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 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 ( larger by a factor , see Fig. 7). Also, the bar begins to form much sooner with the RKF integrator, at Myr instead of Myr with the other two integrators, which is a sign of higher numerical noise amplification.
For the gaseous particles, the pressure and viscous forces contributing to both involve velocities which are not known a priori, and similarly depends on (through Eq. (8)). Therefore the non-gravitational part of and are calculated with the first order predictors: which fortunately preserve the second order accuracy of , and . 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 is estimated from the maximum relative contribution per unit time of the second order terms to the integrated quantities: where and where and are destinated to prevent divergences and a drastic drop of the time step. The value of 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 PM^{2} cells. Ideally, to guarantee a relative uncertainty of the same order or smaller than a given tolerance , it suffice to take . However, a more advisable prescription is: with and . The square root over softens the variations of the time step and puts an upper limit on its growth. Moreover the time step is maintained in the range , with Myr and Myr. The upper boundary is a fraction of the time needed by the stars to cross the central high resolution PM^{2} 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 is in general controlled by the smoothing lengths. If and , 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 . 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 , and in the simulations with fixed gas component, a constant time step has been applied. © European Southern Observatory (ESO) 1999 Online publication: April 28, 1999 |