Exemple #1
0
def get_h2_ch4_mix(x_ch4, x_h2):
    from gas_library import get_ch4_params
    from gas_library import get_h2_params
    from numpy import asarray

    ch4_params = get_ch4_params()
    h2_params = get_h2_params()
    N_i = asarray([-0.25157134971934, -0.62203841111983e-2, 0.88850315184396e-1, -0.35592212573239e-1])
    BetaT = 1.0
    BetaV = 1.0
    GammaT = 1.352643115
    GammaV = 1.018702573
    t_i = asarray([2.0, -1.0, 1.75, 1.4])
    d_i = asarray([1.0, 3.0, 3.0, 4.0])
    p_i = asarray([0.0, 0.0, 0.0, 0.0])
    Rmix = x_ch4 * ch4_params["R"] + x_h2 * h2_params["R"]
    M_amu = x_ch4 * ch4_params["M_amu"] + x_h2 * h2_params["M_amu"]
    n_power_terms_wo_exp = 4
    n_power_terms_w_exp = 0
    h2_ch4_mix_params = {
        "N_i": N_i,
        "BetaT": float(1.0),
        "BetaV": float(1.0),
        "GammaT": float(1.352643115),
        "GammaV": float(1.018702573),
        "t_i": t_i,
        "d_i": d_i,
        "p_i": p_i,
        "n_power_terms_wo_exp": n_power_terms_wo_exp,
        "n_power_terms_w_exp": n_power_terms_w_exp,
        "phi_i": 0,
        "Beta_i": 0,
        "gamma_i": 0,
        "D_i": 0,
        "R": Rmix,
        "M_amu": M_amu,
        "ideal_n": 0,
        "ideal_gamma": 0,
        "n_gaussian_terms": 0,
        "n_critical_terms": 0,
        "RES_a": 0,
        "RES_b": 0,
        "RES_B": 0,
        "RES_C": 0,
        "RES_D": 0,
        "RES_A": 0,
        "ni": 0,
        "ti": 0,
        "vi": 0,
        "ui": 0,
        "ho": 0,
        "so": 0,
        "n_ideal_gas_terms_pow": 0,
        "n_ideal_gas_terms_exp": 0,
        "To": 0,
        "Po": 0,
        "rho_o": 0,
    }
    return h2_ch4_mix_params
Exemple #2
0
from thermodynamic_functions.C_p_vector_mix import C_p_vector_mix
from scale_tau_and_delta_kw_4comp import scale_tau_and_delta_kw_4comp
from thermodynamic_functions.pressure_vector4 import pressure_vector4
from thermodynamic_functions.C_p_vector_mix4 import C_p_vector_mix4

from scipy.optimize import fsolve
from numpy import asarray,zeros

f=open('python_compressibility/calc_Cp/output_T_P.txt','r')
data=f.readline()
f.close()
T_i,P_h2_i,P_he_i,P_ch4_i,P_h2o_i=data.split("\t")

parameters_H2=get_h2_params()
parameters_h2o=get_h2o_params()
parameters_ch4=get_ch4_params()
parameters_he=get_he_params()


Bars_to_kPa=100
T=asarray([float(T_i),float(T_i)])
P_h2=asarray([float(P_h2_i),float(P_h2_i)])*Bars_to_kPa
P_he=asarray([float(P_he_i),float(P_he_i)])*Bars_to_kPa
P_ch4=asarray([float(P_ch4_i),float(P_ch4_i)])*Bars_to_kPa
P_h2o=asarray([float(P_h2o_i),float(P_h2o_i)])*Bars_to_kPa

                                             

