def ex_S4(method, nGG=24): import numpy as np from cyparallel_planes import parallel_planes #from parallel_planes import parallel_planes from pyrad import pyrad_planck_mean as rad_planck_mean from pyrad import pyrad_wsgg as rad_wsgg from pyrad import pyrad_rcslw as rad_rcslw ################################################################################ #--------------------- parameters P = 101325.0 L = 0.3 ntheta = 101 nx = 1001 Twall = 500.0 Tmax = 2500.0 H = 0.1 nGGa = nGG + 1 xco2 = 0.0 xco = 0.0 xh2o = 0.1 xch4 = 0.0 fvs = 0.0 #--------------------- xCO2 = np.full(nx, xco2, dtype=np.float64) xCO = np.full(nx, xco, dtype=np.float64) xH2O = np.full(nx, xh2o, dtype=np.float64) xCH4 = np.full(nx, xch4, dtype=np.float64) fvsoot = np.full(nx, fvs, dtype=np.float64) x = np.zeros(nx) T = np.full(nx, Twall, dtype=np.float64) dx = L / (nx - 1) x[0] = 0.0 Tavg = T[0] for i in range(1, nx): x[i] = x[i - 1] + dx if x[i] <= L / 2 - H / 2 or x[i] >= L / 2 + H / 2: T[i] = Twall elif x[i] < L / 2: T[i] = Twall + (Tmax - Twall) / (L / 2 - (L / 2 - H / 2)) * (x[i] - (L / 2 - H / 2)) else: T[i] = Tmax + (Twall - Tmax) / ( (L / 2 + H / 2) - L / 2) * (x[i] - L / 2) Tavg += T[i] Tavg /= nx if method == 'rcslw': #rad = rad_rcslw(nGG, P, Tmax, xh2o, xco2, xco, fvs) # CHANGE: use T=Tmax or T=Tavg for plot rad = rad_rcslw(nGG, P, Tavg, xh2o, xco2, xco, fvs) # CHANGE: use T=Tmax or T=Tavg for plot elif method == 'wsgg': rad = rad_wsgg() elif method == 'planckmean': rad = rad_planck_mean() else: raise ValueError('unknown radiation method') #------------------- get q, Q x, xQ, q, Q = parallel_planes(rad, L, ntheta, P, T, xH2O, xCO2, xCO, xCH4, fvsoot) print("# x (m), Q (kW/m3)") for i in range(len(xQ)): print(f'{xQ[i]:.5f} {Q[i]/1000:.5f}') #print("# x (m), q (kW/m2)") #for i in range(len(x)): # print(f'{x[i]:.5f} {q[i]/1000:.5f}') #------------------------------------------------------------------------- print() return xQ, Q
def ex_S5(method, nGG=24, use_Tmax=False): import numpy as np from cyparallel_planes import parallel_planes #from parallel_planes import parallel_planes from pyrad import pyrad_planck_mean as rad_planck_mean from pyrad import pyrad_wsgg as rad_wsgg from pyrad import pyrad_rcslw as rad_rcslw ################################################################################ #--------------------- parameters P = 101325.0 L = 2.0 ntheta = 101 nx = 1001 T0 = 1500.0 TL = 500.0 nGGa = nGG + 1 TT = 1500 xco2 = 0.0 xco = 0.0 xh2o = 0.1 fvs = 0.0 #--------------------- xCO2 = np.full(nx, xco2, dtype=np.float64) xCO = np.full(nx, xco, dtype=np.float64) xH2O = np.full(nx, xh2o, dtype=np.float64) xCH4 = np.full(nx, 0.0, dtype=np.float64) fvsoot = np.full(nx, fvs, dtype=np.float64) x = np.zeros(nx) T = np.full(nx, T0, dtype=np.float64) dx = L / (nx - 1) x[0] = 0.0 Tavg = T[0] for i in range(1, nx): x[i] = x[i - 1] + dx T[i] = 1000.0 + 500 * np.cos(np.pi * x[i] / L) Tavg += T[i] Tavg /= nx if method == 'rcslw': rad = rad_rcslw(nGG, P, TT if use_Tmax else Tavg, xh2o, xco2, xco, fvs) # TT gives better results than Tavg elif method == 'wsgg': rad = rad_wsgg() elif method == 'planckmean': rad = rad_planck_mean() else: raise ValueError('unknown radiation method') #------------------- get q, Q x, xQ, q, Q = parallel_planes(rad, L, ntheta, P, T, xH2O, xCO2, xCO, xCH4, fvsoot) print("# x (m), Q (kW/m3)") for i in range(len(xQ)): print(f'{xQ[i]:.5f} {Q[i]/1000:.5f}') #print("# x (m), q (kW/m2)") #for i in range(len(x)): # print(f'{x[i]:.5f} {q[i]/1000:.5f}') #------------------------------------------------------------------------- print() return xQ, Q
#-------------------------------------------------------------------------------- #----------------- define parameters T = 2000.0 # K P = 101325.0 # atm xH2O = 0.8 # xH2O=0.2 is roughly stoich. CH4/air products xCO2 = 0.2 # xCO2=0.1 is roughly stoich. CH4/air products xCO = 0.0 xCH4 = 0.0 fvsoot = 0.0 #----------------- create radiation objects planckmean = rad_planck_mean() wsgg = rad_wsgg() rcslw = rad_rcslw(4, P, T, xH2O, xCO2, xCO, fvsoot) #----------------- compute absorption coefficients and weights kabs_pm, awts_pm = planckmean.get_k_a(T, P, xH2O, xCO2, xCO, xCH4, fvsoot) kabs_wsgg, awts_wsgg = wsgg.get_k_a(T, P, xH2O, xCO2, xCO, xCH4, fvsoot) kabs_rcslw, awts_rcslw = rcslw.get_k_a(T, P, xH2O, xCO2, xCO, xCH4, fvsoot) #----------------- output results print(f"---------------------------") print(f"T (K) = {T:.3f}") print(f"P (Pa) = {P:.3f}") print(f"xH2O = {xH2O:.3f}")
def ex_B3(method, nGG=4): import numpy as np from cyparallel_planes import parallel_planes #from parallel_planes import parallel_planes from pyrad import pyrad_planck_mean as rad_planck_mean from pyrad import pyrad_wsgg as rad_wsgg from pyrad import pyrad_rcslw as rad_rcslw ################################################################################ #--------------------- parameters nGGa = nGG + 1 P = 101325.0 L = 1.0 ntheta = 101 nx = 1001 Twall = 400.0 xco2 = 0.0 xco = 0.0 xh2o = 0.0 xch4 = 0.0 fvs = 0.0 #--------------------- xCO2 = np.full(nx, xco2, dtype=np.float64) xCO = np.full(nx, xco, dtype=np.float64) xH2O = np.full(nx, xh2o, dtype=np.float64) xCH4 = np.full(nx, xch4, dtype=np.float64) fvsoot = np.full(nx, fvs, dtype=np.float64) x = np.zeros(nx) T = np.full(nx, Twall, dtype=np.float64) x = np.linspace(0, L, nx) for i in range(nx): T[i] = 400.0 + 1400.0 * np.sin(np.pi * x[i] / L)**2 xH2O[i] = 1E-4 + (1.0 - 1E-4) * np.sin(np.pi * x[i] / L)**2 xCO2[i] = 1.0 - xH2O[i] xH2O_avg = np.average(xH2O) xCO2_avg = 1.0 - xH2O_avg T_avg = np.average(T) if method == 'rcslw': rad = rad_rcslw(nGG, P, T_avg, xH2O_avg, xCO2_avg, xco, fvs) elif method == 'wsgg': rad = rad_wsgg() elif method == 'planckmean': rad = rad_planck_mean() else: raise ValueError('unknown radiation method') #------------------- get q, Q x, xQ, q, Q = parallel_planes(rad, L, ntheta, P, T, xH2O, xCO2, xCO, xCH4, fvsoot) print("# x (m), Q (kW/m3)") for i in range(len(xQ)): print(f'{xQ[i]:.5f} {Q[i]/1000:.5f}') #print("# x (m), q (kW/m2)") #for i in range(len(x)): # print(f'{x[i]:.5f} {q[i]/1000:.5f}') #------------------------------------------------------------------------- print() return x, xQ, q, Q
def ex_S2(method, nGG=24): import numpy as np from cyparallel_planes import parallel_planes #from parallel_planes import parallel_planes from pyrad import pyrad_planck_mean as rad_planck_mean from pyrad import pyrad_wsgg as rad_wsgg from pyrad import pyrad_rcslw as rad_rcslw sigma = 5.670367E-8 # Stephan-Boltzmann constant ################################################################################ #--------------------- parameters TT = 1000.0 P = 101325.0 xco2_1 = 0.4 xco2_2 = 0.1 Lhot = 0.5 ntheta = 101 nxh = 1001 # for Lcold=0 changes below to keep dx roughly constant Lcold = np.array([0, 0.01, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 1.5, 2.0]) nGGa = nGG+1 xco = 0.0; xh2o=0.0; xch4=0.0; fvs = 0.0 #--------------------- print("# Lcold (m), q(L)/σT^4") qsigT4 = np.empty(len(Lcold)) for iLcold in range(len(Lcold)): L = Lcold[iLcold] + Lhot xco2_avg = (xco2_1*0.5+xco2_2*Lcold[iLcold])/L nx = int(nxh*L/Lhot) xCO2 = np.full(nx, xco2_1, dtype=np.float64) xCO = np.full(nx, xco, dtype=np.float64) xH2O = np.full(nx, xh2o, dtype=np.float64) xCH4 = np.full(nx, xch4, dtype=np.float64) fvsoot = np.full(nx, fvs, dtype=np.float64) x = np.zeros(nx) dx = L/(nx-1) T = np.full(nx, TT, dtype=np.float64) for i in range(1,nx): # mimic c++; pythonic gives different grid/T due to roundoff x[i] = x[i-1] + dx xCO2[i] = xco2_1 if x[i] <= Lhot else xco2_2 if method=='rcslw': rad = rad_rcslw(nGG, P, TT, xh2o, xco2_avg, xco, fvs) elif method=='wsgg': rad = rad_wsgg() elif method=='planckmean': rad = rad_planck_mean() else: raise ValueError('unknown radiation method') #--------------------- get q, Q x, xQ, q, Q = parallel_planes(rad, L, ntheta, P, T, xH2O, xCO2, xCO, xCH4, fvsoot, True) #------------------------------------------------------------------------- qsigT4[iLcold] = q[nx-1]/sigma/TT**4 print(f'{Lcold[iLcold]:10.3f} {qsigT4[iLcold]:15.5f}') print() return Lcold, qsigT4
def ex_S3(method, nGG=24): import numpy as np from cyparallel_planes import parallel_planes #from parallel_planes import parallel_planes from pyrad import pyrad_planck_mean as rad_planck_mean from pyrad import pyrad_wsgg as rad_wsgg from pyrad import pyrad_rcslw as rad_rcslw ################################################################################ #--------------------- parameters P = 101325.0 L = 1.0 ntheta = 101 nx = 1001 Twall = 800.0 nGGa = nGG + 1 xco2 = 0.0 xco = 0.0 xh2o = 0.12 xch4 = 0.0 fvs = 0.0 #--------------------- xCO2 = np.full(nx, xco2, dtype=np.float64) xCO = np.full(nx, xco, dtype=np.float64) xH2O = np.full(nx, xh2o, dtype=np.float64) xCH4 = np.full(nx, xch4, dtype=np.float64) fvsoot = np.full(nx, fvs, dtype=np.float64) x = np.zeros(nx) T = np.full(nx, Twall, dtype=np.float64) dx = L / (nx - 1) x[0] = 0.0 Tavg = T[0] xH2O_avg = 0.0 for i in range(1, nx): x[i] = x[i - 1] + dx T[i] = 4000 * x[i] * (L - x[i]) / L / L + Twall xH2O[i] = 0.8 * x[i] * (L - x[i]) / L / L + xh2o Tavg += T[i] xH2O_avg += xH2O[i] Tavg /= nx xH2O_avg /= nx if method == 'rcslw': rad = rad_rcslw(nGG, P, Tavg, xH2O_avg, xco2, xco, fvs) elif method == 'wsgg': rad = rad_wsgg() elif method == 'planckmean': rad = rad_planck_mean() else: raise ValueError('unknown radiation method') #------------------- get q, Q x, xQ, q, Q = parallel_planes(rad, L, ntheta, P, T, xH2O, xCO2, xCO, xCH4, fvsoot) print("# x (m), Q (kW/m3)") for i in range(len(xQ)): print(f'{xQ[i]:.5f} {Q[i]/1000:.5f}') #print("# x (m), q (kW/m2)") #for i in range(len(x)): # print(f'{x[i]:.5f} {q[i]/1000:.5f}') #------------------------------------------------------------------------- print() return xQ, Q