gc
in FLASH): Could be thought of as an extra layer of padding outside the simulation domain. The alues of these gcs are mostly determined by what the boundary conditions you chose. Generally, you won't have to mess with these when specifying the initial conditions.Simulation_initBlock is called by each block. First we compute the center based on the dimensions of the box (in cgs) from flash.par:
center = abs(xmin-xmax)/2.
We loop through all the coordinates of the cell within each block.
do k = blkLimits(LOW,KAXIS),blkLimits(HIGH,KAXIS)
! get the coordinates of the cell center in the z-direction
zz = zCoord(k)-center
do j = blkLimits(LOW,JAXIS),blkLimits(HIGH,JAXIS)
! get the coordinates of the cell center in the y-direction
yy = yCoord(j)-center
do i = blkLimits(LOW,IAXIS),blkLimits(HIGH,IAXIS)
! get the cell center, left, and right positions in x
xx = xCenter(i)-center
xCenter,yCoord,zCoord
are functions that return the cell position (in cgs) given its cell index. These calculations are based on treating the bottom left corner of the box as the origin, so we minus the box center to get the origin to be at the center, as shown in Fig 3.
<img src="https://github.com/dorisjlee/remote/blob/master/astroSim-tutorial-img/user_coord.png?raw=true%22,width=200,height=200%3E
Fig 3: The corrected xx,yy,zz
are physical positions measured from the origin.
Given the cell positions, you can specify values for initializing the fluid variables. The fluid variables are stored inside the local variables (called rhoZone,presZone,velxZone, velyZone,velzZone in the example) which are then transferred into to the cell one at a time using the method Grid_putData:
call Grid_putPointData(blockId, CENTER, DENS_VAR, EXTERIOR, axis, rhoZone)
For example, you may have an analytical radial density distribution ($\rho= Ar^2$) that you would like to initialize the sphere with:
rr = sqrt(xx**2 + yy**2 + zz**2)
rhoZone = A*rr**2
Or maybe your initial conditions can not be expressed in closed form,then you could also read in precomputed-values for each cell. This optional tutorial will explain how to do linear interpolation to setup the numerical solution of the Lane-Emden Sphere.
As we have already saw, to compute the center of the box, I need to read in the dimensions of the box (xmin,xmax
) from flash.par. Some runtime parameters are used by other simulation modules and some are specific to the problem and defined by the users.
To add in a new runtime parameter:
Simulation_data.F90
, declare the variables to store these runtime parameters:real, save :: fattening_factor,beta_param,xmin,xmax
Simulation_init.F90
, read in the values of the runtime parameter:call RuntimeParameters_get('xmin',xmin)
call RuntimeParameters_get('xmax',xmax)
Simulation_initBlock.F90
, use the data:use Simulation_data, ONLY: xmin,xmax
Note you should NOT declare real::xmin,xmax
again inside Simulation_initBlock.F90
, otherwise, the values that you read in will be overridden.