本文整理汇总了Python中snake.cuibm.simulation.CuIBMSimulation.read_grid方法的典型用法代码示例。如果您正苦于以下问题:Python CuIBMSimulation.read_grid方法的具体用法?Python CuIBMSimulation.read_grid怎么用?Python CuIBMSimulation.read_grid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类snake.cuibm.simulation.CuIBMSimulation
的用法示例。
在下文中一共展示了CuIBMSimulation.read_grid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CuIBMSimulation
# 需要导入模块: from snake.cuibm.simulation import CuIBMSimulation [as 别名]
# 或者: from snake.cuibm.simulation.CuIBMSimulation import read_grid [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)
示例2: CuIBMSimulation
# 需要导入模块: from snake.cuibm.simulation import CuIBMSimulation [as 别名]
# 或者: from snake.cuibm.simulation.CuIBMSimulation import read_grid [as 别名]
warnings.warn('The figures were originally created with snake-0.1.2, '+
'you are using snake-{}'.format(snake.__version__))
atol_min, atol_max = 5, 16
time_step = 1500
main_directory = os.path.dirname(__file__)
reference_directory = os.path.join(main_directory,
'atol16')
reference = CuIBMSimulation(directory=reference_directory,
description='atol=1.0E-16')
reference.read_forces()
fx_reference = reference.forces[0].values[-1]
fy_reference = reference.forces[1].values[-1]
reference.read_grid()
p_reference = reference.read_pressure(time_step)
qx_reference, qy_reference = reference.read_fluxes(time_step)
fx_errors, fy_errors = [], []
p_errors = []
qx_errors, qy_errors = [], []
for atol in range(atol_min, atol_max):
directory = os.path.join(main_directory,
'atol{}'.format(atol))
simu = CuIBMSimulation(directory=directory,
description='1.0E-{}'.format(atol))
simu.read_forces()
fx = simu.forces[0].values[-1]
fy = simu.forces[1].values[-1]
示例3: CuIBMSimulation
# 需要导入模块: from snake.cuibm.simulation import CuIBMSimulation [as 别名]
# 或者: from snake.cuibm.simulation.CuIBMSimulation import read_grid [as 别名]
'uquad': {'directory': os.path.join('uquad_T00.25_20_0.00050',
'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],
示例4: CuIBMSimulation
# 需要导入模块: from snake.cuibm.simulation import CuIBMSimulation [as 别名]
# 或者: from snake.cuibm.simulation.CuIBMSimulation import read_grid [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):
示例5: zip
# 需要导入模块: from snake.cuibm.simulation import CuIBMSimulation [as 别名]
# 或者: from snake.cuibm.simulation.CuIBMSimulation import read_grid [as 别名]
final_time_steps = [2000, 1500, 1250]
refinement_ratio = 2.0
fx, fy = [], []
p = []
qx, qy = [], []
main_directory = os.path.dirname(__file__)
for time_increment, final_time_step in zip(time_increments, final_time_steps):
directory = os.path.join(main_directory, time_increment.replace("=", ""))
simu = CuIBMSimulation(directory=directory, description=time_increment)
simu.read_forces()
fx.append(simu.forces[0].values[-1])
fy.append(simu.forces[1].values[-1])
simu.read_grid()
p_simu = simu.read_pressure(final_time_step)
p.append(p_simu.values)
qx_simu, qy_simu = simu.read_fluxes(final_time_step)
qx.append(qx_simu.values)
qy.append(qy_simu.values)
file_path = os.path.join(os.path.dirname(__file__), "temporalConvergence.txt")
with open(file_path, "w") as outfile:
outfile.write("\n* Drag force:\n")
outfile.write("Value and relative difference with the reference value (smallest dt)\n")
outfile.write("\t{}: {}\n".format(time_increments[0], fx[0]))
for i in (1, 2):
outfile.write("\t{}: {} ({}%)\n".format(time_increments[i], fx[i], (fx[i] - fx[0]) / fx[0] * 100.0))
outfile.write(