• No results found

Question 1 (Marked by Eric Rodger)

N/A
N/A
Protected

Academic year: 2020

Share "Question 1 (Marked by Eric Rodger)"

Copied!
11
0
0

Loading.... (view fulltext now)

Full text

(1)

ChE 3E04 – Process Model Formulation and Solution

Fall 2009

Midterm Exam Solution

Given: Tuesday, November 3 Grading: 20 pts

Question 1 (Marked by Eric Rodger)

a)We start with the total energy balance for reacting systems given in the course notes:

V ρcp

dT

dt =ρcpFA(TA−T) +ρcpFB(TB−T) +rV(−∆H) +Q+Ws

This expression can be written becauseρ,Cp andV are constant (other assumptions are necessary as well). The problem statement gives the following expression for Q:

Q=−k(T−Tw)

The above expression is written with a negative sign because it represents heat lost to the environment. Since it is a mixing tank there is no reaction sor= 0 and there is no expression given for Wsso it is set to zero as well. The final energy balance is:

V ρcp

dT

dt =ρcpFA(TA−T) +ρcpFB(TB−T)−k(T−Tw)

Marking: 0.5 points will be awarded for giving appropriate assumptions, 0.5 points will be given for the accumulation term, 0.5 points for each of the in/out flow terms and one point for the heat loss term.

b) The liquid temperature in the tank at the exit at steady state cannot be higher than bothTA and TB. This can be confirmed by examining the dynamical balance given in part A. At steady state the accumulation term is zero. IfT is greater thanTAandTB then both of the in/out flow terms are less than zero. Therefore for the equation to be satisfied,−k(T−Tw) must be greater than zero. However, this is impossible since we are told in the problem statement thatTw< T.

(2)

Question 2 (Marked by Elliot Cameron)

I tried to mark these questions as fairly as possible but when it comes to short answer questions things are invariably open to interpretation. As always, I invite anyone who feels they were marked incorrectly or unfairly to come see me to discuss the situation and we can go from there. Naturally, each question was worth 1 mark for a total of 5 marks. What follows are my solutions to the problems followed by some general remarks on the solutions I received.

a) Assuming that you are trying to solve the same system as your colleague, the likely problem would be that you chose a different starting point that unfortunately resulted in divergence (this is possible for poor starting point selections). The recommended course of action would be to use the same starting point as your colleague and try again.

Remarks: As a whole, this question was answered fairly well. What I was looking for was

recogni-tion that the performance of the Newton method is impacted by starting point selecrecogni-tion. Another answer that came up a few times was that the colleague might have used a relaxation coefficient (where as you did not). I had not thought of this initially but I believe it to be correct so I considered it an acceptable answer. Many people also speculated that selection of tolerance could be an issue. I did not deduct marks for this (if it accompanied either of the answers I mentioned before) but this is technically incorrect. If Newton Raphson is converging to a given root, the tolerance will not impact the final result, just how long it takes to get there (or how coarse the estimate of the final root is). Tolerance has no impact on the Newton search direction or its length. Many people also speculated that the order of the equations would impact the solution. Again, one needs to look at how this would impact the solution procedure. Newton method basically boils down to iteratively solving the system J∆x = -f, which would likely be solved using some form of LU decomposition with pivoting. Therefore any re-arrangement of equations would be untangled with pivoting and so it is doubtful that it would impact convergence. Anyone who provided any of the last two, or any other, arguments without acknowledgement of the first two arguments was marked wrong accordingly.

b) In the case of the Gauss Seidel method, it is possible that you have re-arranged the system of equations, thus potentially removing diagonal dominance. The recommended course of action would be to check the ordering of your system with that of your colleague.

Remarks: Again, as a whole, this question was also answered fairly well. What I was looking for

(3)

c) No, this is not true. Some finite decimal numbers will have infinite binary representations. A perfect example of this is the decimal number 0.1 (The reason behind the patriot missile defense system failure). This number is finite in decimal form but has a value of 0.00011 in binary.

Remarks: The performance on this question was mixed. Many of you confused ”binary” with ”floating

