π¬
Solver Purpose & Physical Scope
Calculate ASME Section VIII Div 1 cylindrical shell thickness (UG-27), 2:1 ellipsoidal, torispherical, and hemispherical head thicknesses, and MAWP rating.
π Discipline: Tools
β‘ Precision: IEEE-754 64-bit Real(`real(8)`)
π₯ Total Downloads: 346 times
π Source File:
pressure_vessel_asme.f90
π calcul/Tools /
pressure_vessel_asme.f90
program pressure_vessel_asme
implicit none
integer :: iostat_val, mat_idx
double precision :: P_bar, P_MPa, T_degC, D_mm, R_mm, S_allow_MPa, E_joint, CA_mm
double precision :: t_hoop_mm, t_long_mm, t_shell_mm
double precision :: t_ellip_mm, t_tori_mm, t_hemi_mm
double precision :: mawp_shell_bar, t_corroded_mm, t_nom_mm
character(len=32) :: mat_name
! Read inputs
read(*,*,iostat=iostat_val) P_bar ! Design Internal Pressure [bar g]
read(*,*,iostat=iostat_val) T_degC ! Design Temperature [deg C]
read(*,*,iostat=iostat_val) D_mm ! Inside Diameter [mm]
read(*,*,iostat=iostat_val) S_allow_MPa ! Material Allowable Stress S [MPa]
read(*,*,iostat=iostat_val) E_joint ! Joint Efficiency E (0.7 - 1.0)
read(*,*,iostat=iostat_val) CA_mm ! Corrosion Allowance CA [mm]
read(*,*,iostat=iostat_val) t_nom_mm ! Nominal Selected Thickness [mm]
if (iostat_val /= 0) then
write(*,*) 'ERROR: Invalid inputs for ASME pressure vessel sizing.'
stop
end if
P_MPa = P_bar * 0.1d0
R_mm = D_mm / 2.0d0
! UG-27 Shell Thickness Formulas
t_hoop_mm = (P_MPa * R_mm) / (S_allow_MPa * E_joint - 0.6d0 * P_MPa) + CA_mm
t_long_mm = (P_MPa * R_mm) / (2.0d0 * S_allow_MPa * E_joint + 0.4d0 * P_MPa) + CA_mm
t_shell_mm = max(t_hoop_mm, t_long_mm)
! UG-32 Formed Heads Formulas
t_ellip_mm = (P_MPa * D_mm) / (2.0d0 * S_allow_MPa * E_joint - 0.2d0 * P_MPa) + CA_mm
t_tori_mm = (0.885d0 * P_MPa * D_mm) / (S_allow_MPa * E_joint - 0.1d0 * P_MPa) + CA_mm
t_hemi_mm = (P_MPa * R_mm) / (2.0d0 * S_allow_MPa * E_joint - 0.2d0 * P_MPa) + CA_mm
! MAWP of Cylindrical Shell
t_corroded_mm = max(0.5d0, t_nom_mm - CA_mm)
mawp_shell_bar = ((S_allow_MPa * E_joint * t_corroded_mm) / (R_mm + 0.6d0 * t_corroded_mm)) * 10.0d0
! Output Results
write(*,'(A)') '============================================================'
write(*,'(A)') ' THERMOFLUIDCALC β ASME SECTION VIII DIV 1 SIZING ENGINE'
write(*,'(A)') '============================================================'
write(*,'(A,F10.2,A)') 'Design Pressure P = ', P_bar, ' bar(g)'
write(*,'(A,F10.1,A)') 'Inside Diameter D = ', D_mm, ' mm'
write(*,'(A,F10.2,A)') 'Allowable Stress S = ', S_allow_MPa, ' MPa'
write(*,'(A,F10.2)') 'Joint Efficiency Factor E = ', E_joint
write(*,'(A,F10.2,A)') 'Corrosion Allowance CA = ', CA_mm, ' mm'
write(*,'(A)') '------------------------------------------------------------'
write(*,'(A,F10.2,A)') 'Required Shell Thickness = ', t_shell_mm, ' mm'
write(*,'(A,F10.2,A)') '2:1 Ellipsoidal Head Thk = ', t_ellip_mm, ' mm'
write(*,'(A,F10.2,A)') 'ASME Torispherical Head = ', t_tori_mm, ' mm'
write(*,'(A,F10.2,A)') 'Hemispherical Head Thk = ', t_hemi_mm, ' mm'
write(*,'(A,F10.2,A)') 'Shell MAWP (Nominal Thk) = ', mawp_shell_bar, ' bar(g)'
write(*,'(A)') '============================================================'
end program pressure_vessel_asme
π» How to Compile & Run Locally
1. Compilation (GNU Fortran / Intel oneAPI):
gfortran -O3 pressure_vessel_asme.f90 -o pressure_vessel_asme
2. Execution with input.txt redirection:
pressure_vessel_asme < input.txt
π Sample input.txt File Structure
Sample Data:
15.0 80.0 1500.0 138.0 0.85 2.0 14.0
Parameter Description:
Design Pressure P [bar g]\nDesign Temperature [Β°C]\nInside Diameter D [mm]\nAllowable Stress S [MPa]\nJoint Efficiency E\nCorrosion Allowance CA [mm]\nNominal Plate Thickness [mm]