scale="velocity_mag", geom=arrows, factor=0.04, tolerance=0.04) # compute normalized velocity #df_glyph['Velocity_Norm'] = np.linalg.norm(df_glyph['Velocity'], axis=1) return df_glyph ############################################################################# #particles = Lethe_pyvista_tools('D:/results/lethe/alginate/q1-q1', 'first_case.prm') #particles.path_output('output') #particles.read_lethe_to_pyvista('result_particles.pvd', last = 20) fluid = Lethe_pyvista_tools('D:/results/lethe/alginate/q1-q1', 'first_case.prm') fluid.path_output('output') fluid.read_lethe_to_pyvista('result_.pvd') #for i in range(0, len(particles.list_vtu)): #exec(f'particles.df_{i}[\'Velocity_x\'] = particles.df_{i}[\'Velocity\'][:, 0]') # exec(f'particles.df_{i}[\'Velocity_mag\'] = (particles.df_{i}[\'Velocity\'][:, 0]**2 + particles.df_{i}[\'Velocity\'][:, 1]**2 + particles.df_{i}[\'Velocity\'][:, 2]**2)**(1/2)') for i in range(0, len(fluid.list_vtu)): exec( f'fluid.df_{i}[\'velocity_mag\'] = (fluid.df_{i}[\'velocity\'][:, 0]**2 + fluid.df_{i}[\'velocity\'][:, 1]**2 + fluid.df_{i}[\'velocity\'][:, 2]**2)**(1/2)' ) exec( f'fluid.df_{i}[\'ID\'] = np.arange(0, len(fluid.df_{i}[\'velocity_mag\']))' ) exec(f'fluid.df_{i}[\'velocity_x\'] = fluid.df_{i}[\'velocity\'][:, 0]')
from Lethe_pyvista_tools import * #This script prints the content of your prm file as dictionary #To run Lethe_pyvista_tools you need to specify the path to your #case and the name of the .prm file example = Lethe_pyvista_tools('PATH TO YOUR CASE', 'NAME_OF_YOUR_PARAMETERS_FILE.prm') print('This is the dictionary of your .prm file:') print(example.prm_dict) print( 'To print out any value in the dictionary, ask for it using ["parameter_name"] right after .prm_dict variable' ) #To read the data to pyvista dataframe, use the following with #the .pvd file as argument example.read_lethe_to_pyvista('NAME_OF_YOUR_PVD_FILE.pvd')
from openpyxl import load_workbook import os import sys ############################################################################# ############################################################################# '''Simulation properties''' #Take case path as argument and store at currentPath currentPath = sys.argv[1] saveFigDir = currentPath particle_name = sys.argv[2] fluid = Lethe_pyvista_tools(currentPath, prm_file_name='liquid_fluidized_bed.prm') fluid.read_lethe_to_pyvista('result_.pvd', first=1) #fluid.read_lethe_to_pyvista_parallel('result_.pvd', last = 200, processors=2) particle = Lethe_pyvista_tools(currentPath, prm_file_name='liquid_fluidized_bed.prm') model_type = fluid.prm_dict['vans model'].replace('model', '') velocity_order = str(int(fluid.prm_dict['velocity order'])) pressure_order = str(int(fluid.prm_dict['pressure order'])) boundary_condition = fluid.prm_dict['bc 0'] scheme = f'Model type {model_type} - Q{velocity_order}-Q{pressure_order}' dp = particle.prm_dict['diameter']
from Lethe_pyvista_tools import * import sys ############################################################################# ############################################################################# '''Simulation properties''' #Take case path as argument simulation_path = sys.argv[1] # Name the save path save_path = simulation_path # Create the particle object particle = Lethe_pyvista_tools(simulation_path, prm_file_name='liquid_fluidized_bed.prm') # Read data particle.read_lethe_to_pyvista('result_particles.pvd', first=-1) ############################################################################# '''Save particle data''' # Loop through all results for i in range(len(particle.list_vtu)): # Store results in 'df' exec(f'df = particle.df_{i}') # Create the pandas dataframe out of the pyvista df exec(f'tab = pd.DataFrame(df.points)')
def create_particles(df_name): df_ = df_name # create spheres scaled to the diameter of the array "Diameter" df_glyph = df_.glyph(scale='Diameter', geom=sphere) # compute normalized velocity #df_glyph['Velocity_Norm'] = np.linalg.norm(df_glyph['Velocity'], axis=1) return df_glyph ############################################################################# particles = Lethe_pyvista_tools('D:/multiple particles sedimentation', 'IB_flow_PBR.prm') particles.path_output('') particles.read_lethe_to_pyvista('ib_particles_reconstruct.pvd') for i in range(0, len(particles.list_vtu)): exec( f'particles.df_{i}[\'Velocity_x\'] = particles.df_{i}[\'Velocity\'][:, 0]' ) #create a sphere with diameter 1 sphere = pv.Sphere(theta_resolution=50, phi_resolution=50) #create the box box = pv.Box(bounds=(-5.25, -3.25, -0.25, 0.25, -0.25, 0.25)) #Choose the white background for the figure
#import glob #import os import sys ############################################################################# ############################################################################# '''Simulation properties''' #Take case path as argument and store at currentPath currentPath = sys.argv[1] saveFigDir = currentPath particle_name = sys.argv[2] particle = Lethe_pyvista_tools(currentPath, prm_file_name='liquid_fluidized_bed.prm') particle.read_lethe_to_pyvista('result_particles.pvd', last=201) model_type = particle.prm_dict['vans model'].replace('model', '') velocity_order = str(int(particle.prm_dict['velocity order'])) pressure_order = str(int(particle.prm_dict['pressure order'])) scheme = f'Model type {model_type} - Q{velocity_order}-Q{pressure_order}' dp = particle.prm_dict['diameter'] rp = dp / 2 rhop = particle.prm_dict['density particles'] Np = particle.prm_dict['number'] inlet_velocity = particle.prm_dict['u'] eps_comparison = pd.read_excel('D:/results/alginate/Abstract_Results.xlsx')
from Lethe_pyvista_tools import * first_case = Lethe_pyvista_tools() first_case.lethe_import_to_pyvista('result_particles.pvd') print(first_case.list_vtu)