Esempio n. 1
0
import shutil

from matplotlib import pyplot
pyplot.style.use(os.path.join(os.environ['SNAKE'], 'snake', 'styles',
                              'snakeReproducibility.mplstyle'))

import snake
from snake.petibm.simulation import PetIBMSimulation


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

simulation = PetIBMSimulation(directory=os.path.join(os.environ['HOME'],
                                                     'snakeReproducibilityPackages',
                                                     'petibm',
                                                     'exactMarkers',
                                                     'Re2000AoA35'))
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,
                          view=[-1.0, -2.0, 8.0, 2.0],
                          colorbar=(True if time_step == time_steps[-1] 
                                    else False),
                          width=6.0,
Esempio n. 2
0
import os
import yaml
import argparse

from matplotlib import pyplot

import snake
from snake.petibm.simulation import PetIBMSimulation

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__))

directory = os.path.join(os.path.dirname(__file__), 'dt0.0002')
simulation = PetIBMSimulation(description='dt=0.0002', directory=directory)
simulation.read_forces()
simulation.get_mean_forces(limits=[32.0, 64.0])

directory = os.path.join(os.path.dirname(__file__), 'dt0.0004')
loose = PetIBMSimulation(description='dt=0.0004', directory=directory)
loose.read_forces()
loose.get_mean_forces(limits=[32.0, 64.0])

dataframe = simulation.create_dataframe_forces(display_coefficients=True,
                                               coefficient=2.0)
dataframe2 = loose.create_dataframe_forces(display_coefficients=True,
                                           coefficient=2.0)
dataframe = dataframe.append(dataframe2)
print(dataframe)
Esempio n. 3
0
# file: plotForceCoefficients.py
# author: Olivier Mesnard ([email protected])
# description: Plots the instantaneous force coefficients.
# Run this script from the simulation directory.


from snake.petibm.simulation import PetIBMSimulation


simulation = PetIBMSimulation()
simulation.read_forces()
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,
                       coefficient=2.0,
                       display_extrema=True, order=200,
                       limits=(0.0, 80.0, 0.0, 3.0),
                       save_name='forceCoefficients')
dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True,
                                               coefficient=2.0)
print(dataframe)
import os
import sys

from matplotlib import pyplot

import snake
from snake.petibm.simulation import PetIBMSimulation


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

simulation = PetIBMSimulation(description='original markers',
                              directory=os.path.join(os.environ['HOME'],
                                                     'snakeReproducibilityPackages',
                                                     'petibm',
                                                     'exactMarkers',
                                                     'Re2000AoA35'))
simulation.read_forces()
simulation.get_mean_forces(limits=[32.0, 64.0])
simulation.get_strouhal(limits=[32.0, 64.0], order=200)

other = PetIBMSimulation(description='displaced markers',
                         directory=os.path.join(os.environ['HOME'],
                                                'snakeReproducibilityPackages',
                                                'petibm',
                                                'shiftedMarkers',
                                                'Re2000AoA35'))
other.read_forces()
other.get_mean_forces(limits=[32.0, 64.0])
other.get_strouhal(limits=[32.0, 64.0], order=200)
# file: plotForceCoefficients.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.petibm.simulation import PetIBMSimulation
from snake.cuibm.simulation import CuIBMSimulation


simulation = PetIBMSimulation(description="PetIBM")
simulation.read_forces()
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,
    coefficient=2.0,
    display_extrema=True,
    order=200,
Esempio n. 6
0
                    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['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')
import yaml
import argparse

from matplotlib import pyplot

import snake
from snake.petibm.simulation import PetIBMSimulation


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__))


directory = os.path.join(os.path.dirname(__file__), 'rtol8')
simulation = PetIBMSimulation(description='rtol=1.0E-08',
                              directory=directory)
simulation.read_forces()
simulation.get_mean_forces(limits=[32.0, 64.0])

directory = os.path.join(os.path.dirname(__file__), 'rtol5')
loose = PetIBMSimulation(description='rtol=1.0E-05',
                         directory=directory)
