コード例 #1
0
 def CBLFun(U, y):
     u, F, h, G, g = U.T
     T = 1.0 + 0.5 * h * (gamma - 1.0) * MaInf**2
     assert T > 0
     mu = ConstPropMix.GetViscosity(T * TInf, config) / muInf
     return [
         F / mu, -0.5 * g * F / mu, Pr * G / mu,
         -0.5 * Pr * G * g / mu - 2 * F**2 / mu, u / T
     ]
コード例 #2
0
ファイル: MakeInput.py プロジェクト: xyuan/HTR-solver
def GetProfile(Cf):
    yp = np.linspace(0, 2000, Np)

    TauW = Cf * (rhoInf * UInf**2) * 0.5
    uTau = np.sqrt(TauW / rhoW)
    deltaNu = muW / (uTau * rhoW)

    UeqInf = VanDriestUeq(UInf)
    delta99p = delta99In / deltaNu

    # Von Karman constant
    k = 0.41
    c = 5.2

    def profFunc(y):
        # Parameters for Reichardt's inner layer and Finley's wall law
        c1 = -1. / k * np.log(k) + c
        b = 0.33
        eta = 11.0
        return 1.0 / k * np.log(1.0 + k * y) + c1 * (1.0 - np.exp(-y / eta) -
                                                     y / eta * np.exp(-b * y))

    # Coles wake parameter
    cp = 0.5 * k * (UeqInf / uTau - profFunc(delta99p))

    Ueq = np.zeros(Np)
    for i in range(Np):
        yovD = yp[i] / delta99p
        if (yovD < 1.0):
            Ueq[i] = uTau * (profFunc(yp[i]) + 2.0 * cp / k *
                             (np.sin(0.5 * np.pi * yovD))**2)
        else:
            Ueq[i] = UeqInf

    U = FavreU(Ueq)
    T = Tw * (1.0 + (Taw / Tw - 1.0) * (U / UInf) - r * 0.5 *
              (gamma - 1.0) * MaInf**2 * TInf / Tw * (U / UInf)**2)
    rho = ConstPropMix.GetDensity(T, PInf, config)

    assert abs(U[-1] - UInf) / UInf < 1e-3

    return yp * deltaNu, U, T, rho
コード例 #3
0
ファイル: postProc.py プロジェクト: zhjzhang/HTR-solver
def process(frac):
    RhoInf = ConstPropMix.GetDensity(TInf, P, data)
    muInf = ConstPropMix.GetViscosity(TInf, data)
    nuInf = muInf / RhoInf

    dt = data["Integrator"]["fixedDeltaTime"]
    nstep = int(data["Integrator"]["maxIter"])
    time = dt * nstep

    filename = os.path.join(
        dir_name, 'sample0/fluid_iter' + str(nstep).zfill(10) + '/0,0,0-' +
        str(xNum + 1) + ',' + str(yNum + 1) + ',0.hdf')
    exists = os.path.isfile(filename)

    if (not exists):
        # merge files from different tiles
        merge_command = 'python {} {}'.format(
            os.path.expandvars('$HTR_DIR/scripts/merge.py'),
            os.path.join(
                dir_name,
                'sample0/fluid_iter' + str(nstep).zfill(10) + '/*.hdf'))
        mv_command = 'mv {} {}'.format(
            './0,0,0-' + str(xNum + 1) + ',' + str(yNum + 1) + ',0.hdf',
            os.path.join(dir_name,
                         'sample0/fluid_iter' + str(nstep).zfill(10) + '/'))

        try:
            subprocess.call(merge_command, shell=True)
        except OSError:
            print("Failed command: {}".format(merge_command))
            sys.exit()

        try:
            subprocess.call(mv_command, shell=True)
        except OSError:
            print("Failed command: {}".format(mv_command))
            sys.exit()

