示例#1
0
"""
Plots the vorticity field of a 2D cuIBM simulation.
"""

import os
from snake.cuibm.simulation import CuIBMSimulation
from snake.body import Body

simulation = CuIBMSimulation()
simulation.read_grid()

for time_step in simulation.get_time_steps():
    all_bodies = Body(
        file_path=os.path.join('{:0>7}'.format(time_step), 'bodies'))
    n_total = all_bodies.x.size
    bodies = [Body(), Body()]
    bodies[0].x = all_bodies.x[:n_total // 2]
    bodies[0].y = all_bodies.y[:n_total // 2]
    bodies[1].x = all_bodies.x[n_total // 2:]
    bodies[1].y = all_bodies.y[n_total // 2:]
    simulation.read_fields('vorticity', time_step)
    simulation.plot_contour('vorticity',
                            field_range=(-2.0, 2.0, 40),
                            filled_contour=True,
                            bodies=bodies,
                            view=(-3.0, -5.0, 15.0, 5.0),
                            style='seaborn-dark',
                            cmap='viridis',
                            width=8.0)
import os

from matplotlib import pyplot

from snake.cuibm.simulation import CuIBMSimulation
from snake.solutions.ghiaEtAl1982 import GhiaEtAl1982


directory = os.getcwd()

# Reads the velocity fields from files.
simulation = CuIBMSimulation(directory=directory,
                             description='cuIBM')
simulation.read_grid(file_path=os.path.join(directory, 'grid'))
time_step = simulation.get_time_steps()[-1]
simulation.read_fields(['x-velocity', 'y-velocity'], time_step)
# Grabs the mid-cavity velocity values.
y, u = simulation.fields['x-velocity'].get_vertical_gridline_values(0.5)
x, v = simulation.fields['y-velocity'].get_horizontal_gridline_values(0.5)

# Gets the centerline velocities at Re=100 reported in Ghia et al. (1982).
file_path = os.path.join(os.environ['CUIBM_DIR'],
                         'data',
                         'ghia_et_al_1982_lid_driven_cavity.dat')
ghia = GhiaEtAl1982(file_path=file_path, Re=100)

# Plots the instantaneous drag coefficients.
images_directory = os.path.join(directory, 'images')
if not os.path.isdir(images_directory):
  os.makedirs(images_directory)
示例#3
0
"""
Computes, plots, and saves the 2D vorticity field from a cuIBM simulation at
saved time-steps.
"""

from snake.cuibm.simulation import CuIBMSimulation


simulation = CuIBMSimulation()
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),
                          view=(-1.0, -5.0, 15.0, 5.0),
                          cmap='viridis',
                          style='seaborn-dark',
                          width=8.0)
示例#4
0
  Journal of computational physics, 48(3), 387-411.
"""

import os

from matplotlib import pyplot

from snake.cuibm.simulation import CuIBMSimulation
from snake.solutions.ghiaEtAl1982 import GhiaEtAl1982

directory = os.getcwd()

# Reads the velocity fields from files.
simulation = CuIBMSimulation(directory=directory, description='cuIBM')
simulation.read_grid(file_path=os.path.join(directory, 'grid'))
time_step = simulation.get_time_steps()[-1]
simulation.read_fields(['x-velocity', 'y-velocity'], time_step)
# Grabs the mid-cavity velocity values.
y, u = simulation.fields['x-velocity'].get_vertical_gridline_values(0.5)
x, v = simulation.fields['y-velocity'].get_horizontal_gridline_values(0.5)

# Gets the centerline velocities at Re=1000 reported in Ghia et al. (1982).
file_path = os.path.join(os.environ['CUIBM_DIR'], 'data',
                         'ghia_et_al_1982_lid_driven_cavity.dat')
ghia = GhiaEtAl1982(file_path=file_path, Re=1000)

# Plots the instantaneous drag coefficients.
images_directory = os.path.join(directory, 'images')
if not os.path.isdir(images_directory):
    os.makedirs(images_directory)
pyplot.style.use('seaborn-dark')