Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 3D Adaibatic Expansion Test

This test demonstrates simple adiabatic expansion in a cosmological frame. The initial conditions are the critical density in baryons at the starting redshift, T=100K, and no bulk velocity. Gamma is set to 5/3. This test is performed with the cosmology build (`cholla/builds/make.type.cosmology`) and SIMPLE integrator.
Full initial conditions can be found in `cholla/src/grid/initial_conditions.cpp`under `Adiabatic_Expansion()`.

## Parameter file:

This parameter file can be found in [examples/3D/Adiabatic_Expansion.txt](https://github.com/cholla-hydro/cholla/blob/main/examples/3D/Adiabatic_Expansion.txt) on the `dev` branch.
```
#
# Parameter File for the 3D Adiabatic Expansion test.
#

######################################
# number of grid cells in the x dimension
nx=256
# number of grid cells in the y dimension
ny=32
# number of grid cells in the z dimension
nz=32
# output time
tout=1000
# how often to output
outstep=1000
# value of gamma
gamma=1.66666667
# name of initial conditions
init=Adiabatic_Expansion
#Cosmological Parameters
Init_redshift=20.0
#Init_redshift=0.998294693667
H0=50.0
Omega_M=1.0
Omega_L=0.0
Omega_b=1.0
temperature_floor=1.0e-2
scale_outputs_file=scale_output_files/outputs_adiabatic_expansion.txt
# domain properties
xmin=0.0
ymin=0.0
zmin=0.0
xlen=64000.0
ylen=8000.0
zlen=8000.0
# type of boundary conditions
xl_bcnd=1
xu_bcnd=1
yl_bcnd=1
yu_bcnd=1
zl_bcnd=1
zu_bcnd=1
# path to output directory
indir=ics/
outdir=./
```

Upon completion, you should obtain two output files. The final density, velocity, and temperature in physical units are shown below.
:::{figure} adiabatic_expansion.png
Adiabatic Expansion test solution from Cholla.
:::
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/sphinx/ChollaExamples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ Continue porting me from the [wiki](https://github.com/cholla-hydro/cholla/wiki/

1D-123-Test/overview
2D-Rayleigh-Taylor/2D-Rayleigh-Taylor
3D-Adiabatic-Expansion/3D-Adiabatic-Expansion.md
:::

45 changes: 45 additions & 0 deletions examples/3D/Adiabatic_Expansion.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Parameter File for the 3D Adiabatic Expansion test.
#

######################################
# number of grid cells in the x dimension
nx=256
# number of grid cells in the y dimension
ny=32
# number of grid cells in the z dimension
nz=32
# output time
tout=1000
# how often to output
outstep=1000
# value of gamma
gamma=1.66666667
# name of initial conditions
init=Adiabatic_Expansion
#Cosmological Parameters
Init_redshift=20.0
#Init_redshift=0.998294693667
H0=50.0
Omega_M=1.0
Omega_L=0.0
Omega_b=1.0
temperature_floor=1.0e-2
scale_outputs_file=scale_output_files/outputs_zeldovich_grav4.txt
# domain properties
xmin=0.0
ymin=0.0
zmin=0.0
xlen=64000.0
ylen=8000.0
zlen=8000.0
# type of boundary conditions
xl_bcnd=1
xu_bcnd=1
yl_bcnd=1
yu_bcnd=1
zl_bcnd=1
zu_bcnd=1
# path to output directory
indir=ics/
outdir=./
2 changes: 2 additions & 0 deletions src/grid/grid3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,8 @@ class Grid3D

void Zeldovich_Pancake(struct Parameters P);

void Adiabatic_Expansion(struct Parameters P);

void Chemistry_Test(struct Parameters P);

#ifdef MHD
Expand Down
75 changes: 75 additions & 0 deletions src/grid/initial_conditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ void Grid3D::Set_Initial_Conditions(Parameters P)
Uniform_Grid();
} else if (strcmp(P.init, "Zeldovich_Pancake") == 0) {
Zeldovich_Pancake(P);
} else if (strcmp(P.init, "Adiabatic_Expansion") == 0) {
Adiabatic_Expansion(P);
} else if (strcmp(P.init, "Chemistry_Test") == 0) {
Chemistry_Test(P);
#ifdef MHD
Expand Down Expand Up @@ -1557,6 +1559,79 @@ void Grid3D::Zeldovich_Pancake(struct Parameters P)
E = ics_values[2 * nPoints + index];
U = ics_values[3 * nPoints + index];
// //
// temp = T_init * pow( dens/rho_0, 2./3.);
// U = temp / (gamma-1) / MP * KB * 1e-10 * dens;
// E = 0.5*dens*vel*vel + U;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these additions in the Zeldovich Pancake ICs intentional?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(It's possible git is just confused about which parts of the file have changed, given that below it appears as though the end of the new Adiabatic Expansion test has not been altered, I just want to double-check that this file looks as intended.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are intentional. They reflect how the adiabatic ICs are set. You can remove them if you want, and I can add them back after I am done with testing the Zeldovich test.

// chprintf( "%f \n", vel );
C.density[id] = dens;
C.momentum_x[id] = dens * vel;
C.momentum_y[id] = 0;
C.momentum_z[id] = 0;
C.Energy[id] = E;

#ifdef DE
C.GasEnergy[id] = U;
#endif
}
}
}

