Chee 400 Chee 400
Chee 400 Chee 400
9/15/11
HOMEWORK #2
EQ_Solve.m
%Stephen Dufreche %File for solving an equation by the method of Successive Substitution clc clear %Get name of the equation file which must be solved. Capture it as a %string and convert to a function handle. fname = str2func(input('Name of function containing equation to be solved: ', 's')); %Input initial guess for function. x0 = input('Initial guess for function solution: '); %Pass fname and x0 to solver function and capture solution. [x i]= xgx(fname, x0); disp(['The root is: ' num2str(x)]) disp(['The calculation took ' num2str(i) ' iterations to complete.'])
HOMEWORK #2
xgx.m
%Function file to solve an equation using the SS method. %Receive passed variables 'fnctn' and 'x0' %Return final calculated value of 'x' and the number of iterations. function [A i]= xgx(fnctn, x0) %Set up the first values of 'x' x(1) = x0; %Evaluate the function referenced by fnctn. %Pass the value of x(1) to it. x(2) = fnctn(x(1)); %Set the initial position of x to 2. i = 2; %Continue evaluating the loop as long as the current and previous values of %x differ by more than 10^-6 while (abs(x(i) - x(i-1)) >= 10^(-6)) %Move the current position of x up by one. i = i + 1; %Evaluate the function referenced by fnctn. %Pass the value of x(i-1) to it. x(i) = fnctn(x(i-1)); end %Set the variable which will be passed as the last position in x. A = x(i);
HOMEWORK #2
EQ1.m
%Function file to define an equation which will be solved by the SS method %Receive passed variable and name it 'x' %Return calculated value of 'A' function A = EQ1(x) A = x^(0.5)+2.1;
NMIN
Calculate ki from vapor pressure. Use Antoines equation.
# Feed Composition xF1 = 0.15 xF2 = 0.18 xF3 = 0.18 xF4 = 0.49 # Distillate flow rates D1 = xF1 D2 = xF2 - B2 D3 = 0.05 * xF3 D4 = 0 tD = D1 + D2 + D3 + D4 # Bottoms flow rates B1 = 0 B2 = 0.001*(B3+B4)/(0.999) B3 = 0.95 * xF3 B4 = xF4 tB = B1 + B2 + B3 + B4 # Distillate composition xD1 = D1 / tD xD2 = D2 / tD xD3 = D3 / tD xD4 = D4 / tD # Bottoms composition xB1 = B1 / tB xB2 = B2 / tB xB3 = B3 / tB xB4 = B4 / tB P = 7 # pressure bar # Dew point temperature at the top of the column f(TD) = xD1 / k1D + xD2 / k2D + xD3 / k3D - 1 TD(0) = 270 k1D = 10 ^ (3.93835 - 659.739 / (TD - 16.719)) / P k2D = 10 ^ (4.53678 - 1149.36 / (TD + 24.906)) / P k3D = 10 ^ (4.3281 - 1132.108 / (TD + 0.918)) / P # Bubble point temperature at the bottom of the column f(TB) = xB2 * k2B + xB3 * k3B + xB4 * k4B - 1 TB(0) = 300 k2B = 10 ^ (4.53678 - 1149.36 / (TB + 24.906)) / P k3B = 10 ^ (4.3281 - 1132.108 / (TB + 0.918)) / P k4B = 10 ^ (4.35576 - 1175.581 / (TB - 2.071)) / P # Fenske Correlation Nmin = log((xD2 / xD3) * (xB3 / xB2)) / log(sqrt((k2D / k3D) * (k2B / k3B)))
RMIN
Calculate ki of feed from vapor pressure. Use Antoines equation.
# Bubble point temperature of the feed f(TF) = xF1 * k1F + xF2 * k2F + xF3 * k3F + xF4 * k4F - 1 TF(0) = 300 k1F = 10 ^ (3.93835 - 659.739 / (TF - 16.719)) / P k2F = 10 ^ (4.53678 - 1149.36 / (TF + 24.906)) / P k3F = 10 ^ (4.3281 - 1132.108 / (TF + 0.918)) / P k4F = 10 ^ (4.35576 - 1175.581 / (TF - 2.071)) / P # Underwood Equations f(theta) = xF1 * (k1F / k3F) / (k1F / k3F - theta) + xF2 * (k2F / k3F) / (k2F / k3F - theta) + xF3 / (1 - theta) + xF4 * (k4F / k3F) / (k4F / k3F - theta) theta(0) = 1.5 Rmin = xD1 * (k1D / k3D) / (k1D / k3D - theta) + xD2 * (k2D / k3D) / (k2D / k3D - theta) + xD3 / (1 - theta) - 1
NMIN AT R = RMIN*1.5
Calculate ki of feed from vapor pressure. Use Antoines equation.
# Number of theoretical trays X = (R - Rmin) / (Rmin + 1) Y = 0.75 * (1 - X ^ 0.5658) N = Y * (Nmin + 1) + Nmin # Number of stages above and below the feed stage m = N - N / (1 + 10 ^ (0.206 * log((tB / tD) * (xF3 / xF2) * (xB2 / xD3) ^ 2))) # Specify the reflux ratio R R=1.5*Rmin