from digitalmodel.asset_integrity.rsf_calculations import calculate_rsf, check_ffs_level1
# Level 1 screening — General Metal Loss
result = calculate_rsf(
t_measured=0.280, # measured wall thickness (inches)
t_required=0.150, # required minimum wall thickness (inches)
t_nominal=0.375, # original design wall thickness (inches)
)
print(f"RSF: {result['rsf']:.4f}") # e.g. 0.7467
print(f"FFS: {result['ffs_acceptable']}") # True if RSF >= RSF_allowable (0.90)
print(f"MAWP ratio: {result['mawp_ratio']:.4f}")
# Level 1 acceptability check
check = check_ffs_level1(
t_measured=0.280,
t_required=0.150,
t_nominal=0.375,
design_pressure_psi=1200.0,
smys_psi=65000,
outer_diameter_in=12.75,
)
print(f"Level 1 acceptable: {check['acceptable']}")
print(f"MAWP remaining: {check['mawp_psi']:.1f} psi")
from digitalmodel.asset_integrity.rsf_calculations import remaining_life
# Linear corrosion model (most common)
life = remaining_life(
t_current=0.280, # measured wall (inches)
t_minimum=0.150, # required wall (code minimum)
corrosion_rate_in_per_yr=0.008, # measured corrosion rate
model="linear",
)
print(f"Remaining life: {life['remaining_years']:.1f} years")
print(f"Next inspection by: {life['inspection_date']}")
# Power-law model for accelerating corrosion
life_pw = remaining_life(
t_current=0.280,
t_minimum=0.150,
corrosion_rate_in_per_yr=0.008,
model="power_law",
power_law_exponent=1.3,
)
from digitalmodel.asset_integrity.rsf_calculations import process_ut_grid
# Read UT measurement grid from CSV
# CSV format: rows=axial positions, cols=circumferential positions, values=thickness (inches)
ctp = process_ut_grid(
csv_path="inspection_data/UT_grid_node_123.csv",
t_nominal=0.375,
t_required=0.150,
)
print(f"Minimum measured thickness: {ctp['t_min']:.4f} in")
print(f"Average thickness: {ctp['t_avg']:.4f} in")
print(f"Metal loss fraction: {ctp['metal_loss_pct']:.1f}%")
print(f"CTP grid shape: {ctp['grid_shape']}")
print(f"Points below t_required: {ctp['critical_points']}")