#here we are using the ideal gas law as a proxy for density. The final pressure will be defined by the equation of state.
#In other words this is a kludge to keep density fixed, then calculate the real pressure.	                         
Exemple #3
0
def PressureCAPI(T_i,P_h2_i,P_he_i,P_ch4_i,P_h2o_i):

	from gas_library import get_h2_params	
	from gas_library import get_ch4_params
	from gas_library import get_he_params
	from gas_library import get_h2o_params
	from gas_library import get_h2_ch4_mix
	from gas_library import get_h2_h2o_mix
	from thermodynamic_functions.C_p_vector_mix import C_p_vector_mix
	from scale_tau_and_delta_kw_4comp import scale_tau_and_delta_kw_4comp
	from thermodynamic_functions.pressure_vector4 import pressure_vector4
	from thermodynamic_functions.C_p_vector_mix4 import C_p_vector_mix4

	from scipy.optimize import fsolve
	from numpy import asarray,zeros
        
	#f=open('python_compressibility/calc_Cp/output_T_P.txt','r')
	#data=f.readline()
	#f.close()
        #data=input_string_from_C
	#T_i,P_h2_i,P_he_i,P_ch4_i,P_h2o_i=data.split("\t")

	parameters_H2=get_h2_params()
	parameters_h2o=get_h2o_params()
	parameters_ch4=get_ch4_params()
	parameters_he=get_he_params()


	Bars_to_kPa=100
	T=asarray([float(T_i),float(T_i)])
	P_h2=asarray([float(P_h2_i),float(P_h2_i)])*Bars_to_kPa
	P_he=asarray([float(P_he_i),float(P_he_i)])*Bars_to_kPa
	P_ch4=asarray([float(P_ch4_i),float(P_ch4_i)])*Bars_to_kPa
	P_h2o=asarray([float(P_h2o_i),float(P_h2o_i)])*Bars_to_kPa

                                             

	#here we are using the ideal gas law as a proxy for density. The final pressure will be defined by the equation of state.
	#In other words this is a kludge to keep density fixed, then calculate the real pressure.	                         

	density_h2=P_h2/((parameters_H2['R']/parameters_H2['M_amu'])*T)
	#density_h2=fsolve(residual_pressure_pure_substance,density_guess_h2,args=(P_h2,T,parameters_H2))
	delta_h2=density_h2/parameters_H2['rho_c']

	density_h2o=P_h2o/((parameters_h2o['R']/parameters_h2o['M_amu'])*T)
	#density_h2o=fsolve(residual_pressure_pure_substance,density_guess_h2o,args=(P_h2o,T,parameters_h2o))
	delta_h2o=density_h2o/parameters_h2o['rho_c']

	density_he=P_he/((parameters_he['R']/parameters_he['M_amu'])*T)
	#density_he=fsolve(residual_pressure_pure_substance,density_guess_he,args=(P_he,T,parameters_he))
	delta_he=density_he/parameters_he['rho_c']

	density_ch4=P_ch4/((parameters_ch4['R']/parameters_ch4['M_amu'])*T)
	#density_ch4=fsolve(residual_pressure_pure_substance,density_guess_ch4,args=(P_ch4,T,parameters_ch4))
	delta_ch4=density_ch4/parameters_ch4['rho_c']


	density=density_h2+density_h2o+density_ch4+density_he
	#note we're calculating x_h2 and x_ch4 according to the mixture of just H2+CH4, not the whole thing He+h2o+etc...
	molar_density_h2=density_h2/parameters_H2['M_amu']
	molar_density_he=density_he/parameters_he['M_amu']
	molar_density_ch4=density_ch4/parameters_ch4['M_amu']
	molar_density_h2o=density_h2o/parameters_h2o['M_amu']

	x_h2=molar_density_h2/(molar_density_h2+molar_density_ch4+molar_density_he+molar_density_h2o)
	x_ch4=molar_density_ch4/(molar_density_h2+molar_density_ch4+molar_density_he+molar_density_h2o)
	x_he=molar_density_he/(molar_density_h2+molar_density_ch4+molar_density_he+molar_density_h2o)
	x_h2o=molar_density_h2o/(molar_density_h2+molar_density_ch4+molar_density_he+molar_density_h2o)

	h2_ch4_mix_params=get_h2_ch4_mix(x_h2,x_ch4)
	h2_h2o_mix_params=get_h2_h2o_mix(x_h2,x_h2o)

	M_amu_mix=x_h2*parameters_H2['M_amu']+x_he*parameters_he['M_amu']+x_ch4*parameters_ch4['M_amu']+x_h2o*parameters_h2o['M_amu']
	[tau,delta,Tc_mix,rho_c_mix]=scale_tau_and_delta_kw_4comp(T,density/M_amu_mix,x_h2,x_ch4,x_h2o,x_he,parameters_H2['Tc'],parameters_ch4['Tc'],parameters_h2o['Tc'],parameters_he['Tc'],parameters_H2['rho_c']/parameters_H2['M_amu'],parameters_ch4['rho_c']/parameters_ch4['M_amu'],parameters_h2o['rho_c']/parameters_h2o['M_amu'],parameters_he['rho_c']/parameters_he['M_amu'],h2_ch4_mix_params['BetaT'],h2_ch4_mix_params['BetaV'],h2_ch4_mix_params['GammaT'],h2_ch4_mix_params['GammaV'],h2_h2o_mix_params['BetaT'],h2_h2o_mix_params['BetaV'],h2_h2o_mix_params['GammaT'],h2_h2o_mix_params['GammaV'],1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0)
        
	Pcalc=pressure_vector4(density,T,tau,delta,parameters_H2,parameters_ch4,parameters_h2o,parameters_he,h2_ch4_mix_params,h2_h2o_mix_params,x_h2,x_ch4,x_h2o,x_he,rho_c_mix,Tc_mix)

	CP_mix=C_p_vector_mix4(density,T,delta,tau,parameters_H2,parameters_ch4,parameters_he,parameters_h2o,h2_ch4_mix_params,h2_h2o_mix_params,x_h2,x_ch4,x_he,x_h2o)
	Pcalc=Pcalc/Bars_to_kPa
        #print Pcalc[0],CP_mix[0]#,T_i,P_h2_i,P_he_i,P_ch4_i,P_h2o_i
        return (float(Pcalc[0]),float(CP_mix[0]))
Exemple #4
0
from gas_library import get_h2_params
from gas_library import get_ch4_params
from gas_library import get_he_params
from gas_library import get_h2o_params
from gas_library import get_h2_ch4_mix
from gas_library import get_h2_h2o_mix
from scale_tau_and_delta_kw_4comp import scale_tau_and_delta_kw_4comp
from thermodynamic_functions.pressure_vector4 import pressure_vector4
from numpy import asarray,zeros

h2_params=get_h2_params()
ch4_params=get_ch4_params()
he_params=get_he_params()
h2o_params=get_h2o_params()
h2_ch4_mix_params=get_h2_ch4_mix(0.5,0.5)
h2_h2o_mix_params=get_h2_h2o_mix(0.5,0.5)
density=asarray([0.1,0.1])
x_h2=asarray([0.99,0.99])
x_ch4=asarray([0.01,0.01])
x_h2o=asarray([0.00,0.00])
x_he=asarray([0.0,0.0])
T=asarray([500.0,500.0])


M_amu_mix=x_h2*h2_params['M_amu']+x_ch4*ch4_params['M_amu']+x_h2o*h2o_params['M_amu']+x_he*he_params['M_amu']
[tau,delta,Tc_mix,rho_c_mix]=scale_tau_and_delta_kw_4comp(T,density/M_amu_mix,x_h2,x_ch4,x_h2o,x_he,h2_params['Tc'],ch4_params['Tc'],h2o_params['Tc'],he_params['Tc'],h2_params['rho_c']/h2_params['M_amu'],ch4_params['rho_c']/ch4_params['M_amu'],h2o_params['rho_c']/h2o_params['M_amu'],he_params['rho_c']/he_params['M_amu'],h2_ch4_mix_params['BetaT'],h2_ch4_mix_params['BetaV'],h2_ch4_mix_params['GammaT'],h2_ch4_mix_params['GammaV'],h2_h2o_mix_params['BetaT'],h2_h2o_mix_params['BetaV'],h2_h2o_mix_params['GammaT'],h2_h2o_mix_params['GammaV'],1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0)
print 'tau,delta',tau,delta
P=pressure_vector4(density,T,tau,delta,h2_params,ch4_params,h2o_params,he_params,h2_ch4_mix_params,h2_h2o_mix_params,x_h2,x_ch4,x_h2o,x_he,rho_c_mix,Tc_mix)
print P