# compute mean coefficients of each OpenFOAM simulations cd, cl = [], [] directory = os.path.join(os.environ['HOME'], 'simulations_OpenFOAM', 'flyingSnake2d', 'snappyHexMesh', 'surfaceFeatureExtract') folders = [ 'flyingSnake2dRe1000AoA25_20151103', 'flyingSnake2dRe1000AoA30_20151103', 'flyingSnake2dRe1000AoA35_20151030', 'flyingSnake2dRe1000AoA40_20151110', 'flyingSnake2dRe2000AoA25_20151103', 'flyingSnake2dRe2000AoA30_20151103', 'flyingSnake2dRe2000AoA35_20151030', 'flyingSnake2dRe2000AoA40_20151110' ] for folder in folders: simulation = OpenFOAMSimulation(directory=os.path.join(directory, folder)) simulation.read_forces(display_coefficients=True) simulation.get_mean_forces(limits=[32.0, 64.0]) cd.append(simulation.forces[0].mean['value']) cl.append(simulation.forces[1].mean['value']) # compute mean coefficients of each simulations from Krishnan et al. (2014) cd_krishnan, cl_krishnan = [], [] for Re in [1000, 2000]: for a in aoa: directory = os.path.join(os.environ['SNAKE'], 'resources', 'flyingSnake2d_cuibm_anush', 'flyingSnake2dRe{}AoA{}'.format(Re, a)) krishnan = CuIBMSimulation(directory=directory) krishnan.read_forces() krishnan.get_mean_forces(limits=[32.0, 64.0]) cd_krishnan.append(2.0 * krishnan.forces[0].mean['value']) cl_krishnan.append(2.0 * krishnan.forces[1].mean['value'])
""" Post-processes the force coefficients from a OpenFOAM simulation. This script reads the forces, computes the mean forces within a given range, computes the Strouhal number within a range, plots the force coefficients, saves the figure, and prints a data-frame that contains the mean values. """ from snake.openfoam.simulation import OpenFOAMSimulation simulation = OpenFOAMSimulation() simulation.read_forces(display_coefficients=True) time_limits = (32.0, 64.0) simulation.get_mean_forces(limits=time_limits) simulation.get_strouhal(limits=time_limits, order=200) simulation.plot_forces(display_coefficients=True, display_extrema=True, order=200, limits=(0.0, 80.0, 0.0, 3.0), save_name='forceCoefficients', style='mesnardo', show=True) dataframe = simulation.create_dataframe_forces(display_strouhal=True, display_coefficients=True) print(dataframe)
# file: plotLiftCoefficientCompareKrishnanEtAl2014.py # author: Olivier Mesnard ([email protected]) # description: Plots the instantaneous lift coefficient # and compare to results from Krishnan et al. (2014). # Run this script from the simulation directory. import os from snake.openfoam.simulation import OpenFOAMSimulation from snake.cuibm.simulation import CuIBMSimulation simulation = OpenFOAMSimulation(description='IcoFOAM') simulation.read_forces(display_coefficients=True) simulation.get_mean_forces(limits=[32.0, 64.0]) simulation.get_strouhal(limits=[32.0, 64.0], order=200) krishnan = CuIBMSimulation(description='Krishnan et al. (2014)') krishnan.read_forces(file_path='{}/resources/flyingSnake2d_cuibm_anush/' 'flyingSnake2dRe2000AoA35/forces' ''.format(os.environ['SNAKE'])) krishnan.get_mean_forces(limits=[32.0, 64.0]) krishnan.get_strouhal(limits=[32.0, 64.0], order=200) simulation.plot_forces(indices=[1], display_coefficients=True, display_extrema=True, order=200, limits=(0.0, 80.0, 0.0, 3.0), other_simulations=krishnan, other_coefficients=2.0,
""" Post-processes the force coefficients from a OpenFOAM simulation. This script reads the forces, computes the mean forces within a given range, computes the Strouhal number within a range, plots the force coefficients, saves the figure, and prints a data-frame that contains the mean values. """ from snake.openfoam.simulation import OpenFOAMSimulation simulation = OpenFOAMSimulation() simulation.read_forces(display_coefficients=True) time_limits = (32.0, 64.0) simulation.get_mean_forces(limits=time_limits) simulation.get_strouhal(limits=time_limits, order=200) simulation.plot_forces(display_coefficients=True, display_extrema=True, order=200, limits=(0.0, 80.0, 0.0, 3.0), save_name='forceCoefficients', style='mesnardo', show=True) dataframe = simulation.create_dataframe_forces(display_strouhal=True, display_coefficients=True) print(dataframe)