point”. Binary is a theoretical construct, like decimal, that has an infinite number of representations. Floating point is a system that imposes a constraint on the number of allowable representations. You can have decimal floating point, you can have binary floating point. You can have floating point to any base for that matter. What about hexidecimal floating point? (floating point, base 16). Having said this, I was very leniant in my marking when it came to what was defined as ”finite”. Did the question mean finite in total or finite within a floating point system? There are countless numbers that would be finite in decimal and finite in binary, but would require some form of rounding to fit within a binary floating point architecture. I considered this acknowledgement of limited space limiting the number of finite representations to be acceptable. However, I feel the true answer would be to acknowledge that some finite decimal numbers have infinite binary representations, regardless of the floating point system used. The answers given for this question were quite varied and so any answer that fell off of these two main points I tried to give some part marks for for displaying some understanding of the problem, but obviously marks were deducted.

d) This code constructs a 3x3 coefficient matrix A and a 3x1 answer vector b. The final line calls MATLAB’s LU decomposition/solver algorithm, which solves the linear systemAx = bforx. The final line will therefore output (because it is not capped by a ”;”) a 3x1 vector containing the solution to the system

Ax = b.

Remarks: The performance on this question was generally very good. Many of you confused what

internal operations the ”\” operator actually performs. I did not deduct marks as long as you still acknowledged that this code would solve the system Ax = b and output the solution vector x, but it should be made clear that ”\” does not perform Gauss elimination or ”matrix division”, it solves the system using LU decomposition with partial pivoting. I deducted marks for anyone who did not acknowledge the purpose of the code or its output and for those who erroneously thought that ”\” would cause an error or that not assigning a variable to recieve the solution of Ax=b would result in an error (MATLAB uses the default ”ans” variable when no variable is declared).

e) You could use options (i) and (iii) because both of these methods only require function evalua-tions in their algorithms. Option (ii), on the other hand, requires an explicit function for the derivative and so would not be appropriate for a black box function.

Remarks: Out of the five problems this problem yielded the poorest overall performance. Many

(4)

Question 3 (Marked by Eric Rodger)

a)The following system of equations is determined through stoichiometry:

4n+ 0p−q = 2 0n+ 2p−3q = 16

0n+p−4q = 0

Marking: 0.5 points will be given for each correct equation. Partial marks will be given for incorrect equations.

b)The model can be represented in matrix form as follows:

4 0 −1 0 2 −3 0 1 −4

    n p q  =   2 16 0  

Note that depending on how this initial system is formulated, a different set of steps will need to be carried out to arrive at the answer. One such progression is shown here.

Notice that the first column already contains zeros in the correct spots. For the second column no pivoting is needed. To complete the forward elimination step, row 2 must be multiplied by 1/2 and the result subtracted from row 3:

4 0 −1 0 2 −3 0 0 −5/2

    n p q  =   2 16 −8  

Now that the system has been transformed into an upper triangular system, the back substitution step can be performed. First, the third row is solved forq:

−5

2q = −8

q = 16 5

Next, this result is used to solve the second row forp:

2p−3q = 16

p = 16 + 3q 2

p = 64 5

Finally, the previous two results are used to solve the first row forn:

4n−q = 2

n = 2 +q 4

n = 13 10

Therefore the solution for the system is:

(5)
(6)

Question 4 (Marked by Elliot Cameron)

We start by subbing in the desired enthalpy of reaction for the term ∆H0

r(T) and re-arranging the function to the form f(x) = 0. (1 point)

∆Hr0(T) =−10000−0.2T+ 1.5x10−3T2+ 2x105

T [cal/mol]

−9258 =−10000−0.2T+ 1.5x10−3T2+2x105

T [cal/mol]

f(T) =−742−0.2T+ 1.5x10−3T2+2x105

T = 0 [cal/mol]

Next we take the derivative of the function. (1 point)

f(T) =−742−0.2T+ 1.5x10−3T2+2x105

T = 0 [cal/mol]

f′(T) =−0.2 + 3.0x10−3T2x105

T2 [cal/mol*K]

First Iteration: (1 point)

T(0)= 301.0K

f(301.0) =−742−0.2(301.0) + 1.5x10−3(301.0)2+ 2x105

(301.0)

f(301.0) =−1.846672757475176

f′(301.0) =−0.2 + 3.0x10−3(301.0) 2x105

