Physics Documentation

The physics modules in HELPR implement models for fracture mechanics, fatigue, materials, and environment-specific pipeline behaviors.

api docu

Provides the public API for accessing HELPR physics models.

class helpr.api.CrackEvolutionAnalysis(outer_diameter, wall_thickness, flaw_depth, max_pressure, min_pressure, temperature, volume_fraction_h2, yield_strength, fracture_resistance, flaw_length, crack_growth_model=None, delta_c_rule=None, stress_intensity_method=None, surface=None, residual_stress_intensity_factor=None, weld_thickness=None, weld_yield_strength=None, weld_flaw_distance=None, weld_flaw_direction=None, weld_steel=None, weld_process=None, aleatory_samples=0, epistemic_samples=0, sample_type='deterministic', random_seed=None, max_cycles=None, cycle_step=None, fad_type=None)

Bases: object

Class to hold API capability for carrying out pipeline fracture and fatigue analyses.

crack_growth_model
max_cycles
cycle_step
nominal_input_parameter_values
sampling_input_parameter_values
number_of_aleatory_samples
number_of_epistemic_samples
sample_type
uncertain_parameters
random_seed
weld_flaw_direction
weld_steel
weld_process
nominal_load_cycling

Results from crack growth analysis for a deterministic (single) pipe instance.

Type:

dict

nominal_life_criteria

Life criteria results for a deterministic (single) pipe instance.

Type:

dict

load_cycling

Results from crack growth analysis for all samples in a probabilistic study.

Type:

dict

life_criteria

Life criteria results for all samples in a probabilistic study.

Type:

dict

ex_rates_plot

Filepath to generated rate plot.

Type:

str or None

crack_growth_plot

Filepath to generated crack growth plot.

Type:

str or None

apply_inspection_mitigation(probability_of_detection, detection_resolution, inspection_frequency, criteria, save_fig=False)

Run inspection and mitigation analysis on crack evolution results.

Parameters:
  • probability_of_detection (float) – Probability of a crack being detected at each inspection.

  • detection_resolution (float) – Crack depth that is detectable by inspection. For example, a value of 0.3 indicates any crack larger than 30% of wall thickness is detectable.

  • inspection_frequency (int) – Number of cycles between each inspection. For example, a 4-year inspection interval would have a frequency of 4 * 365 cycles.

  • criteria (str) – Failure criteria to select from life criteria results.

  • save_fig (bool, optional) – Flag for saving the hist and cdf plots to png files.

Returns:

  • filepath (list) – List of file paths to created hist and cdf figures

  • plot_data (list) – List of lists of data contained in generated figures

assemble_failure_assessment_diagram(save_fig=False)

Creates failure assessment diagram.

Parameters:

save_fig (bool, optional) – Flag for saving the diagram to a png file.

Returns:

A tuple containing:

  • plotany

    The generated failure assessment plot.

  • dataany

    Data associated with the plot.

Return type:

tuple

static calc_life_assessment_instance(stress_state, pipe, crack_growth, delta_c_rule, other_stress_state, max_cycles, cycle_step)

Calculate a life assessment for a single crack evolution instance

Parameters:
  • stress_state

  • pipe

  • weld

  • crack_growth

  • environment_specification

  • delta_c_rule

  • max_cycles

  • cycle_step

Returns:

all_cycles

Return type:

dict

check_parameter_names()

Ensures parameter object names match assigned parameter.

Raises:

ValueError – If any parameter object name does not match its assigned parameter name.

collect_intermediate_variables(analysis_modules, nominal=False)

Extracts intermediate variable values from analysis for pre and post processing steps

Parameters:
  • analysis_modules (dict) – Dictionary of analysis modules containing environmental and stress state information.

  • nominal (bool, optional) – If True, collects nominal intermediate variables; otherwise, collects sampling intermediate variables.

execute_crack_growth_analysis(analysis_modules, sample_size)

Starts the process running crack growth analysis.

gather_single_crack_cycle_evolution(single_pipe_index=None)

Gets results for a single pipe crack growth analysis from an ensemble analysis.

Parameters:

single_pipe_index (int, optional) – Index of requested pipe. Defaults to None.

Returns:

DataFrame of single pipe analysis results.

Return type:

pandas.DataFrame

gen_random_seed(random_seed)

Sets random seed for recreating.

Parameters:

random_seed (float) – The specified random seed or None.

Returns:

The generated random seed.

Return type:

int

generate_input_parameter_plots(save_figs=False)

Creates plots of the samples of the input parameters.

Parameters:

save_figs (bool, optional) – Flag for saving plots to PNG files. Defaults to False.

Returns:

Dictionary of file paths for the generated plots.

Return type:

dict

generate_probabilistic_results_plots(plotted_variable)

Creates ensemble of plots for probabilistic analysis results.

Parameters:

plotted_variable (list) – List of pipe life criteria to plot.

Raises:

ValueError – If the sample type is ‘deterministic’.

get_design_curve_plot()

Returns plot ready for GUI display.

get_random_seed()

Returns the random seed value.

Returns:

The random seed value.

Return type:

float

perform_deterministic_study()

Performs a deterministic analysis. Calculates crack growth evolution and then failure assessment

perform_probabilistic_study()

Performs a probabilistic analysis. Calculates crack growth evolution and then failure assessment

perform_study()

Starts crack evolution analysis study.

postprocess_single_crack_results(single_pipe_index=None, save_figs=False)

Postprocesses a single pipe’s results from an ensemble analysis. If no pipe index is specified, nominal results are shown.

Parameters:
  • single_pipe_index (int, optional) – Index of requested pipe. Defaults to None.

  • save_figs (bool, optional) – Flag that enables saving plots to png files. Defaults to False.

print_nominal_intermediate_variables()

Prints nominal values of intermediate variables

save_results(folder_name=None, output_dir=None)

Saves crack evolution simulation results.

Parameters:
  • folder_name (str, optional) – Folder name to store results into. Defaults to ‘Results/’.

  • output_dir (str, optional) – Directory path for creating the results folder. Defaults to current working directory.

set_random_state()

Sets up the random state.

setup_crack_growth_analysis(parameter_value_dict, sample_size)

Creates the underlying modules for the crack growth analysis.

setup_deterministic_study()

Setup modules for deterministic analysis.

setup_probabilistic_study()

Setup modules for probabilistic analysis.

setup_study()

Setup crack evolution analysis modules.

static specify_study(input_parameters, aleatory_samples, epistemic_samples, sample_type, random_state)

Builds up study framework in terms of study type, sample size distribution type, and uncertainty classification.

Parameters:
  • input_parameters (dict) – Dictionary of input parameters for the study.

  • aleatory_samples (int) – Number of aleatory samples.

  • epistemic_samples (int) – Number of epistemic samples.

  • sample_type (str) – Type of sampling (‘deterministic’, ‘random’, ‘lhs’, ‘bounding’, or ‘sensitivity’).

  • random_state (np.random.Generator) – Random state for reproducibility.

Returns:

The initialized study object based on the specified sample type.

Return type:

Sampling.UncertaintyStudy or Sampling.RandomStudy or Sampling.LHSStudy or Sampling.BoundingStudy or Sampling.OneAtATimeSensitivityStudy

Raises:

ValueError – If the sample_type is not one of the valid options.

settings docu

Monitors the state of crack evolution calculations.

class helpr.settings.Status(value)

Bases: Enum

Defines analysis status flags.

helpr.settings.get_settings_str()

function get analysis settings in a string format

helpr.settings.is_finished()

Checks if analysis ran to completion.

helpr.settings.is_stopped()

Checks if analysis was stopped.

helpr.settings.is_stopping()

Checks if analysis stopping flag is set.

crack_growth docu

Implements fatigue crack growth models used for damage evolution.

class helpr.physics.crack_growth.CrackGrowth(environment, growth_model_specification)

Bases: object

Definition for crack growth physics model.

environment_specification
model_arguments
delta_k
delta_a
delta_n
r_ratio
calc_air_curve_da(c=6.89E-12, m=3)

Calculate delta A (crack size increment) based on an air reference curve.

Uses a default Paris Law with typical values for air.

Parameters:
  • c (float, optional) – Paris Law constant. Default is 6.89E-12.

  • m (float, optional) – Paris Law exponent. Default is 3.

Returns:

Crack size increment (delta A).

Return type:

float

calc_air_curve_dn(c=6.89E-12, m=3)

Delta N from air curve using default Paris Law.

Parameters:
  • c (float, optional) – Paris Law constant.

  • m (float, optional) – Paris Law exponent.

Returns:

Change in number of cycles.

Return type:

float

calc_change_in_crack_size(delta_n, delta_k, r_ratio, cycle_index=0)

Calculates the change in crack size (delta A) based on cycles and selected model.

Parameters:
  • delta_n (float) – Number of load cycles.

  • delta_k (float) – Stress intensity factor range.

  • r_ratio (float) – Load ratio, between 0 and 1.

  • cycle_index (int, optional) – Index of pressure cycle value, defaults to 0.

Returns:

Calculated change in crack size (delta A).

Return type:

float

Raises:

ValueError – If required model parameters are not provided or model is invalid.

calc_code_case_2938_da_higher_k(parameter=1.5E-11, m=3.66, multiplier=2)

Calculates delta a (change in crack size) for higher K values following code case 2938 (stress driven).

Parameters:
  • parameter (float, optional) – Base Paris Law constant for crack growth. Default is 1.5E-11.

  • m (float, optional) – Paris Law exponent. Default is 3.66.

  • multiplier (float, optional) – Multiplier applied to the fugacity correction term. Default is 2.

Returns:

Estimated crack size increment (Δa) in meters.

Return type:

float

calc_code_case_2938_da_lower_k(parameter=3.5E-14, m=6.5, multiplier=0.4286)

Calculate delta A (crack size increment) for lower K values using Code Case 2938.

This method applies a hydrogen-driven model with fugacity correction, based on the Paris Law.

Parameters:
  • parameter (float, optional) – Base Paris Law coefficient. Default is 3.5E-14.

  • m (float, optional) – Paris Law exponent. Default is 6.5.

  • multiplier (float, optional) – Multiplier for fugacity correction. Default is 0.4286.

Returns:

Crack size increment (delta A).

Return type:

float

calc_code_case_2938_dn_higher_k(parameter=1.5E-11, m=3.66, multiplier=2)

Calculate delta N (number of cycles) for higher K values using Code Case 2938.

This method applies a stress-driven model with fugacity correction for hydrogen environments, using the Paris Law.

Parameters:
  • parameter (float, optional) – Base Paris Law coefficient. Default is 1.5E-11.

  • m (float, optional) – Paris Law exponent. Default is 3.66.

  • multiplier (float, optional) – Multiplier for fugacity correction. Default is 2.

Returns:

Estimated number of load cycles (delta N) for higher K values.

Return type:

float

calc_code_case_2938_dn_lower_k(parameter=3.5E-14, m=6.5, multiplier=0.4286)

Calculates delta N using Code Case 2938 at lower K.

Parameters:
  • parameter (float) – Paris Law parameter.

  • m (float) – Paris Law exponent.

  • multiplier (float) – Multiplier for fugacity correction.

Returns:

Change in number of cycles.

Return type:

float

calc_da_code_case_2938()

Calculate delta A using Code Case 2938.

Returns:

Change in crack size.

Return type:

float

calc_da_g202006()

Calculate delta A using G 202006 model.

Returns:

Change in crack size (delta A).

Return type:

float

calc_da_paris_law(c, m)

Calculates delta A using Paris Law: delta_A = delta_N * (c * delta_K^m)

Parameters:
  • c (float) – Paris Law constant.

  • m (float) – Paris Law exponent.

Returns:

Change in crack size. Returns 0 if any value is non-positive.

Return type:

float

calc_delta_n(delta_a, delta_k, r_ratio)

Calculates delta N (number of load cycles) based on selected crack growth model.

Parameters:
  • delta_a (float) – Change in crack size.

  • delta_k (float) – Stress intensity factor range.

  • r_ratio (float) – Load ratio (minimum load / maximum load), must be between 0 and 1.

Returns:

Calculated change in number of cycles (delta N).

Return type:

float

Raises:

ValueError – If required model parameters are not specified or if model name is invalid.

calc_dn_code_case_2938()

Calculate delta N using Code Case 2938.

Returns:

Change in number of cycles.

Return type:

float

calc_dn_g202006()

Calculate delta N using G 202006 model.

Returns:

Number of cycles (delta N).

Return type:

float

calc_dn_paris_law(c, m)

Calculates delta N using Paris Law: delta_N = delta_a / (c * delta_K^m)

Parameters:
  • c (float) – Paris Law constant.

  • m (float) – Paris Law exponent.

Returns:

Calculated change in number of cycles. Returns math.inf if any value is non-positive.

Return type:

float

calc_fugacity_correction(p, multiplier, case)

Calculate fugacity correction for Code Case 2938.

Parameters:
  • p (float) – Base Paris Law coefficient.

  • multiplier (float) – Correction multiplier.

  • case (str) – ‘low’ or ‘high’.

Returns:

Corrected Paris Law coefficient.

Return type:

float

calc_g202006_da_higher_k(parameter=1.2E-7, m=3, multiplier=3)

Calculates delta a (change in crack size) for high K values following DVGW Research Project G 202006 Final Report page 171. Dividing parameter by 1000 to convert from mm/cycle to m/cycle

Parameters:
  • parameter (float) – Paris Law parameter.

  • m (float) – Paris Law exponent.

  • multiplier (float) – Correction multiplier.

Returns:

Change in crack size.

Return type:

float

calc_g202006_da_lower_k(parameter=4.4E-13, m=7, multiplier=3)

Calculates delta a (change in crack size) for high K values following DVGW Research Project G 202006 Final Report page 171. Dividing parameter by 1000 to convert from mm/cycle to m/cycle

Parameters:
  • parameter (float) – Paris Law parameter.

  • m (float) – Paris Law exponent.

  • multiplier (float) – Correction multiplier.

Returns:

Change in crack size.

Return type:

float

calc_g202006_dn_higher_k(parameter=1.2E-7, m=3, multiplier=3)

Calculates delta a (change in crack size) for high K values following DVGW Research Project G 202006 Final Report page 171. Dividing parameter by 1000 to convert from mm/cycle to m/cycle

Parameters:
  • parameter (float) – Paris Law parameter.

  • m (float) – Paris Law exponent.

  • multiplier (float) – Correction multiplier.

Returns:

Change in number of cycles.

Return type:

float

calc_g202006_dn_lower_k(parameter=4.4E-13, m=7, multiplier=3)

Calculates delta a (change in crack size) for high K values following DVGW Research Project G 202006 Final Report page 171. Dividing parameter by 1000 to convert from mm/cycle to m/cycle

Parameters:
  • parameter (float) – Paris Law parameter.

  • m (float) – Paris Law exponent.

  • multiplier (float) – Correction multiplier.

Returns:

Change in number of cycles.

Return type:

float

calc_partial_pressure_correction(p, multiplier, case)

Calculates hydrogen partial pressure correction for delta a. Multiplying partial pressure x10 to convert from MPa to bar.

Parameters:
  • p (float) – Paris Law base constant.

  • multiplier (float) – Correction multiplier.

  • case (str) – ‘low’ or ‘high’, indicating the K-region.

Returns:

Corrected Paris Law coefficient.

Return type:

float

helpr.physics.crack_growth.get_design_curve(specified_r, max_pressure=None, min_pressure=None, temperature=None, volume_fraction_h2=None, environment_obj=None, crack_growth_model=None, samples=99)

Generates design curves (ΔK vs. da/dN) for given material/environment.

Parameters:
  • specified_r (float) – Load ratio R.

  • specified_fugacity (float, optional) – Fugacity ratio to override environment’s default.

  • max_pressure (float, optional) – Maximum pressure in MPa.

  • min_pressure (float, optional) – Minimum pressure in MPa.

  • temperature (float, optional) – Temperature in Kelvin.

  • volume_fraction_h2 (float, optional) – Volume fraction of hydrogen in gas.

  • environment_obj (EnvironmentSpecification, optional) – Predefined environment object. Used if pressure/temp/H2 are not given.

  • crack_growth_model (dict, optional) – Crack growth model specification dictionary.

  • samples (int, optional) – Number of samples in the curve.

Returns:

  • delta_k (list of float) – ΔK values used for the curve.

  • da_dn (list of float) – Corresponding da/dN values computed from the model.

Raises:

ValueError – If insufficient environment input is provided.

crack_initiation docu

Models the initial formation of cracks under cyclic loading.

class helpr.physics.crack_initiation.DefectSpecification(flaw_depth, flaw_length, surface='inside', location_factor=1)

Bases: object

Definition of crack initiation physics.

flaw_depth
flaw_length
surface
location_factor

environment docu

Represents environmental effects (e.g., corrosion) on pipeline behavior.

class helpr.physics.environment.EnvironmentSpecification(max_pressure, min_pressure, temperature, volume_fraction_h2, reference_pressure=106.0)

Bases: object

Pipe interior environment specification.

max_pressure
min_pressure
temperature
volume_fraction_h2
reference_pressure
fugacity

Fugacity coefficient of blended gas.

Type:

float

reference_fugacity

Fugacity coefficient of pure H2.

Type:

float

fugacity_ratio

(fugacity / reference fugacity) ** 1/2.

partial_pressure

Partial pressure of hydrogen gas [MPa].

Type:

float

calc_derived_quantities()

Calculates other attributes based on input parameters.

calc_fugacity(pressure, temperature, volume_fraction_h2)

Calculates fugacity.

Parameters:
  • pressure (Parameter) – Pressure inside the pipeline [MPa].

  • temperature (Parameter) – Temperature of gas inside the pipeline [K].

  • volume_fraction_h2 (Parameter) – Volume fraction of H2 in gas [%].

Returns:

Computed fugacity of hydrogen [MPa].

Return type:

float

static calc_fugacity_coefficient(pressure, temperature, co_volume=15.84)

Calculates fugacity using Abel-Noble EOS Reference Pressure.

Parameters:
  • pressure (float) – Pressure [MPa].

  • temperature (float) – Temperature [K].

  • co_volume (float, optional) – CO volume (b). Default is 15.84 [cm^3/mol].

Returns:

Calculated fugacity coefficient.

Return type:

float

calc_fugacity_ratio()

Calculates fugacity ratio.

Returns:

Calculated fugacity ratio.

Return type:

float

class helpr.physics.environment.EnvironmentSpecificationRandomLoad(max_pressure, min_pressure, temperature, volume_fraction_h2, reference_pressure=106.0)

Bases: EnvironmentSpecification

Pipe interior environment specification for case with random loading.

max_pressure
Type:

list, np.array

min_pressure
Type:

list, np.array

temperature
Type:

float

volume_fraction_h2
Type:

float

reference_pressure
Type:

float, list, np.array

fugacity

Fugacity coefficient of blended gas.

Type:

float

reference_fugacity

Fugacity coefficient of pure H2.

Type:

float

fugacity_ratio

(fugacity / reference fugacity) ** 1/2.

partial_presure

max pressure * H2 volume fraction

fracture docu

Implements fracture toughness models and failure prediction logic.

Module to hold fracture assessment diagram (FAD) functionality

class helpr.physics.fracture.FailureAssessment(fracture_resistance, yield_stress, fad_type)

Bases: object

Class for failure assessment calculations.

fracture_resistance
yield_stress
assess_failure_state(stress_intensity_factor, reference_stress_solution)

Calculate location of failure assessment diagram.

Parameters:
  • stress_intensity_factor (float or np.ndarray) – Applied stress intensity factor (K).

  • reference_stress_solution (float or np.ndarray) – Reference stress used for calculating load ratio.

Returns:

Tuple containing: - toughness_ratio : K / K_IC - load_ratio : σ_ref / σ_y

Return type:

tuple of float

helpr.physics.fracture.calc_combined_stress_intensity_factor(k_primary, k_secondary_residual, yield_strength, primary_ref_stress, crack_depth, crack_length)

Calculates the combined stress intensity factor based on the Level 2 Assessment procedure included in API 579-1 Section 9.4.3.2.

Parameters:
  • k_primary (float) – Primary stress intensity factor.

  • k_secondary_residual (float) – Secondary/residual stress intensity factor.

  • yield_strength (float) – Material yield stress.

  • primary_ref_stress (float) – Reference stress due to primary loading.

  • crack_depth (float) – Crack depth (a) in meters.

  • crack_length (float) – Crack length (2c) in meters.

Returns:

Combined maximum stress intensity factor.

Return type:

float

Notes

Includes calculation of φ₀ and ζ influence factors from tabulated data.

helpr.physics.fracture.calculate_failure_assessment(parameters, fatigue_results, stress_state, fad_type)

Calculates failure assessment values for load cycling results.

Parameters:
  • parameters (dict) – Analysis input parameters.

  • fatigue_results (dict) – Analysis load cycling results.

  • stress_state (GenericStressState) – Stress state specification.

  • fad_type (str) – Type of FAD calcualtion to be completed.

helpr.physics.fracture.determine_fad_values(fatigue_instance, stress_state, failure_assessment)

Determine the toughness and load ratios for a given fatigue instance based on the stress state and failure assessment.

Parameters:
  • fatigue_instance (dict) –

    A dictionary containing properties of the fatigue instance, including:

    • ’Kmax (MPa m^1/2)’: The primary stress intensity factor.

    • ’Kres (MPa m^1/2)’: The residual stress intensity factor.

    • ’a (m)’: The crack depth.

    • ’c (m)’: The crack length.

  • stress_state (object) –

    An object representing the stress state, which should have the following attributes:

    • stress_intensity_methodstr

      The method used to calculate stress intensity (‘anderson’ or ‘api’).

    • calc_stress_solutioncallable

      A method to calculate the stress solution based on crack depth for the ‘anderson’ method.

    • calc_ref_stress_apicallable

      A method to calculate the reference stress for the ‘api’ method.

  • failure_assessment (object) –

    An object that provides the method to assess the failure state. It should have the following method:

    • assess_failure_state(stress_intensity_factor, ref_stress_solution,

      crack_depth, crack_length)

Returns:

A tuple containing:

  • toughness_ratiofloat

    The calculated toughness ratio for the fatigue instance.

  • load_ratiofloat

    The calculated load ratio for the fatigue instance.

Return type:

tuple

Raises:

ValueError – If the specified stress intensity method is not ‘anderson’ or ‘api’.

helpr.physics.fracture.process_fatigue_instance(fatigue_instance, fracture_resistance, yield_stress, stress_state, fad_type)

Process a single fatigue instance to determine toughness and load ratios.

Parameters:
  • fatigue_instance (dict) – A dictionary representing the fatigue instance data.

  • fracture_resistance (float) – The fracture resistance parameter for the failure assessment.

  • yield_stress (float) – The yield stress parameter for the failure assessment.

  • stress (float) – The stress state associated with the fatigue instance.

  • fad_type (str) – Indicates the type of FAD to be computed.

Returns:

The updated fatigue instance with calculated toughness and load ratios.

Return type:

dict

inspection_mitigation docu

Models inspection intervals, mitigation strategies, and defect detection.

class helpr.physics.inspection_mitigation.InspectionMitigation(probability_of_detection, detection_resolution, inspection_frequency)

Bases: object

Inspection Mitigation - Determine when a pipe is inspected for cracks and mitigate cracks identified through inspection.

probability_of_detection
detection_resolution
inspection_frequency
static count_inspections_until_mitigated(mitigation_state: array, inspection_schedule: list)

Determines the number of inspections until the first ‘Mitigated’ state.

Parameters:
  • mitigation_state (np.ndarray) – State labels after mitigation (‘Mitigated’, etc.).

  • inspection_schedule (list) – Corresponding cycle numbers for each inspection.

Returns:

Cycle number when mitigation first occurred, or np.nan if none occurred.

Return type:

int or float

static determine_inspection_schedule(cycle_count: list, inspection_frequency) array

Determines the cycle counts where inspection occurs.

Parameters:
  • cycle_count (list) – List of total cycle values for a single sample.

  • inspection_frequency (float) – Frequency (in cycles) at which inspections are performed.

Returns:

Array of cycle numbers when inspections occur.

Return type:

np.ndarray

static inspect_crack(inspection_schedule: list, crack_size: list, failure_criteria: float, detection_resolution: float, cycle_count: list) tuple[int, ndarray]

Simulates an inspection of a pipe to determine the number of inspections where a crack is detectable but not failed yet, and returns an array indicating the state of the crack for each inspection.

Parameters:
  • inspection_schedule (list) – Cycle numbers at which inspections occur.

  • crack_size (list) – Crack size (a/t) values corresponding to cycle_count.

  • failure_criteria (float) – Crack size threshold for failure (a/t).

  • detection_resolution (float) – Crack size threshold for detectability (a/t).

  • cycle_count (list) – Total cycles corresponding to crack sizes.

Returns:

Array of inspection states: ‘Not Detectable’, ‘Detectable’, or ‘Failed’.

Return type:

np.ndarray

inspect_then_mitigate(load_cycling: list, failure_criteria: array, random_state=npr.default_rng()) list

Perform inspection and mitigation analysis on crack evolution results.

Parameters:
  • load_cycling (list) – Analysis load cycling results.

  • failure_criteria (numpy.ndarray) – Analysis failure criteria.

  • random_state (numpy.random, optional) – Random state, defaults to standard numpy rng.

Returns:

mitigated_cracks – List of bool values for each sample indicating whether or not the failure was mitigated.

Return type:

list

static mitigate_crack(state_array: ndarray, random_state: Generator, probability_of_detection: float) None

Determines if mitigation of a crack occurs based on the state array and probability of detection, and modifies the state_array directly to reflect mitigation.

Parameters:
  • state_array (np.ndarray) – Array of inspection states (‘Detectable’, etc.).

  • random_state (np.random.Generator) – Random generator for applying detection probability.

  • probability_of_detection (float) – Probability of mitigating a detected crack.

Returns:

Modified state array with entries possibly updated to ‘Mitigated’.

Return type:

np.ndarray

life_assessment docu

Handles the evolution of crack growth across loading cycles.

Copyright 2023-2025 National Technology & Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software.

You should have received a copy of the BSD License along with HELPR.

class helpr.physics.life_assessment.LifeAssessment(pipe_specification, stress_state, crack_growth, delta_c_rule, other_stress_state=None)

Bases: object

Class for running fatigue evolution analysis for a single sample.

pipe_specification
stress_state
crack_growth
delta_c_rule
other_stress_state
cycle_dict
cycle
calc_delta_k(k_max, k_res, r_ratio)

Calculates delta k value.

Parameters:
  • k_max (float) – Maximum stress intensity factor.

  • k_res (float) – Residual stress intensity factor.

  • r_ratio (float) – R ratio = K_min / K_max (adjusted).

