def quantities(basename, dirname=data_dir):
    # =========
    # Computing
    print(dirname)
    nframes = len(glob.glob1(dirname, basename + "*.dat"))
    time = np.zeros(nframes)
    enstrophy = np.zeros(nframes)
    kinetic_energy = np.zeros(nframes)
    for iframe in range(nframes):
        # Load the data
        filename = dirname + basename + f"{iframe:04d}.dat"
        print(filename)
        ds = apt.load_datfile(filename)
        ad = ds.load_all_data(regriddir=dirname + "regridded_data/")
        omega = ad['omega']
        velocity_x = ad['v1']
        velocity_y = ad['v2']
        rho = ad['rho']
        kin_energy_density = rho * (velocity_x**2 + velocity_y**2) / 2
        Dx = 1 / np.size(omega, 1)

        # Compute quantities
        time[iframe] = ds.get_time()
        enstrophy[iframe] = 1 / 2 * Dx * np.linalg.norm(omega)**2
        kinetic_energy[iframe] = Dx * np.linalg.norm(kin_energy_density)**2

    # ======
    # Saving (doesn't seem to be necessary, loads very fast when regridded)
    # np.save(data_dir + basename + "time.npy", time)
    # np.save(data_dir + basename + "enstr.npy", enstrophy)

    # ========
    # Plotting
    # plt.plot(time, enstrophy)
    # plt.xlabel("Time")
    # plt.ylabel("Enstrophy")
    # plt.show()
    return time, enstrophy, kinetic_energy
    def update(iframe):
        """Updating function for the MATLAB AnimationWriter."""
        ax.clear()

        # Extract the data for the current frame
        filename = data_dir + basename + f"{iframe:04d}.dat"
        ds = apt.load_datfile(filename)
        time = ds.get_time()

        # Plot and set figure
        ds.amrplot(quantity,
                   fig=fig,
                   ax=ax,
                   draw_mesh=True,
                   mesh_linewidth=0.5,
                   mesh_color='white',
                   mesh_linestyle='solid',
                   mesh_opacity=0.8)
        ax.set_xlabel(r'$x$')
        ax.set_ylabel(r'$y$')
        ax.set_xlim([0.0, 1.0])  # Unit square
        ax.set_ylim([0.0, 1.0])  # Unit square
        ax.set_title(f"{quantity} at time {time:.2f}")
    def update(iframe):
        """Updating function for the MATLAB AnimationWriter."""
        ax.clear()

        # Extract the data for the current frame
        filename = data_dir + basename + f"{iframe:04d}.dat"
        ds = apt.load_datfile(filename)
        ad = ds.load_all_data(regriddir=data_dir + "regridded_data/")
        xx = ds.get_coordinate_arrays()[0]
        yy = ds.get_coordinate_arrays()[1]
        zz = ad[quantity].transpose()
        time = ds.get_time()

        # Make a contourplot #vmin=minval, vmax=maxval, extend='both', cmap='Oranges', levels=200)
        contourplot = ax.contourf(xx, yy, zz)
        ax.set_xlabel(r'$x$')
        ax.set_ylabel(r'$y$')
        ax.set_xlim([0.0, 1.0])  # Unit square
        ax.set_ylim([0.0, 1.0])  # Unit square
        ax.set_title(f"{quantity} at time {time:.2f}")

        # Update the colorbar
        cax.cla()
        fig.colorbar(contourplot, cax=cax)
physical_time = np.round(time_stamps*dt, 1)
for stuff in range(len(file_names)):
    FIRST = True
    file_name = file_names[stuff]
    path_2_file = path_2_files[stuff]
    Full_path = path_2_shared_drive + path_2_file + file_name

    for ind, ti in enumerate(time_stamps):
        clipped_rho_data = []
        clipped_sch = []
        clipped_Te_data = []
        jet_sides_index1_array = []
        jet_sides_index2_array = []
        offset = str(ti).zfill(4)
        if dat_file==True:
            ds = apt.load_datfile(Full_path+offset+'.dat')
            ad = ds.load_all_data()      
            var_rho_data = ad['rho']*unit_density
        if vtu_file==True:
            ds = apt.load_vtkfile(ti, file=Full_path, type='vtu')
    
            var_rho_data = apt.vtkfiles.rgplot(ds.rho, data=ds, cmap='hot')
            var_Te_data = apt.vtkfiles.rgplot(ds.T, data=ds, cmap='hot')
            var_rho_data, x_grid0, y_grid0 = var_rho_data.get_data(xres=xres, yres=yres)
            var_Te_data, x_grid0, y_grid0 = var_Te_data.get_data(xres=xres, yres=yres)
            sch = convert_2_schlieren(var_rho_data, x_grid=x_grid0, 
                                   y_grid=y_grid0, sch=schlieren_value)
            var_rho_data = var_rho_data*g_cm3_to_kg_m3
            plt.close('all')
            shape = np.shape(var_rho_data)
            if FIRST == True:
Example #5
0
file_name = 'jet_P300_B50A_40_'
Full_path = path_2_shared_drive + path_2_file + file_name

SMALL_SIZE = 40
MEDIUM_SIZE = SMALL_SIZE + 2
BIGGER_SIZE = MEDIUM_SIZE + 2

plt.rc('font', size=SMALL_SIZE)  # controls default text sizes
plt.rc('axes', titlesize=SMALL_SIZE)  # fontsize of the axes title
plt.rc('axes', labelsize=BIGGER_SIZE)  # fontsize of the x and y labels
plt.rc('xtick', labelsize=SMALL_SIZE)  # fontsize of the tick labels
plt.rc('ytick', labelsize=SMALL_SIZE)  # fontsize of the tick labels
plt.rc('legend', fontsize=SMALL_SIZE)  # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title

ds = apt.load_datfile(Full_path + '0000.dat')
#F, ax =  plt.subplots(figsize=(30, 24))
p = ds.amrplot('T',
               draw_mesh=True,
               mesh_linewidth=1.25,
               mesh_color='white',
               mesh_linestyle='solid',
               mesh_opacity=1,
               cmap='coolwarm')
#p.ax.set_xlim(-1,1)
#p.ax.set_ylim(0,1.5)

xticks = p.ax.get_xticks() * 10
yticks = p.ax.get_yticks() * 10
p.ax.set_xticklabels(xticks)
p.ax.set_yticklabels(yticks)