# 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)
Beispiel #2
0
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)

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,
        2.0 * simulation.forces[0].values,
        label='$C_d$ ($\Delta t= 2 \cdot 10^{-4}$)',
        color='#377eb8',
        linestyle='-',
        linewidth=2,
    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,
                                               coefficient=2.0)
dataframe2 = other.create_dataframe_forces(display_strouhal=True,
                                           display_coefficients=True,
                                           coefficient=2.0)
dataframe = dataframe.append(dataframe2)
print(dataframe)

pyplot.style.use(
    os.path.join(os.environ['SNAKE'], 'snake', 'styles',
                 'snakeReproducibility.mplstyle'))
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,
                '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)

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, 2.0*simulation.forces[0].values,
        label='$C_d$ ($rtol=10^{-8}$)',
        color='#377eb8',
        linestyle='-',
        linewidth=2,
        zorder=10)
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,
                                           display_coefficients=True,
                                           coefficient=2.0)
dataframe = dataframe.append(dataframe2)
print(dataframe)
Beispiel #6
0
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,
                       save_name='liftCoefficientCompareKrishnanEtAl2014')
dataframe = simulation.create_dataframe_forces(indices=[1],
                                               display_strouhal=True,
                                               display_coefficients=True,
                                               coefficient=2.0)
dataframe2 = krishnan.create_dataframe_forces(indices=[1],
                                              display_strouhal=True,
                                              display_coefficients=True,
                                              coefficient=2.0)
dataframe = dataframe.append(dataframe2)
print(dataframe)