(301.0)2

f′(301.0) =−1.504481153629651

T(1)=T(0) f(T(0))

f′(T(0))

T(1)= (301.0K)−1.846672757475176

−1.504481153629651

(7)

Termination Criteria Check: (1 point)

For the sake of this problem we assumeǫtol = 10−8.

f(299.77. . .) =−742−0.2(299.77. . .) + 1.5x10−3(299.77. . .)2+ 2x105

(299.77. . .)

f(299.77. . .) = 0.013354540536056 |f(299.77. . .)|= 0.013354540536056

|f(T(1))| ≤10−8? No

T(1)T(0)

T(1)

=

(299.77. . .)−(301.0) (299.77. . .)

T(1)T(0)

T(1)

= 0.004094598527104

T(1)T(0)

T(1)

Less thanǫtol= 10−8? No

Second Iteration: (0.25 point)

T(1) = 299.77. . . K

f(299.77. . .) =−742−0.2(299.77. . .) + 1.5x10−3(299.77. . .)2+ 2x105

(299.77. . .)

f(299.77. . .) = 0.013354540536056

f′(299.77. . .) =−0.2 + 3.0x10−3(299.77. . .) 2x105

(299.77. . .)2

f′(299.77. . .) =−1.526278006585444

T(2) =T(1)− f(T

(1))

f′(T(1))

T(2) = (299.77. . .)− 0.013354540536056 −1.526278006585444

(8)

Termination Criteria Check: (0.25 point)

For the sake of this problem we assumeǫtol = 10−8.

f(299.78. . .) =−742−0.2(299.78. . .) + 1.5x10−3(299.78. . .)2+ 2x105

(299.78. . .)

f(299.78. . .) = 6.832084409325034e−007 |f(299.78. . .)|= 6.832084409325034e−007

|f(T(2))| ≤10−8? No

T(2)T(1)

T(2)

=

(299.78. . .)−(299.77. . .) (299.78. . .)

T(2)T(1)

T(2)

= 2.918708774809660e−005

T(2)T(1)

T(2)

Less thanǫtol= 10−8? No

Third Iteration: (0.25 point)

T(2) = 299.78. . . K

f(299.78. . .) =−742−0.2(299.78. . .) + 1.5x10−3(299.78. . .)2+ 2x105

(299.78. . .)

f(299.78. . .) = 6.832084409325034e−007

f′(299.78. . .) =−0.2 + 3.0x10−3(299.78. . .) 2x105

(299.78. . .)2

f′(299.78. . .) =−1.526121841940195

T(3) =T(2)− f(T

(2))

f′(T(2))

T(3) = (299.78. . .)−6.832084409325034e−007 −1.526121841940195

(9)

Termination Criteria Check: (0.25 point)

For the sake of this problem we assumeǫtol = 10−8.

f(299.781. . .) =−742−0.2(299.781. . .) + 1.5x10−3(299.781. . .)2+ 2x105

(299.781. . .)

f(299.781. . .) = 1.136868377216160e−013 |f(299.781. . .)|= 1.136868377216160e−013

|f(T(3))| ≤10−8? Yes

T(3)T(2)

T(3)

=

(299.781. . .)−(299.78. . .) (299.781. . .)

T(3)T(2)

T(3)

= 1.493342637484132e−009

T(3)T(2)

T(3)

(10)

Question 5 - Bonus (Marked by Elliot Cameron)

This was a harder question to mark because so few marks were allotted to it. Really I was just looking for acknowledgement that the secant method is merely Newton’s method with a finite difference approximation used for the derivative. I have given a basic mark scheme embedded in my implementation below, but when it came to individual codes (which varied greatly) I used my best judgement when trying to fit those implementations into my marking scheme. That having been said, One possible method of converting the provided code so that it implements the Secant method is provided below.

(0.25 point for change 1)

1) Change line 1 to ”function xfinal = secant(g,x0,x1,eps,maxit)” (0.75 point for changes 2 - 6)

2) Change line 5 to ”function x(1) = x0;”

3) Insert ”function x(2) = x1;” between line 5 and 6 4) Change line 6 to ”f(1) = g(x(1));”

5) Insert ”f(2) = g(x(2));” between lines 6 and 7

