• Aucun résultat trouvé

2.1 Radiative magnetohydrodynamic simulations

2.1.4 The CO 5 BOLD code

The CO5BOLD code and a history of magnetohydrodynamic simulations is extensively discussed in Freytag et al. (2012). In present days, the CO5BOLD code is used for the simulation of a variety of stellar atmospheres, among which the Sun, solar-type stars, red giants and white and brown dwarfs are the main examples (Straus et al.2017). This large spectrum of simulations is permitted by a modular construction of the code, allowing to choose among different solvers: a hydrodynamic module or a magnetohydrodynamic module, and radiative transfer schemes with short or long characteristics with specific boundary conditions. In this section we will give a brief description of the modules we actually use for the simulation of the surface layers of the Sun.

As stated in Sect. 2.1.1, our simulations are essentially parameter-free.

There is for instance no micro- or macroturbulence parameters, since spa-tial and temporal averages of spectral line profiles calculated from simulations properly reproduce the shape of observed spectral lines, thanks to the presence of a self-consistent velocity field evolving with the simulations. The usual

pa-rameters characterising stars (effective temperature, surface gravity and chem-ical composition) must however be set, as well as the many numerchem-ical parame-ters (solvers, boundary conditions, numerical viscosity and time stepping are a few examples). For this purpose, a “parameter file” is provided to CO5BOLD, together with a file with opacities (possibly providing a few opacity bands) and a file with interpolation coefficients for the equation of state. Again, we will focus here our discussion on the main parameters we use in our simulations. A complete list is available in the CO5BOLD user manual (see e.g. Freytag et al.

2010).

Global parameters and boundary conditions: The surface gravity is set to the solar value, g = 27500 cm s−2, or log10(g[cm s−2]) = 4.44. The chem-ical composition is set through the opacity bands and the equation of state and is discussed in the next paragraph. The effective temperature is set in-directly through the boundary conditions. The boundary conditions at the sides of the box perpendicular to the horizontal axes are set periodic both for the magnetohydrodynamic solver and for the radiative transfer module. The boundary conditions at the bottom are set to “inoutflow2”. The implemen-tation is non-trivial, but it describes an open lower boundary for which the entropy inflow is specified and the adjustment rate of entropy and pressure in this lower layer is fixed in order to damp out possible oscillations. The entropy inflow parameter must be determined by trial and error untill the de-sired effective temperature is reached. The top boundary condition is set to

“transmitting”, for which density is extrapolated out of the box by assuming it to be exponentially decreasing. This is achieved by assuming the density scale height to be proportional to the pressure scale height for some provided constant. Temperature is also adjusted towards a specified fraction of the ef-fective temperature at a given rate. The scale height of the optical depth at the upper boundary is also adjusted by a parameter for the radiative transfer module.

The magnetic boundary conditions are also periodic at the sides. At the bottom they depend on the model; we tried two different kinds, either “ver-tical”, which is a constant extrapolation of the vertical component while the transversal components are fixed to zero, or “inoutflow”, which allows to fix a strength of the (horizontally) advected magnetic field by ascending mate-rial. The magnetic boundary conditions at the top are set to “vertical”. We also implemented the “mixed” boundary conditions, which are equivalent to

“vertical” in regions of down-flows, or make a constant extrapolation of the magnetic field in regions of up-flows. With the “mixed” boundary conditions, we aimed at preventing a numerical instability that we encountered, but af-ter the problem was sorted out two parallel runs with “vertical” and “mixed”

conditions stayed stable.

2.1. Radiative magnetohydrodynamic simulations 11

Opacities and equation of state: Opacities are given in a separate file as a function of gas pressureP and temperatureT, for a number of values of log10(P) and T. These tables are interpolated in CO5BOLD. They contain monochromatic Rosseland mean opacities, as well as five additional bands.

They are based on a 1D MARCS model atmosphere from the Montpellier-Uppsala group (Gustafsson et al.2008) and are extensively discussed in Ludwig

& Steffen (2013), together with the particular CO5BOLD implementation of the opacity binning method. Interpolation coefficients for the equation of state are also provided in a separate file by the CIFIST (Cosmological Impact of the First STars) group.

Time management: CO5BOLD provides adaptive time stepping. The time step is re-evaluated at each iteration and at each cell both for the (M-)HD module and the RT module, and the minimal value is chosen as the final time step. For the (M-)HD module, the time step is fixed by the Courant condition, which states that a magnetosonic wave (or sound wave in the non-magnetic case) should cross at most one computing cell during a single time step. In practice a parameter is fixed to limit the time step to a fraction of the Courant upper bound, that is taken as a recommendation for the next step. This value might be revised and the time step recomputed if the next upper bound is below the recommended value. For some simple linear problems, without radiative transport, this procedure is guaranteed to be stable. For radiative transport the time step that ensures numerical stability can only be estimated.

