calc_liquid_composition
despasito.thermodynamics.calc.calc_liquid_composition
- calc_liquid_composition(xi, yi, phiv, P, T, Eos, density_opts={}, maxiter=20, tol=1e-06, tol_trivial=0.05, **kwargs)[source]
Find liquid mole fraction given pressure, vapor 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 liquid or critical fluid, we use another function to produce a new guess.
- Parameters:
xi (numpy.ndarray) – Guess in liquid mole fraction of each component, sum(xi) should equal 1.0
yi (numpy.ndarray) – Vapor mole fraction of each component, sum(xi) should equal 1.0
phiv (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=20) – 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 xi “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 (dict, Optional) – Optional keywords for
find_new_xi()
- Returns:
xi (numpy.ndarray) – Liquid mole fraction of each component, sum(xi) should equal 1.0
phil (float) – Fugacity coefficient of liquid 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