calc_vapor_composition
despasito.thermodynamics.calc.calc_vapor_composition
- calc_vapor_composition(yi, xi, phil, P, T, Eos, density_opts={}, maxiter=50, tol=1e-06, tol_trivial=0.05, **kwargs)[source]
Find vapor mole fraction given pressure, liquid mole fraction, and temperature.
Objective function is the sum of the predicted “mole numbers” predicted by the computed fugacity coefficients. Note that by “mole number” we mean that the prediction will only sum to one when the correct pressure is chosen in the outer loop. In this inner loop, we seek to find a mole fraction that is converged to reproduce itself in a prediction. If it hasn’t, the new “mole numbers” are normalized into mole fractions and used as the next guess. In the case that a guess doesn’t produce a gas or critical fluid, we use another function to produce a new guess.
- Parameters:
yi (numpy.ndarray) – Guess in vapor mole fraction of each component, sum(xi) should equal 1.0
xi (numpy.ndarray) – Liquid mole fraction of each component, sum(xi) should equal 1.0
phil (float) – Fugacity coefficient of liquid at system pressure
P (float) – [Pa] Pressure of the system
T (float) – [K] Temperature of the system
Eos (obj) – An instance of the defined EOS class to be used in thermodynamic computations.
density_opts (dict, Optional, default={}) – Dictionary of options used in calculating pressure vs. specific volume in
pressure_vs_volume_arrays()maxiter (int, Optional, default=50) – Maximum number of iteration for both the outer pressure and inner vapor mole fraction loops
tol (float, Optional, default=1e-6) – Tolerance in sum of predicted yi “mole numbers”
tol_trivial (float, Optional, default=0.05) – If the vapor and liquid mole fractions are within this tolerance, search for a different composition
kwargs (NA, Optional) – Other other keyword arguments for
find_new_yi()
- Returns:
yi (numpy.ndarray) – Vapor mole fraction of each component, sum(xi) should equal 1.0
phiv (float) – Fugacity coefficient of vapor at system pressure
flag (int) – Flag identifying the fluid type. A value of 0 is vapor, 1 is liquid, 2 mean a critical fluid, 3 means that neither is true, 4 means ideal gas is assumed