def average_com_detrend(n_init, n_fin, off=0.5, nb=5) : init_array = dm.read_density_file(folder_name+'/'+file_root+str(n_init).zfill(5)+'.dat', bin='y') left_branch_avg, right_branch_avg, xcom_0 = detect_interface(init_array, off, nb) for n in range(n_init+1, n_fin+1) : print("[ interface frame "+str(n)+" ]") n_array = dm.read_density_file(folder_name+'/'+file_root+str(n).zfill(5)+'.dat', bin='y') left_branch, right_branch, xcom = detect_interface(n_array, off, nb) left_branch_avg = left_branch_avg + left_branch - (xcom-xcom_0) right_branch_avg = right_branch_avg + right_branch - (xcom-xcom_0) return left_branch_avg/(n_fin-n_init+1), right_branch_avg/(n_fin-n_init+1)
spin_up_steps = 0 n_init = FP.first_stamp + spin_up_steps n_fin = FP.last_stamp dt = FP.time_step n_dump = 10 tot_amu = 0 print("Producing averaged profile ") for idx in range(n_init, n_fin): if idx % n_dump == 0: print("Obtainig frame " + str(idx)) t_label = str(dt * idx) + ' ps' print("tot amu = " + str(tot_amu)) # Time-averaging window rho = dm.read_density_file(folder_name + '/' + file_root + '{:05d}'.format(idx) + '.dat', bin='y') U, V = dm.read_velocity_file(folder_name + '/' + file_root + '{:05d}'.format(idx) + '.dat') K = 0.5 * np.multiply(rho, np.multiply(U, U) + np.multiply(V, V)) profile_velocity_x = np.add(np.mean(U, axis=0), profile_velocity_x) profile_velocity_z = np.add(np.mean(V, axis=0), profile_velocity_z) profile_kinetic_energy = np.add(np.mean(K, axis=0), profile_kinetic_energy) tot_amu = np.sum(np.sum(rho)) profile_velocity_x /= n_fin - n_init profile_velocity_z /= n_fin - n_init profile_kinetic_energy /= n_fin - n_init Ly = 4.65840 volume = Lx * Ly * Lz
base_name = 'flow_' # folder_name = '100nm/third_run' # file_name = 'flow_00900.dat' # folder_name = 'RawFlowData' # file_name = 'flow_SOL_00100.dat' # PARAMETERS TO TUNE Lx = 60.00000 Lz = 35.37240 # Lx = 300.00000 # Lz = 200.44360 # Lx = 75.60000 # Lz = 28.00000 vel_x, vel_z = dm.read_velocity_file(folder_name + '/' + file_name) rho = dm.read_density_file(folder_name + '/' + file_name, bin='y') # p_x = np.multiply(rho, vel_x) # p_z = np.multiply(rho, vel_z) Nx = vel_x.shape[0] Nz = vel_x.shape[1] hx = Lx / Nx # [nm] hz = Lz / Nz # [nm] x = hx * np.arange(0.0, Nx, 1.0, dtype=float) z = hz * np.arange(0.0, Nz, 1.0, dtype=float) X, Z = np.meshgrid(x, z, sparse=False, indexing='ij') kin_ener = 0.5 * np.multiply( rho, np.multiply(vel_x, vel_x) + np.multiply(vel_z, vel_z)) # Try to average with values at previous steps
import sys import densmap as dm import numpy as np FP = dm.fitting_parameters(par_file='parameters_shear.txt') folder_name = FP.folder_name file_root = 'flow_' Lx = FP.lenght_x Lz = FP.lenght_z # CREATING MESHGRID print("Creating meshgrid") dummy_dens = dm.read_density_file(folder_name + '/' + file_root + '00500.dat', bin='y') dummy_vel_x, dummy_vel_z = dm.read_velocity_file(folder_name + '/' + file_root + '00500.dat') Nx = dummy_dens.shape[0] Nz = dummy_dens.shape[1] hx = Lx / Nx hz = Lz / Nz x = hx * np.arange(0.0, Nx, 1.0, dtype=float) z = hz * np.arange(0.0, Nz, 1.0, dtype=float) X, Z = np.meshgrid(x, z, sparse=False, indexing='ij') # Manually tune, crop window [nm] x0_crop = 87.00 x1_crop = 100.0 z0_crop = 0.000 z1_crop = 6.000
output_file_name = "com.mp4" folder_name = 'Q4Ca005' file_root = 'flow_' # PARAMETERS TO TUNE Lx = 159.75000 Lz = 30.63400 n_init = 8626 n_fin = 8628 # CREATING MESHGRID print("Creating meshgrid") density_array = dm.read_density_file(folder_name + '/' + file_root + '04000.dat', bin='y') Nx = density_array.shape[0] Nz = density_array.shape[1] hx = Lx / Nx hz = Lz / Nz x = hx * np.arange(0.0, Nx, 1.0, dtype=float) z = hz * np.arange(0.0, Nz, 1.0, dtype=float) X, Z = np.meshgrid(x, z, sparse=False, indexing='ij') # Testing .vtk output function """ vtk_folder = "/home/michele/densmap/TestVtk" dm.export_scalar_vtk(x, z, hx, hz, 2.5, density_array) """
import matplotlib.pyplot as plt from matplotlib import cm import os # User inputs folder_name = 'Q4Ca002' ni = 683 nf = 1183 Lx = 159.75000 Lz = 30.63400 nbins = 4 ref_order = 7 # Generate meshgrid file_root = 'flow_' init_array = dm.read_density_file(folder_name+'/'+file_root+'00001.dat', bin='y') Nx = init_array.shape[0] Nz = init_array.shape[1] hx = Lx/Nx hz = Lz/Nz x = hx*(np.arange(0.0,Nx,1.0, dtype=float)+0.5) z = hz*(np.arange(0.0,Nz,1.0, dtype=float)+0.5) X, Z = np.meshgrid(x, z, sparse=False, indexing='ij') def detect_interface(density_array, offset, nband) : M = int(np.ceil(offset*Nx)) left_branch = np.zeros( Nz, dtype=float ) right_branch = np.zeros( Nz, dtype=float ) mass_strip = np.zeros( Nz, dtype=float ) xcom_strip = np.zeros( Nz, dtype=float ) for j in range(Nz) :
def contact_angle_from_density ( filename, smoother, density_th=2.0, h=1.85 ) : _, theta = dm.equilibrium_from_density( filename, smoother, density_th, hx, hz, h ) return theta # a = np.array([0.00, 0.75, 1.00, 1.25, 1.50, 1.75]) a = np.array([0.00, 0.25, 0.50, 0.75, 1.00, 1.25, 1.50, 1.75]) # PARAMETERS TO TUNE Lx = 60.00000 # [nm] Lz = 35.37240 # [nm] r_h2o = 0.09584 # Detecting dimensions dummy_file = '20nm/flow_sit_f/flow_00125.dat' density_array = dm.read_density_file(dummy_file, bin='y') Nx = density_array.shape[0] Nz = density_array.shape[1] hx = Lx/Nx hz = Lz/Nz nx = Nx nz = Nz x = hx*np.arange(0.0, nx, 1.0, dtype=float) z = hz*np.arange(0.0, nz, 1.0, dtype=float) X, Z = np.meshgrid(x, z, sparse=False, indexing='ij') # Smoothing kernel once for all smoother = dm.smooth_kernel(r_h2o, hx, hz) master_folder = '20nm/' folders_sit = 'flow_sit'
# Output file name output_file_name = "t94_ca01_diff_ds.mp4" folder_ens1 = 'Theta94Ca010_10nm' folder_ens2 = 'Theta94Ca01_double' file_root = 'flow_' # PARAMETERS TO TUNE Lx = 159.57001 Lz = 29.04330 # CREATING MESHGRID print("Creating meshgrid") density_array = dm.read_density_file(folder_ens1 + '/' + file_root + '00001.dat', bin='y') Nx = density_array.shape[0] Nz = density_array.shape[1] hx = Lx / Nx hz = Lz / Nz x = hx * np.arange(0.0, Nx, 1.0, dtype=float) z = hz * np.arange(0.0, Nz, 1.0, dtype=float) X, Z = np.meshgrid(x, z, sparse=False, indexing='ij') # Section for density computation N_low = int(np.floor(70.0 / hx)) N_upp = int(np.ceil(90.0 / hx)) # INITIALIZING SMOOTHING KERNEL r_mol = 0.39876