Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

External Pressure VBA Code

Status
Not open for further replies.

xsamp

Mechanical
Oct 14, 2014
6
Good evening,

Im trying to develop a code to dimension vessel code thickness using VBA. So, the internal pressure process is direct, but to external pressure, i need find a way to make my program find A and B values on ASME data tables.I hope you can help me with that.

Thank you
 
xsamp, you don't say but cylinders, Sec VIII, Div 1?

Regards,

Mike
 
I will work with cilinder an sphere vessel. So I believe that if i find a way do cilinder to external pressure, i would do with other kind of vessel. Im using Division I.
 
xsamp, OK, kind of an involved process. First, do some example problems by hand to understand it. I don't have any code for you but here's the general process for cylinders, following UG-28:

Tabular data for Fig. G might be represented by an array. Calculate Do / t & L / Do and select bracketing values for A. Calculate A by interpolation. Limiting values per various parts of UG-28 are tested at each step.

Select the proper external pressure data, based on material under consideration. Using the calculated value of A and external design temperature, select bracketing values of B.

Calculate B by performing two interpolations, on A and on temperature.

Depending on value of Do/ T, perform calculations per UG-28(c)(1) or UG-28(c)(2).

To calculate a required thickness, a thickness is assumed, external pressure calculated and the resulting value tested, iterating to a desired degree of convergance.

To check a given thickness only one pass through the process is needed, assuming the thickness is adequate.

Process is much the same for a sphere, but somewhat simpler.

Warning: I am not a particularily skilled programmer and I know nothing about VBA. Terms such as array may not be exactly correct.

Plan B: Use commmercial software.

Regards,

Mike
 
I got it SnTMan,

Unfortunately the data i have from ASME (Tabular G) is in pdf format. I understand I have to interpolate values, but do you know how can I get the equation that generates those graphics or another format of those tables? Im writing a work and I have to calculate it by myself, so I cant use commercial softwares.
 
xsamp, no I don't. Section II, Part D is the primary reference.

Regards,

Mike
 
An ex-colleague of me made the external pressure calc in Excel without VBA.
In gross lines, here's how it works. Please notice the formatting defines the visual representation in excel and the worksheets youll have have to make.
[ol 1]
[li]Creat a new Excel workbook. Make 1 sheet your calculation results sheet, where all inputs and results are defined, incl. material and temperature. The other sheet(s) are used for determing G, A and B.[/li]
[li]Make an input field for calculating D/t and L/D. Worst case, L/D is greater than 50[/li]
[li]Copy paste the table that belongs with figure G of II-D (table G) into excel, just by selecting the data in pdf, crtl+C | crtl + V. Excel has easy ways of re-organizing large amounts of data in row and columns in such a format you can easily work with that data (use the Data ribbon, and use "Text to columns"). Make an array or table. Now, and this is where Im on the same page as Mike (Im not a skilled programmer either - if someone in your company is, get him to join you).[/li]
[li]Determine your lower and higher D/T value that comes back in table G. Do the interpolation to find A from table G (this sounds easy, but should be pretty straightforward in excel for an experienced excel guru - no VBA required).[/li]
[li]Copy value A back into your input/result sheet[/li]
[li]Just as you can make an input for table G in excel, you can also do this for e.g. table HA-2 (this is 316). Once you get the hang of it, its fairly easy to get all material tables into excel.[/li]
[li]Assuming you use 316, thus HA-2, copy the found value of A into this sheet, and let the sheet determine the value of B, in the same way as defined in step 4.[/li]
[li]Copy value B back into your input/result sheet[/li]
[li]Now, you need to do some programming in excel (fairly easy using IF and AND statements) to determine if you have to follow how you can calculate UG-28(c)(1) or (c)(2). From there on, you can determine Pa (or Pa1/Pa2)[/li]
[/ol]

The programming will require some background data to be available. Ive found it easy to have all stress values from II-D table 1A in excel. Using VLOOKUP and INDEX functions, you can easily determine stress allowables based on the given temperature input.
In your input/result sheet, you could use a dropdown for selecting your material. With a VLOOKUP, excel then can easily determine the corresponding stress allowable that is used in determining Pa/Pa1/Pa2.

Hope this helps. In the end, run some test calcs by hand to determine if your calcs and programming are OK.
 
Thank you all. I''l try it. From my own good I hope it works. lol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor