""" Plots and saves the 2D pressure field from a PetIBM simulation at saved time-steps. """ from snake.petibm.simulation import PetIBMSimulation simulation = PetIBMSimulation() simulation.read_grid() for time_step in simulation.get_time_steps(): simulation.read_fields('pressure', time_step) simulation.plot_contour('pressure', field_range=(-1.0, 0.5, 101), filled_contour=True, view=[-15.0, -15.0, 15.0, 15.0], style='mesnardo', cmap='viridis', save_name='pressure', width=8.0)
# file: plotVorticitySnake.py # author: Olivier Mesnard ([email protected]) # description: Plots the 2D vorticity field near the snake. # Run this script from the simulation directory. from snake.petibm.simulation import PetIBMSimulation from snake.body import Body simulation = PetIBMSimulation() simulation.read_grid() body = Body(file_path='flyingSnake2dAoA35ds0.004.body') for time_step in simulation.get_time_steps(): simulation.read_fields('vorticity', time_step) simulation.plot_contour('vorticity', field_range=[-5.0, 5.0, 101], filled_contour=True, view=[-0.75, -1.0, 1.50, 1.0], bodies=body, width=8.0)
dirs = yaml.load(infile) simulation_directory = dirs['petibm011_vorticity']['Re2000AoA35'] simulation = PetIBMSimulation(directory=simulation_directory) simulation.read_grid(file_path=os.path.join(simulation.directory, 'grid.txt')) time_steps = [47500, 130000, 132500, 160000] file_paths_in = [] for time_step in time_steps: simulation.read_fields('vorticity', time_step) simulation.plot_contour('vorticity', field_range=[-5.0, 5.0, 101], time_increment=0.0004, view=[-1.0, -2.0, 8.0, 2.0], colorbar=(True if time_step == time_steps[-1] else False), width=6.0, dpi=300, style='snakeReproducibility') file_paths_in.append(os.path.join(simulation.directory, 'images', 'vorticity_-1.00_-2.00_8.00_2.00', 'vorticity{:0>7}.png'.format(time_step))) # convert the four .png files into one file_path_out = os.path.join(args.save_directory, 'petibm011_vorticityRe2000AoA35.png') os.system('convert -append {} {}'.format(' '.join(file_paths_in), file_path_out)) # convert the four .png files into a single .pdf
# file: plotPressure.py # author: Olivier Mesnard ([email protected]) # description: Plots the 2D pressure field. # Run this script from the simulation directory. from snake.petibm.simulation import PetIBMSimulation simulation = PetIBMSimulation() simulation.read_grid() for time_step in simulation.get_time_steps(): simulation.read_fields('pressure', time_step) simulation.plot_contour('pressure', field_range=[-1.0, 0.5, 101], filled_contour=True, view=[-15.0, -15.0, 15.0, 15.0], save_name='pressure', width=8.0)
'flyingSnake', '2d', 'cuibmGrid', 'velocityBiCGStabPoissonBiCGStab', 'flyingSnake2dRe2000AoA35_20160426') simulation = PetIBMSimulation(directory=directory) simulation.read_grid() time_steps = [47500, 130000, 132500, 160000] source_paths = [] for time_step in time_steps: simulation.read_fields('vorticity', time_step) simulation.plot_contour('vorticity', field_range=[-5.0, 5.0, 101], time_increment=0.0004, filled_contour=True, view=[-1.0, -2.0, 8.0, 2.0], colorbar=(True if time_step == time_steps[-1] else False), width=6.0) source_paths.append(os.path.join(directory, 'images', 'vorticity_-1.00_-2.00_8.00_2.00', 'vorticity{:0>7}.png'.format(time_step))) # copy .png file here shutil.copy(source_paths[-1], 'petibm-0.1.1_vorticity{}Re2000AoA35.png'.format(time_step)) # create single .pdf page with pdfjam destination_path = os.path.join(os.getcwd(), 'petibm-0.1.1_vorticityRe2000AoA35.pdf') os.system('pdfjam {} --nup 1x{} --outfile {}'.format(' '.join(source_paths),
# file: plotVorticity.py # author: Olivier Mesnard ([email protected]) # description: Plots the 2D vorticity field. # Run this script from the simulation directory. from snake.petibm.simulation import PetIBMSimulation simulation = PetIBMSimulation() simulation.read_grid() for time_step in simulation.get_time_steps(): simulation.read_fields('vorticity', time_step) simulation.plot_contour('vorticity', field_range=[-5.0, 5.0, 101], filled_contour=True, view=[-2.0, -5.0, 15.0, 5.0], width=8.0)
directory = os.path.join(os.environ['HOME'], 'simulations_PetIBM', 'flyingSnake', '2d', 'cuibmGrid', 'velocityBiCGStabPoissonBiCGStab', 'flyingSnake2dRe2000AoA35_20160426') simulation = PetIBMSimulation(directory=directory) simulation.read_grid() time_steps = [47500, 130000, 132500, 160000] source_paths = [] for time_step in time_steps: simulation.read_fields('vorticity', time_step) simulation.plot_contour( 'vorticity', field_range=[-5.0, 5.0, 101], time_increment=0.0004, filled_contour=True, view=[-1.0, -2.0, 8.0, 2.0], colorbar=(True if time_step == time_steps[-1] else False), width=6.0) source_paths.append( os.path.join(directory, 'images', 'vorticity_-1.00_-2.00_8.00_2.00', 'vorticity{:0>7}.png'.format(time_step))) # copy .png file here shutil.copy(source_paths[-1], 'petibm-0.1.1_vorticity{}Re2000AoA35.png'.format(time_step)) # create single .pdf page with pdfjam destination_path = os.path.join(os.getcwd(), 'petibm-0.1.1_vorticityRe2000AoA35.pdf') os.system('pdfjam {} --nup 1x{} --outfile {}'.format(' '.join(source_paths), len(source_paths),
""" Computes, plots, and saves the 2D vorticity field from a PetIBM simulation at saved time-steps. """ from snake.petibm.simulation import PetIBMSimulation simulation = PetIBMSimulation() simulation.read_grid() for time_step in simulation.get_time_steps(): simulation.read_fields('vorticity', time_step) simulation.plot_contour('vorticity', field_range=(-5.0, 5.0, 101), filled_contour=True, view=[-2.0, -5.0, 15.0, 5.0], style='mesnardo', width=8.0)
with open(args.map, 'r') as infile: dirs = yaml.load(infile) simulation_directory = dirs['petibm011_vorticity']['Re2000AoA35'] simulation = PetIBMSimulation(directory=simulation_directory) simulation.read_grid(file_path=os.path.join(simulation.directory, 'grid.txt')) time_steps = [47500, 130000, 132500, 160000] file_paths_in = [] for time_step in time_steps: simulation.read_fields('vorticity', time_step) simulation.plot_contour( 'vorticity', field_range=[-5.0, 5.0, 101], time_increment=0.0004, view=[-1.0, -2.0, 8.0, 2.0], colorbar=(True if time_step == time_steps[-1] else False), width=6.0, dpi=300, style='snakeReproducibility') file_paths_in.append( os.path.join(simulation.directory, 'images', 'vorticity_-1.00_-2.00_8.00_2.00', 'vorticity{:0>7}.png'.format(time_step))) # convert the four .png files into one file_path_out = os.path.join(args.save_directory, 'petibm011_vorticityRe2000AoA35.png') os.system('convert -append {} {}'.format(' '.join(file_paths_in), file_path_out)) # convert the four .png files into a single .pdf
# file: plotPressure.py # author: Olivier Mesnard ([email protected]) # description: Plots the 2D pressure field. # Run this script from the simulation directory. from snake.petibm.simulation import PetIBMSimulation simulation = PetIBMSimulation() simulation.read_grid() for time_step in simulation.get_time_steps(): simulation.read_fields("pressure", time_step) simulation.plot_contour( "pressure", field_range=[-1.0, 0.5, 101], filled_contour=True, view=[-15.0, -15.0, 15.0, 15.0], save_name="pressure", width=8.0, )