The University of Western Ontrio Fculty of Engineering Science Deprtment of Chemicl nd Biochemicl Engineering CBE 9b - Computtion And Optimiztion For Engineers Mtlb Project Introduction Prof. A. Jutn Jn 07 A unique set of rndom numbers will be supplied to ech student, b, c, d. These numbers will form the bsis of your project. Mny problems nd progrms tht you re required to complete will be bsed on these numbers. 6.b mens tke b (ignore sign) shift deciml left dd it to 6, etc. For exmple, if b = -4.63, then 6.b = 6.463 A comprehensive report in MS Word complete with Mtlb progrms, output, grphs nd solutions is due two weeks before the finl exms. Erlier prt submission my lso be required. A 5% levy per dy will pply to lte submission. Extr mrks will be wrded for nlysis nd discussion of your results nd detiled comments on progrm lines. DO NOT INCLUDE long tbles of numericl dt in your project submission. Lbeled grphs must be used to show ll dt. Avoid submitting nswers without explntion or nlysis. Show ll fully documented progrms nd Mtlb commnds to ccomplish ll steps.. Generte tble of conversions from vrible T formed using the : opertor which strts with nd increses by, then stops t 0. The tble should look like this. The fctor in brckets re used to convert T to other units. T T (/b) T (c/d)... 0. Form mtrix of the form below, where (elements) re numbers from the mgic commnd. Do not insert, b, c, d one t time. First form vector v = [, b, c, d., b, c, d] nd insert whole vector.
A = b c d [elements] [elements] b c d b c d Clculte the squre of ll the elements round the perimeter of the mtrix(squre first, then Sum). Use Mtlb commnds sum to ccomplish this. Use mtrix extrction commnds to pick up whole rows nd columns. e.g. top row = A(, :) 3. Write for loop to clculte vector nmed S which contins the sum of the min digonl of A, nd every digonl sum bove the min (\). Hint: use dig nd sum. Crete new mtrix clled B by removing the first nd the lst 3 columns of A. b. Using the commnds find nd ==, locte ll occurrences of b in mtrix B. Using single commnd, replce ll vlues of b with c*b. c. Crete plot using vector S for the x-xis dt nd the first column of mtrix B for the y-xis dt. Sort the dt in scending order before you plot. Lbel both xes.
4. Pump flow dt F cn be generted from the dt for qudrtic eqution F = x + bx + c. Where x is the vlve opening (use rnge of x from : 0. : 0). Use polyfit to re-estimte the pump curve coefficients ^ ^ ^, b, c nd compre to originl vlues. Add some noise to the dt using F = F + n* rndn (size (y)). Do this for low noise n =. Refit the dt nd compre chnge in fitted vlues, b, c. Repet for n = 0. Comment on effect of noise. Plot ll three curves using different symbols on the sme grph. Use legend to distinguish them. Repet the plot using the subplot commnd with three seprte plots. 5. Given the polynomil: f(x) =.cx 5 + x 4 + bx 3 + cx + 5.cx + 4 Find numericlly ll of the roots of f(x).. Confirm the roots by plotting f(x) over n pproprite rnge of x. b. How mny extremum (mx or min) points does f(x) hve? c. Find the vlues of x tht correspond to these extremum points. d. Find the extremum vlues of f(x). e. Confirm your nswers in questions c. nd d. grphiclly. Useful commnds: polyvl, polyder, roots subplot grid hold xis. 6. Bckground. Het clcultions re employed routinely in chemicl nd petroleum engineering s well s in mny other fields of engineering. This ppliction provides simple but useful exmple of such computtions. One problem tht is often encountered is the determintion of the quntity of het required to rise the temperture of mteril. The chrcteristic tht is needed to crry out this computtion is the het cpcity c. This prmeter represents the quntity of het required to
rise unit mss by unit temperture. If c is constnt over the rnge of tempertures being exmined, the required het ΔH (in clories) cn be clculted by ΔH = mc ΔT (4.) where c hs units of cl/(g. C), m = mss (g), nd ΔT = chnge in temperture ( C). For exmple, the mount of het required to rise 0 g of wter from 5 to 0 C is equl to ΔH = 0() (0-5) = 00 cl where the het cpcity of wter is pproximtely cl/ (g. C). Such computtion is dequte when ΔT is smll. However, for lrge rnge of temperture, the het cpcity is not constnt nd, in fct, vries s function of temperture. The het cpcity of your mteril increses with temperture ccording to the reltionship. c(t) =.c + b x 0-4 T +. x 0-7 T 3 (4.) In this instnce you re sked to compute the het required to rise 000 g of this mteril from 00 to 00 C. Solution: We cn clculte the verge vlue of c(t): _ c ( T ) T c( T ) dt T = T T (4.3) which cn be substituted into Eq. (4.) to yield ΔH = m T T c( T ) dt (4.4) where ΔT = T T. Now becuse, for the present cse, c(t) is simple polynomil, ΔH cn be determined nlyticlly. Plot c vs. T nd clculte ΔH nlyticlly for your mteril nd then clculte it numericlly using qud. Compre the two results. 7. The following dt hve been collected from btch rector: x Y 0.4 0.36 30.66 40 3. 50 8.8
djust y to give y = Y + 0.b where 0.b mens tke your number b nd shift the deciml to the left side (ignoring sign). Which of the following three models best represent the reltionship between y nd x? To nswer this you cn plot ech cse nd compre visully. You cn lso supplement this with comprison of the lest squres for the residuls eg sum(ydt-ymodel)^. For ) below you cn use logs to convert the equtions to stright line form..) y = e β x + β y = e β + β x + β x^ y = αx β b.) y = α x β /( + x α ) use lsqcurvefit for this cse. Why is this necessry? 8. A rector converts n orgnic compound to product P by heting the mteril in the presence of n dditive A. The dditive cn be injected into the rector, while stem cn be injected into heting coil inside the rector to provide het. Some conversion cn be obtined by heting without ddition of A, nd vice vers.. In order to predict the yield of P, Y p (lb mole product per lb mole feed), s function of the mole frction of A, X A, nd the stem ddition S (in lb/lb mole feed), the following dt hve been obtined. Y p X A S 0. 0.3 0 0.3 0 35 0.5 0 65 0.b 0.4 9. Fit liner model Y P = c o + c X A + c S Tht provides lest squres fit to the dt b. If we require tht the model lwys must fit the point Y P = 0 for X A = S = 0 obtin c 0, c, c, so tht lest-squres fit is obtined.
9. The conservtion of het cn be used to develop het blnce for long, thin rod (Fig. 3). If the rod is not insulted long its length (x) nd the system is t stedy stte, the differentil eqution (DE) tht results is d T + h ( T T) = 0 Where h is het trnsfer coefficient (cm - ) tht prmeterizes the rte of het dissiption to the surrounding ir nd T is the temperture of the surrounding ir ( C). Becuse this is second order DE, two boundry conditions (BC's) re required. These re initil vlue (x = 0) BC's nd re given s dt T (0) = 40. b C nd (0) = 0 C / cm The vlues of the other prmeters re h = b cm T = c C 0.0, 0.. Write Mtlb min (script) progrm nd function using ode45 to integrte this eqution. Wht is the vlue of the temperture T t distnce 0 cm long the rod, i.e. T (0). plot T vs. x (show xis scles nd intercepts). b. nother wy of giving BC's for similr problem is clled Boundry Vlue problem. For this second cse we give the BC's t two seprte vlues of x. ( ) T 0 = 40. b C nd T(0) = 00. c C In order to solve this problem using ode45 with these BC's, guess for the initil derivtive dt ( 0) must first be mde, followed by n integrtion to x = 0. Then compre the result to the required T (0) nd guess gin. One cn use liner interpoltion (interp.m) to find suitble vlue of ( 0) the correct T (0). dt which gives
Write script file to perform these clcultions nd hence clculte the correct vlue of dt ( 0) (to 4 decimls) which gives the correct BC t x = 0 cm. i.e. T(0) = 00.c C. 0. A simple biorector model (ssuming stedy-stte opertion) is μmx x 0 = D x k m x kx + + s x D C k μ + x x + k x x m mx 0 = ( ) f where μ mx = 0.5b k m = 0. k = 0.4545 C = 0.4 s f = 4.c (use your personl c) x is the biomss concentrtion (mss of cells) nd x is the substrte concentrtion (food source for the cells). Find the stedy-stte vlues for x nd x if D = 0.3 (There my be up to three solutions, depending on your set of numbers, but you my find less ).. Use fsolve nd severl initil guesses for the solution vector. b. Check these vlues by substitution into the originl equtions c. Assume x is not zero in the first eqution, solve for D nd substitute for it in the second eqution. Then multiply out by hnd to form polynomil, substitute the (non zero) vlue for x found in prt., then use roots to solve for x nd compre this nswer to tht obtined in prt. Note fsolve cnnot find solutions tht re complex ( it cuts of complex prt), wheres roots cn. Downlod the document: StirredTnks.pdf from my home pge under mfiles/9. Set up the solution to these equtions using Simulink using your own choice of prmeters. Plot the motion of the concentrtion in both tnks in response to step chnge in the flow dye into the first tnk. Does the concentrtion response you obtin for the tnks mke sense to you?
Support this by discussion of your results using bsic engineering common sense. Explin your Simulink block digrm nd your results.