The procedures recommended by API [1a] for the interconversion of ASTM D 86 and TBP (True Boiling Point) distillation curves are transposed into Mathcad computation platform. Two Mathcad versions are presented for each of direct, ASTM to TBP, and the backward, TBP to ASTM, curves conversions according to the API procedure. The first version, simpler, but with fewer possibilities of use, was presented in the first part [1a]. This second part comprises the relations of the API procedure written as functions in the Mathcad worksheet. The procedure functions can be placed in a separate area of the worksheet, area which may be then collapsed, locked and hidden. Alternatively, the functions can be stored in a specific Mathcad file, which can be afterwards inserted and employed in the main worksheet with “Reference” command. Other possibilities of Mathcad environment for interconnection of worksheets (files), such as utilization of Mathconnex or creation of Mathcad E-books, are briefly mentioned, too. Utilization of Mathcad procedures is illustrated through several examples. The Mathcad worksheets comprising the API procedures are thus providing a convenient computer tool for fast prediction of one of ASTM and TBP distillation curve starting from the other one.
Key words : ASTM D 86, TBP, distillation, interconversion, Mathcad, petroleum
Introduction
The goal of the present work is to offer a general, easy-to-use Mathcad versions of the API (American Petroleum Institute) procedures for the ASTM D 86 and TBP distillation curves interconversion. A simpler Mathcad version of the API procedures was given in the first part [1a]. However the simpler Mathcad version has limited possibilities of use, or even no utility in some applications, such as those of iterative tasks commonly solved with programming modules. Furthermore, numerical data assignements needed to be placed in the worksheet before the method’s expressions (case of worksheet setting of “Automatic calculation” as default, that is turned on ; anyhow, if turned off, most of the present discussion becomes meaningless). In this second part we are going to provide Mathcad written procedures which are more concise and have extended range of application.
The relations needed for distillation curves interconversion originating from reference [2] and adapted by the author for temperatures in degrees centigrade have been given explicitly in the first part [1a].
Since the API procedure for ASTM – TBP distillation curves interconversion was described in Part 1 [1a], the reader is urged to refer to that part or to the original API reference [2] for a better comprehension and details on both the API method procedure and Mathcad version herein presented. Numerical checks against examples taken from literature [2] [3] [7] and made in order to verify our Mathcad versions of the API procedure, are also shown.
Get Help With Your Essay
If you need assistance with writing your essay, our professional essay writing service is here to help!
Mathcad implementation of API procedures for ASTM – TBP distillation curves interconversion. Using functions
The main part of the Mathcad worksheet with the API method for estimation of TBP curve from ASTM distillation curve is reproduced in Fig. 1. Assignments of parameters values being identical with those already given in Fig. 1a of the first part [1a], the beginning area of the Mathcad worksheet containing these assignments is no more shown in the present Fig. 1. In the same area omitted from Fig. 1, there are also definitions of range variables «ip» and «id», which again are identical with those in Part 1, that is «ip := 0,1..6» and «id:=0,1..5», needed for indexing current points of the distillation curve (corresponding to 0, 10, 30, 50, 70, 90 and 100 % vol.) and differences (between temperatures), respectively. Thus, the distillation curve is assumed to be represented in the same format as in Part 1, i.e. 7 rows ´ 2 columns matrix, where the first column elements are volume percentages (0, 10, 30, 50, 70, 90 and 100) of distillate and the second column elements are the corresponding six temperatures (oC) on the (ASTM or TBP) distillation curve.
The task of the function « dt_DC » (where dt and DC in notation stand for difference of temperatures and distillation curve) as defined by relation (1) in Fig. 1 is to pick up all pairs of consecutive temperatures on the given ASTM curve, to compute the difference between the two temperatures, and to give the result as a 6 elements array, which elements are the temperature differences. One of the two arguments of the function «dt_DC» in Fig. 1 needs to be the range variable id. Otherwise, a definition like
(a)
would issue an error message (“Illegal context” and expression (a) written in Mathcad turning into red) because, as expected, a range variable is not allowed as parameter within the function definition, or, being more specific, within the expression assigned to a function.
Another definition but more lengthy, which can be used to obtain the same numerical result as «dt_DC» function in relation (1) of Fig. 1, i.e. the six temperature differences, is the next one :
(b)
Fig. 1. Portion of the Mathcad worksheet with functions definitions to be used for API procedure for TBP curve prediction from the ASTM D86 distillation curve (continued with applications in Figures 2 and 3)
Even if the numerical values produced with both definitions, (1) in Fig.1 or above (b), are same, it is worth of mention that the two outputs have different meanings in Mathcad. Thus, while the latter definition (b) produces a six-element vector, the first definition, which is used in relation (1) of Fig. 1, produces an array (which may be also called table) with also 6 values, but which has not the quality of a vector in Mathcad. Consequently, neither several operations typical for vectors, such as transposition (operator „T” as superscript) or „vectorize” (operator denoted by an arrow above an expression containing a vector) can be applied to the output of the two‑argument function «dt_DC». This behavior may be probably better understood if a function definition like that in relation (1) of Fig.1 for «dt_DC» is regarded as six one-variable functions simultaneously defined. Difference between the outputs of the two functions, «dt_DC» and «dt_DCb» is similar to that between a true vector and a range variable such as «ip» or «id» which is used for indexing.
When desired, a workaround able to lead to a vector output is thus provided by the above definition of «dt_DCb» in (b). Moreover, this definition can be rewritten in a more concise form within a Mathcad worksheet using programming modules (see Part 3 [1b]).
In step 2 (Fig. 1), temperature for 50%vol. on TBP curve is estimated with the function denoted «t_50%TBP», from temperature for 50% vol. of ASTM, as in API procedure described in Part 1 [1a]. According correlations of the same procedure (that is relations (3) given in Part 1), differences between temperatures on TBP curve are then calculated in step 3 based on
Fig. 2. Part of the worksheet containing an example using the Mathcad version of API procedure for ASTM-to-TBP distillation curves conversion (Mathcad version of the procedure given in Fig. 1 ; ASTM data and experimental TBP from [2])
temperature differences of ASTM curve. This is done employing again a function with two arguments, of which the first is the range variable «id» (function named «dt_TBP»). Finally, TBP temperatures are determined in the 4th and last step with function «t_DC» by subtracting or adding to priorly determined «t50%TBP» the appropriate temperature gaps found in step 3 (Fig. 1).
An example using the Mathcad version of the API procedure described above is given in the portion of the Mathcad worksheet shown in Fig. 2. As previously explained, since the output of the function «dt_DC» in step 1 or of the function «dt_TBP» in step 3 (Fig. 2) is an array (table) and not a vector, presence of the index «id» at vector-variables «ΔtASTM1» or «ΔtTBP1», respectively, is imperative for a correct assignment of values computed by functions («dt_DC» or «dt_TBP») to the elements of mentioned vectors. Otherwise, the aforementioned error message (“Illegal context”) would be issued and corresponding expressions turned into red.
Fig. 3. Part of the worksheet with another example using the Mathcad version of API procedure for ASTM-to-TBP distillation curves conversion (Mathcad version of the API procedure given in Fig. 1 ; ASTM data and corresponding TBP estimated by Edmister‑Okamoto procedure taken from [3])
Even if it can be readily noticed from both Fig. 1 and example in Fig. 2, we emphasize that in the present Mathcad version of API procedure (Fig. 1) it is possible to write the expressions of the procedure as a standalone suite, independent on the 7 ´ 2 matrix with distillation curve data, due to use of functions. On the contrary, for the simpler Mathcad version given in Part 1 [1a], it was necessary to provide the distillation curve matrix in the Mathcad worksheet before the relations of the API procedure. Thus, presentation of simpler Mathcad procedure in [1a] was actually possible only using a numerical example. However, it can be mentioned that even in the case of simpler version in Part 1 a workaround for the infringement of normal order, that is with data in the begining of the worksheet, may be provided by the use of a global definition (available in Mathcad).
ASTM distillation data for example in Fig. 2 was taken from API Technical Data Book [2]. The TBP curve determined in Fig. 2 is identical with that computed in [2] from the same ASTM distillation data and with same API procedure. For comparaison, experimental TBP (vector «TBPexp») retrieved from the mentioned reference [2] is also given in Fig. 2.
Fig. 4. Area of worksheet with the Mathcad version of the reversed API procedure, for conversion of the TBP curve into ASTM distillation curve
The use of the same Mathcad version of the API procedure is illustrated with another example in the part of the worksheet reproduced in Fig. 3. ASTM data (7 ´ 2 matrix «ASTM2») in Fig. 3 and corresponding TBP values (matrix «TBP2_EO») estimated with Edmister and Okamoto method [4] are quoted from reference [3].
The suite of definitions shown in Fig. 1 as well as the two examples (Fig. 2 and 3) have been actually written in the same Mathcad worksheet.
The Mathcad version of the reversed API procedure, for TBP curve conversion to ASTM distillation curve, is illustrated in Fig. 4. In step 1 the temperature differences between two consecutive temperatures amongst those of selected points on TBP curve can be computed with the same function «dt_DC» given in Fig. 1. Since the Mathcad versions of both direct and reversed API procedures have been written in same worksheet, there was no more need for another function definition for step 1 in Fig. 4.
Find Out How UKEssays.com Can Help You!
Our academic experts are ready and waiting to assist with any writing project you may have. From simple essay plans, through to full dissertations, you can guarantee we have a service perfectly matched to your needs.
View our academic writing services
Coefficients in the expression of the function «t_50%ASTM» in relation (6) (Fig. 4), needed for the prediction of the 50% temperature on ASTM curve based on 50% temperature on TBP curve, are taken from Part 1 [1a] and they are coming from the same API procedure [2]. As shown in Fig. 4, the temperature for 50% on ASTM curve can also be determined with the function «tr_50%ASTM», which is the inverse of function «t_50%PRF» defined previously in the worksheet (with relation (2) in Fig. 1). The inverse function, «tr_50%ASTM», is defined using the Mathcad built-in function «root». First argument of «root» is the expression of whose root is wanted, the second argument indicates the variable with respect to which the equation defined by the expression has to be solved, and the 3rd and 4th arguments specify the interval where the desired root is lying.
Fig. 5. Portion of Mathcad worksheet with example of TBP curve conversion into
ASTM D86 distillation curve (API procedure [2])
Presence of last two arguments is optional: when these are included, Ridder or Brent algorithm is used internally by «root» to determine the solution; otherwise Mueller-secant algorithm is employed. The accuracy of the computed root is determined by parameter TOL (tolerance) whose value can be set (for the entire worksheet) from Mathcad menu. For details on the Mathcad root function or on the mentioned algorithms, references [5-6, 9] may be consulted. Notations used in relation (6r) of Fig. 4 show that equation “t_50%TBP(χ)‑t=0” is (numerically) solved with respect to variable χ (that is unknown χ) and the desired root (ASTM temperature for 50% vol.) is within interval (0, 1000) ( oC ) for all possible values of parameter «t» (temperature for 50% vol. on TBP curve).
Differences between temperatures on ASTM curve are computed in step 3 based on temperature differences on TBP curve determined in step 1. Being previously defined in the worksheet (Fig. 1), coefficients «AAPIC» and «BAPI» in relations (7) are known. Finally, in step 4 temperatures on the ASTM curve are calculated using the same function «t_DC» already defined in a proceeding zone (Fig. 1) of the worksheet.
We recall that for features of Mathcad employed herein or other capabilities reader can find valuable and detailed information with good examples in Mathcad help [5a] and particularly in the Resource Center [5b] accompanying Mathcad platform.
The use of the Mathcad version for the reversed API procedure, that is for TBP curve to ASTM curve conversion, is illustrated with the example in the part of Mathcad worksheet reproduced by Fig. 5.
Other possibilities of utilization of Mathcad written procedures
Two of these possibilities are illustrated below, one using an inserted area and the other the Reference command provided by the Mathcad environment.
An area can be readily inserted in a worksheet, using the commands from Insert menu. In our case (Fig. 6), after inserting a new area (a blank area initially) in the worksheet, we have merely copied (” Copy/Paste “) the area given in Fig. 1 and pasted it in the inserted blank area. The area thus inserted contains also the assignments of values to parameters Aid and Bid needed in the procedure (parameters which values are given in Tab. 1 of [1a] and are named «AAPIC» «BAPI» in Figures 1a,b and 2 in the same reference [1a] and which are no more shown in Fig.1 of the present part). Obviously, in such a case one has to provide a sufficient size of the inserted area. Its enlargement can be made by selecting one (usually the lower) of the crosshairs corresponding to the boundaries of inserted area and dragging it, or by clicking inside area and typing ‘Enter’ one or several times, as needed to accommodate the whole pasted part. The inserted area may be then easily collapsed (Fig. 6), as indicated by instructions in the dialog box which appears with a mouse right-button click. After collapsing, the inserted region can be locked and protected by a password and then provided with a time stamp. Always after collapsing, presence of the inserted region may be even made invisible (hidden) [5b]. All content of Fig. 6 was actually written in a new Mathcad file (worksheet), different from those illustrated in previous figures.
Fig. 6. Mathcad worksheet with inserted area collapsed and an example of ASTM curve conversion into TBP curve
Fig. 7. Mathcad worksheet with Reference to the Mathcad file (named here “ASTM‑TBP interconvAPI simple functions.mcd”) containing the API procedure for the two distillation curves interconversion
The Reference command (Fig. 7) allows all variables or functions definitions from another worksheet (“referenced worksheet” or “referenced Mathcad file”) to be made available in the current (parent) worksheet. Thus the current worksheet will behave as if one should have inserted into it the actual regions from the referenced worksheet. The ‘Reference’ containing line is merely introduced by a first mouse click in the main (parent) worksheet in the place where the referenced file is desired, then making the insert from the Reference command accessible in menu (Insert – Reference), followed by pointing to referenced file location (as asked by dialog box). An icon (right headed arrow inside a square) will mark the place from which the referenced worksheet will take effect within the parent worksheet. “(R)” after the file name (“ASTM-TBP interconvAPI simple functions.mcd” in occurrence, Fig. 7) means that the relative path was chosen in the present case in order to locate the referenced file. Even if the referenced Mathcad file itself cannot be seen in the current (parent) worksheet, it may be opened with a double click on its ‘Reference’ icon and then accessed and even modified.
Like for any other computational environment or programming language, it is strongly advisable to use systematic and mnemonic notations for various variables, functions,…, both in main and inserted worksheet (collapsed or not, or with Reference), in order to avoid errors. As already mentioned in [1a], errors in computed results may appear in case of notations overlap, even without any error message highlighted by Mathcad (without any expression turned into red).
In the case of long worksheets, more complicated structures of linked (concatenated) worksheets can be thus envisaged. For example a worksheet with an inserted area can be referenced from another worksheet. Again, in order to reduce the possibility of errors and for an acceptable readability, it is however advisable to limit to only a few the worksheets thus interconnected. If this is not possible, there are alternatives offered by Mathcad platform, such as use of Mathconnex environment or creation of a Mathcad electronic book. Both alternatives are easy to use and well documented in Mathcad help, for example the latter in the ‘Author’s reference’ item within Help menu. Moreover, recent versions of Mathcad, i.e. starting with 2001i, offer the possibility to save worksheets under XML or HTML format.
Conclusion
In the Mathcad version of API procedure for ASTM-TBP distillation curves interconversion presented in this part, use of functions allows to write the expressions of the procedure as a standalone suite, independent on the 7 ´ 2 matrix comprising distillation data. Utilization of some Mathcad features, such as functions with two arguments one of which being a range variable, vector-valued functions, definition of an inverse of a function using built-in root function, or area insertion in a Mathcad worksheet, are illustrated through examples. Interconnection of Mathcad worksheets (files) through the ,Reference command is also exemplified. Such features of Mathcad platform can provide added readability and broader generality to worksheets. Other capabilities of Mathcad, like utilization of Mathconnex or creation of Mathcad E-books are briefly envisaged. The Mathcad worksheets comprising the API procedures are thus providing a convenient tool for fast prediction of an ASTM or TBP distillation curve starting from the other one.
Cite This Work
To export a reference to this article please select a referencing style below: