3. Setting Up New Problems

A new FLASH problem is created by making a directory for it under FLASH4/source/Simulation/SimulationMain. This location is where the FLASH setup script looks to find the problem-specific files. The FLASH distribution includes a number of pre-written simulations; however, most FLASH users will want to simulate their own problems, so it is important to understand the techniques for adding a customized problem simulation.

Every simulation directory contains routines to initialize the FLASH grid. The directory also includes a Config file which contains information about infrastructure and physics units, and the runtime parameters required by the simulation (see Chp:The FLASH configuration script). The files that are usually included in the Simulation directory for a problem are:

Config Lists the units and variables required for the problem, defines runtime parameters and initializes them with default values.
Makefile The make include file for the Simulation.
Simulation_data.F90 Fortran module which stores data and parameters specific to the Simulation.
Simulation_init.F90 Fortran routine which reads the runtime parameters, and performs other necessary initializations.
Simulation_initBlock.F90 Fortran routine for setting initial conditions in a single block.
Simulation_initSpecies.F90 Optional Fortran routine for initializing species properties if multiple species are being used.
flash.par A text file that specifies values for the runtime parameters. The values in flash.par override the defaults from Config files.

In addition to these basic files, a particular simulation may include some files of its own. These files could provide either new functionality not available in FLASH, or they may include customized versions of any of the FLASH routines. For example, a problem might require a custom refinement criterion instead of the one provided with FLASH. If a customized implementation of Grid_markRefineDerefine is placed in the Simulation directory, it will replace FLASH's own implementation when the problem is setup. In general, users are encouraged to put any modifications of core FLASH files in the SimulationMain directory in which they are working rather than by altering the default FLASH routines. This encapsulation of personal changes will make it easier to integrate Flash Center patches, and to upgrade to more recent versions of the code. The user might also wish to include data files in the SimulationMain necessary for initial conditions. Please see the LINKIF and DATAFILES keywords in Sec:ConfigFileSyntax for more information on linking in datafiles or conditionally linking customized implementations of FLASH routines.

The next few paragraphs are devoted to the detailed examination of the basic files for an example setup. The example we describe here is a hydrodynamical simulation of the Sod shock tube problem, which has a one-dimensional flow discontinuity. We construct the initial conditions for this problem by establishing a planar interface at some angle to the $ x$ and $ y$ axes, across which the density and pressure values are discontinuous. The fluid is initially at rest on either side of the interface. To create a new simulation, we first create a new directory Sod in Simulation/SimulationMain and then add the Config, Makefile, flash.par, Simulation_initBlock.F90, Simulation_init.F90 and Simulation_data.F90 files. Since this is a single fluid simulation, there is no need for a Simulation_initSpecies file. The easiest way to construct these files is to use files from another setup as templates.



Subsections