예제 #1
0
"""
Plots the 2D pressure field from a OpenFOAM simulation at given times using the
visualization software ParaView.
"""

from snake.openfoam.simulation import OpenFOAMSimulation


simulation = OpenFOAMSimulation()
simulation.plot_field_contours_paraview('pressure',
                                        field_range=(-1.0, 0.5),
                                        view=(-2.0, -5.0, 15.0, 5.0),
                                        times=(0.0, 100.0, 2.0),
                                        width=800)
예제 #2
0
# file: plotVorticity.py
# author: Olivier Mesnard ([email protected])
# description: Plots the 2D vorticity field.
# Run this script from the simulation directory.


from snake.openfoam.simulation import OpenFOAMSimulation


simulation = OpenFOAMSimulation()
simulation.plot_field_contours_paraview('vorticity',
                                        field_range=(-5.0, 5.0),
                                        view=(-2.0, -5.0, 15.0, 5.0),
                                        times=(0.0, 100.0, 2.0),
                                        width=800)
예제 #3
0
# file: plotForceCoefficientsCompareKrishnanEtAl2014.py
# author: Olivier Mesnard ([email protected])
# description: Plots the instantaneous force coefficients
#              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(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,
parser.add_argument('--save-dir',
                    dest='save_directory',
                    type=str,
                    default=script_directory,
                    help='directory where to save the figures')
args = parser.parse_args()
with open(args.map, 'r') as infile:
    dirs = yaml.load(infile)

# Computes the mean coefficients from the OpenFOAM simulations.
# The force coefficients are averaged between 32 and 64 time-units.
cd_openfoam, cl_openfoam = [], []
for re in ['Re1000', 'Re2000']:
    for aoa in ['AoA25', 'AoA30', 'AoA35', 'AoA40']:
        simulation_directory = dirs['openfoam_forceCoefficientsVsAoA'][re][aoa]
        simulation = OpenFOAMSimulation(directory=simulation_directory)
        simulation.read_forces(display_coefficients=True)
        simulation.get_mean_forces(limits=[32.0, 64.0])
        cd_openfoam.append(simulation.forces[0].mean['value'])
        cl_openfoam.append(simulation.forces[1].mean['value'])

# Computes the mean coefficients from the cuIBM simulations
# reported in Krishnan et al. (2014).
# The force coefficients are averaged between 32 and 64 time-units.
cd_krishnan, cl_krishnan = [], []
for re in ['Re1000', 'Re2000']:
    for aoa in ['AoA25', 'AoA30', 'AoA35', 'AoA40']:
        simulation_directory = os.path.join(os.environ['SNAKE'], 'resources',
                                            'flyingSnake2d_cuibm_anush',
                                            'flyingSnake2d' + re + aoa)
        krishnan = CuIBMSimulation(directory=simulation_directory)
예제 #5
0
# file: plotForceCoefficientsRe2000AoA35.py
# author: Olivier Mesnard ([email protected])
# description: Plots the instantaneous force coefficients
#              and compares to results from Krishnan et al. (2014).

import os

from matplotlib import pyplot

from snake.openfoam.simulation import OpenFOAMSimulation
from snake.cuibm.simulation import CuIBMSimulation

simulation = OpenFOAMSimulation(description='IcoFOAM',
                                directory=os.path.join(
                                    os.environ['HOME'], 'simulations_OpenFOAM',
                                    'flyingSnake2d', 'snappyHexMesh',
                                    'surfaceFeatureExtract',
                                    'flyingSnake2dRe2000AoA30_20151103'))
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/'
                     'flyingSnake2dRe2000AoA30/forces'
                     ''.format(os.environ['SNAKE']))
krishnan.get_mean_forces(limits=[32.0, 64.0])
krishnan.get_strouhal(limits=[32.0, 64.0], order=200)

dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True)
예제 #6
0
# file: plotForceCoefficients.py
# author: Olivier Mesnard ([email protected])
# description: Plots the instantaneous force coefficients.
# Run this script from the simulation directory.


from snake.openfoam.simulation import OpenFOAMSimulation


simulation = OpenFOAMSimulation()
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)

simulation.plot_forces(display_coefficients=True,
                       display_extrema=True, order=200,
                       limits=(0.0, 80.0, 0.0, 3.0),
                       save_name='forceCoefficients')
simulation.plot_forces(display_coefficients=True,
                       display_extrema=True, order=200,
                       limits=(0.0, 100.0, 0.0, 3.0),
                       save_name='forceCoefficientsExtended')
dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True)
print(dataframe)
                    type=str, 
                    default=os.path.join(script_directory, 'map.yaml'), 
                    help='file containing the list of simulation directories')
parser.add_argument('--save-dir', 
                    dest='save_directory', 
                    type=str, 
                    default=script_directory, 
                    help='directory where to save the figures')
args = parser.parse_args()
with open(args.map, 'r') as infile:
  dirs = yaml.load(infile)

# Plots the force coefficients at Re=2000 and AoA=30deg
# and compares to the results reported in Krishnan et al. (2014).
simulation_directory = dirs['openfoam_forceCoefficientsRe2000']['Re2000AoA30']
simulation = OpenFOAMSimulation(description='IcoFOAM',
                                directory=simulation_directory)
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=os.path.join(os.environ['SNAKE'],
                                            'resources',
                                            'flyingSnake2d_cuibm_anush',
                                            'flyingSnake2dRe2000AoA30',
                                            'forces'))
krishnan.get_mean_forces(limits=[32.0, 64.0])
krishnan.get_strouhal(limits=[32.0, 64.0], order=200)

dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True)
예제 #8
0
"""
Plots the maximum CFL number over the course of the simulation.

The maximum CFL values are read from the log file (output) of OpenFOAM.
"""

import os
from snake.openfoam.simulation import OpenFOAMSimulation


simulation = OpenFOAMSimulation()
filepath = os.path.join('log.run', 'log.icoFoam')
simulation.read_maximum_cfl(filepath)
simulation.get_mean_maximum_cfl(limits=(60.0, 80.0))
simulation.plot_maximum_cfl(display_extrema=True, order=200,
                            limits=(0.0, 100.0, 0.5, 2.0),
                            save_name='maximumCFL')
                    type=str,
                    default=os.path.join(script_directory, 'map.yaml'),
                    help='file containing the list of simulation directories')
parser.add_argument('--save-dir',
                    dest='save_directory',
                    type=str,
                    default=script_directory,
                    help='directory where to save the figures')
args = parser.parse_args()
with open(args.map, 'r') as infile:
    dirs = yaml.load(infile)

# Plots the force coefficients at Re=2000 and AoA=30deg
# and compares to the results reported in Krishnan et al. (2014).
simulation_directory = dirs['openfoam_forceCoefficientsRe2000']['Re2000AoA30']
simulation = OpenFOAMSimulation(description='IcoFOAM',
                                directory=simulation_directory)
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=os.path.join(
    os.environ['SNAKE'], 'resources', 'flyingSnake2d_cuibm_anush',
    'flyingSnake2dRe2000AoA30', 'forces'))
krishnan.get_mean_forces(limits=[32.0, 64.0])
krishnan.get_strouhal(limits=[32.0, 64.0], order=200)

dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True)
dataframe2 = krishnan.create_dataframe_forces(display_strouhal=True,
                                              display_coefficients=True,
#              and compares to results from Krishnan et al. (2014).

import os
import sys

from matplotlib import pyplot

import snake
from snake.openfoam.simulation import OpenFOAMSimulation
from snake.cuibm.simulation import CuIBMSimulation

print('\nPython version:\n{}'.format(sys.version))
print('\nsnake version: {}\n'.format(snake.__version__))

simulation = OpenFOAMSimulation(
    description='IcoFOAM',
    directory=os.path.join(os.environ['HOME'], 'snakeReproducibilityPackages',
                           'openfoam', 'snappyHexMesh', 'Re2000AoA30'))
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=os.path.join(
    os.environ['SNAKE'], 'resources', 'flyingSnake2d_cuibm_anush',
    'flyingSnake2dRe2000AoA30', 'forces'))
