<jupyter_start><jupyter_text>Steady State Material Balances On a Separation TrainThis is the second problem of the famous set of [Ten Problems in Chemical Engineering](https://www.polymath-software.com/ASEE/Tenprobs.pdf).  Here, the goal is to solve a set of simultaneous linear equations.<NAME>, 2019  Problem SetupA distillation train fractionates a feed $F$ containing Xylene, Styrene, Toluene, and Benzene.  The distillate  $D$ and bottoms $B$  from the first column are each distilled again, with stream $D$ yielding $D_1$ and $B_1$ and stream $B$ yielding $D_2$ and $B_2$.  The overall material balance for the system is:Xylene: $0.07D_1+0.18B_1+0.15D_2+0.24B_2 = 0.15F$Styrene: $0.04D_1+0.24B_1+0.10D_2+0.65B_2 = 0.25F$Toluene: $0.54D_1+0.42B_1+0.54D_2+0.10B_2 = 0.40F$Benzene: $0.35D_1+0.16B_1+0.21D_2+0.01B_2 = 0.20F$  Problem Tasksa) Calculate the molar flow rates of streams $D_1$, $D_2$, $B_1$ and $B_2$.              b) Determine the molar flow rates and compositions of streams $B$ and $D$  Solutions Solution to part a)Solving the system of linear equations is very straightforward using the `numpy` package.  First, define a matrix of the species concentrations and flowrates:<jupyter_code>import numpy as np
F = 70
A = np.array([[0.07,0.18,0.15,0.24],
               [0.04,0.24,0.10,0.65],
               [0.54,0.42,0.54,0.10],
               [0.35,0.16,0.21,0.01]])
b = np.array([0.15,0.25,0.40,0.2])*F

X = np.linalg.solve(A,b)

# print the results, the line can be split using "\"
print('Molar flow of D1 is {:0.4}, B1 is {:0.4},\
D2 is {:0.4}, and B2 is {:0.4}'.format(*X))<jupyter_output>Molar flow of D1 is 26.25, B1 is 17.5,D2 is 8.75, and B2 is 17.5<jupyter_text>Solution to part b)To find the flow rates of streams B and D , we can selectively sum parts of the solution from a).  Multiplying the flow rates in part a) by the corresponding composition gives molar flow rates for the species that can be summed and divided by the flow rates to give molar fractions.<jupyter_code>D = X[0:2].sum()
print('Molar flow of D is {:0.4}'.format(D))
D_comps = (A[:,0:2]*X[0:2]).sum(axis=1)/D

print('Mole fraction in D of Xylene is {:0.4},\
Styrene is {:0.4}, Toluene is {:0.4}, and Benzene \
is {:0.4}'.format(*D_comps))
B = X[2:4].sum()
print('Molar flow of B is {:0.4}'.format(B))
B_comps = (A[:,2:4]*X[2:4]).sum(axis=1)/B

print('Molar fraction in B of Xylene is {:0.4},\
Styrene is {:0.4}, Toluene is {:0.4}, and Benzene \
is {:0.4}'.format(*B_comps))<jupyter_output>Molar flow of B is 26.25
Molar fraction in B of Xylene is 0.21,Styrene is 0.4667, Toluene is 0.2467, and Benzene is 0.07667<jupyter_text>Reference“The Use of Mathematical Software packages in Chemical Engineering”, <NAME>, <NAME>, <NAME>, <NAME>, Workshop Material from Session 12, Chemical Engineering Summer School, Snowbird,Utah, Aug., 1997.<jupyter_code>%load_ext watermark
%watermark -v -p numpy<jupyter_output>CPython 3.7.3
IPython 7.6.1

numpy 1.16.4
{'fraction_non_alphanumeric': 0.1409646739130435, 'fraction_numerical': 0.08525815217391304, 'mean_word_length': 4.212389380530974, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '35723', 'license': 'MIT', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1135, 'n_words': 365, 'path': 'Ten_Problems/Problem_02.ipynb', 'repo_name': 'chepyle/Python4ChEs', 'size': '2989'}