6) Change line 7 to ”df = (f(2)-f(1))/(x(2)-x(1));”

7) Change line 11 to ”fprintf(’iter x(1) x(2) f(1) f(2) dx\n’);”

8) Change line 12 to ”fprintf(’%4d %11.4e %11.4e %11.4e %11.4e %11.4e\n’, it, x(1), x(2), f(1), f(2), -f(2)/df);”

9) Change line 16 to ”% SECANT METHOD STEP” (1.0 point for changes 10 - 17)

10) Remove line 17

11) Change line 18 to ”dx = -f(2)/df;”

12) Insert ”x(1) = x(2)” between lines 18 and 19 13) Change line 19 to ”x(2) = x(2) + dx;”

14) Insert ”f(1) = g(x(1));” between lines 19 and 20 15) Change line 20 to ”f(2) = g(x(2));”

16) Change line 21 to ”df = (f(2)-f(1))/(x(2)-x(1));” 17) Change line 22 to ”err = abs(f(2));”

18) Change line 26 to ”fprintf(’%4d %11.4e %11.4e %11.4e %11.4e %11.4e\n’, it, x(1), x(2), f(1), f(2), -f(2)/df);”

19) Insert the following code between lines 27 and 28:

if(it > maxit)

fprintf(’Maximum number of iterations exceeded\n’); return;

else

xfinal = x(2); end

When implemented, the above changes would result in the following code.

secant.m

1 function xfinal = secant( g, x0, x1, eps, maxit ) 2

3 % INITIALIZATION 4 it = 0;

5 x(1) = x0; 6 x(2) = x1; 7 f(1) = g(x(1)); 8 f(2) = g(x(2));

9 df = (f(2)-f(1))/(x(2)-x(1)); 10 err = 2*eps;

11

12 %DISPLAY

13 fprintf(’iter x(1) x(2) f(1) f(2) dx\n’);

14 fprintf(’%4d %11.4e %11.4e %11.4e %11.4e %11.4e\n’, it, x(1), x(2), f(1), f(2), -f(2)/df); 15

(11)

18 % SECANT_METHOD STEP 19 dx = -f(2)/df; 20 x(1) = x(2); 21 x(2) = x(2) + dx; 22 f(1) = g(x(1)); 23 f(2) = g(x(2));

24 df = (f(2)-f(1))/(x(2)-x(1)); 25 err = abs(f(2));

26 it = it+1; 27

28 % DISPLAY

29 fprintf(’%4d %11.4e %11.4e %11.4e %11.4e %11.4e\n’, it, x(1), x(2), f(1), f(2), -f(2)/df); 30 end

31 if(it > maxit)

32 fprintf(’Maximum number of iterations exceeded\n’);

33 return;

34 else

35 xfinal = x(2); 36 end

37 end

The input arguments of this function are as follows:

• g, handle of the nonlinear function to be solved,f(x∗) = 0

• x0, first initial guess required by secant method

• x1, second initial guess required by secant method (this could have been packed in with x0 as a single vector argument, although the code would need to be modified slightly to accomodate this...)

• eps, the user tolerance for terminating the iterations,|f(xk)|< ǫ tol

References

Related documents

The present study showed that the incidence of pulmo- nary oedema could have been increased by the total dosage of ritodrine hydrochloride, irrespective of the therapeutic duration

term applies to children or young people who, for whatever reason, require additional support, long or short term, in order to help them make the most of their

South Texas College Academic Affairs Division has developed dual enrollment programs to have a direct impact on student success from “at-risk” students to high achieving Juniors

The basic idea is that an object is inferred to have one (unobserved) property on the grounds that it has another, observed, one: ‘there is fire on the mountain because there is

Transmitter is located on each tire of vehicle for transmission of temperature and pressure value of each tire consist of Pressure sensor mpx6400 interface with PSoC

research, used a moderated mediation model analyzing the contribution of attachment style, socio-cognitive correlates (i.e. rumination, attribution, and empathy), and perceived

Three first – level themes were identified that specify the conditions required to perform continuous video monitoring: Camera recording (e.g. being able to turn off the

The specific objectives were (a) to examine the effects of demographic factors (i.e., age, gender, education, and religion), health status, and life satisfaction on death