loose.read_forces()
loose.get_mean_forces(limits=[32.0, 64.0])

dataframe = simulation.create_dataframe_forces(display_coefficients=True,
                                               coefficient=2.0)
dataframe2 = loose.create_dataframe_forces(display_coefficients=True,
                                           coefficient=2.0)
dataframe = dataframe.append(dataframe2)
print(dataframe)
Esempio n. 8
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['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')
Esempio n. 9
0
"""
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)
Esempio n. 10
0
# file: plotForceCoefficients.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.petibm.simulation import PetIBMSimulation
from snake.cuibm.simulation import CuIBMSimulation

simulation = PetIBMSimulation(description='PetIBM')
simulation.read_forces()
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,
                       coefficient=2.0,
                       display_extrema=True,
                       order=200,
                       limits=(0.0, 80.0, 0.0, 3.0),
                       other_simulations=krishnan,
                       other_coefficients=2.0,
# description: Plots the instantaneous force coefficients
#              and compares to results from Krishnan et al. (2014).


import os

from matplotlib import pyplot

from snake.petibm.simulation import PetIBMSimulation
from snake.cuibm.simulation import CuIBMSimulation


simulation = PetIBMSimulation(description='PetIBM',
                              directory=os.path.join(os.environ['HOME'],
                                                     'simulations_PetIBM',
                                                     'flyingSnake',
                                                     '2d',
                                                     'cuibmGrid',
                                                     'velocityCGPoissonBiCGStab',
                                                     'flyingSnake2dRe2000AoA35_bugFixPoisson_20160202'))
simulation.read_forces()
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)

dataframe = simulation.create_dataframe_forces(display_strouhal=True,
Esempio n. 12
0
"""
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)
Esempio n. 13
0
"""
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)
Esempio n. 14
0
                    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)

# Computes the mean force coefficients from the PetIBM simulation
# that uses shifted markers (rotation around the center of mass).
# The force coefficients are averaged between 32 and 64 time-units.
simulation_directory = dirs['petibm011_forceCoefficientsRe2000AoA35'][
    'displaced']
simulation = PetIBMSimulation(description='PetIBM (displaced markers)',
                              directory=simulation_directory)
simulation.read_forces()
simulation.get_mean_forces(limits=[32.0, 64.0])
simulation.get_strouhal(limits=[32.0, 64.0], order=200)

# Computes the mean force coefficients from the PetIBM simulation
# that uses exact markers (rotation around the origin (0,0)).
# The set of markers is identical to the one used in Krishnan et al. (2014).
# The force coefficients are averaged between 32 and 64 time-units.
simulation_directory = dirs['petibm011_forceCoefficientsRe2000AoA35'][
    'original']
simulation2 = PetIBMSimulation(description='PetIBM (original markers)',
                               directory=simulation_directory)
simulation2.read_forces()
simulation2.get_mean_forces(limits=[32.0, 64.0])
simulation2.get_strouhal(limits=[32.0, 64.0], order=200)
Esempio n. 15
0
"""

import os
from matplotlib import pyplot
from snake.petibm.simulation import PetIBMSimulation

script_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = os.path.abspath(os.path.join(script_dir, os.pardir))

# Time limits used to average the quantities.
time_limits = (32.0, 64.0)

dataframes = []

directory = root_dir
simu1 = PetIBMSimulation(description='Batch Shipyard', directory=directory)
simu1.read_forces()
# simu1.get_mean_forces(limits=time_limits)
# simu1.get_strouhal(limits=time_limits, order=200)
# dataframes.append(simu1.create_dataframe_forces(display_strouhal=True,
#                                                 display_coefficients=True,
#                                                 coefficient=2.0))

directory = os.path.join(os.environ['HOME'], 'git', 'mesnardo', 'snakeLips',
                         'simulations', 'Re2000', 'both', 'aoa35')
