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(display_coefficients=True, display_extrema=True, order=200, limits=(0.0, 80.0, 0.0, 3.0), other_simulations=krishnan, other_coefficients=2.0, save_name='forceCoefficientsCompareKrishnanEtAl2014') dataframe = simulation.create_dataframe_forces(display_strouhal=True, display_coefficients=True) dataframe2 = krishnan.create_dataframe_forces(display_strouhal=True, display_coefficients=True, coefficient=2.0) dataframe = dataframe.append(dataframe2) print(dataframe)
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, save_name='liftCoefficientCompareKrishnanEtAl2014') dataframe = simulation.create_dataframe_forces(indices=[1], display_strouhal=True, display_coefficients=True) dataframe2 = krishnan.create_dataframe_forces(indices=[1], display_strouhal=True, display_coefficients=True, coefficient=2.0) dataframe = dataframe.append(dataframe2) print(dataframe)
directory=directory) simulation.read_forces(display_coefficients=True) simulation.get_mean_forces(limits=[32.0, 64.0]) # Reads the instantaneous forces from the simulation that uses less demanding # exit criterion for the iterative solvers (tol=1.0E-06). # The force coefficients are averaged between 32 and 64 time-units. directory = os.path.join(os.path.dirname(__file__), 'tol1.0E-06') other = OpenFOAMSimulation(description='tol=1.0E-06', directory=directory) other.read_forces(display_coefficients=True) other.get_mean_forces(limits=[32.0, 64.0]) # Displays the time-averaged force coefficients into a table. dataframe = simulation.create_dataframe_forces(display_coefficients=True) dataframe2 = other.create_dataframe_forces(display_coefficients=True) dataframe = dataframe.append(dataframe2) print(dataframe) # Plots the instantaneous force coefficients fig, ax = pyplot.subplots(figsize=(6, 4)) ax.grid(True, zorder=0) ax.set_xlabel('non-dimensional time-unit') ax.set_ylabel('force coefficients') ax.plot(simulation.forces[0].times, simulation.forces[0].values, label='$C_d$ ($tol=10^{-8}$)', color='#377eb8', linestyle='-', linewidth=2, zorder=10)