diff --git a/src/cooling/grackle/cooling_io.h b/src/cooling/grackle/cooling_io.h index 0d7a1f664ecb0df8c1985757dcd30e07bb395199..4f6e02f9b9220c51510418b969ac4315a925604d 100644 --- a/src/cooling/grackle/cooling_io.h +++ b/src/cooling/grackle/cooling_io.h @@ -33,7 +33,7 @@ void cooling_read_particles(struct part* parts, struct io_props* list, *num_fields += 1; /* List what we want to read */ - list[0] = io_make_input_field("HeDensity", FLOAT, 1, OPTIONAL, + list[0] = io_make_input_field("HeDensity", FLOAT, 1, COMPULSORY, UNIT_CONV_DENSITY, parts, cooling_data.He_density); } diff --git a/tests/Makefile.am b/tests/Makefile.am index 998a0e0bb05704ff8f8502a0452755cca37b3378..7e139754598bc3e52771b47c02c39429c9bd49c9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,7 +17,7 @@ # Add the source directory and debug to CFLAGS AM_CFLAGS = -I$(top_srcdir)/src $(HDF5_CPPFLAGS) -AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(FFTW_LIBS) +AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(FFTW_LIBS) $(GRACKLE_LIBS) # List of programs and scripts to run in the test suite TESTS = testGreetings testMaths testReading.sh testSingle testKernel testSymmetry \ diff --git a/tests/makeInput.py b/tests/makeInput.py index 93c173b75aab3e14639372df5a77474acd3fc4e5..eb2b5a078837b753ff94e282c03d2cde901b595d 100644 --- a/tests/makeInput.py +++ b/tests/makeInput.py @@ -37,6 +37,7 @@ fileName = "input.hdf5" numPart = L**3 mass = boxSize**3 * rho / numPart internalEnergy = P / ((gamma - 1.)*rho) +he_density = rho * 0.24 #Generate particles coords = zeros((numPart, 3)) @@ -45,6 +46,7 @@ m = zeros((numPart, 1)) h = zeros((numPart, 1)) u = zeros((numPart, 1)) ids = zeros((numPart, 1), dtype='L') +he = zeros((numPart, 1)) for i in range(L): for j in range(L): @@ -63,7 +65,7 @@ for i in range(L): h[index] = 2.251 * boxSize / L u[index] = internalEnergy ids[index] = index - + he[index] = he_density #-------------------------------------------------- @@ -110,5 +112,7 @@ ds = grp.create_dataset('InternalEnergy', (numPart,1), 'f') ds[()] = u ds = grp.create_dataset('ParticleIDs', (numPart, 1), 'L') ds[()] = ids +ds = grp.create_dataset('HeDensity', (numPart, 1), 'f') +ds[()] = he file.close() diff --git a/tests/testReading.c b/tests/testReading.c index b47b0419101443371b75d150afa934f91593c4ff..c087401499dbfc16be08e664a95d61bcc03f578c 100644 --- a/tests/testReading.c +++ b/tests/testReading.c @@ -42,6 +42,7 @@ int main() { const double boxSize = 1.; const size_t L = 4; const double rho = 2.; + const float He_density = rho * 0.24; /* Read data */ read_ic_single("input.hdf5", &us, dim, &parts, &gparts, &sparts, &Ngas, @@ -92,6 +93,13 @@ int main() { assert(parts[n].a_hydro[0] == 0.); assert(parts[n].a_hydro[1] == 0.); assert(parts[n].a_hydro[2] == 0.); + +#ifdef COOLING_GRACKLE + printf("Test %g, %g, %g\n", parts[n].cooling_data.He_density, + He_density, + parts[n].cooling_data.He_density-He_density); + assert(parts[n].cooling_data.He_density == He_density); +#endif } /* Clean-up */