krishnan.get_mean_forces(limits=[32.0, 64.0])
krishnan.get_strouhal(limits=[32.0, 64.0], order=200)

dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True)
dataframe2 = krishnan.create_dataframe_forces(display_strouhal=True,
예제 #11
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)
# file: plotForceCoefficientsCompareOther.py
# author: Olivier Mesnard ([email protected])
# description: Plots the instantaneous force coefficients
#              and compare to results from previous simulation.
# Run this script from the simulation directory.


from snake.openfoam.simulation import OpenFOAMSimulation


simulation = OpenFOAMSimulation(description="present")
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)

other = OpenFOAMSimulation(description="other", directory="")
other.read_forces(display_coefficients=True)
other.get_mean_forces(limits=[32.0, 64.0])
other.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=other,
    other_coefficients=1.0,
    save_name="forceCoefficientsCompareOther",
)
dataframe = simulation.create_dataframe_forces(display_strouhal=True, display_coefficients=True)
dataframe2 = other.create_dataframe_forces(display_strouhal=True, display_coefficients=True)
예제 #13
0
"""
Post-processes the force coefficients from a OpenFOAM simulation and compare
them to another 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.simulation import Simulation
from snake.openfoam.simulation import OpenFOAMSimulation

simulation = OpenFOAMSimulation(description='present')
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)

other = Simulation(description='', directory='', software='')
other.read_forces()
other.get_mean_forces(limits=time_limits)
other.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),
                       other_simulations=other,
                       other_coefficients=1.0,
                       save_name='forceCoefficientsCompareOther',
                       style='mesnardo',
# file: plotForceCoefficientsCompareOther.py
# author: Olivier Mesnard ([email protected])
# description: Plots the instantaneous force coefficients
#              and compare to results from previous simulation.
# Run this script from the simulation directory.

from snake.openfoam.simulation import OpenFOAMSimulation

simulation = OpenFOAMSimulation(description='present')
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)

other = OpenFOAMSimulation(description='other', directory='')
other.read_forces(display_coefficients=True)
other.get_mean_forces(limits=[32.0, 64.0])
other.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=other,
                       other_coefficients=1.0,
                       save_name='forceCoefficientsCompareOther')
dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True)
dataframe2 = other.create_dataframe_forces(display_strouhal=True,
                                           display_coefficients=True)
dataframe = dataframe.append(dataframe2)
print(dataframe)
예제 #15
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.openfoam.simulation import OpenFOAMSimulation


simulation = OpenFOAMSimulation()
simulation.plot_field_contours_paraview(
    "vorticity", field_range=(-5.0, 5.0), view=(-0.75, -1.0, 1.50, 1.0), times=(0.0, 100.0, 2.0), width=800
)
예제 #16
0
"""
Plots the 2D vorticity field from a OpenFOAM simulation at given times using
the visualization software ParaView.
"""

from snake.openfoam.simulation import OpenFOAMSimulation


simulation = OpenFOAMSimulation()
simulation.plot_field_contours_paraview('vorticity',
                                        field_range=(-5.0, 5.0),
                                        view=(-2.0, -5.0, 15.0, 5.0),
                                        times=(0.0, 100.0, 2.0),
                                        width=800)
예제 #17
0
import os
import warnings

from matplotlib import pyplot

import snake
from snake.openfoam.simulation import OpenFOAMSimulation

if snake.__version__ != '0.1.2':
    warnings.warn('The figures were originally created with snake-0.1.2, ' +
                  'you are using snake-{}'.format(snake.__version__))

# Reads the instantaneous forces from the simulation on the fine grid.
# The force coefficients are averaged between 32 and 64 time-units.
directory = os.path.join(os.path.dirname(__file__), 'h0.002')
simulation = OpenFOAMSimulation(description='fine (5.3M cells)',
                                directory=directory)
simulation.read_forces(display_coefficients=True)
simulation.get_mean_forces(limits=[32.0, 64.0])

# Reads the instantaneous forces from the simulation on the coarse grid.
# The force coefficients are averaged between 32 and 64 time-units.
directory = os.path.join(os.path.dirname(__file__), 'h0.004')
other = OpenFOAMSimulation(description='coarse (3.4M cells)',
                           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)
예제 #18
0
# file: plotMaximumCFL.py
# author: Olivier Mesnard ([email protected])
# description: Plot the instantaneous maximum CFL number.
# Run this script from the simulation directory.

from snake.openfoam.simulation import OpenFOAMSimulation

simulation = OpenFOAMSimulation()
simulation.read_maximum_cfl('log.run/log.icoFoam')
simulation.get_mean_maximum_cfl(limits=(60.0, 80.0))
simulation.plot_maximum_cfl(display_extrema=True,
                            order=200,
                            limits=(0.0, 100.0, 0.5, 2.0),
                            save_name='maximumCFL')
예제 #19
0
#              copies the .png files here,
#              and creates one .pdf page with the images.

import os
import sys
import shutil

import snake
from snake.openfoam.simulation import OpenFOAMSimulation

print('\nPython version:\n{}'.format(sys.version))
print('\nsnake version: {}\n'.format(snake.__version__))

directory = os.path.join(os.environ['HOME'], 'snakeReproducibilityPackages',
                         'openfoam', 'gmsh', 'Re2000AoA35')
simulation = OpenFOAMSimulation(directory=directory)
simulation.plot_field_contours_paraview('pressure',
                                        field_range=(-1.0, 0.5),
                                        view=(-2.0, -3.0, 15.0, 3.0),
                                        times=(52.0, 53.0, 1.0),
                                        width=600,
                                        colormap='viridis')

# locate images of interest
images_directory = os.path.join(simulation.directory, 'images',
                                'pressure_-2.00_-3.00_15.00_3.00')
file_names = ['pressure052.00.png', 'pressure053.00.png']
source_paths = [os.path.join(images_directory, name) for name in file_names]
# copy .png files here
destination_paths = [
    os.path.join(os.getcwd(),
from matplotlib import pyplot

import snake
from snake.openfoam.simulation import OpenFOAMSimulation


if snake.__version__ != '0.1.2':
  warnings.warn('The figures were originally created with snake-0.1.2, '+
                'you are using snake-{}'.format(snake.__version__))

# Reads the instantaneous forces from the simulation that uses more demanding
# exit criterion for the iterative solvers (tol=1.0E-08).
# The force coefficients are averaged between 32 and 64 time-units.
directory = os.path.join(os.path.dirname(__file__),
                         'tol1.0E-08')
simulation = OpenFOAMSimulation(description='tol=1.0E-08',
                                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)
예제 #21
0
parser.add_argument('--map', 
                    dest='map', 
                    type=str, 
                    default=os.path.join(script_directory, 'map.yaml'), 
                    help='file containing the list of simulation directories')
parser.add_argument('--save-dir', 
                    dest='save_directory', 
                    type=str, 
                    default=script_directory, 
                    help='directory where to save the figures')
args = parser.parse_args()
with open(args.map, 'r') as infile:
  dirs = yaml.load(infile)

simulation_directory = dirs['openfoam_vorticity52Re2000AoA35_gmshZeroGradient']['Re2000AoA35']
simulation = OpenFOAMSimulation(directory=simulation_directory)
simulation.plot_field_contours_paraview('vorticity',
                                        field_range=(-5.0, 5.0),
                                        view=(-5.0, -8.0, 10.0, 2.0),
                                        times=(52.0, 52.0, 1.0),
                                        width=1000,
                                        colormap='RdBu_r')
simulation.plot_field_contours_paraview('vorticity',
                                        field_range=(-5.0, 5.0),
                                        view=(2.20, -7.30, 2.80, -6.70),
                                        times=(52.0, 52.0, 1.0),
                                        width=300,
                                        colormap='RdBu_r',
                                        display_scalar_bar=False,
                                        display_time_text=False,
                                        display_mesh=True)
예제 #22
0
import sys
import shutil

import snake
from snake.openfoam.simulation import OpenFOAMSimulation


print('\nPython version:\n{}'.format(sys.version))
print('\nsnake version: {}\n'.format(snake.__version__))

directory = os.path.join(os.environ['HOME'],
                         'snakeReproducibilityPackages',
                         'openfoam',
                         'gmsh',
                         'Re2000AoA35')
simulation = OpenFOAMSimulation(directory=directory)
simulation.plot_field_contours_paraview('pressure',
                                        field_range=(-1.0, 0.5),
                                        view=(-2.0, -3.0, 15.0, 3.0),
                                        times=(52.0, 53.0, 1.0),
                                        width=600,
                                        colormap='viridis')

# locate images of interest
images_directory = os.path.join(simulation.directory, 
                                'images', 
                                'pressure_-2.00_-3.00_15.00_3.00')
file_names = ['pressure052.00.png', 'pressure053.00.png']
source_paths = [os.path.join(images_directory, name) for name in file_names]
# copy .png files here
destination_paths = [os.path.join(os.getcwd(), 
예제 #23
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)
# 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,
# 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()
예제 #26
0
import sys
import shutil

import snake
from snake.openfoam.simulation import OpenFOAMSimulation


print('\nPython version:\n{}'.format(sys.version))
print('\nsnake version: {}\n'.format(snake.__version__))

directory = os.path.join(os.environ['HOME'],
                         'snakeReproducibilityPackages',
                         'openfoam',
                         'gmsh',
                         'Re2000AoA35')
simulation = OpenFOAMSimulation(directory=directory)
simulation.plot_field_contours_paraview('vorticity',
                                        field_range=(-5.0, 5.0),
                                        view=(-5.0, -8.0, 10.0, 2.0),
                                        times=(52.0, 52.0, 1.0),
                                        width=600,
                                        colormap='RdBu_r')

images_directory = os.path.join(directory, 
                                'images', 
                                'vorticity_-5.00_-8.00_10.00_2.00')
file_name_source = 'vorticity052.00.png'
file_name_destination = 'openfoam_vorticity52Re2000AoA35_gmshZeroGradient.pdf'
# copy the .png file
shutil.copy(os.path.join(images_directory,
                         file_name_source), 
예제 #27
0
# file: plotPressure.py
# author: Olivier Mesnard ([email protected])
# description: Plots the 2D pressure field.
# Run this script from the simulation directory.

from snake.openfoam.simulation import OpenFOAMSimulation

simulation = OpenFOAMSimulation()
simulation.plot_field_contours_paraview('pressure',
                                        field_range=(-1.0, 0.5),
                                        view=(-2.0, -5.0, 15.0, 5.0),
                                        times=(0.0, 100.0, 2.0),
                                        width=800)
예제 #28
0
aoa = [25, 30, 35, 40]

# 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])
예제 #29
0
# file: plotForceCoefficients.py
# author: Olivier Mesnard ([email protected])
# description: Plots the instantaneous force coefficients.
# Run this script from the simulation directory.

from snake.openfoam.simulation import OpenFOAMSimulation

simulation = OpenFOAMSimulation()
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)

simulation.plot_forces(display_coefficients=True,
                       display_extrema=True,
                       order=200,
                       limits=(0.0, 80.0, 0.0, 3.0),
                       save_name='forceCoefficients')
simulation.plot_forces(display_coefficients=True,
                       display_extrema=True,
                       order=200,
                       limits=(0.0, 100.0, 0.0, 3.0),
                       save_name='forceCoefficientsExtended')
dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True)
print(dataframe)