simu2 = PetIBMSimulation(description='Colonialone', directory=directory)
simu2.read_forces()
# simu2.get_mean_forces(limits=time_limits)
# simu2.get_strouhal(limits=time_limits, order=200)
# dataframes.append(simu2.create_dataframe_forces(display_strouhal=True,
#                                                 display_coefficients=True,
Esempio n. 16
0
# file: plotVorticity.py
# author: Olivier Mesnard ([email protected])
# description: Plots the 2D vorticity fields,
#              copies each .png file here,
#              and merges .png files into one .pdf page.

import os
import shutil

from snake.petibm.simulation import PetIBMSimulation

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(
Esempio n. 17
0
# author: Olivier Mesnard ([email protected])
# description: Plots the instantaneous force coefficients
#              and compare to results from other simulation.
# Run this script from the simulation directory.


from snake.ibamr.simulation import IBAMRSimulation
from snake.petibm.simulation import PetIBMSimulation


simulation = IBAMRSimulation(description='IBAMR')
simulation.read_forces()
simulation.get_mean_forces(limits=[32.0, 64.0])
simulation.get_strouhal(limits=[32.0, 64.0], order=200)

other = PetIBMSimulation(description='other',
                         directory='other')
other.read_forces()
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,
                       coefficient=-2.0,
                       display_extrema=True, order=200,
                       limits=(0.0, 80.0, 0.0, 3.0),
                       other_simulations=other,
                       other_coefficients=2.0,
                       save_name='forceCoefficientsCompareOther')
dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True,
                                               coefficient=-2.0)
