Initial conditions#

In this chapter, we cover how initial conditions are prepared and read. There are several ways to provide the starting state of a RAMSES simulation. For basic geometries, the user can use the parameters in the init_params namelist block. For more advanced setups that can be described analytically, there are the condinit subroutines. Finally, RAMSES also supports input from files with specified formats.

1. Analytical initial conditions on the grid with condinit#

RAMSES users may already have experience with implementing initial conditions using the condinit routine. This routine is called by init_flow_fine during the setup phase of the simulation. At the time of writing, there are two versions available in the public version: one for hydro and one for mhd. Remark that recently, the system has been reworked to support various default setups (rather than replying on the patch system).

As input, the condinit routine receives the cell center positions (in code units) of the nn cells in the vector sweep, as well as the cell size of the current level. From this information, the primitive variables are then calculated. Several prescriptions are available by default and can be selected by setting condinit_kind in the namelist. One can easily add their own analytical initial conditions as a new subroutine following the existing examples. Finally, the primitive variables are converted to the conservative ones. The conservative variables are then returned to init_flow_fine through the array u, where they are written to uold.

Exercise

Implement a new condinit_type that adds a sinusoidal perturbation on a uniform density background in 1D: \(\rho(x) = \rho_0 [1 + A \cos(\frac{2\pi x}{\lambda})]\) The pressure is set to the same value as the density.

2. Input file formats#

Another way to provide the initial conditions is through files, by setting the namelist parameters initfile and filetype. For the variables on the grid, supported formats are ascii and grafic (see init_flow_fine.f90), while for particles ascii, grafic, and gadget are available (see init_part.f90, and the chapter on particles).

If you want to add your own input file, good luck.