Michael Lloyd

Add-Ons for gas and liquid flow thru an orifice

13 posts in this topic

I converted some of my structured text routines to CLX Add-ons. If anyone is interested I would be happy to share. They are tried and true routines that I've used for years. Both are used for calculating flow through an orifice plate. Gas Routine: It follows AGA7 but does not include a calculation for a live NX19 z factor (if you don't know what that is then you probably don't need the add-on). I've compared it to TotalFlow's and Fisher ROC's and while I wouldn't use it for custody transfer it's very good for plant or system balancing. If you understand gas measurement then you'll understand the required inputs. Personally I map the input values to the tag with structured text and then lock the routine with a password so someone doesn't screw something up. Inputs: Atmospheric Pressure, Pressure Base, Temperature Base, Pipe ID, Plate Bore, Inches of Water, Flowing Pressure (PSIG), Flowing Temperature (°F), Specific Gravity, Z factor, Cp/Cv, Nitrogen Mol %, CO2 Mol%. You can set the last two to zero if you aren't correcting for btu Outputs: SCFH, MSCFD, MMSCFD, and #/Hr as well as Beta Ratio and the factors used to calculate flow through an orifice (Fr, Fgr, Fpb, etc) Liquid Routine: This is a much simpler routine. The result is extremely accurate if you feed it good data. The routine requires you to know, or at least guess accurately , what the flowing specific gravity of the fluid is as well as the specific gravity at 60°F. For processes that have widely varying temperature (for instance a hot oil heater. On cold startup the oil is 60 - 100° but when running it can be as much as 350 - 600°. The specific gravity of the oil varies significantly between the two conditions) I use a function generator (10 x and y data points) set up with specific gravity for the range of operating conditions. Neither routine requires the user to input factors. Inputs: Pipe ID, Plate Bore, Flowing Temperature, Specific gravity@ 60°F, Specific gravity@ flowing temperature °F, inches of water differential. Outputs: GPM, BPH, and #/HR (plus all of the intermediate calcs like Beta ratio, etc)
3 people like this

Share this post


Link to post
Share on other sites
You do mean AGA 3 don't you? I know picky, picky. Post it I'm sure someone will be interested. http://xivix.ca/AGA_ALL/AGA/ENG/AGA7.htm http://xivix.ca/AGA_ALL/AGA/ENG/AGA3.htm

Share this post


Link to post
Share on other sites
Yep. I've been doing a bunch of crude oil measurement station work lately (AGA7). I'll try to attach the little one and see how it goes. This is an example of how I map the IO. It doesn't have to be done this way. It's just how I do it. Doing it in a locked structured text file prevents accidental "fat fingering". Typically the result is fed to an alarm block and causes a shutdown so it's important that the data be somewhat protected. FI761.Hw := Analog[3].PV; I don't like the built in alarming so I have my own array tag for alarming. The differential pressure is here. The next line is the temperature FI761.F := Analog[9].PV; FI761.D := 4.026; FI761.Bore := 1.625; FI761.SG60 := 0.72; The thing that you can't see in the above is where FI761.SGF is coming from. I used a function generator to calculate the flowing specific gravity of the oil flowing through the orifice based on temperature. The mfg of the oil lists the specific gravity of the fluid from 0 thru 600° in 100° increments. I passed the result to the tag in the function block. In hindsight I wish that I would have been consistent and passed it to the tag in the same way as I did the other data. I can't attach the AddOn. It's not a permitted file type. The following is the program listing. If someone will give me a clue for how to attach the L5X I'll attach it instead // Calculations for liquid flow through an orifice plate If Hw <= 0.0 THEN Hw := 0.00; END_IF; b := Bore / D; // Beta ratio b2 := b**2; // Beta squared b3 := b**3; // Beta cubed b10:= b*10; // Beta times 10 s := (0.598 * b2) + (0.01 * b3) + ((0.00001947 * b2) * (b10) ** 4.425); n_gpm := 5.667; // Constant for calculating gallons per minute n_bph := 8.096; // Constant for calculating barrels per hour D2 := D ** 2; // Pipe ID Squared Fa := 1 + (0.000185 * (F - 68.0)); // Flowing temperature factor SgF := (SG_F ** 0.5) / SG60; // Specific Gravity Correction Factor Sqrt_Hw := Hw ** 0.5; // Square Root of the differential // Calculate Flow Rates GPM := s * n_gpm * D2 * Fa * SgF * Sqrt_Hw ; // Flow in gallons per minute BPH := s * n_bph * D2 * Fa * SgF * Sqrt_Hw ; // Flow in barrels per hour LBHR := GPM * 500 * SG60 ; // Flow in #/HR I put the constants into tags for identification. I originally wrote it without doing that and found that people wanted to know why there was a fixed constant multiplier (making sure I wasn't fudging a number I guess). I don't remember which flow measurement book that I pulled the equations from but they aren't something that I derived. The AGA3 version is way too big to post the code for here. Edited by Michael Lloyd