It is taken to be a fraction of thecharacteristic time scale of a small sinusoidal disturbance with a wavelength of the grid size in a homogeneous background and grey radiative energy exchange (Freytag et al.2010).

Parallelization: The CO5BOLD code is OpenMP parallel. This means that OpenMP tasks run concurrently and share memory. The code is hence suitable for running on (single) big nodes with limited NUMA (Non-Uniform Memory Access) effects. On recent hardware, we found that the code can run efficiently on nodes of at most 16-18 CPUs; on bigger nodes the NUMA effects are re-sponsible for a slow-down of the code. OpenMP being a directive-oriented programming model, the implementation is almost transparent. The draw-back is that the code cannot run on multiple nodes, so that the enormous resources provided by supercomputers are underused.

Numerical solvers and schemes: For our simulations we used both the Roe hydrodynamic solver and the HLLMHD magnetohydrodynamic solver, to-gether with the MSRad radiative transport scheme (see following paragraphs for a more detailed description of the Roe, HLL-MHD and MSRad schemes).

Both (M-)HD solvers use finite volume methods, meaning that the Gauss

theo-rem is applied in order to evaluate divergences as surface integrals, so that the relevant physical quantities are handled as fluxes through cell boundaries and these methods are conservative. For our runs we used a directional operator splitting scheme, reducing the 3D problem to a sequence of one-dimensional sweeps. Other non-split schemes are available as well. We also used in all of our runs the Hancock time integration scheme, so that terms in second order in time are approximated by a Hancock predictor step. The various operators ((M-)HD, RT, tensor viscosity) are separated by using operator splitting.

The Roe and the HLLMHD solvers: The Roe solver is described in Roe (1986). The solver used in CO5BOLD is however a modified version of it. It is an approximate 1D Riemann solver of Roe type that accounts for a realistic equation of state, a non-equidistant grid (even though all of our models are equidistant), and the presence of source terms due to the gravity field. The main characteristic of the implementation of the HLL solver in CO5BOLD is its ability to both ensure positivity of the gas pressure and use a constrained transport method that guarantees that∇·Bis kept constant up to quantization (round-off) errors. For∇ ·B, no error arises from the discretization. The HLL scheme is described in Harten et al. (1983), and its specific implementation to the CO5BOLD code is described by Schaffenberger et al. (2005,2006).

The MSrad radiative transport scheme: The MSrad RT scheme uses long characteristics to solve the RT equation with the Feautrier method for each opacity band, assuming Local Thermodynamic Equilibrium (LTE). The implementation of the Feautrier method in CO5BOLD is described by Freytag et al. (2012). The relevant quantity that the RT module should provide to the MHD module is the divergence of the radiative flux, see Eq. (2.1). In CO5BOLD, the exchanged quantities between the two modules is the heat source due to radiation,

whereJν has been defined by the solid angle averaged mean intensity, Jν ≡ 1

4π Z

S2

Iν(~Ω) dΩ. (2.6)

2.1. Radiative magnetohydrodynamic simulations 13

The main numerical difficulty comes from the fact that the simulated region encompasses the transition between optically thin and optically thick medium.

Indeed, determining firstFrad and then numerically computing the divergence is not suitable in optically thin media where the radiative flux stays almost constant from cell to cell. Instead, computingJν−Sνin order to use Eq. (2.5) is numerically unstable in extremely thick medium, where Jν is almost equal to the source function. Besides, this method does not necessarily guarantee conservation of energy, in the sense that the difference between the total flux at the top of the box and the total flux at the bottom of the box is not guaranteed to be equal to the integratedQrad over the whole box. The MSrad RT scheme overcomes both of these problems by solving the RT equation using its own implementation of the Feautrier method with long characteristics for the new variablepν(Ω)~ ≡ 12

Iν(+Ω) +~ Iν(−~Ω)

−Sν. Here, the indexν does not refer any more to a specific frequency, but to a given opacity band, as discussed at the end of Sect. 2.1.2. The RT equation is hence solved for all bands along straight long rays (characteristics) crossing the computational box from top to bottom, at different azimuthal and inclination angles. Integrals over the sphere are numerically performed using a Lobatto quadrature, see Sect.2.B.2.