dataframe2 = other.create_dataframe_forces(display_strouhal=True,
aoa = [25, 30, 35, 40]

# compute mean coefficients of each PetIBM simulations
cd, cl = [], []
directory = os.path.join(os.environ['HOME'], 'simulations_PetIBM',
                         'flyingSnake', '2d', 'cuibmGrid',
                         'velocityCGPoissonBiCGStab')
folders = [
    'flyingSnake2dRe1000AoA25_20150805', 'flyingSnake2dRe1000AoA30_20150807',
    'flyingSnake2dRe1000AoA35_20150807', 'flyingSnake2dRe1000AoA40_20150807',
    'flyingSnake2dRe2000AoA25_20150807', 'flyingSnake2dRe2000AoA30_20150807',
    'flyingSnake2dRe2000AoA35_bugFixPoisson_20160202',
    'flyingSnake2dRe2000AoA40_20150807'
]
for folder in folders:
    simulation = PetIBMSimulation(directory=os.path.join(directory, folder))
    simulation.read_forces()
    simulation.get_mean_forces(limits=[32.0, 64.0])
    cd.append(2.0 * simulation.forces[0].mean['value'])
    cl.append(2.0 * simulation.forces[1].mean['value'])

# read forces from simulation with exact same markers than Krishnan et al. (2014)
simulation = PetIBMSimulation(directory=os.path.join(
    os.environ['HOME'], 'simulations_PetIBM', 'flyingSnake', '2d', 'cuibmGrid',
    'velocityBiCGStabPoissonBiCGStab', 'flyingSnake2dRe2000AoA35_20160426'))
simulation.read_forces()
simulation.get_mean_forces(limits=[32.0, 64.0])
cd_exact = 2.0 * simulation.forces[0].mean['value']
cl_exact = 2.0 * simulation.forces[1].mean['value']

# compute mean coefficients of each simulations from Krishnan et al. (2014)
Post-processes the force coefficients from a PetIBM simulation and compare them
to cuIBM ones (obtained by Anush Krishnan and
published into Krishnan et al., 2014).

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.
"""

import os

from snake.petibm.simulation import PetIBMSimulation
from snake.cuibm.simulation import CuIBMSimulation


simulation = PetIBMSimulation(description='PetIBM')
simulation.read_forces()
time_limits = (32.0, 64.0)
simulation.get_mean_forces(limits=time_limits)
simulation.get_strouhal(limits=time_limits, order=200)

krishnan = CuIBMSimulation(description='Krishnan et al. (2014)')
filepath = os.path.join(os.environ['SNAKE'],
                        'resources',
                        'flyingSnake2d_cuibm_anush',
                        'flyingSnake2dRe2000AoA35',
                        'forces')
krishnan.read_forces(file_path=filepath)
krishnan.get_mean_forces(limits=time_limits)
krishnan.get_strouhal(limits=time_limits, order=200)
Esempio n. 20
0
# file: plotForceCoefficients.py
# author: Olivier Mesnard ([email protected])
# description: Plots the instantaneous force coefficients.
# Run this script from the simulation directory.

from snake.petibm.simulation import PetIBMSimulation

simulation = PetIBMSimulation()
simulation.read_forces()
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,
                       coefficient=2.0,
                       display_extrema=True,
                       order=200,
                       limits=(0.0, 80.0, 0.0, 3.0),
                       save_name='forceCoefficients')
dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True,
                                               coefficient=2.0)
print(dataframe)
Esempio n. 21
0
"""
Post-processes the force coefficients from a PetIBM simulation and compare them
to cuIBM ones (obtained by Anush Krishnan and
published into Krishnan et al., 2014).

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.
"""

import os

from snake.petibm.simulation import PetIBMSimulation
from snake.cuibm.simulation import CuIBMSimulation

simulation = PetIBMSimulation(description='PetIBM')
simulation.read_forces()
time_limits = (32.0, 64.0)
simulation.get_mean_forces(limits=time_limits)
simulation.get_strouhal(limits=time_limits, order=200)

krishnan = CuIBMSimulation(description='Krishnan et al. (2014)')
filepath = os.path.join(os.environ['SNAKE'], 'resources',
                        'flyingSnake2d_cuibm_anush',
                        'flyingSnake2dRe2000AoA35', 'forces')
krishnan.read_forces(file_path=filepath)
krishnan.get_mean_forces(limits=time_limits)
krishnan.get_strouhal(limits=time_limits, order=200)

simulation.plot_forces(display_coefficients=True,
                       coefficient=2.0,
Esempio n. 22
0

import os
import shutil

from snake.petibm.simulation import PetIBMSimulation


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,
# description: Plots the instantaneous force coefficients
#              and compares to simulation with displaced markers.

import os
import sys

from matplotlib import pyplot

import snake
from snake.petibm.simulation import PetIBMSimulation

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

simulation = PetIBMSimulation(
    description='original markers',
    directory=os.path.join(os.environ['HOME'], 'snakeReproducibilityPackages',
                           'petibm', 'exactMarkers', 'Re2000AoA35'))
simulation.read_forces()
simulation.get_mean_forces(limits=[32.0, 64.0])
simulation.get_strouhal(limits=[32.0, 64.0], order=200)

other = PetIBMSimulation(
    description='displaced markers',
    directory=os.path.join(os.environ['HOME'], 'snakeReproducibilityPackages',
                           'petibm', 'shiftedMarkers', 'Re2000AoA35'))
other.read_forces()
other.get_mean_forces(limits=[32.0, 64.0])
other.get_strouhal(limits=[32.0, 64.0], order=200)

dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True,
import snake
from snake.petibm.simulation import PetIBMSimulation
from snake.cuibm.simulation import CuIBMSimulation

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

aoa = [25, 30, 35, 40]

# compute mean coefficients of each PetIBM simulations
cd, cl = [], []
directory = os.path.join(os.environ['HOME'], 'snakeReproducibilityPackages',
                         'petibm', 'shiftedMarkers')
folders = ['Re{}AoA{}'.format(re, a) for re in [1000, 2000] for a in aoa]
for folder in folders:
    simulation = PetIBMSimulation(directory=os.path.join(directory, folder))
    simulation.read_forces()
    simulation.get_mean_forces(limits=[32.0, 64.0])
    cd.append(2.0 * simulation.forces[0].mean['value'])
    cl.append(2.0 * simulation.forces[1].mean['value'])

# read forces from simulation with exact same markers than Krishnan et al. (2014)
simulation = PetIBMSimulation(
    directory=os.path.join(os.environ['HOME'], 'snakeReproducibilityPackages',
                           'petibm', 'exactMarkers', 'Re2000AoA35'))
simulation.read_forces()
simulation.get_mean_forces(limits=[32.0, 64.0])
cd_exact = 2.0 * simulation.forces[0].mean['value']
cl_exact = 2.0 * simulation.forces[1].mean['value']

# compute mean coefficients of each simulations from Krishnan et al. (2014)
Esempio n. 25
0
"""
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)
                    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 PetIBM simulations
# with displaced markers.
# The force coefficients are averaged between 32 and 64 time-units.
cd_displaced, cl_displaced = [], []
for re in ['Re1000', 'Re2000']:
    for aoa in ['AoA25', 'AoA30', 'AoA35', 'AoA40']:
        simulation_directory = dirs['petibm011_forceCoefficientsVsAoA'][re][
            aoa]
        simulation = PetIBMSimulation(directory=simulation_directory)
        simulation.read_forces()
        simulation.get_mean_forces(limits=[32.0, 64.0])
        cd_displaced.append(2.0 * simulation.forces[0].mean['value'])
        cl_displaced.append(2.0 * simulation.forces[1].mean['value'])

# Computes the mean coefficients from the PetIBM simulations
# with non-displaced (original) markers.
# The force coefficients are averaged between 32 and 64 time-units.
simulation_directory = dirs['petibm011_forceCoefficientsVsAoA']['Re2000'][
    'AoA35original']
simulation = PetIBMSimulation(directory=simulation_directory)
simulation.read_forces()
simulation.get_mean_forces(limits=[32.0, 64.0])
cd_original = 2.0 * simulation.forces[0].mean['value']
cl_original = 2.0 * simulation.forces[1].mean['value']
Esempio n. 27
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)
Esempio n. 28
0
# file: plotForceCoefficientsCompare.py
# author: Olivier Mesnard ([email protected])
# description: Plots the instantaneous force coefficients
#              and compare to other results.
# Run this script from the simulation directory.

from snake.simulation import Simulation
from snake.petibm.simulation import PetIBMSimulation

simulation = PetIBMSimulation(description='PetIBM (present)')
simulation.read_forces()
simulation.get_mean_forces(limits=[32.0, 64.0])
simulation.get_strouhal(limits=[32.0, 64.0], order=200)

other = Simulation(description='', directory='', software='')
other.read_forces()
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,
                       coefficient=2.0,
                       display_extrema=True,
                       order=200,
                       limits=(0.0, 80.0, 0.0, 3.0),
                       other_simulations=other,
                       other_coefficients=2.0,
                       save_name='forceCoefficientsCompare')

dataframe = simulation.create_dataframe_forces(display_strouhal=True,
                                               display_coefficients=True,
                                               coefficient=2.0)
                    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 PetIBM simulations 
# with displaced markers.
# The force coefficients are averaged between 32 and 64 time-units.
cd_displaced, cl_displaced = [], []
for re in ['Re1000', 'Re2000']:
  for aoa in ['AoA25', 'AoA30', 'AoA35', 'AoA40']:
    simulation_directory = dirs['petibm011_forceCoefficientsVsAoA'][re][aoa]
    simulation = PetIBMSimulation(directory=simulation_directory)
    simulation.read_forces()
    simulation.get_mean_forces(limits=[32.0, 64.0])
    cd_displaced.append(2.0*simulation.forces[0].mean['value'])
    cl_displaced.append(2.0*simulation.forces[1].mean['value'])

# Computes the mean coefficients from the PetIBM simulations 
# with non-displaced (original) markers.
# The force coefficients are averaged between 32 and 64 time-units.
simulation_directory = dirs['petibm011_forceCoefficientsVsAoA']['Re2000']['AoA35original']
simulation = PetIBMSimulation(directory=simulation_directory)
simulation.read_forces()
simulation.get_mean_forces(limits=[32.0, 64.0])
cd_original = 2.0*simulation.forces[0].mean['value']
cl_original = 2.0*simulation.forces[1].mean['value']
Esempio n. 30
0
# 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,
    )