Skip to content

Commit

Permalink
Introduced automated tests for EnzoMethodGrackle
Browse files Browse the repository at this point in the history
A section was also added to the website documentation to describe these tests.
  • Loading branch information
mabruzzo committed Aug 4, 2021
1 parent e6e04e6 commit c53c505
Show file tree
Hide file tree
Showing 12 changed files with 914 additions and 0 deletions.
34 changes: 34 additions & 0 deletions doc/source/tests/grackle.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
----------------
Grackle Tests
----------------

Tests for the method that invokes Grackle. These tests set up a
cooling test without hydrodynamics to run many one-zone models in
Grackle, fully sampling the density, temperature, and metallicity
parameter space over which the chemistry and cooling/heating tables
are valid.

method_grackle_general
======================

This test compares the summary statistics computed for several grackle
fields after a certain period of time to previously archived values.
The simulation timesteps are much larger that the cooling/heating
timescales, to help improve detection of problems related to SMP mode.

This test is somewhat fragile given that upgrading Grackle versions could
conceivably alter the field values. In the future it would be better to
replace this with a test that:

1. checks out and builds a previous commit of Enzo-E
2. runs the simulation and saves the exact field values after running the simulations
3. checks out and builds a newer commit of Enzo-E (while leaving the build of Grackle unchanged)
4. runs the simulation and confirms that the Grackle related field values are identical to the field values from the earlier simulation.

method_grackle_cooling_dt
=========================

This test runs Grackle for a fixed number of cycles, and compares the
final simulation time to a reference value. Each simulation timestep
is set fraction of the minimum magnitude of the cooling/heating
timestep.
1 change: 1 addition & 0 deletions doc/source/tests/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This testing section describes tests on enzo-e program
collapse
cosmology
gravity
grackle
heat
helloworld
hierarchy
Expand Down
213 changes: 213 additions & 0 deletions input/Grackle/grackle.incl
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
#
# Grackle Test Problem:
#
# Sets up a cooling test without hydrodynamics to run many
# one-zone models in Grackle, fully sampling the density,
# temperature, and metallicity parameter space over which
# the chemistry and cooling/heating tables are valid.
#
# When including this file to launch a simulation, be sure to:
# - overwrite the entry in Method:grackle:data_file parameter
# - specify a stopping condition
# - specify an output schedule for the "data" output fileset
# (or drop that fileset from the output list)

Boundary {
type = "reflecting";
}

Domain {
lower = [ 0.0, 0.0, 0.0];
upper = [ 1.0, 1.0, 1.0];
}

Units {
density = 1.6726219E-24; # m_H in grams... so n = 1.0 cm^-3 for pure hydrogen
time = 3.15576E13; # 1 Myr in seconds
length = 3.086E16; # 1 pc in cm - does not actually matter
}

Field {
alignment = 8;
gamma = 1.400;
ghost_depth = 3;
list = [ "density",
"internal_energy",
"total_energy",
"velocity_x",
"velocity_y",
"velocity_z",
# purposefully commenting these out to test automatic
# creation of needed fields
# "HI_density",
# "HII_density",
"HM_density",
"HeI_density",
"HeII_density",
"HeIII_density",
"H2I_density",
"H2II_density",
"DI_density",
"DII_density",
"HDI_density",
"e_density",
"metal_density",
"cooling_time",
"temperature",
"pressure",
"gamma"
];

padding = 0;
}

Group {
list = ["color", "derived"];

# fields that should be advected by hydro MUST be defined
# as color here. This is handled automatically in
# EnzoMethodGrackle for the Grackle-specific fields (species)
# but not everything
color {
field_list = [
"HI_density",
"HII_density",
"HM_density",
"HeI_density",
"HeII_density",
"HeIII_density",
"H2I_density",
"H2II_density",
"DI_density",
"DII_density",
"HDI_density",
"e_density",
"metal_density",
"cooling_time",
"temperature",
"pressure",
"gamma" ];
}

# derived fields grouping enables Enzo-E to ensure
# that all derived fields are updated prior to output
# In order for this to work, these MUST have their own
# compute classes.
derived {
field_list = ["temperature",
"pressure",
"cooling_time"];
}
}