##############################################################################
#                        Read Prometeo Output Data                           #
##############################################################################

    f = h5py.File(filename, 'r')

    # Get the data
    centerCoordinates = f['centerCoordinates']
    cellWidth = f['cellWidth']
    pressure = f['pressure']
    temperature = f['temperature']
    density = f['rho']
    velocity = f['velocity']

    # Get simulation data along a line (ignore ghost cells)
    x_slice_idx = int(frac * xNum)

    x0 = centerCoordinates[0, 0, 0][0] - xOrigin
    x = centerCoordinates[0, 0, x_slice_idx][0] - xOrigin
    y = centerCoordinates[0, :, x_slice_idx][:, 1] - yOrigin
    u = velocity[0, :, x_slice_idx][:, 0]
    v = velocity[0, :, x_slice_idx][:, 1]
    T = temperature[0, :, x_slice_idx]
    p = pressure[0, :, x_slice_idx]
    rho = density[0, :, x_slice_idx]

    x += Re * nuInf / U - x0
    myRe = U * x / nuInf
    print(myRe)

    eta = np.zeros(y.size)
    for i in range(y.size):
        if (i > 0):
            rhoMid = 0.5 * (rho[i] + rho[i - 1])
            eta[i] = eta[i - 1] + U / (muInf * np.sqrt(2 * myRe)) * rhoMid * (
                y[i] - y[i - 1])

    return eta, u / U, v * np.sqrt(2.0 * myRe) / U, T / TInf, p
コード例 #4
0
assert config["BC"]["yBCRight"]["TemperatureProfile"]["type"] == "Constant"
assert config["BC"]["yBCLeft"]["TemperatureProfile"]["temperature"] == config[
    "BC"]["yBCRight"]["TemperatureProfile"]["temperature"]
Tw = config["BC"]["yBCLeft"]["TemperatureProfile"]["temperature"]

# Read properties
Pb = config["Flow"]["initParams"][0]
Tb = config["Flow"]["initParams"][1]
gamma = config["Flow"]["gamma"]
R = config["Flow"]["gasConstant"]
assert config["Flow"]["turbForcing"]["type"] == "CHANNEL"
assert config["Flow"]["initCase"] == "ChannelFlow"
assert Tw == Tb

cW = np.sqrt(gamma * R * Tw)
muW = ConstPropMix.GetViscosity(Tw, config)

uB = cW * MaB
rhoB = Pb / (R * Tb)

h = ReB * muW / (rhoB * uB)
print("h = ", h)

rhoW = rhoB
uTau = ReTau * muW / (rhoW * h)
deltaNu = muW / (uTau * rhoW)
TauW = uTau**2 * rhoB

yPlusTrg = 0.8

コード例 #5
0
ReIn = config["Case"]["ReInlet"]
MaInf = config["Case"]["MaInf"]
TInf = config["Case"]["TInf"]
PInf = config["Case"]["PInf"]
TwOvT = config["Case"]["TwOvTInf"]
xTurb = config["Case"]["xTurb"]
yPlus = config["Case"]["yPlus"]

R = config["Flow"]["gasConstant"]
gamma = config["Flow"]["gamma"]
Pr = config["Flow"]["prandtl"]

# Free-stream mixture properties
cInf = np.sqrt(gamma * R * TInf)
muInf = ConstPropMix.GetViscosity(TInf, config)

# Free-stream conditions
UInf = cInf * MaInf
rhoInf = ConstPropMix.GetDensity(TInf, PInf, config)

# Inlet displacement thickness
deltaStarIn = muInf * ReIn / (UInf * rhoInf)

# Wall properties
Tw = TInf * TwOvT
muW = ConstPropMix.GetViscosity(Tw, config)
rhoW = ConstPropMix.GetDensity(Tw, PInf, config)

r = Pr**(1.0 / 3.0)
Taw = TInf * (1.0 + r * 0.5 * (gamma - 1.0) * MaInf**2)
コード例 #6
0
ファイル: MakeInput.py プロジェクト: xyuan/HTR-solver
restartDir = config["Flow"]["initCase"]["restartDir"]

