当前位置: 首页>>代码示例>>Python>>正文


Python CuIBMSimulation.read_fields方法代码示例

本文整理汇总了Python中snake.cuibm.simulation.CuIBMSimulation.read_fields方法的典型用法代码示例。如果您正苦于以下问题:Python CuIBMSimulation.read_fields方法的具体用法?Python CuIBMSimulation.read_fields怎么用?Python CuIBMSimulation.read_fields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在snake.cuibm.simulation.CuIBMSimulation的用法示例。


在下文中一共展示了CuIBMSimulation.read_fields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CuIBMSimulation

# 需要导入模块: from snake.cuibm.simulation import CuIBMSimulation [as 别名]
# 或者: from snake.cuibm.simulation.CuIBMSimulation import read_fields [as 别名]
"""
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)
开发者ID:barbagroup,项目名称:cuIBM,代码行数:21,代码来源:plotVorticity.py

示例2: Mesnard

# 需要导入模块: from snake.cuibm.simulation import CuIBMSimulation [as 别名]
# 或者: from snake.cuibm.simulation.CuIBMSimulation import read_fields [as 别名]
# 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.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], filled_contour=True, view=[-0.75, -1.0, 1.50, 1.0], width=8.0
    )
开发者ID:mesnardo,项目名称:snake,代码行数:19,代码来源:plotVorticitySnake.py

示例3: CuIBMSimulation

# 需要导入模块: from snake.cuibm.simulation import CuIBMSimulation [as 别名]
# 或者: from snake.cuibm.simulation.CuIBMSimulation import read_fields [as 别名]
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)
pyplot.style.use('seaborn-dark')
开发者ID:barbagroup,项目名称:cuIBM,代码行数:33,代码来源:plotCenterlineVelocities.py

示例4: CuIBMSimulation

# 需要导入模块: from snake.cuibm.simulation import CuIBMSimulation [as 别名]
# 或者: from snake.cuibm.simulation.CuIBMSimulation import read_fields [as 别名]
                                            'linear'),
                  'folders': ['20', '60', '180', '540']},
        'vquad': {'directory': os.path.join('vquad_T00.25_20_0.00050',
                                            'linear'),
                  'folders': ['20', '60', '180', '540']}}

time_step = 500
field_names = ['x-velocity', 'y-velocity']

for key, series in data.items():
  series['cases'] = []
  for folder in series['folders']:
    case = CuIBMSimulation(directory=os.path.join(series['directory'], folder),
                           description=folder)
    case.read_grid()
    case.read_fields(field_names, time_step)
    nx, ny = case.grid[0].size - 1, case.grid[1].size - 1
    masks = read_mask(os.path.join(case.directory, 'mask.txt'), nx, ny)
    for i, name in enumerate(field_names):
      case.fields[name].values = numpy.multiply(case.fields[name].values,
                                                masks[i])

    series['cases'].append(case)
  series['first'] = get_observed_orders(series['cases'][:-1],
                                        field_names,
                                        series['cases'][0],
                                        save_name=None)
  series['last'] = get_observed_orders(series['cases'][1:],
                                       field_names,
                                       series['cases'][0],
                                       save_name=None)
开发者ID:barbagroup,项目名称:cuIBM,代码行数:33,代码来源:convergence.py


注:本文中的snake.cuibm.simulation.CuIBMSimulation.read_fields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。