You are to write the code for a convergence module that can deal with one to three
Question:
You are to write the code for a convergence module that can deal with one to three tear stream variables using theWegstein algorithm, as outlined in Appendix A.2. The object is to determine the values of one, two, or three of the variables x1, x2, x3 and that satisfy the relations
where f1, f2, and h may be simple algebraic functions, or they may represent the composite set of calculations involved in proceeding around a cycle of unit operations to recalculate tear stream variables. The calculation consists of assuming values for the tear stream variables [xia, i = 1, …, 3]; computing [xic = fi(x1a, x2a, x3a), i = 1, …, 3]; determining whether xia, and xic, are within a specified tolerance of each other for each i ; and if they are not, using the Wegstein algorithm to estimate the values of x1a, x2a, and x3a to be used in the next iteration. The module code should be written in terms of the following variables:
(a) Write the code for a module subprogram called CONVG that has as its arguments XA, XC. N, KMAX, EPS, and IPR. The values of N, KMAX, EPS, IPR, and the elements of XA are input variables, and the final estimated values of xi are to be returned in array XC. The code should execute the procedure outline in Section A.2g separately for each of the N variables, up to a maximum of KMAX iterations. If this limit is reached and convergence has not been attained, an error message should be printed and the program terminated. In a real flowchart simulator, the code would be written so that the module could be inserted as a block in the flowchart (see, for example, the flowchart block diagram on p. xxx), and the tear stream variables XC (I) would then be recalculated from assumed values of XA (I) by proceeding around the cycle. To simplify the coding in this problem, however, have the subprogram call a function-generating subroutine of the form
CALL FUNCGEN(N , XA ,XC)
You will need to write Subroutine FUNCGEN to evaluate
XC (1) = fi[XA(1) ,XA(2) , XA (3)]
and similarly for XC (2) and XC (3).
(b) Apply your code to the problem of Example A.2-2. Build in an upper limit of 20 iterations (KMAX = 20).
Step by Step Answer:
Elementary Principles of Chemical Processes
ISBN: 978-0471720638
3rd Edition
Authors: Richard M. Felder, Ronald W. Rousseau