15fileName =
"sedov.hdf5"
18coords = zeros((numPart, 3))
22for i
in range(numPart):
23 coords[i, 0] = i * vol / numPart + vol / (2.0 * numPart)
24 h[i] = 1.2348 * vol / numPart
27v = zeros((numPart, 3))
28ids = linspace(1, numPart, numPart)
33r = abs(coords[:, 0] - 0.5)
34m[:] = rho0 * vol / numPart
35u[:] = P0 / (rho0 * (gamma - 1))
39u[index[0:N_inject]] = E0 / (N_inject * m[0])
44file = h5py.File(fileName,
"w")
47grp = file.create_group(
"/Header")
48grp.attrs[
"BoxSize"] = [1.0, 1.0, 1.0]
49grp.attrs[
"NumPart_Total"] = [numPart, 0, 0, 0, 0, 0]
50grp.attrs[
"NumPart_Total_HighWord"] = [0, 0, 0, 0, 0, 0]
51grp.attrs[
"NumPart_ThisFile"] = [numPart, 0, 0, 0, 0, 0]
52grp.attrs[
"Time"] = 0.0
53grp.attrs[
"NumFilesPerSnapshot"] = 1
54grp.attrs[
"MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
55grp.attrs[
"Flag_Entropy_ICs"] = 0
56grp.attrs[
"Dimension"] = 1
59grp = file.create_group(
"/Units")
60grp.attrs[
"Unit length in cgs (U_L)"] = 1.0
61grp.attrs[
"Unit mass in cgs (U_M)"] = 1.0
62grp.attrs[
"Unit time in cgs (U_t)"] = 1.0
63grp.attrs[
"Unit current in cgs (U_I)"] = 1.0
64grp.attrs[
"Unit temperature in cgs (U_T)"] = 1.0
67grp = file.create_group(
"/PartType0")
68grp.create_dataset(
"Coordinates", data=coords, dtype=
"d")
69grp.create_dataset(
"Velocities", data=v, dtype=
"f")
70grp.create_dataset(
"Masses", data=m, dtype=
"f")
71grp.create_dataset(
"SmoothingLength", data=h, dtype=
"f")
72grp.create_dataset(
"InternalEnergy", data=u, dtype=
"f")
73grp.create_dataset(
"ParticleIDs", data=ids, dtype=
"L")