def locate_shock_front(stageName, nbi, nbj):
    """
    Reads all flow blocks and returns the coordinates 
    of the shock front, searching along the stagnation line.
    """
    blockData = []
    for ib in range(nbi):
        blockData.append([])
        for jb in range(nbj):
            blkindx = ib * nbj + jb
            fileName = 'flow/t0001/%s.flow.b%04d.t0001.gz' \
                % (stageName, blkindx)
            fp = gzip.open(fileName, "r")
            blk = StructuredGridFlow()
            blk.read(fp)
            blockData[ib].append(blk)
            fp.close()
    jb = 0
    nj = blockData[0][jb].nj
    j = 0
    x = []
    y = []
    p = []
    for ib in range(nbi):
        ni = blockData[ib][jb].ni
        k = 0  # 2D only
        for i in range(ni):
            x.append(blockData[ib][jb].data['pos.x'][i, j, k])
            y.append(blockData[ib][jb].data['pos.y'][i, j, k])
            p.append(blockData[ib][jb].data['p'][i, j, k])
    return locate_shock_along_strip(x, y, p)
示例#2
0
#! /usr/bin/env python
# \file locate_bow_shock.py
# PJ, 08-Nov-2009, updated for Eilmer3

import sys, os, gzip
sys.path.append(os.path.expandvars("$HOME/e3bin"))
from e3_flow import StructuredGridFlow

print "Locate a bow shock by its pressure jump."

# Block 0 contains the stagnation point.
fileName = 'flow/t9999/cyl.flow.b0000.t9999.gz'
fp = gzip.open(fileName, "r")
blockData = StructuredGridFlow()
blockData.read(fp)
fp.close()

# Since this is a 3D simulation, the shock is not expected
# to be flat in the k-direction (along the cylinder axis).
# Sample the shock layer in a few places near the stagnation line.
x_sum = 0.0
n_sample = 6
for k in range(n_sample):
    j = 0
    p_trigger = 10000.0  # Pa
    x_old = blockData.data['pos.x'][0, j, k]
    p_old = blockData.data['p'][0, j, k]
    for i in range(blockData.ni):
        x = blockData.data['pos.x'][i, j, k]
        p = blockData.data['p'][i, j, k]
        if p > p_trigger: break
示例#3
0
文件: a_vt.py 项目: zwghit/CFCFD-NG
print "\n\ncaculate the average temperature and velocity."

fileName = 'grid/t0000/tc_flow_nitrogen.grid.b0000.t0000.gz'
print "Read grid file:", fileName
fin = GzipFile(fileName, "rb")
grd = StructuredGrid()
grd.read(f=fin)
fin.close()
print "Read grid: ni=", grd.ni, "nj=", grd.nj, "nk=", grd.nk

fileName = 'flow/t0036/tc_flow_nitrogen.flow.b0000.t0036.gz'
print "Read solution file:", fileName
fin = GzipFile(fileName, "rb")
soln = StructuredGridFlow()
soln.read(fin)
fin.close()
ni = soln.ni
nj = soln.nj
nk = soln.nk
print "Read solution: ni=", ni, "nj=", nj, "nk=", nk

# Caculate the averaged velocity and temperature along the radial gap
# South surface of block 0
fileName = "average.txt"
fout = open(fileName, "w")
j = 0
v_tan = 0.0
vel_tan = 0.0
T_tan = 0.0
Tem_tan = 0.0
示例#4
0
nib = 3
njb = 2
bindx_list = [[0, 1], [2, 3], [4, 5]]
flow = []
grd = []
for ib in range(nib):
    flow.append([])
    grd.append([])
    for jb in range(njb):
        bindx = '%04d' % bindx_list[ib][jb]
        print "bindx=", bindx
        fileName = 'flow/t' + tindx + '/' + jobName + '.flow.b' + bindx + '.t' + tindx + '.gz'
        fp = gzip.open(fileName, "r")
        f = StructuredGridFlow()
        flow[-1].append(f)
        f.read(fp)
        fp.close()
        print "flow data: ni,nj,nk=", f.ni, f.nj, f.nk
        # The grid is always at tindx 0.
        fileName = 'grid/t0000/' + jobName + '.grid.b' + bindx + '.t0000.gz'
        fp = gzip.open(fileName, "r")
        g = StructuredGrid()
        grd[-1].append(g)
        g.read(fp)
        fp.close()
        print "grid data: ni,nj,nk=", g.ni, g.nj, g.nk


# Work down the duct (i-direction) and compute fraction of area where gas is not
# purely one species or the other.
def process_one_slice(flow, grd, i):