#endif // COSMOLOGY
}

void Grid3D::Adiabatic_Expansion(struct Parameters P)
{
#ifndef COSMOLOGY
chprintf("To run an Adiabatic Expansion test, COSMOLOGY has to be turned ON \n");
exit(-1);
#else

int i, j, k, id;
Real x_pos, y_pos, z_pos;
Real H0, h, Omega_M, rho_0, G, z_zeldovich, z_init, x_center, T_init, k_x;

chprintf("Setting Adiabatic Expansion initial conditions...\n");
H0 = P.H0;
h = H0 / 100;
Omega_M = P.Omega_M;

chprintf(" h = %f \n", h);
chprintf(" Omega_M = %f \n", Omega_M);

H0 /= 1000; //[km/s / kpc]
G = G_COSMO;
rho_0 = 3 * H0 * H0 / (8 * M_PI * G) * Omega_M / h / h;
z_init = P.Init_redshift;
chprintf(" rho_0 = %f \n", rho_0);
chprintf(" z_init = %f \n", z_init);

T_init = 100;
chprintf(" T initial = %f \n", T_init);

k_x = 2 * M_PI / H.xdglobal;

Real dens, vel, temp, U, E, gamma;
gamma = P.gamma;

int index;
// set the initial values of the conserved variables
for (k = H.n_ghost; k < H.nz - H.n_ghost; k++) {
for (j = H.n_ghost; j < H.ny - H.n_ghost; j++) {
for (i = H.n_ghost; i < H.nx - H.n_ghost; i++) {
id = i + j * H.nx + k * H.nx * H.ny;

// Analytical Initial Conditions
// dens = rho_0 / ( 1 - ( 1 + z_zeldovich ) / ( 1 + z_init ) * cos(
// k_x*( x_pos - x_center )) ); vel = - H0 * ( 1 + z_zeldovich ) /
// sqrt( 1 + z_init ) * sin( k_x*( x_pos - x_center )) / k_x; temp =
// T_init * pow( dens / rho_0, 2./3 ); U = temp / (gamma - 1) / MP * KB
// * 1e-10 * dens; E = 0.5 * dens * vel * vel + U;

dens = rho_0;
vel = 0;
U = T_init / (gamma - 1) / MP * KB * 1e-10 * rho_0;
E = U;

// chprintf( "%f \n", vel );
C.density[id] = dens;
Expand Down
13 changes: 13 additions & 0 deletions src/particles/particles_3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ void Particles3D::Initialize(Parameters *P, const SpatialDomainProps &spatial_pr
Initialize_Sphere(P);
} else if (strcmp(P->init, "Zeldovich_Pancake") == 0) {
Initialize_Zeldovich_Pancake(P);
} else if (strcmp(P->init, "Adiabatic_Expansion") == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume these modifications to the particles ICs are only necessary because the cosmology make-type by default includes particles?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in tests I tried to compile the code with cosmology and without particles and the compilation failed.

Initialize_Adiabatic_Expansion(P);
} else if (strcmp(P->init, "Read_Grid") == 0) {
Load_Particles_Data(P);
} else if (strcmp(P->init, "Isolated_Stellar_Cluster") == 0) {
Expand Down Expand Up @@ -1139,6 +1141,17 @@ void Particles3D::Initialize_Zeldovich_Pancake(struct Parameters *P)
chprintf(" Particles Zeldovich Pancake Initialized, n_local: %lu\n", n_local);
}

void Particles3D::Initialize_Adiabatic_Expansion(struct Parameters *P)
{
// No particles for the Adiabatic Expansion problem. n_local=0

chprintf("Setting Adiabatic Expansion initial conditions...\n");

n_local = 0;

chprintf(" Particles Adiabatic Expansion initialized, n_local: %lu\n", n_local);
}

void Grid3D::Initialize_Uniform_Particles()
{
// Initialize positions assigning one particle at each cell in a uniform grid
Expand Down
2 changes: 2 additions & 0 deletions src/particles/particles_3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ class Particles3D

void Initialize_Zeldovich_Pancake(struct Parameters *P);

void Initialize_Adiabatic_Expansion(struct Parameters *P);

void Load_Particles_Data(struct Parameters *P);

void Free_Memory();
Expand Down