In this chapter we describe the common interface for all hydrodynamics, grid based codes. For particle based, SPH codes see the gravitational dynamics specifications.
All parameters have to be accessed with functions following
the template of the get_timestep
and set_timestep
functions.
A parameter access function may only retrieve or
update the value of a single parameter. After all parameters have been set, the
commit_parameters
function should be called,
this gives the code the opportunity prepare the model.
Perform initialization in the code dependent on the values of the parameters. Called after the parameters have been set or updated.
int32 commit_parameters();
function commit_parameters()
integer :: commit_parameters
end function
Code is initialized
Error happened during initialization, this error needs to be further specified by every code implementation -2 - ERROR not yet implemented
Most hydrodynamical codes work on grids or a hierarchy of grids. The following methods define the functionality to setup and query the grids.
Retrieves the i,j and k index of the grid cell containing the given x, y and z position. The cell is looked up in the grid specified by index_of_grid.
int32 get_index_of_position(float64 x, float64 y, float64 z,
int32 index_of_grid, float64 * i, float64 * j, float64 * k);
function get_index_of_position(x, y, z, index_of_grid, i, j, k)
double precision :: x, y, z, i, j, k
integer :: index_of_grid
integer :: get_index_of_position
end function
x (float64, IN) –
y (float64, IN) –
z (float64, IN) –
index_of_grid (int32, IN) –
i (float64, OUT) –
j (float64, OUT) –
k (float64, OUT) –
Returns the min and max values of indices in each direction. The range is inclusive, the min index and max index both exist and can be queried. The total number of cells in one direction is max - min + 1.
The returntype is a list of 3 tuples, each tuples contains the minimum and maximum value in the index range.
For C/C++ codes the returned values will usually be: ((0, nmeshx-1), (0, nmeshy-1), (0, nmeshz-1))
For Fortran codes the returned values will usually be: ((1, nmeshx), (1, nmeshy), (1, nmeshz))
Retrieves the x, y and z position of the center of the cell with coordinates i, j, k in the grid specified by the index_of_grid
int32 get_position_of_index(int32 i, int32 j, int32 k,
int32 index_of_grid, float64 * x, float64 * y, float64 * z);
function get_position_of_index(i, j, k, index_of_grid, x, y, z)
integer :: i, j, k, index_of_grid
double precision :: x, y, z
integer :: get_position_of_index
end function
i (int32, IN) –
j (int32, IN) –
k (int32, IN) –
index_of_grid (int32, IN) –
x (float64, OUT) –
y (float64, OUT) –
z (float64, OUT) –
Sets the boundary conditions on the grid. Boundaries can be: “reflective”, “periodic”.
xbound1 – inner or left boundary in the x direction
xbound2 – outer or right boundary in the x direction
ybound1 – inner or front boundary in the y direction
ybound2 – outer or back boundary in the y direction
zbound1 – inner or bottom boundary in the z direction
zbound1 – outer or top boundary in the z direction
Sets the number of mesh cells in each direction, and the length of the grid in each direction.
nmeshx – number of mesh cells in the x direction
nmeshy – number of mesh cells in the y direction
nmeshz – number of mesh cells in the z direction
xlength – total length of the grid in the x direction
ylength – total length of the grid in the y direction
zlength – total length of the grid in the z direction
Grid points in a hydrodynamics code have a well known, minimal state. This state is is defined by a density, momentum density and energy density. The state can be retrieved and updated with the following functions.
int32 get_grid_state(int32 i, int32 j, int32 k, int32 index_of_grid,
float64 * rho, float64 * rhovx, float64 * rhovy, float64 * rhovz,
float64 * en, int32 number_of_points);
function get_grid_state(i, j, k, index_of_grid, rho, rhovx, rhovy, rhovz, &
en, number_of_points)
integer :: i, j, k, index_of_grid, number_of_points
double precision :: rho, rhovx, rhovy, rhovz, en
integer :: get_grid_state
end function
i (int32, IN) –
j (int32, IN) –
k (int32, IN) –
index_of_grid (int32, IN) –
rho (float64, OUT) –
rhovx (float64, OUT) –
rhovy (float64, OUT) –
rhovz (float64, OUT) –
en (float64, OUT) –
number_of_points (int32,) –
int32 set_grid_state(int32 i, int32 j, int32 k, float64 rho,
float64 rhovx, float64 rhovy, float64 rhovz, float64 en,
int32 index_of_grid, int32 number_of_points);
function set_grid_state(i, j, k, rho, rhovx, rhovy, rhovz, en, &
index_of_grid, number_of_points)
integer :: i, j, k, index_of_grid, number_of_points
double precision :: rho, rhovx, rhovy, rhovz, en
integer :: set_grid_state
end function
i (int32, IN) –
j (int32, IN) –
k (int32, IN) –
rho (float64, IN) –
rhovx (float64, IN) –
rhovy (float64, IN) –
rhovz (float64, IN) –
en (float64, IN) –
index_of_grid (int32, IN) –
number_of_points (int32,) –
Not all information of a grid point can be transferred with the fill_grid_state and get_grid_state functions. To
support other properties (like pressure or MHD properties), the code can define get_
and set_
functions. These
functions must get or set one scalar property (1 argument) or a vector property (3 arguments)
int32 set_grid_density(int32 i, int32 j, int32 k, float64 rho,
int32 index_of_grid, int32 number_of_points);
function set_grid_density(i, j, k, rho, index_of_grid, number_of_points)
integer :: i, j, k, index_of_grid, number_of_points
double precision :: rho
integer :: set_grid_density
end function
i (int32, IN) –
j (int32, IN) –
k (int32, IN) –
rho (float64, IN) –
index_of_grid (int32, IN) –
number_of_points (int32,) –
int32 set_grid_energy_density(int32 i, int32 j, int32 k, float64 en,
int32 index_of_grid, int32 number_of_points);
function set_grid_energy_density(i, j, k, en, index_of_grid, &
number_of_points)
integer :: i, j, k, index_of_grid, number_of_points
double precision :: en
integer :: set_grid_energy_density
end function
i (int32, IN) –
j (int32, IN) –
k (int32, IN) –
en (float64, IN) –
index_of_grid (int32, IN) –
number_of_points (int32,) –
int32 set_grid_momentum_density(int32 i, int32 j, int32 k,
float64 rhovx, float64 rhovy, float64 rhovz, int32 index_of_grid,
int32 number_of_points);
function set_grid_momentum_density(i, j, k, rhovx, rhovy, rhovz, &
index_of_grid, number_of_points)
integer :: i, j, k, index_of_grid, number_of_points
double precision :: rhovx, rhovy, rhovz
integer :: set_grid_momentum_density
end function
i (int32, IN) –
j (int32, IN) –
k (int32, IN) –
rhovx (float64, IN) –
rhovy (float64, IN) –
rhovz (float64, IN) –
index_of_grid (int32, IN) –
number_of_points (int32,) –
The hydrodynamics codes evolve the properties all grid cells in time. The following functions are needed to control the evolution in the code.
Perform accounting before evolving the model. This method will be called after setting the parameters and filling the grid points but just before evolving the system
int32 initialize_grid();
function initialize_grid()
integer :: initialize_grid
end function
The state of the code can be queried, before, during and after the model calculations. The following function can be used to query the exact model time.
Some Hydrodynamics codes support external acceleration or potential fields. The following functions can be used to enter a gravitational potential field.