Returns:

ΔK value for the cycle.

Return type:

float

calc_k_max_f_q(phi=math.pi / 2, previous_step_values=False)

Calculates k_max, f, and q values.

Parameters:
  • phi (float, optional) – Angle for SIF calculation. Default is π/2.

  • previous_step_values (bool, optional) – If True, use values from previous cycle.

Returns:

K_max, K_min, K_res, F, and Q values.

Return type:

tuple

calc_life_assessment(max_cycles, cycle_step)

Runs a fatigue crack life assessment analysis.

Parameters:
  • max_cycles (int or None) – Maximum number of cycles to run the life assessment for before stopping. If None, the assessment will run until instances reach a/t > 0.8. Note that an assessment may stop before reaching max_cycles if all instances reach a/t > 0.8 before that number of cycles. Default is None.

  • cycle_step (float or None) – Number of cycles to iterate by at each evaluation step. If None, the number of cycles will be dynamically adjusted each iteration based on the crack growth. Default is None.

Returns:

cycle_dict – Complete dict of results for all samples (lists).

Return type:

dict

static change_a_over_t_step_size(current_step_size, change_in_a_over_t)

Calculates a/t step size.

Parameters:
  • current_step_size (float) – Current step size.

  • change_in_a_over_t (float) – Change in a/t since the previous cycle.

Returns:

Adjusted step size for a/t.

Return type:

float

check_stopping_criteria(max_cycles)

Determines whether to stop life assessment based on current crack conditions and the maximum number of cycles.

Parameters:

max_cycles (int) – Max number of cycles allowed.

Returns:

True if assessment should stop, otherwise False.

Return type:

bool

compute_cycle_at()

Computes results for single a/t cycle.

compute_cycle_n(cycle_step)

Computes results for an explicit number of cycles.

create_clean_cycle()

Resets the cycle dictionary.

create_cycle_dict()

Initialize dictionary to store full fatigue crack analysis as lists

initial_cycle()

Sets up initial cycle dictionary.

initialize_c()

Initializes value of c based on initial a/c ratio in stress state module

selecting_a_over_t_step_size()

Adaptively calculates a/t step size.

Returns:

Suggested increment in a/t.

Return type:

float

step_through_cycles(max_cycles, cycle_step)

Loop through fatigue cycles until failure or max_cycles is reached.

Parameters:
  • max_cycles (int) – Maximum number of allowable load cycles.

  • cycle_step (float or None) – Number of cycles per step, or None for adaptive stepping.

update_a()

Calculates current crack depth (a) value.

update_a_over_t()

Calculates current a/t value.

update_c()

Calculates current crack width (c) value.

update_c_through_delta_k()

Updates cycle values for c, eta, k_max, k_res, f, q, and delta k.

update_cycle_dict()

Inserts single cycle results into overall analysis results.

update_delta_a()

Calculates current delta a value.

update_delta_k()

Updates delta k value at current cycle.

update_delta_n()

Calculates current delta n value.

update_k_values_f_q()

Updates k_max, k_min, k_res, f, and q values at current cycle.

update_r_ratio()

Updates r_ratio value at current cycle.

update_total_cycles()

Calculates current cycle count.

material docu

Defines material behavior, fatigue properties, and failure thresholds.

class helpr.physics.material.MaterialSpecification(yield_strength, fracture_resistance)

Bases: object

Class defining material specifications for base material and welds.

yield_strength
fracture_resistance

pipe docu

Defines pipe geometry, dimensions, and structural attributes.

class helpr.physics.pipe.Pipe(outer_diameter, wall_thickness)

Bases: object

Class defining physical Pipe properties.

outer_diameter
wall_thickness
pipe_avg_radius
inner_diameter
calc_average_radius()

Calculates the average pipe radius.

Returns:

The average radius of the pipe.

Return type:

float

calc_inner_diameter()

Calculates the inner diameter of the pipe.

Returns:

The inner diameter of the pipe.

Return type:

float

calc_t_over_r()

Calculates the ratio of wall thickness to inner radius.

Returns:

The ratio of wall thickness to inner radius.

Return type:

float

residual_stress docu

Defines the residual stress state.

class helpr.physics.residual_stress.CircumferentialWeld(pipe, environment, material, defect, weld_thickness, flaw_direction, heat_input, flaw_distance=0, weld_yield_strength=None)

Bases: Weld

Full penetration circumferential weld for straight pipe.

heat_input

Supplied heat input in J/mm.

Type:

float

norm_heat_input

Normalized heat input (J/mm per mm of wall thickness).

Type:

float

calc_par_resid_stress(x)

Calculates parallel residual stress at depth x in the wall, based on weld thickness and pipe geometry per API 579-1.

Parameters:

x (float) – Distance through the pipe wall from the inside surface, in meters.

Returns:

Attenuated parallel residual stress at depth x, in MPa.

Return type:

float

calc_par_stress_attenuation(stress)

Calculates attenuation of parallel residual stress based on flaw distance.

Parameters:

stress (float) – Unattenuated residual stress, in MPa.

Returns:

Attenuated parallel residual stress, in MPa.

Return type:

float

calc_perp_resid_stress(x)

Calculates perpendicular residual stress at depth x in the wall, based on normalized heat input and API 579-1 residual stress models.

Parameters:

x (float) – Distance through the pipe wall from the inside surface, in meters.

Returns:

Attenuated perpendicular residual stress at depth x, in MPa.

Return type:

float

calc_perp_stress_attenuation(stress)

Calculates attenuation of perpendicular residual stress based on flaw distance and pipe geometry.

Parameters:

stress (float) – Unattenuated residual stress, in MPa.

Returns:

Attenuated perpendicular residual stress, in MPa.

Return type:

float

class helpr.physics.residual_stress.FilletWeld(pipe, environment, material, defect, weld_thickness, flaw_direction, joint, surface, flaw_distance=0, weld_material=None, weld_yield_strength=None)

Bases: Weld

Full penetration fillet weld for pipe joint connections.

pipe_specification
environment_specification
material_specification
defect_specification
weld_thickness
flaw_direction
flaw_distance
weld_yield_strength
joint
surface
weld_material
calc_corner_branch_par_resid_stress(x)

Calculate residual stress parallel to the weld seam for a piping branch connection weld on a corner joint, as per API 579-1 Section 9D.10.4.2(a).

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Residual stress at the specified depth, in MPa.

Return type:

float

calc_corner_branch_perp_resid_stress(x)

Calculate residual stress perpendicular to the weld seam for a piping branch connection weld on a corner joint, as per API 579-1 Section 9D.10.4.1(a).

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Unattenuated residual stress, in MPa.

Return type:

float

calc_corner_pad_par_resid_stress(x)

Calculate residual stress parallel to the weld seam for a reinforcing pad shell fillet weld on a corner joint, as per API 579-1 Section 9D.10.3.2(a).

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Residual stress at the specified depth, in MPa.

Return type:

float

calc_corner_pad_perp_resid_stress(x)

Calculate residual stress perpendicular to the weld seam for a reinforcing pad shell fillet weld on a corner joint, as per API 579-1 Section 9D.10.3.1(a).

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Unattenuated residual stress, in MPa.

Return type:

float

calc_corner_pad_perp_stress_attenuation(stress)

Calculate stress attenuation perpendicular to the weld seam for a coner joint reinforcing pad shell fillet weld, as per API 579-1 Section 9D.10.3.1(b).

Parameters:

stress (float) – Initial residual stress, in MPa.

Returns:

Attenuated residual stress, in MPa.

Return type:

float

calc_corner_par_resid_stress(x)

Calculates parallel residual stress for a corner joint using surface-specific formula.

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Attenuated parallel residual stress, in MPa.

Return type:

float

calc_corner_perp_resid_stress(x)

Calculates perpendicular residual stress for a corner joint using surface-specific formula.

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Raw perpendicular residual stress, in MPa.

Return type:

float

calc_corner_setin_par_resid_stress(x)

Calculate residual stress parallel to the weld seam for a set-in nozzle weld at a corner joint, as per API 579-1 Section 9D.10.1.2(a).

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Residual stress at the specified depth, in MPa.

Return type:

float

calc_corner_setin_par_stress_attenuation(stress)

Calculate stress attenuation parallel to the weld seam for a corner joint set-in nozzle weld, as per API 579-1 Section 9D.10.1.2(b). This same guidance is used for the parallel stress attenuation for all other corner joint welds given in API 579-1, as per Sections 9D.10.2.2(b), 9D.10.3.2(b), and 9D.10.4.2(b).

Parameters:

stress (float) – Initial residual stress, in MPa.

Returns:

Attenuated residual stress, in MPa.

Return type:

float

calc_corner_setin_perp_resid_stress(x)

Calculates residual stress perpendicular to the weld seam for a set-in nozzle weld at a corner joint, as per API 579-1 Section 9D.10.1.1(a).

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Unattenuated residual stress, in MPa.

Return type:

float

calc_corner_setin_perp_stress_attenuation(stress)

Calculate stress attenuation perpendicular to the weld seam for a corner joint set-in nozzle weld, as per API 579-1 Section 9D.10.1.1(b). This same guidance is used for perpendicular stress attenuation for set-on and piping branch connection welds, as per Sections 9D.10.2.1(b) and 9D.10.4.1(b).

Parameters:

stress (float) – Initial residual stress, in MPa.

Returns:

Attenuated residual stress, in MPa.

Return type:

float

calc_corner_seton_par_resid_stress(x)

Calculate residual stress parallel to the weld seam for a set-on nozzle weld at a corner joint, as per API 579-1 Section 9D.10.2.2(a).

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Residual stress at the specified depth, in MPa.

Return type:

float

calc_corner_seton_perp_resid_stress(x)

Calculates residual stress perpendicular to the weld seam for a set-on nozzle weld at a corner joint, as per API 579-1 Section 9D.10.2.1(a).

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Unattenuated residual stress, in MPa.

Return type:

float

calc_par_resid_stress(x)

Calculates parallel residual stress at depth x based on joint and surface configuration.

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Attenuated parallel residual stress, in MPa.

Return type:

float

calc_par_stress_attenuation(stress)

Calculate stress attenuation parallel to the weld seam for a full penetration fillet weld.

Parameters:

stress (float) – Initial residual stress, in MPa.

Returns:

Attenuated residual stress, in MPa.

Return type:

float

calc_perp_resid_stress(x)

Calculates perpendicular residual stress at depth x based on joint and surface configuration.

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Attenuated perpendicular residual stress, in MPa.

Return type:

float

calc_perp_stress_attenuation(stress)

Calculate stress attenuation perpendicular to the weld seam for a full penetration fillet weld.

Parameters:

stress (float) – Initial residual stress, in MPa.

Returns:

Attenuated residual stress, in MPa.

Return type:

float

calc_tee_mainplate_resid_stress(x)

Calculate residual stress for a tee joint weld connecting to a main plate, as per API 579-1 Section 9D.11.1.1(a).

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Residual stress at the specified depth, in MPa.

Return type:

float

calc_tee_par_resid_stress(x)

Calculates parallel residual stress for a tee joint using surface-specific formula.

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Attenuated parallel residual stress, in MPa.

Return type:

float

calc_tee_perp_resid_stress(x)

Calculates perpendicular residual stress for a tee joint using surface-specific formula.

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Attenuated perpendicular residual stress, in MPa.

Return type:

float

calc_tee_stayplate_resid_stress(x)

Calculate residual stress for a tee joint weld connecting to a stay plate, as per API 579-1 Section 9D.11.2.1(a).

Parameters:

x (float) – Distance through the pipe wall, in meters.

Returns:

Residual stress at the specified depth, in MPa.

Return type:

float

calc_tee_stress_attenuation(stress)

Calculate stress attenuation for a tee joint fillet weld, as per API 579-1 Sections 9D.11.1.1(b), 9D.11.1.2(b), 9D.11.2.1(b), and 9D.11.2.2(b).

Parameters:

stress (float) – Initial residual stress, in MPa.

Returns:

Attenuated residual stress, in MPa.

Return type:

float

class helpr.physics.residual_stress.HeatInput

Bases: ABC

Abstract class for calculating heat input for welding processeses based on different known inputs.

abstract calc_heat_input()

Calculates the heat input in J/mm.

class helpr.physics.residual_stress.HeatInputFromPower(current, voltage, travel_speed)

Bases: HeatInput

Class for calculating heat input for welding processes based on known current, voltage, and weld travel speed.

current
voltage
speed
calc_heat_input()

Calculate the heat input.

Returns:

The calculated heat input in J/mm.

Return type:

float

class helpr.physics.residual_stress.HeatInputFromProcess(process, weld_steel)

Bases: HeatInput

Class for calculating heat input for welding processes based on known type of welding process and weld material, estimating based on values in Table 9D.1M of API 579-1.

process
weld_steel
calc_heat_input()

Returns a representative heat input value based on the given welding process and steel type.

Returns:

Heat input in J/mm, based on empirical values from API 579-1 Table 9D.1M.

Return type:

float

class helpr.physics.residual_stress.LongitudinalWeld(pipe, environment, material, defect, weld_thickness, flaw_direction, flaw_distance=0, weld_yield_strength=None)

Bases: Weld

Full penetration longitudinal weld for straight pipe.

calc_par_resid_stress(x)

Calculates the residual stress parallel to the weld at a given depth x through the pipe wall.

Parameters:

x (float) – Distance from the inside surface through the pipe wall, in meters.

Returns:

Attenuated parallel residual stress at depth x, in MPa.