Initial {
list = ["grackle_test"];
grackle_test {
# See note in "Mesh" on running in < 3D

minimum_H_number_density = 0.0001;
maximum_H_number_density = 1000.0;
minimum_metallicity = 1.0;
maximum_metallicity = 1.0;
minimum_temperature = 10.0;
maximum_temperature = 1.0E8;

# Keep temperature constant with changing mu?
reset_energies = 0;

dt = 100.0;
}
}

Mesh {
# This test problem varies density, temperature,
# and metallicity over x, y, and z dimensions
# respectively. For smaller problems you can
# run in 1 or 2 dimensions by changing the below
# accordingly and setting the min/max values in
# initialization to be the same. Currently cannot
# pick which value goes in which dimension,
# so 2D can only be density and temperature,
# 1D can only vary density.

#root_blocks = [ 4, 4];
#root_rank = 2;
#root_size = [128, 128];

# 3D test example:
root_blocks = [ 4, 4, 4];
root_rank = 3;
root_size = [32, 32, 32];

}

Method {
list = [ "grackle", "null"];

grackle {
courant = 0.40; # meaningless unless use_cooling_timestep = true;

data_file = "CloudyData_UVB=HM2012_shielded.h5";

with_radiative_cooling = 1;
primordial_chemistry = 3; # 1, 2, or 3
metal_cooling = 1; # 0 or 1 (off/on)
UVbackground = 1; # on or off
self_shielding_method = 3; # 0 - 3 (0 or 3 recommended)

HydrogenFractionByMass = 0.73;

# set this to true to limit the maximum timestep to the product of the
# minimum cooling/heating time and courant.
use_cooling_timestep = false; # default is false
}

# use this to limit maximum timestep if grackle::use_cooling_timestep is
# set to false and Grackle crashes due to max iteration limit - this is
# not needed generally in a real simulation as hydro timestep will
# be small (usually)
null { dt = 100.0; }

}

Output {
list = ["data"];

data {
field_list = [ "density",
"internal_energy",
"total_energy",
"velocity_x",
"velocity_y",
"velocity_z",
"HI_density",
"HII_density",
"HM_density",
"HeI_density",
"HeII_density",
"HeIII_density",
"H2I_density",
"H2II_density",
"DI_density",
"DII_density",
"HDI_density",
"e_density",
"metal_density",
"cooling_time",
"temperature",
"pressure",
"gamma"
];

dir = ["GRACKLE_TEST_%03d","cycle"];
name = [ "method_grackle-1-%03d.h5", "proc" ];
schedule {
var = "time";
step = 1000.0;
start = 0.0;
}
type = "data";
}

}

24 changes: 24 additions & 0 deletions input/Grackle/method_grackle_cooling_dt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# this file is used for a test where the cooling time is used to limit
# the size of the timestep
#
# The automated test will also overwrite the entry in
# Method:grackle:data_file parameter with a valid path

include "input/Grackle/grackle.incl"

Output { list = []; } # don't write any outputs

Method {
list = [ "grackle" ]; # intentionally omit "null"
grackle {
courant = 0.40;
use_cooling_timestep = true;
}
}

Testing {
time_final = [0.00201833123232718];
time_tolerance = 1.0e-4;
}

Stopping { cycle = 20; }
19 changes: 19 additions & 0 deletions input/Grackle/method_grackle_general.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# this file is used for checking general consistency of grackle results
# (without using a timestep based on the minimum cooling time)
#
# The automated test will also overwrite the entry in
# Method:grackle:data_file parameter with a valid path

include "input/Grackle/grackle.incl"

Output {
data {
dir = ["GeneralGrackle-%06.2f", "time"];
schedule {
var = "time";
list = [500.0];
}
}
}

Stopping { time = 500.0; }
Loading

0 comments on commit c53c505

Please sign in to comment.