|
Solving Integral Equations in Microsoft Excel My spreadsheet template, TankVolume,
calculates the liquid volume of partially filled tanks, horizontal or vertical, with
various types of heads. One of these, the
torispherical head, requires that integral equations be solved. This article shows how the integrals are evaluated.
Torispherical heads are also called F&D or flanged and dished. The standard F&D head has f = 1.0 and kD = 3 times the metal thickness of the head. ASME F&D heads require a dish radius no greater than the diameter (f <= 1.0) and knuckle radius no less than 6% of the diameter (k >= 0.06) or three times the metal thickness, whichever is greater.
where k = knuckle radius D = vessel diameter h = fill height of the vessel n = R kD + (k2D2 x2)^0.5, where R = vessel radius (= D/2) w = R h It looks complicated, but solving in Excel is straightforward if it is done sequentially as described below. Integrals that are too complex to express implicitly are solved using
numerical methods. A number of
numerical methods have been used for integrals with Simpsons Rule being one
of the best. I chose to use Simpsons
Rule for this problem. (Other methods include
the trapezoidal rule, Riemann sums, Romberg integration, Gaussian quadratures and the Simpsons rule requires that the integral be broken into intervals. Since the integral is evaluating the area under a curve, from x=0 to x= (2kDh-h2)^.5, the method first calculates the maximum value for x, divides that by the number of intervals, and then evaluates the function for each value of x. In other words, if the maximum value of x was 10 and there were 10 intervals, then the function would be evaluated with x = 0, 1, 2, 3, 4, etc. Notice that the term called n above includes x in its formula. An even number of intervals is required. The more the better. I found through trial and error that a good number to use for this particular problem is 1000 intervals. Implementation could be done in a tabular form on an Excel worksheet. However, it is much more elegant to solve Simpsons Rule in a Visual Basic for Applications function subroutine. Listing 1 gives the function. This is located in a VBA Module within TankVolume. Each place the calculation is required, the function is called using a cell formula of the form: = Toris_V1(k, D, h) where the variables k, D, and h are as defined above. Since recalculation takes time, which can be noticable, I put the function call in a conditional statement so it is only used when the tank is horizontal with torispherical heads. Assume the variable head_type refers to the type of head and a value of head_type=4 refers to torispherical, the conditional function call becomes: = if(head_type=4,Toris_V1(k, D, h), 0) In this case, the function is called only if the heads are torispherical. Otherwise, a value of 0 is returned. This is perfectly fine since the result of this cell in the spreadsheet is only used for torispherical heads.
Listing 1: Simpsons RuleFunction
Toris_V1(k, D, H) As Double By: Stephen M. Hall, PE, Author of TankVolume (purchase the author's Software) |
ChE Plus Subscriber - Click Here for a Printable Version