Return type:

float

calc_par_stress_attenuation(stress)

Applies attenuation to the parallel residual stress based on the flaw’s distance from the weld.

Parameters:

stress (float) – Initial parallel residual stress, in MPa.

Returns:

Attenuated parallel residual stress, in MPa.

Return type:

float

calc_perp_resid_stress(x)

Calculates the residual stress perpendicular to the weld at a given depth x through the pipe wall.

Parameters:

x (float) – Distance from the inside surface through the pipe wall, in meters.

Returns:

Attenuated perpendicular residual stress at depth x, in MPa.

Return type:

float

calc_perp_stress_attenuation(stress)

Applies attenuation to the perpendicular residual stress based on the flaw’s distance from the weld.

Parameters:

stress (float) – Initial perpendicular residual stress, in MPa.

Returns:

Attenuated perpendicular residual stress, in MPa.

Return type:

float

class helpr.physics.residual_stress.Weld(pipe, environment, material, defect, weld_thickness, flaw_direction, flaw_distance=0, weld_yield_strength=None)

Bases: object

Parent class for types of pipe welds included in API 579-1 residual stress calculations.

pipe_specification
environment_specification
material_specification
defect_specification
weld_thickness
flaw_direction
flaw_distance
weld_yield_strength
abstract calc_par_resid_stress(x)

Calculates the residual stress parallel to the weld.

Parameters:

x (float) – Distance from the inside surface of the pipe wall, in meters.

Returns:

Parallel residual stress in MPa.

Return type:

float

abstract calc_par_stress_attenuation(stress)

Calculates the attenuation from the parallel residual stress based on the distance between the flaw and the weld.

Parameters:

stress (float) – Initial residual stress in MPa.

Returns:

Attenuated residual stress in MPa.

Return type:

float

abstract calc_perp_resid_stress(x)

Calculates the residual stress perpendicular to the weld.

Parameters:

x (float) – Distance from the inside surface of the pipe wall, in meters.

Returns:

Perpendicular residual stress in MPa.

Return type:

float

abstract calc_perp_stress_attenuation(stress)

Calculates the attenuation from the perpendicular residual stress based on the distance between the flaw and the weld.

Parameters:

stress (float) – Initial residual stress in MPa.

Returns:

Attenuated residual stress in MPa.

Return type:

float

calc_resid_stress(x)

Calculates the residual stress resulting from the weld affecting a flaw.

Parameters:

x (float) – The distance through the wall to measure at, in meters. Relative to the side opposite of the widest weld groove width or last weld pass (typically the inside surface).

Returns:

resid_stress – The residual stress from the weld at the selected location, in MPa.

Return type:

float

Raises:

ValueError – If x is greater than or equal to the wall thickness.

calc_resid_stress_intensity_factor(crack_depth)

Calculates stress intensity factor (k) from the residual stress of the weld.

Parameters:

crack_depth (float) – Depth of the crack through the wall, in meters.

Returns:

Stress intensity factor in MPa√m.

Return type:

float

stress_state docu

Handles applied loads, internal pressure, and stress calculations.

class helpr.physics.stress_state.GenericStressState(pipe, environment, material, defect, stress_intensity_method=None, preloaded_tables=None)

Bases: object

Parent Class for generic Stress State capabilities.

pipe_specification
environment_specification
material_specification
defect_specification
stress_intensity_method
initial_crack_depth
initial_crack_length
initial_a_over_c
percent_smys
calc_allowable_stress()

Calculates the pipe’s total allowable stress.

Returns:

Total allowable stress (MPa).

Return type:

float

calc_f()

Calculates the current f values.

Returns:

Current f value.

Return type:

float

calc_hoop_stress(remaining_thickness)

Calculates hoop stress.

Parameters:

remaining_thickness (float) – Remaining wall thickness (m).

Returns:

Calculated hoop stress (MPa).

Return type:

float

calc_initial_crack_depth()

Calculates initial crack depth.

Returns:

Initial crack depth (m).

Return type:

float

calc_longitudinal_stress(remaining_thickness)

Calculates longitudinal stress.

Parameters:

remaining_thickness (float) – Remaining wall thickness (m).

Returns:

Calculated longitudinal stress (MPa).

Return type:

float

calc_q(current_a_over_c)

Calculates Q variable from Equation (9B.95) in API 579-1.

Parameters:

current_a_over_c (float) – Crack depth to half-length ratio.

Returns:

Q correction factor.

Return type:

float

calc_remaining_wall_thickness(crack_depth)

Calculates the remaining (non-cracked) pipe wall thickness.

Parameters:

crack_depth (float) – Crack depth in meters.

Returns:

Remaining wall thickness in meters.

Return type:

float

calc_stress_intensity_factor(crack_depth, crack_length)

Calculates stress intensity factor (k).

Parameters:
  • crack_depth (float) – Depth of the crack (m).

  • crack_length (float) – Length of the crack (m).

calc_stress_solution(crack_depth)

Calculates stress solution.

Parameters:

crack_depth (float) – Crack depth in meters.

Raises:

ValueError – If the stress calculation is not specified for the generic stress class.

check_initial_stress_criteria()

Checks the initial stress state of the pipe.

Raises:

UserWarning – If the stress state exceeds 72% SMYS.

class helpr.physics.stress_state.InternalAxialHoopStress(pipe, environment, material, defect, stress_intensity_method, preloaded_tables=None)

Bases: GenericStressState

Stress State Class for Internal Axial Hoop Stress Cases.

api_infinite_crack_G_table
api_finite_crack_A_table
calc_G_parameters_finite_length(A, Q, phi)

Calculates influence coefficients for a finite length surface cracks based on equations in API 579-1 Section 9B.5.10.

Parameters:
  • A (object) – The A table object used for calculations.

  • Q (float) – The Q parameter used in calculations.

  • phi (float) – The angle to the crack tip (rad).

Returns:

A tuple containing: - float: G0 coefficient. - float: G1 coefficient. - float: G2 coefficient. - float: G3 coefficient. - float: G4 coefficient.

Return type:

tuple

calc_k_solution_finite_length_part_through_flaw_api(crack_depth, crack_length, phi=math.pi / 2)

Calculates stress intensity factor for longitudinal direction surface cracks with semi-elliptical shape, internal pressure (KCSCLE1), given in Equation (9B.186) in API 579-1 Section 9B.5.10.

Dimensional limits: 1. 0.0 <= a/t <= 0.8 2. 0.03125 <= a/c <= 2.0 3. phi <= pi/2; for pi/2 < phi <= pi, K_I(phi) = K_I(pi - phi) 4. 0.0 <= t/inner_radius <= 1.0

Parameters:
  • crack_depth (float) – The depth of the crack (m).

  • crack_length (float) – The length of the crack (m).

  • phi (float, optional) – The angle to the crack tip (rad). Default is π/2.

Returns:

A tuple containing: - float: The calculated stress intensity factor. - list: A list of f-values (not used for API method). - float: The calculated q-value.

Return type:

tuple

calc_k_solution_finite_length_part_through_internal_flaw(crack_depth, crack_length)

Calculates stress intensity factor for finite length part-through internal flaws.

Parameters:
  • crack_depth (float) – The depth of the crack (m).

  • crack_length (float) – The length of the crack (m).

Returns:

A tuple containing: - float: The scaled pressure multiplied by the square root of (π * crack_depth / q_value) and f_value. - float: The f-value associated with the calculation. - float: The q-value associated with the calculation.

Return type:

tuple

calc_k_solution_long_part_through_flaw_api(crack_depth, crack_length)

Calculates stress intensity factor for longitudinal direction surface cracks with infinite length, internal pressure (KCSCLL1), given in Equation (9B.176) in API 579-1 Section 9B.5.4.

Dimensional limits: 1. 0.0 <= a/t <= 0.8 2. 0.0 <= t/inner_radius <= 1.0

Parameters:
  • crack_depth (float) – Crack depth, a (m).

  • crack_length (float) – Crack length, 2c (m). Only used for q-value.

Returns:

  • float: Calculated stress intensity factor (MPa*sqrt(m)).

  • float: f-value (unused, returns NaN).

  • float: q-value used in the calculation.

Return type:

tuple

calc_k_solution_long_part_through_internal_flaw(crack_depth, crack_length)

Calculates K for long part-through internal flaws.

Parameters:
  • crack_depth (float) – Crack depth (m).

  • crack_length (float) – Crack length (m).

Returns:

  • float: K solution.

  • float: f-value.

  • float: q-value.

Return type:

tuple

calc_ref_stress_api(crack_depth)

Calculates reference stress using API 579-1 Annex 9C.5.10.

Parameters:

crack_depth (float) – Crack depth (m).

Returns:

Reference stress (MPa).

Return type:

float

Notes

Falls back to standard stress solution if crack length or depth is zero.

calc_stress_intensity_factor(crack_depth, crack_length, cycle_index=0, phi=math.pi / 2)

Calculates the stress intensity factor. For finite length flaws, either the Anderson analytical method (method='anderson') or the API 579-1 method (method='api') can be used.

Parameters:
  • crack_depth (float) – Crack depth (m).

  • crack_length (float) – Crack length (m).

  • cycle_index (int) – Index of loading profile, defaults to 0 for cases with fixed loading

  • phi (float, optional) – Angle to crack tip in radians. Default is pi/2.

Returns:

  • float: Maximum K (MPa * sqrt(m)).

  • float: Minimum K (MPa * sqrt(m)).

  • float: f-value.

  • float: q-value.

Return type:

tuple

Raises:

ValueError – If Anderson method is used for a non-interior crack.

calc_stress_solution(crack_depth)

Calculates stress solution.

Parameters:

crack_depth (float) – Crack depth (m).

Returns:

Calculated stress solution (MPa).

Return type:

float

check_anderson_solution_assumptions()

Checks validity of Anderson solution assumptions based on geometric limits.

Raises:

UserWarning – If geometry violates Anderson criteria for R_i/t or a/t.

check_api_solution_assumptions()

Checks that the inputs do not violate the API 579-1 dimensional limits

Raises:

UserWarning – If the crack depth to wall thickness ratio exceeds 0.8.

interp_table_parameters(table, **table_args)

Interpolates values for the influence coefficients based on provided in API 579-1. The table_args provided should match the dimensions in the provided table.

Parameters:
  • table (xarray.DataArray) – API 579-1 lookup table.

  • **table_args (dict) – Parameters used to interpolate the table.

Returns:

Interpolated value.

Return type:

float

Raises:

ValueError – If input parameter dimensions are inconsistent.

static load_api_tables(surface)

Loads the data from the necessary lookup tables from API 579-1.

Parameters:

surface (str) – Crack surface location. Must be either ‘inside’ or ‘outside’.

Returns:

  • api_infinite_crack_G_tablexarray.DataArray

    G table data for infinite surface cracks, filtered by surface.

  • api_finite_crack_A_tablexarray.DataArray

    A table data for finite surface cracks corresponding to the specified surface.

Return type:

tuple of xarray.DataArray

Raises:

ValueError – If surface is not ‘inside’ or ‘outside’.

class helpr.physics.stress_state.InternalCircumferentialLongitudinalStress(pipe, environment, material, defect, stress_intensity_method=None, preloaded_tables=None)

Bases: GenericStressState

Stress State Class for Internal Circumferential Longitudinal Stress Cases.

calc_f(q_value, radius_thickness_ratio, xi)

Calculates current f value.

Parameters:
  • q_value (float) – The calculated q-value.

  • radius_thickness_ratio (float) – The ratio of the pipe’s average radius to its wall thickness.

  • xi (float) – The ratio of crack length to wall thickness.

Returns:

The calculated geometry correction factor ‘f’.

Return type:

float

Notes

This empirical equation captures the interaction between geometry, crack length, and wall thickness, used to scale the longitudinal stress to estimate the stress intensity.

calc_stress_intensity_factor(crack_depth, crack_length, cycle_index=0)

Calculates stress intensity factor.

Parameters:
  • crack_depth (float) – Current crack depth, a (m)

  • crack_length (float) – Current crack length, 2c (m)

  • cycle_index (int) – Index of loading profile, default to 0 for fix loading cases

Returns:

A 4-element tuple containing:

  • k_maxfloat

    Maximum stress intensity factor (MPa√m).

  • k_minfloat

    Minimum stress intensity factor (MPa√m), adjusted by pressure ratio.

  • f_valuefloat

    The correction factor for the geometry and crack configuration.

  • q_valuefloat

    The q-factor accounting for the elliptical shape of the crack.

Return type:

tuple of float

Notes

The SIF is calculated using a modified form of the classical elliptical surface crack solution under internal pressure.

calc_stress_solution(crack_depth)

Calculates stress solution.

Parameters:

crack_depth (float) – Crack depth (m).

Returns:

The calculated longitudinal stress based on the remaining wall thickness.

Return type:

float

helpr.physics.stress_state.calc_r_ratio(k_min, k_max, k_res=0)

Calculates the R ratio from applied stresses.

Parameters:
  • k_min (float) – Minimum stress intensity factor.

  • k_max (float) – Maximum stress intensity factor.

  • k_res (float, optional) – Residual stress intensity factor (default is 0).

Returns:

Calculated R ratio.

Return type:

float

helpr.physics.stress_state.open_nc_table(nc_file)

Opens a saved NetCDF file of lookup table values from API 579-1.

Parameters:

nc_file (str) – Name of the NetCDF file to load.

Returns:

Loaded data array from the NetCDF file.

Return type:

xarray.DataArray