#!/usr/bin/env python # coding: utf-8 # In[2]: import numpy as np import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') from scipy.integrate import quad from scipy.interpolate import interp1d from scipy.optimize import curve_fit, fsolve # ## Problem 1 # # When a vapor is in equilibrium with a liquid, there is no net transfer of mass between the vapor and liquid, and compositions (vapor and liquid) are constant with time. For simple (ideal) systems, Raoult’s law may be used to calculate the compositions, temperature, and pressure of the system. However, for non-ideal systems, a modified version of Raoult’s law may be used. For a non-ideal binary system (i.e. consisting of only 2 components, we’ll call them components 0 and 1), the following variables are important: # * Vapor: $y_0$, $y_1$ # * Liquid: $x_0$, $x_1$, $\gamma_0$, $\gamma_1$, $P_{vap,0}$, $P_{vap,1}$, # # \begin{align} # &y_0 = \text{mole fraction of species 0 in the vapor phase,}\\ # &y_1 = \text{mole fraction of species 1 in the vapor phase,}\\ # &x_0 = \text{mole fraction of species 0 in the liquid phase,}\\ # &x_1 = \text{mole fraction of species 1 in the liquid phase,}\\ # &P_{vap,0} = \text{vapor pressure of species 0,}\\ # &P_{vap,1} = \text{vapor pressure of species 1,}\\ # &\gamma_0 = \text{activity coefficient of species 0,}\\ # &\gamma_1 = \text{activity coefficient of species 1.}\\ # \end{align} # # Equilibrium between the vapor and liquid can be expressed by the following relationships: # $$y_0P = \gamma_0x_0P_{vap,0},$$ # $$y_1P = \gamma_1x_1P_{vap,1}.$$ # # The activitiy coefficients can be approximated as: # $$\gamma_0 = \exp(0.95x_1^2),$$ # $$\gamma_1 = \exp(0.95x_0^2).$$ # # The vaport pressures (atm) are functions of $T$ (K) and can be calculated from # $$P_{vap,i} = \frac{1}{760}10^{A_i - B_i/(C_i+T)},$$ # # | i | A | B | C | # |---|----|----|---| # | 0 | 8.04494 | 1554.3 | 222.63 | # | 1 | 7.96681 | 1668.21| 228.0 | # # **Find $x_0$, $x_1$, $\gamma_0$, $\gamma_1$, and $P$ given $T=300$ K and $y_0=0.5$.** (Recall, mole fractions sum to 1.) # # # In[ ]: # ## Problem 2 # # Solve the following two equations in the two unknowns $c_L$ and $c_{\eta}$: # $$\int_0^{\infty}E(\kappa)d\kappa = K,$$ # # $$\int_0^{\infty}2\nu\kappa^2E(\kappa)d\kappa = \epsilon.$$ # Here, $\nu = 1.5\times 10^{-5}$, $K = 0.008$, and $\epsilon = 0.003$. # # You can take $\infty\approx 1E5$. # # We also have the following functions and relations: # $$L = \frac{K^{3/2}}{\epsilon},$$ # $$\eta = \left(\frac{\nu^3}{\epsilon}\right)^{1/4},$$ # # $$E(\kappa) = 1.5\epsilon^{2/3}\kappa^{-5/3}f_L(\kappa)f_{\eta}(\kappa),$$ # # $$f_L(\kappa) = \left(\frac{\kappa L}{[(\kappa L)^2 + c_L]^{1/2}}\right)^{11/3},$$ # # $$f_{\eta}(\kappa) = \exp(-5.2([(\kappa\eta)^4 + c_{\eta}^4]^{1/4}-c_{\eta})).$$ # # * Guesses: $c_L=5$, $c_{\eta}=0.5$. # * Note: $K$ is different than $\kappa$ # In[ ]: # In[ ]: