next up previous contents
Next: Read in your own Up: Setting up Initial Condition Previous: Setting up Initial Condition   Contents

Let TYCHO generate initial conditions

If you want TYCHO to generate ICs you have to edit the routine make_ic in the source file make_ic.c. TYCHO stores all hydrodynamic quantities in three dimensional arrays which are indexed in an simple way. Additionally the initial-conditions switch in the Parameterfile has to be set to 0. In the following the default make_ic-function is shown and explained in some detail.

int make_ic(int x, int y, int z) {
    int i, j, k;
    double velo_x, velo_y, velo_z;

    double T0, T, A, rho0, pre0;
Here the constants for the implemented temperature distribution in a stratified atmosphere are defined.
    //T(z)=T_0 + A*(z-z0)
    T0 = 288.15; //[K]
    A = -6.5E-3; //[K/m]
Pressure and temperature at a certain level for the stratified atmosphere are assigned here.
    rho0 = 1.229; // Density at sea level [kg/m^3]
    pre0 = 1.013E5; //pressure at sea level [N/m^2]
In order to get a physical gas distribution we assign very small velocities to the gas.
    velo_x = small;
    velo_y = small;
    velo_z = small;
If one needs a toy atmosphere to play around one has to switch in the Parameterfile the Stratified Atmosphere to 1.
    if (strat_const_atmos == 1) {
        for (i = 0; i < x; i++) {
            for (j = 0; j < y; j++) {
                for (k = 0; k < z; k++) {

                T = T0 + A * ((ymax / y) * j);

                rho[i][j][k] = rho0 * pow((T / T0), ....
                               (-grav_acc / (gasconstant * A) + 1));
                pre[i][j][k] = pre0 * pow((T / T0), ....
                               (-grav_acc / (gasconstant * A)));

                vx[i][j][k] = velo_x;
                vy[i][j][k] = velo_y;
                vz[i][j][k] = velo_z;
                }
            }
        }
    }
If one needs a homogeneous atmosphere one needs to switch in the Parameterfile the Stratified Atmosphere to 0.
    if (strat_const_atmos == 0) {
        for (i = 0; i < x; i++) {
            for (j = 0; j < y; j++) {
                for (k = 0; k < z; k++) {

                    rho[i][j][k] = 1.2;
                    pre[i][j][k] = 300 * gasconstant * rho[i][j][k];

                    vx[i][j][k] = velo_x;
                    vy[i][j][k] = velo_y;
                    vz[i][j][k] = velo_z;
                }
            }
        }
    }

    return 0;
}
Assuming your simulation should include an obstacle build by TYCHO you have to define the shape, density and temperature in the initiate_domain function. An example for a 2D circle-like obstacle is given in the file make_ic.c. The obtacle_density and obstacle_temperature constants are specified within the Parameterfile.

/*!
 The form of the obstacle is defined in this function
 example of just a round thing.
 */
int initiate_domain(int x, int y, int z) {
    int i, j, k;

    for (i = 0; i < x; i++) {
        for (j = 0; j < y; j++) {
            for (k = 0; k < z; k++) {
                int i2 = i - x / 2.0;
                int j2 = j - y / 2.0;
                int xy = sqrt(i2 * i2 + j2 * j2);

                if (xy < x / 20) {
                    dom[i][j][k] = 1;
                    rho[i][j][k] = obstacle_density;
                    pre[i][j][k] = obstacle_temperature;

                    vx[i][j][k] = 0.0;
                    vy[i][j][k] = 0.0;
                    vz[i][j][k] = 0.0;
                } else {
                    dom[i][j][k] = 0;
                }

            }
        }
    }

    printf("Initiate domain done\n");

    return 0;
}

To summarize, defining your own ICs in the make_ic-function requires full specification of the five 3-dimensional arrays rho, pre, vx, vy, vz. If 2 dimensional simulations are needed, then just assign 1 to the index k. Remember that this code strictly uses SI-units. Consequently a 1D simulation needs x=1, y=1 and z=1.


next up previous contents
Next: Read in your own Up: Setting up Initial Condition Previous: Setting up Initial Condition   Contents
2013-02-06