Share this post


Link to post
Share on other sites
Nice work. Zip it first then post.

Share this post


Link to post
Share on other sites
Thanks. I'll try to attach both. I just remembered that I put source protection on the files. What a pita I'm not going to strip the protection off You can either leave it and use my password... change it to yours... or strip it out completely. Doesn't matter to me but if you strip it out someone will probably screw it up... The pw should be m1958l The last character is a lowercase "ell" LF.zip AGA3.zip
1 person likes this

Share this post


Link to post
Share on other sites
Thanks I'm sure many will find them useful. I don't have the software to view unfortunately. Maybe you can put those in the download section. No, I don't know how that is done but maybe one of the moderators will do that for you.

Share this post


Link to post
Share on other sites
Hi Michael, your pipe diameter and bore sizes are in inches, correct? Thanks!

Share this post


Link to post
Share on other sites
That is correct. I map the parameters in structured text. You don't have to. You can just put them into the tag but if someone fat fingers the value it'll hose up the calc. That's the only reason I map them in Structured Text Like so for Liquid: //Flow Rate Calculation Mapping FI3005.HW := Analog[31].PV; This is one tag from a UDT that I made. It can be whatever you need it to be.FI3005.Tf := 85.0;FI3005.D := 6.065;FI3005.Bore := 3.250;FI3005.Sg60 := 0.75;FI3005.SgF := 0.80;FI3005.ngpm := 5.667;FI3005.nbph := 8.096;Gas is like so. It's a tad more involved calc (* Gas Flow *)FI201A.Atm := 14.696; // Atmospheric PressureFI201A.Pb := 14.696; // Base Pressure PSIAFI201A.Tb := 60.0; // Base Temperatre °FFI201A.Hw := Analog[8].PV; // Compressor Suction Flow Inches of WaterFI201A.Pf := Analog[4].PV; // Compressor Suction Pressure PSIGFI201A.Tf := Analog[25].PV; // Compressor Suction Temperature °FFI201A.D := 16.0; // Pipe IDFI201A.Bore := 7.5; // Plate BoreFI201A.Sg := 0.585; // Specific Gravity @ 60°FFI201A.Fpv := 1.0225; // FPvFI201A.CO2 := 0.0; // CO2 Mol %FI201A.N2 := 0.0; // Nitrogen Mol %FI201A.k := 1.29; // k Factor Both of these were cut and pastes from a live program

Share this post


Link to post
Share on other sites
Cool! Thanks!!

Share this post


Link to post
Share on other sites

I am looking for some routines or an AOI to do this but am not able to download the attachments.  Any help would be appreciated.

1 person likes this

Share this post


Link to post
Share on other sites

I am very interested in utilizing your AGA3 and AGA7 AOI's.  How can I get a hold of them to check them out?

Share this post


Link to post
Share on other sites

Are these add-ons still available? I would really like to get a copy of them

 

Share this post


Link to post
Share on other sites
On 2/17/2011 at 11:06 PM, Michael Lloyd said:

Thanks. I'll try to attach both. I just remembered that I put source protection on the files. What a pita I'm not going to strip the protection off You can either leave it and use my password... change it to yours... or strip it out completely. Doesn't matter to me but if you strip it out someone will probably screw it up... The pw should be m1958l The last character is a lowercase "ell" LF.zip AGA3.zip

Do you still have these add-ons? The attachments aren't showing. I am looking to perform AGA3 calcs in Studio 5000 and this would be extremely helpful.

 

Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now