hspace=0.04,
                    top=0.98,
                    bottom=0.02,
                    left=0.02,
                    right=0.98)

reader = phd.Hdf5()
for i in range(4):  # over columns
    for j in range(2):  # over plots

        file_name = static_names[j][i]
        particles = reader.read(file_name)
        time = h5py.File(file_name, "r").attrs["time"]

        ax = axes[j, i]
        patch, colors = phd.vor_collection(particles, "density")
        particles.remove_tagged_particles(phd.ParticleTAGS.Ghost)

        print(particles["density"].min(), particles["density"].max())

        p = PatchCollection(patch, cmap="jet", edgecolor="none")
        p.set_array(np.array(colors))
        p.set_clim([0.9, 2.1])
        ax.add_collection(p)
        ax.set_xlim(0, 1)
        ax.set_ylim(0, 3)

        ax.text(0.07,
                2.80,
                r"$t=%0.2f$" % time,
                fontsize=14,
Example #2
0
    reader = phd.Hdf5()
    vortex = reader.read(fi)
    time = h5py.File(fi, "r").attrs["time"]

    vortex.register_carray(vortex.get_carray_size(),
            "v-theta", "double")
    vortex.register_carray(vortex.get_carray_size(),
            "rad", "double")

    # put position and velocity in radial coordinates
    theta = np.arctan2(vortex["position-y"]-0.5, vortex["position-x"]-0.5)
    vortex["rad"][:] = np.sqrt((vortex["position-x"]-0.5)**2 + (vortex["position-y"]-0.5)**2)
    vortex["v-theta"][:] = (-np.sin(theta)*vortex["velocity-x"] + np.cos(theta)*vortex["velocity-y"])

    # third column
    patch, colors = phd.vor_collection(vortex, "v-theta")
    vortex.remove_tagged_particles(phd.ParticleTAGS.Ghost)

    p = PatchCollection(patch, edgecolor="none", linewidth=0.1, cmap="jet", alpha=0.9)
    p.set_array(np.array(colors))
    p.set_clim([0, 1.0])
    ax = axes[0,i]
    ax.text(0.03, 0.92, r"$t=%0.2f$" % time, fontsize=12,
            bbox=dict(boxstyle="round", facecolor="white"))
    ax.set_xlabel("X", fontsize=12)
    ax.set_ylabel("Y", fontsize=12)
    ax.set_xticks([0, 0.2, 0.4, 0.6, 0.8, 1.0])
    ax.set_yticks([0, 0.2, 0.4, 0.6, 0.8, 1.0])
    ax.set_xticklabels([0, 0.2, 0.4, 0.6, 0.8, 1.0])
    ax.set_yticklabels([0, 0.2, 0.4, 0.6, 0.8, 1.0])
    ax.set_xlim(0,1)
Example #3
0
reader = phd.Hdf5()
fig, axes = plt.subplots(2, 2, figsize=(8, 8))
file_names = [
    "kelvin_output/time_interval/time_interval0004/time_interval0004.hdf5",
    "kelvin_output/time_interval/time_interval0009/time_interval0009.hdf5",
    "kelvin_output/time_interval/time_interval0014/time_interval0014.hdf5",
    "kelvin_output/final_output/final_output0000/final_output0000.hdf5"
]

#for i, file_name in enumerate(file_names):
for i in range(2):
    for j in range(2):

        file_name = file_names[2 * i + j]
        kelvin = reader.read(file_name)
        patch, colors = phd.vor_collection(kelvin, "density")
        kelvin.remove_tagged_particles(phd.ParticleTAGS.Ghost)

        time = h5py.File(file_name, "r").attrs["time"]

        p = PatchCollection(patch, edgecolor="gray", linewidth=0.1)
        p.set_array(np.array(colors))
        p.set_clim([0.9, 2.1])

        ax = axes[i, j]
        ax.text(0.03,
                0.92,
                r"$t=%0.2f$" % time,
                fontsize=18,
                bbox=dict(boxstyle="round", facecolor="white"))
        ax.set_xlim(0, 1)
Example #4
0
# single-core solution
file_name = "explosion_output/final_output/final_output0000/final_output0000.hdf5"
reader = phd.Hdf5()
sedov = reader.read(file_name)

# exact sedov solution
exact = np.loadtxt("solution.txt")
rad_ex = exact[:, 0]
rho_ex = exact[:, 1]
vel_ex = exact[:, 2]
pre_ex = exact[:, 3]

fig, axes = plt.subplots(1, 2, figsize=(12, 6))

patch, colors = phd.vor_collection(sedov, "density")
sedov.remove_tagged_particles(phd.ParticleTAGS.Ghost)

p = PatchCollection(patch, edgecolor="none", linewidth=0.1, alpha=0.8)
p.set_array(np.array(colors))
p.set_clim([0, 1.0])
ax = axes[0]
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
ax.add_collection(p)

# put position and velocity in radial coordinates
rad = np.sqrt((sedov["position-x"] - 0.5)**2 + (sedov["position-y"] - 0.5)**2)
vel = (sedov["velocity-x"]*(sedov["position-x"]-0.5) +\
f = h5py.File(file_name, 'r')
sod_sc = phd.ParticleContainer(f['/density'].size)
for field in fields:
    sod_sc[field][:] = f['/' + field][:]
f.close()

# exact riemann solution
f = h5py.File("riemann_sol.hdf5", "r")
pos_ex = f['/x'][:]
rho_ex = f['/density'][:]
per_ex = f['/pressure'][:]
vel_ex = f['/velocity'][:]
f.close()

fig, axes = plt.subplots(3, 3, figsize=(12, 12))
patch, colors = phd.vor_collection(sod_sc, "density")
sod_sc.remove_tagged_particles(phd.ParticleTAGS.Ghost)

p = PatchCollection(patch, alpha=0.4)
p.set_array(np.array(colors))
p.set_clim([0, 1.0])
ax = axes[0, 1]
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
ax.add_collection(p)

# first remove interior particles
tag = np.where(sod_mc['type'] == phd.ParticleTAGS.Interior)[0]
sod_mc.remove_items(tag)
Example #6
0
# single-core solution
file_name = "explosion_output/final_output/final_output0000/final_output0000.hdf5"
reader = phd.Hdf5()
explosion = reader.read(file_name)

# exact explosion solution
exact = np.loadtxt("solution.txt")
rad_ex = exact[:, 0]
rho_ex = exact[:, 1]
vel_ex = exact[:, 2]
pre_ex = exact[:, 3]

fig, axes = plt.subplots(2, 2, figsize=(12, 12))

patch, colors = phd.vor_collection(explosion, "density")
explosion.remove_tagged_particles(phd.ParticleTAGS.Ghost)

p = PatchCollection(patch, edgecolor="none", linewidth=0.1, alpha=0.8)
p.set_array(np.array(colors))
p.set_clim([0, 1.0])
ax = axes[0, 0]
ax.set_xlabel("X", fontsize=18)
ax.set_ylabel("Y", fontsize=18)
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
ax.add_collection(p)

# put position and velocity in radial coordinates
rad = np.sqrt((explosion["position-x"] - 0.5)**2 +
              (explosion["position-y"] - 0.5)**2)
Example #7
0
file_name = "sod_output/final_output/final_output0000/final_output0000.hdf5"
reader = phd.Hdf5()
sod = reader.read(file_name)

# exact riemann solution
f = h5py.File("riemann_sol.hdf5", "r")
pos_ex = f["/x"][:]
rho_ex = f["/density"][:]
pre_ex = f["/pressure"][:]
vel_ex = f["/velocity"][:]
f.close()

fig, axes = plt.subplots(2, 2, figsize=(12, 12))
plt.suptitle("Sod Simulation")

patch, colors = phd.vor_collection(sod, "density")
sod.remove_tagged_particles(phd.ParticleTAGS.Ghost)

p = PatchCollection(patch, edgecolor="black", linewidth=0.3, alpha=0.8)
p.set_array(np.array(colors))
p.set_clim([0, 1.0])
ax = axes[0, 0]
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
ax.add_collection(p)

ax = axes[0, 1]
ax.scatter(sod["position-x"],
           sod["density"],