config["BC"]["xBCLeft"]["VelocityProfile"]["FileDir"] = restartDir
config["BC"]["xBCLeft"]["TemperatureProfile"]["FileDir"] = restartDir
TInf = 300.0
Tw = 300.0
P = config["BC"]["xBCLeft"]["P"]
UInf = 2083.67
Rex0 = 100000

config["Integrator"]["vorticityScale"] = UInf / 0.0528088569936

aInf = np.sqrt(gamma * R * TInf)
MaInf = UInf / aInf

RhoInf = ConstPropMix.GetDensity(TInf, P, config)
muInf = ConstPropMix.GetViscosity(TInf, config)
nuInf = muInf / RhoInf

##############################################################################
#                              Generate Grid                                 #
##############################################################################

xGrid, dx = gridGen.GetGrid(config["Grid"]["origin"][0],
                            config["Grid"]["xWidth"], config["Grid"]["xNum"],
                            config["Grid"]["xType"],
                            config["Grid"]["xStretching"], False)

yGrid, dy = gridGen.GetGrid(config["Grid"]["origin"][1],
                            config["Grid"]["yWidth"],
                            config["Grid"]["yNum"],
コード例 #7
0
ファイル: MakeInput.py プロジェクト: zhjzhang/HTR-solver
def writeTile(xt, yt, zt):
    lo_bound = [(xt) * NxTile + halo[0], (yt) * NyTile + halo[1],
                (zt) * NzTile + halo[2]]
    hi_bound = [(xt + 1) * NxTile - 1 + halo[0],
                (yt + 1) * NyTile - 1 + halo[1],
                (zt + 1) * NzTile - 1 + halo[2]]
    if (xt == 0): lo_bound[0] -= halo[0]
    if (yt == 0): lo_bound[1] -= halo[1]
    if (zt == 0): lo_bound[2] -= halo[2]
    if (xt == Ntiles[0] - 1): hi_bound[0] += halo[0]
    if (yt == Ntiles[1] - 1): hi_bound[1] += halo[1]
    if (zt == Ntiles[2] - 1): hi_bound[2] += halo[2]
    filename = ('%s,%s,%s-%s,%s,%s.hdf' %
                (lo_bound[0], lo_bound[1], lo_bound[2], hi_bound[0],
                 hi_bound[1], hi_bound[2]))
    print("Working on: ", filename)

    shape = [
        hi_bound[2] - lo_bound[2] + 1, hi_bound[1] - lo_bound[1] + 1,
        hi_bound[0] - lo_bound[0] + 1
    ]

    centerCoordinates = np.ndarray(shape, dtype=np.dtype('(3,)f8'))
    cellWidth = np.ndarray(shape, dtype=np.dtype('(3,)f8'))
    rho = np.ndarray(shape)
    pressure = np.ndarray(shape)
    temperature = np.ndarray(shape)
    MolarFracs = np.ndarray(shape, dtype=np.dtype('(1,)f8'))
    velocity = np.ndarray(shape, dtype=np.dtype('(3,)f8'))
    dudtBoundary = np.ndarray(shape, dtype=np.dtype('(3,)f8'))
    dTdtBoundary = np.ndarray(shape)
    pressure[:] = PInf
    dudtBoundary[:] = [0.0, 0.0, 0.0]
    dTdtBoundary[:] = 0.0
    for (k, kc) in enumerate(centerCoordinates):
        for (j, jc) in enumerate(kc):
            for (i, ic) in enumerate(jc):
                Re = rhoInf * UInf * xGrid[i + lo_bound[0]] / muInf
                yB = etaB * xGrid[i + lo_bound[0]] / np.sqrt(Re)
                vB1 = vB / np.sqrt(Re)

                u = np.interp(yGrid[j + lo_bound[1]], yB, uB)
                v = np.interp(yGrid[j + lo_bound[1]], yB, vB1)
                T = np.interp(yGrid[j + lo_bound[1]], yB, TB)

                centerCoordinates[k, j, i] = [
                    xGrid[i + lo_bound[0]], yGrid[j + lo_bound[1]],
                    zGrid[k + lo_bound[2]]
                ]
                cellWidth[k, j, i] = [
                    dx[i + lo_bound[0]], dy[j + lo_bound[1]],
                    dz[k + lo_bound[2]]
                ]
                temperature[k, j, i] = T
                rho[k, j, i] = ConstPropMix.GetDensity(T, PInf, config)
                MolarFracs[k, j, i] = [
                    1.0,
                ]
                velocity[k, j, i] = [u, v, 0.0]

    with h5py.File(os.path.join(restartDir, filename), 'w') as fout:
        fout.attrs.create("SpeciesNames", ["MIX".encode()], dtype="S20")
        fout.attrs.create("timeStep", 0)
        fout.attrs.create("simTime", 0.0)
        fout.attrs.create("channelForcing", 0.0)

        fout.create_dataset("centerCoordinates",
                            shape=shape,
                            dtype=np.dtype("(3,)f8"))
        fout.create_dataset("cellWidth", shape=shape, dtype=np.dtype("(3,)f8"))
        fout.create_dataset("rho", shape=shape, dtype=np.dtype("f8"))
        fout.create_dataset("pressure", shape=shape, dtype=np.dtype("f8"))
        fout.create_dataset("temperature", shape=shape, dtype=np.dtype("f8"))
        fout.create_dataset("MolarFracs",
                            shape=shape,
                            dtype=np.dtype("(1,)f8"))
        fout.create_dataset("velocity", shape=shape, dtype=np.dtype("(3,)f8"))
        fout.create_dataset("dudtBoundary",
                            shape=shape,
                            dtype=np.dtype("(3,)f8"))
        fout.create_dataset("dTdtBoundary", shape=shape, dtype=np.dtype("f8"))
        fout.create_dataset("MolarFracs_profile",
                            shape=shape,
                            dtype=np.dtype("(1,)f8"))
        fout.create_dataset("velocity_profile",
                            shape=shape,
                            dtype=np.dtype("(3,)f8"))
        fout.create_dataset("temperature_profile",
                            shape=shape,
                            dtype=np.dtype("f8"))

        fout["centerCoordinates"][:] = centerCoordinates
        fout["cellWidth"][:] = cellWidth
        fout["rho"][:] = rho
        fout["pressure"][:] = pressure
        fout["temperature"][:] = temperature
        fout["MolarFracs"][:] = MolarFracs
        fout["velocity"][:] = velocity
        fout["dudtBoundary"][:] = dudtBoundary
        fout["dTdtBoundary"][:] = dTdtBoundary
        fout["MolarFracs_profile"][:] = MolarFracs
        fout["velocity_profile"][:] = velocity
        fout["temperature_profile"][:] = temperature
コード例 #8
0
yStretching  = data["Grid"]["yStretching"]

gamma = data["Flow"]["mixture"]["gamma"]
R     = data["Flow"]["mixture"]["gasConstant"]
Pr    = data["Flow"]["mixture"]["prandtl"]

TInf = data["BC"]["xBCLeft"]["TemperatureProfile"]["temperature"]
Tw   = data["BC"]["xBCLeft"]["TemperatureProfile"]["temperature"]
P    = data["BC"]["xBCLeft"]["P"]
U    = data["BC"]["xBCLeft"]["VelocityProfile"]["velocity"]
Re   = data["BC"]["xBCLeft"]["VelocityProfile"]["Reynolds"]
 
aInf = np.sqrt(gamma*R*TInf)
MaInf = U/aInf

RhoInf = ConstPropMix.GetDensity(TInf, P, data)
muInf = ConstPropMix.GetViscosity(TInf, data)
nuInf = muInf/RhoInf

##############################################################################
#                           Compute Blasius Solution                         #
##############################################################################
def GetCBL():
   def CBLFun(U, y):
      u, F, h, G, g = U.T
      T = 1.0 + 0.5*h*(gamma - 1.0)*MaInf**2
      mu = T**0.7
      return [ F/mu,
               -0.5*g*F/mu,
               Pr*G/mu,
               -0.5*Pr*G*g/mu - 2*F**2/mu,