Tests Documentation
These tests are written using pytest and can be run from the command line:
All tests can be evaluated via
pytestExecuting
pytestfrom thetestsdirectory or above within the repo will execute all testsExecuting
pytestwithin a specific directory will only execute tests in that directoryExecuting
pytest path/to/text_file.pywill only execute single specified test
Unit Tests
These tests ensure that individual HELPR components behave as expected.
test_crack_growth docu
Unit tests for crack growth models and their integration in the fatigue pipeline.
- class helpr.tests.unit_tests.test_crack_growth.CrackGrowthTestCase(methodName='runTest')
Bases:
TestCaseClass for units tests of crack growth module.
- max_pressure
Maximum pressure in MPa.
- Type:
float
- min_pressure
Minimum pressure in MPa.
- Type:
float
- r_ratio
Load ratio (minimum load / maximum load), must be between 0 and 1.
- Type:
float
- temperature
Temperature in Kelvin.
- Type:
float
- volume_fraction_h2
Volume fraction of hydrogen in gas.
- Type:
float
- delta_k
Stress intensity factor range.
- Type:
float
- delta_a
Change in crack size.
- Type:
float
- delta_n
Number of load cycles.
- Type:
float
- growth_model_specification
Specify whether ASME Code Case 2938 w/ fugacity correction (code_case_2938) or a generic Paris Law (paris_law) will be used.
- Type:
dict
- environment
Specification of the gaseous environment within the pipeline.
- Type:
- setUp()
Function to specify common inputs to crack growth module.
- tearDown()
Teardown function.
- test_0pct_h2()
Unit test for having no hydrogen in crack growth calculations.
- test_100pct_h2()
Unit test that crack growth following ASME curve.
- test_bad_crack_growth_model_specifications()
Unit test for passing invalid crack growth rate model.
- Raises:
ValueError – If the growth model specification is invalid or missing required parameters.
- test_calc_change_in_crack_size_missing_inputs()
Test calc_change_in_crack_size triggers error if delta_n or delta_k is None.
- Raises:
ValueError – If delta_n or delta_k is None.
- test_calc_code_case_2938_da_higher_k_direct()
Test calculation of delta A for Code Case 2938 at higher K values.
- test_calc_code_case_2938_dn_higher_k_direct()
Test calculation of delta N for Code Case 2938 at higher K values.
- test_calc_da_g202006_air_case()
Test delta_a from G202006 model when partial pressure is 0 (air curve path).
- test_calc_da_g202006_higher_k()
Trigger calc_g202006_da_higher_k.
- test_calc_da_g202006_path()
Test G 202006 model path for delta_a.
- test_calc_delta_n_missing_inputs()
Test calc_delta_n triggers error if delta_a or delta_k is None.
- Raises:
ValueError – If delta_a or delta_k is None.
- test_calc_delta_n_paris_law_missing_c_m()
Test error raised when Paris Law is selected without ‘c’ and ‘m’.
- Raises:
ValueError – If ‘c’ and ‘m’ are not specified for Paris Law.
- test_calc_dn_g202006_air_case()
Test delta_n from G202006 model when partial pressure is 0 (air curve path).
- test_calc_dn_g202006_higher_k()
Trigger calc_g202006_dn_higher_k.
- test_calc_dn_g202006_path()
Test G 202006 model path for delta_n.
- test_calc_g202006_da_higher_k_path()
Ensure calc_g202006_da_higher_k return path executes.
- test_calc_g202006_dn_higher_k_path()
Ensure calc_g202006_dn_higher_k return path executes.
- test_default()
Unit test of default behavior of crack growth module.
- test_design_curve_function()
Unit test to check that design curve calculation function performs as expected.
- test_get_design_curve_raises_value_error_without_inputs()
Test get_design_curve raises error when neither env_obj nor full inputs are passed.
- Raises:
ValueError – If neither env_obj nor full inputs are provided.
- test_invalid_fugacity_correction_case()
Unit test of passing invalid input to fugacity correction.
- Raises:
ValueError – If the case is not specified or is invalid.
- test_invalid_partial_pressure_correction_case()
Ensure ValueError raised for invalid ‘case’ in partial pressure correction.
- Raises:
ValueError – If the ‘case’ is not a valid value.
- test_partial_pressure_correction_high_case()
Test partial pressure correction explicitly with ‘high’ case.
- test_specify_paris_law_crack_growth()
Unit test of specifying inputs for a paris law crack growth model.
test_crack_initiation docu
Validates models for determining initial crack formation.
- class helpr.tests.unit_tests.test_crack_initiation.CrackInitiationTestCase(methodName='runTest')
Bases:
TestCaseClass for units test of crack initiation module
- location_factor
Location factor for the defect.
- Type:
float
- flaw_depth
Depth of the flaw.
- Type:
float
- flaw_length
Length of the flaw.
- Type:
float
- surface
Surface of the defect (inside or outside).
- Type:
str
- setUp()
Function for specifying common inputs to crack initiation module.
- tearDown()
Teardown function.
- test_bad_surface_specification()
Unit test of check that bad specifications of defect surface are caught.
- Raises:
ValueError – If the surface specification is invalid.
- test_default()
Unit test of default functionality of crack initiation module.
test_environment docu
Tests for the environmental effects on material degradation.
- class helpr.tests.unit_tests.test_environment.EnvironmentTestCase(methodName='runTest')
Bases:
TestCaseClass for unit tests of environment module.
- setUp()
Function to specify common inputs to environment module.
- tearDown()
Teardown function.
- test_calc_fugacity_numpy_path()
Test calc_fugacity triggers np.exp path with numpy input.
- test_fugacity_ratio()
Unit test of fugacity ratio calculation.
- test_h2_volume_fraction()
Unit test of changing h2 volume fraction in environment.
test_fracture docu
Tests fracture mechanics models and critical failure logic.
- class helpr.tests.unit_tests.test_fracture.MockStressState(method='anderson')
Bases:
objectMock class to simulate the stress state behavior.
- stress_intensity_method
Method used for calculating stress intensity.
- Type:
str
- calc_ref_stress_api(crack_depth)
Calculate the reference stress for the API method.
- Parameters:
crack_depth (float) – Depth of the crack.
- Returns:
Reference stress for the API method.
- Return type:
float
- calc_stress_solution(crack_depth)
Calculate the reference stress for the API method.
- Parameters:
crack_depth (float) – Depth of the crack.
- Returns:
Reference stress for the API method.
- Return type:
float
- class helpr.tests.unit_tests.test_fracture.TestFailureAssessment(methodName='runTest')
Bases:
TestCaseClass for unit tests of fracture module.
- fracture_resistance
Fracture resistance of the material.
- Type:
float
- yield_stress
Yield stress of the material.
- Type:
float
- failure_assessment
Failure assessment object.
- Type:
- setUp()
Set up test cases.
- test_assess_failure_state()
Test the assess_failure_state method.
- test_determine_fad_values_anderson()
Test the determine_fad_values function for Anderson method.
- test_determine_fad_values_api()
Test the determine_fad_values function for API method.
- test_determine_fad_values_invalid_type()
Test the determine_fad_values function with an invalid FAD type.
- test_process_fatigue_instance()
Test the process_fatigue_instance function.
test_inspection_mitigation docu
Tests inspection modeling and mitigation strategy logic.
- class helpr.tests.unit_tests.test_inspection_mitigation.InspectionMitigationTestCase(methodName='runTest')
Bases:
TestCaseClass for unit tests of Inspection Mitigation module.
- probability_of_detection
Probability of detection for the inspection.
- Type:
float
- detection_resolution
Detection resolution for the inspection.
- Type:
float
- inspection_frequency
Frequency of the inspection.
- Type:
int
- inspection_mitigation
InspectionMitigation object.
- Type:
- setUp()
Set up the test case with initial parameters.
- test_count_inspections_until_mitigated()
Test the count_inspections_until_mitigated method.
- test_determine_inspection_schedule()
Test the determine_inspection_schedule method.
- test_initialization()
Test the initialization of the InspectionMitigation class.
- test_inspect_crack()
Test the inspect_crack method.
- test_inspect_then_mitigate()
Test the inspect_then_mitigate method.
- test_mitigate_crack()
Test the mitigate_crack method.
test_life_assessment docu
Tests the evolution of crack cycles under fatigue loading.
- class helpr.tests.unit_tests.test_life_assessment.LifeAssessmentTestCase(methodName='runTest')
Bases:
TestCaseClass for unit tests of cycle evolution module.
- initial_flaw_length
Initial flaw length.
- Type:
float
- defect_det
Defect specification object.
- Type:
- material_det
Material specification object.
- Type:
- environment_det
Environment specification object.
- Type:
- stress_state_anderson_det
Stress state object using Anderson method.
- Type:
- stress_state_api_det
Stress state object using API method.
- Type:
- crack_growth_det
Crack growth object.
- Type:
- delta_c_rule
Delta c rule.
- Type:
str
- max_cycles
Maximum number of cycles.
- Type:
float
- cycle_step
Cycle step.
- Type:
float
- setUp()
Function to specify common cycle evolution inputs.
- tearDown()
Teardown function.
- test_bad_delta_c_rule_specification()
Test to check that improper delta_c_rule specifications fail.
- Raises:
ValueError – If delta_c_rule is not specified as ‘proportional’, ‘fixed’, or ‘independent’.
- test_calc_life_assessment_w_cycle_step()
Test to confirm the life assessment behaves properly when a cycle step is provided.
- test_calc_life_assessment_w_max()
Test to confirm the life assessment behaves properly when a max number of cycles is provided.
- test_calc_life_assessment_w_max_overridden()
Test to confirm the life assessment behaves properly when a max number of cycles is provided but a/t > 0.8 is reached before that number of cycles.
- test_calc_life_assessment_w_other_stress_badtype()
Test that the life assessment returns an error when other_stress_state is an invalid type.
- Raises:
TypeError – If other_stress_state is not of type float, Weld, or None.
- test_calc_life_assessment_w_other_stress_float()
Test that the life assessment behaves properly when a float is specified as another stress state.
- test_calc_life_assessment_w_other_stress_weld()
Test that the life assessment behaves properly when a weld is specified as another stress state.
- test_change_a_over_t_step_size_logic()
Test change_a_over_t_step_size returns correct adjusted step sizes.
- test_default()
Test default functionality of cycle evolution class.
- test_fixed_c()
Test to check crack length remains unchanged when specified even if the cycling still works properly.
- test_independent_c()
Test to check crack length independently propagates when specified.
- test_life_assessment_early_exit_due_to_stopping()
Test that life assessment exits early if settings.is_stopping() is True.
- test_proportional_c()
Test to check crack length ratio to a remains unchanged when specified even if the cycling still works properly.
test_material docu
Validates material property handling and definitions.
- class helpr.tests.unit_tests.test_material.MaterialTestCase(methodName='runTest')
Bases:
TestCaseClass for unit tests of material module.
- yield_strength
Yield strength of the material.
- Type:
float
- fracture_resistance
Fracture resistance of the material.
- Type:
float
- setUp()
Function for specifying common material module inputs.
- tearDown()
Teardown function.
- test_default()
Unit test of default behavior for material module.
test_parameter docu
Tests parameter definitions and handling infrastructure.
- class helpr.tests.unit_tests.test_parameter.ParameterTestCase(methodName='runTest')
Bases:
TestCaseClass for unit test of parameter module.
- lower_bound
Lower bound for the parameter.
- Type:
float
- upper_bound
Upper bound for the parameter.
- Type:
float
- name
Name of the parameter.
- Type:
str
- setUp() None
Set up the test case.
- tearDown() None
Teardown function.
- test_above_bounds()
Unit test of specifying parameter value above upper bound.
- Raises:
ValueError – If the parameter value is above the upper bound.
- test_below_bounds()
Unit test of specifying parameter value below lower bound.
- Raises:
ValueError – If the parameter value is below the lower bound.
- test_default()
Unit tests of default behavior of parameter module.
- test_get_length_invalid_type()
Test get_length with unsupported type to trigger ValueError.
- Raises:
ValueError – If the input type is not supported.
- test_get_length_list_and_array()
Test get_length with list and array inputs.
- test_get_length_scalar()
Test get_length with scalar float and int.
- test_make_array()
Unit test of specifying size of parameter object.
- Raises:
ValueError – If the size of the parameter value is not valid.
- test_passed_array()
Unit test of passing of parameter value in single element array to parameter module.
- test_passed_list()
Unit test of passing of parameter values in single element list to parameter module.
test_pipe docu
Tests pipe geometry, features, and structural attributes.
- class helpr.tests.unit_tests.test_pipe.PipeTestCase(methodName='runTest')
Bases:
TestCaseClass for pipe module unit tests.
- setUp()
Function to specify common inputs to pipe module.
- tearDown()
Teardown function.
- test_bad_pipe_size()
Unit tests of bad pipe size specification.
- Raises:
ValueError – If the wall thickness is greater than or equal to the outer diameter.
- test_simple_calcs()
Unit test to check simple pipe calculations
test_residual_stress docu
Tests specification of residual stress
- class helpr.tests.unit_tests.test_residual_stress.AdditionalResidualStressCoverage(methodName='runTest')
Bases:
TestCaseClass for additional unit tests of residual stress calculations.
- environment
Environment specification object with max pressure, min pressure, temperature, and volume fraction of hydrogen.
- Type:
- material
Material specification object with yield strength and fracture resistance.
- Type:
- defect
Defect specification object with flaw depth, flaw length, and surface.
- Type:
- weld_thickness
Thickness of the weld.
- Type:
float
- x
Value of x for the test case.
- Type:
float
- setUp()
Set up the test cases with the required parameters.
- test_circumferential_weld()
Unit test to check residual stress calculation for a circumferential weld.
- test_fillet_weld()
Unit test to check residual stress calculation for a fillet weld.
- class helpr.tests.unit_tests.test_residual_stress.CircumferentialWeldTestCase(methodName='runTest')
Bases:
TestCase- Class for unit tests of CircumferentialWeld objects and
accompanying residual stress calculations.
- environment
Environment specification object with max pressure, min pressure, temperature, and volume fraction of hydrogen.
- Type:
- material
Material specification object with yield strength and fracture resistance.
- Type:
- defect
Defect specification object with flaw depth, flaw length, and surface.
- Type:
- weld_thickness
Thickness of the weld.
- Type:
float
- heat
Heat for the test case.
- Type:
int
- x
Value of x for the test case.
- Type:
float
- setUp()
Set uo the test cases with the required parameters.
- test_calc_resid_stress()
Unit test to check residual stress for various configurations of a circumferential weld.
- test_calc_resid_stress_bad_x()
Unit test to check proper error handling if x is not less than the pipe wall thickness.
- Raises:
ValueError – If x is not less than the pipe wall thickness.
- test_circumferentialweld_bad_heat_input()
Unit test to check proper error handling if the heat input is negative.
- Raises:
ValueError – If the heat input is negative.
- class helpr.tests.unit_tests.test_residual_stress.FilletWeldTestCase(methodName='runTest')
Bases:
TestCaseClass for unit tests of FilletWeld objects and accompanying residual stress calculations.
- environment
Environment specification object with max pressure, min pressure, temperature, and volume fraction of hydrogen.
- Type:
- material
Material specification object with yield strength and fracture resistance.
- Type:
- defect
Defect specification object with flaw depth, flaw length, and surface.
- Type:
- weld_thickness
Thickness of the weld.
- Type:
float
- x
Value of x for the test case.
- Type:
float
- weld_material
Material of the weld
- Type:
str
- setUp()
Set up the test case with the required parameters.
- test_calc_corner_setin_perp_stress_attenuation_extremes()
Unit test to check stress attenuation calculation for a corner joint with a set-in surface.
- test_calc_resid_stress_corner()
Unit test to check residual stress for various configurations of a corner joint fillet weld.
- test_calc_resid_stress_tee()
Unit test to check residual stress for various configurations of a tee joint fillet weld.
- test_calc_tee_mainplate_high_x()
Unit test to check residual stress calculation for a tee joint with a mainplate surface.
- test_calc_tee_stayplate_low_t()
Unit test to check residual stress calculation for a tee joint with a stayplate surface and low wall thickness.
- test_calc_tee_stayplate_mid_t()
Unit test to check residual stress calculation for a tee joint with a stayplate surface and medium wall thickness.
- test_filletweld_bad_joint()
Unit test to check proper error handling if the joint type is invalid.
- Raises:
ValueError – If the joint type is not recognized.
- test_filletweld_bad_surface()
Unit test to check proper error handling if the surface type is invalid.
- Raises:
ValueError – If the surface type is invalid for the given joint type.
- test_filletweld_bad_weld_material()
Unit test to check proper error handling if the weld material type is invalid.
- Raises:
ValueError – If the weld material type is not recognized.
- test_filletweld_joint_surface_mismatch()
Unit test to check proper error handling if a corner joint surface is used for tee joint and vice versa.
- Raises:
ValueError – If the surface type is not valid for the given joint type.
- test_filletweld_material_not_specified()
Unit test to check that FilletWeld warns and defaults if weld_material is not specified for a piping branch corner weld.
- Raises:
UserWarning – If weld_material is not specified for a piping branch corner weld.
- test_invalid_flaw_direction_in_base_class()
Unit test to check proper error handling if the flaw direction is invalid.
- Raises:
ValueError – If the flaw direction is not recognized.
- test_tee_mainplate_resid_stress_small_t()
Unit test to check residual stress calculation for a tee joint with a mainplate surface and small wall thickness.
- class helpr.tests.unit_tests.test_residual_stress.HeatInputTestCase(methodName='runTest')
Bases:
TestCaseClass for unit tests of heat input objects.
- test_heat_input_from_power()
Check that the heat input math works correctly within the HeatInputFromPower class.
- test_heat_input_from_process()
Check that the heat input logic works correctly within the HeatInputFromProcess class.
- test_heat_input_from_process_bad_process()
Check that the proper error is raised if an invalid process is given.
- Raises:
ValueError – If the weld process is not recognized.
- test_heat_input_from_process_bad_steel()
Check that the proper error is raised if an invalid weld steel is given.
- Raises:
ValueError – If the weld steel is not recognized.
- class helpr.tests.unit_tests.test_residual_stress.LongitudinalWeldTestCase(methodName='runTest')
Bases:
TestCaseClass for unit tests of LongitudinalWeld objects and accompanying residual stress calculations.
- environment
Environment specification object with max pressure, min pressure, temperature, and volume fraction of hydrogen.
- Type:
- material
Material specification object with yield strength and fracture resistance.
- Type:
- defect
Defect specification object with flaw depth, flaw length, and surface.
- Type:
- weld_thickness
Thickness of the weld.
- Type:
float
- x
Value of x for the test case.
- Type:
float
- setUp()
Hook method for setting up the test fixture before exercising it.
- test_calc_resid_stress()
Unit test to check residual stress for various configurations of a longitudinal weld.
test_stress_state_unit docu
Tests loading and stress conditions applied to pipelines.
- class helpr.tests.unit_tests.test_stress_state_unit.InternalAxialHoopStressTestCase(methodName='runTest')
Bases:
StressStateTestCaseClass for unit tests of internal axial hoop stress class.
- stress_state_anderson
Instance of InternalAxialHoopStress class using Anderson’s method.
- Type:
- stress_state_api_internal
Instance of InternalAxialHoopStress class using API method for internal cracks.
- Type:
- stress_state_api_external
Instance of InternalAxialHoopStress class using API method for external cracks.
- Type:
- setUp()
Set up the test case.
- test_calc_k_solution_finite_length_api_reshapes()
Test reshaping in calc_k_solution_finite_length_part_through_flaw_api.
- test_load_api_table_invalid_surface()
Unit test to check an exception is raised when an invalid surface is specified when loading API table.
- Raises:
ValueError – If the surface is not ‘inside’ or ‘outside’.
- test_ref_stress_api()
Unit test to check default behavior of API reference stress solution method for typical inputs.
- test_ref_stress_api_with_zero_crack()
Test calc_ref_stress_api triggers fallback for zero crack depth.
- test_stress_intensity_factor_anderson_external()
Unit test to check that axial hoop stress intensity factor calculated with Anderson’s equation produces error message for external crack.
- Raises:
ValueError – If the Anderson stress intensity method is used for an external crack.
- test_stress_intensity_factor_anderson_internal()
Unit test to check that axial hoop stress intensity factor calculated with Anderson’s equation produces expected values (hand calc) for internal crack.
- test_stress_intensity_factor_invalid_method()
Unit test to check an exception is raised when a method other than Anderson or API is specified.
- Raises:
ValueError – If the stress_intensity_method is not ‘anderson’ or ‘api’.
test_unit_conversion docu
Tests unit converstions.
- helpr.tests.unit_tests.test_unit_conversion.test_convert_in_to_m()
Test conversion from inches to meters.
- helpr.tests.unit_tests.test_unit_conversion.test_convert_ksi_to_mpa()
Test conversion from ksi to MPa.
- helpr.tests.unit_tests.test_unit_conversion.test_convert_psi_to_mpa()
Test conversion from psi to MPa.
- helpr.tests.unit_tests.test_unit_conversion.test_get_variable_units_non_plotting(var, expected)
Test getting variable units for non-plotting.
- Parameters:
var (str) – Variable name.
expected (str) – Expected unit string.
- helpr.tests.unit_tests.test_unit_conversion.test_get_variable_units_plotting(var, expected)
Test getting variable units for plotting.
- Parameters:
var (str) – Variable name.
expected (str) – Expected unit string.
Integration Tests
These tests check the integration of various modules used to complete a full analysis.
test_api docu
Tests the internal API of HELPR modules.
- class helpr.tests.integration_tests.test_api.APITestCase(methodName='runTest')
Bases:
TestCaseClass for unit tests of api module.
- outer_diameter
Outer diameter of the pipe.
- Type:
Uncertainty.DeterministicCharacterization
- wall_thickness
Wall thickness of the pipe.
- Type:
Uncertainty.DeterministicCharacterization
- flaw_depth
Depth of the flaw.
- Type:
Uncertainty.DeterministicCharacterization
- max_pressure
Maximum pressure.
- Type:
Uncertainty.DeterministicCharacterization
- min_pressure
Minimum pressure.
- Type:
Uncertainty.DeterministicCharacterization
- temperature
Temperature.
- Type:
Uncertainty.DeterministicCharacterization
- volume_fraction_h2
Volume fraction of hydrogen.
- Type:
Uncertainty.DeterministicCharacterization
- yield_strength
Yield strength of the material.
- Type:
Uncertainty.DeterministicCharacterization
- fracture_resistance
Fracture resistance of the material.
- Type:
Uncertainty.DeterministicCharacterization
- flaw_length
Length of the flaw.
- Type:
Uncertainty.DeterministicCharacterization
- unc_flaw_depth
Uncertainty in the flaw depth.
- Type:
Uncertainty.NormalDistribution
- unc_temperature
Uncertainty in the temperature.
- Type:
Uncertainty.UniformDistribution
- unc_volume_fraction_h2
Uncertainty in the volume fraction of hydrogen.
- Type:
Uncertainty.UniformDistribution
- folder_path_deterministic
Path to the folder for deterministic results.
- Type:
str
- folder_path_probabilistic
Path to the folder for probabilistic results.
- Type:
str
- deterministic_study
Deterministic study object.
- Type:
- deterministic_results
Deterministic results object.
- Type:
- probabilistic_results
Probabilistic results object.
- Type:
- weld_thickness
Thickness of the weld.
- Type:
float
- weld_yield_strength
Yield strength of the weld.
- Type:
float
- weld_flaw_distance
Distance of the flaw from the weld.
- Type:
float
- weld_flaw_direction
Direction of the flaw with respect to the weld.
- Type:
str
- weld_steel
Type of steel used in the weld.
- Type:
str
- weld_process
Process used to create the weld.
- Type:
str
- assert_is_file(path)
Function to assert if file exists.
- Raises:
AssertionError – If the file does not exist.
- rm_tree(path)
Function to remove results save folder after unit test.
- setUp()
Function to specify common inputs to api module.
- tearDown()
Teardown function.
- test_api_bounding_sensitivity_study()
Unit test for specifying a bound value sensitivity study in api.
- test_api_deterministic_w_residual_stress()
Unit test for deterministic study with an explicitly given residual stress included in the inputs.
- test_api_deterministic_w_weld()
Unit test for deterministic study with weld parameters included in the inputs.
- test_api_lhs_sensitivity_study()
Unit test for specifying a bound value sensitivity study in api.
- test_api_nominal_evaluations()
Unit test for ensuring nominal probabilistic results match deterministic results.
- test_api_probabilistic_w_residual_stress()
Unit test for deterministic study with an explicitly given residual stress included in the inputs.
- test_api_probabilistic_w_weld()
Unit test for deterministic study with weld parameters included in the inputs.
- test_api_scalar_inputs()
Unit test for passing scaling inputs (deterministic evaluation) to api.
- test_api_uncertain_inputs()
Unit test for passing uncertain inputs to api.
- test_bad_study_type_specification()
Unit test for specifying a bound value sensitivity study in api.
- Raises:
ValueError – If the study type is not supported.
- test_create_failure_assessment_diagram()
Unit test for creating failure assessment diagram.
- test_create_input_parameter_plots()
Unit test for creating input parameter plots.
- test_create_probabilistic_plots()
Unit test for creating probabilistic plots.
- Raises:
ValueError – If the analysis results are not probabilistic.
- test_default_values_for_missing_optional_params()
Unit test to check that default values are used for missing optional parameters.
- test_generating_intermediate_variables()
Unit test for generating intermediate variables (derived from input variables).
- test_incorrect_parameter_name()
Unit test for warning of incorrect parameter name.
- Raises:
ValueError – If the parameter name is incorrect.
- test_inspection_mitigation_results()
Unit test for applying inspection mitigation function to crack evolution results.
- test_missing_weld_params_raises_type_error()
Unit test to check that a TypeError is raised when missing weld parameters are not provided.
- Raises:
TypeError – If the weld parameters are not provided.
- test_perform_probabilistic_study_stopping()
Unit test to simulate stopping condition in perform_probabilistic_study.
- test_postprocess_assigns_plot_when_plot_result_is_valid()
Unit test to confirm plot assignments when plot_result is not None.
- test_print_intermediate_variables()
Unit test for printing nominal intermediate variables.
- test_random_loading()
Unit test for using random load profiles
- Raises:
ValueError – If the cycle_step specification isn’t correct.
- test_random_loading_incorrect_time_stepping()
Unit test for erroring when cycle step = 1 isn’t selected for study using random loading profiles.
- Raises:
ValueError – If the cycle_step specification isn’t correct.
- test_reload_random_seed()
Unit test to check ability to use previous random seed.
- test_save_deterministic_results()
Unit test to check deterministic result saving capability.
- test_save_probabilistic_results()
Unit test to check probabilistic result saving capability.
- test_set_resid_stress_params_no_explicit_resid_stress()
Unit test to check that weld inputs are passed in properly if an explicit residual K is not provided.
- test_set_resid_stress_params_no_resid_stress()
Unit test to check that no residual stress is calculated if all weld inputs are None and explicit value is not provided.
- test_set_resid_stress_params_w_explicit_resid_stress()
Unit test to check that the residual stress defaults to the explicit input argument if both an explicit K and a weld are given.
- test_specifying_random_seed()
Unit test to check ability to specify random seed.
test_plots docu
Tests HELPR plotting functions for visual output consistency.
- class helpr.tests.integration_tests.test_plots.PlotsTestCase(methodName='runTest')
Bases:
PlotsTestCaseBaseClass for plotting functions.
- fig_dir
The directory where figures will be saved.
- Type:
str
- plotted_variable
The variable that will be plotted.
- Type:
str
- example_results_anderson
The results of a crack evolution analysis using the Anderson stress intensity method.
- Type:
- example_results_api
The results of a crack evolution analysis using the API stress intensity method.
- Type:
- single_life_criteria_result
The life criteria for a single pipe.
- Type:
dict
- single_load_cycling
The load cycling data for a single pipe.
- Type:
dict
- setUp()
Function to specify common inputs to plot functions.
- tearDown()
Function to clean up after each test.
- test_crack_growth_rate_plot()
Test for creation of crack growth rate plot.
- test_cycle_life_cdf_ci()
Test for creation of life criteria cdf confidence intervals plot.
- test_cycle_life_cdfs()
Test for creation of life criteria cdfs plot.
- test_cycle_life_criteria_scatter_plot_color_by_variable()
Test for creation of life criteria scatter plot with changing colors by variable.
- test_cycle_life_criteria_scatter_plot_no_color_by_variable()
Test for creation of life criteria scatter plot without changing colors by variable.
- test_cycle_life_pdf()
Test for creation of life criteria pdfs plot.
- test_design_curve_plot()
Test for creation of design curve plot.
- test_failure_assessment_diagram_anderson()
Test for creation of failure assessment diagram using the Anderson stress intensity method.
- test_failure_assessment_diagram_api()
Test for creation of failure assessment diagram using the API stress intensity method.
- test_inspection_mitigation_plots()
Test for creation of inspection mitigation plots.
- test_life_assessment_ensemble_plot()
Test for creation of life assessment plot for pipe ensemble.
- test_pipe_life_assessment_plot()
Test for creation of life assessment plot for single instance.
- test_sensitivity_results_plot()
Test for creation of sensitivity plot.
test_postprocessing docu
Tests postprocessing utilities for simulation output.
- class helpr.tests.integration_tests.test_postprocessing.PostProcessingTestCase(methodName='runTest')
Bases:
TestCaseUnit test for postprocessing module.
- yield_strength
The yield strength of the material, in MPa.
- Type:
float
- delta_c_rule
The delta c rule used for crack growth.
- Type:
str
- load_cycling
The result of the calc_life_assessment method, representing the load cycling data for the pipe.
- Type:
dict
- life_criteria
The result of the calc_pipe_life_criteria method, representing the life criteria for the pipe.
- Type:
dict
- setUp()
Function to specify common postprocessing inputs.
- tearDown()
Tear down function.
- test_calc_pipe_life_criteria_default_a_crit()
Test that a(crit)/t defaults to 0.8 if the pipe fracture resistance is never met.
- test_calc_pipe_life_criteria_hydrogen_impact()
Test that a(crit) and associated number of cycles match expected values from internal development notebook varying amount of hydrogen.
- test_calc_pipe_life_criteria_typical()
Test that a(crit) and associated number of cycles match expected values from the examples/demo_deterministic.ipynb notebook.
- test_crack_evolution_plotting()
Test for generating crack evolution plot.
- test_warn_cycles_to_a_crit_not_reached()
Test that a warning is raised when a_crit is not reached and a/t is small.
test_stress_state_integration docu
Tests integration of stress state information throughout dependent modules.
- class helpr.tests.integration_tests.test_stress_state_integration.InternalAxialHoopStressTestCase(methodName='runTest')
Bases:
StressStateTestCaseClass for unit tests of internal axial hoop stress class.
- stress_state_anderson
Internal axial hoop stress state object using the Anderson method.
- Type:
- stress_state_api_internal
Internal axial hoop stress state object using the API method for internal defects.
- Type:
- stress_state_api_external
Internal axial hoop stress state object using the API method for external defects.
- Type:
- setUp()
Sets up the test case by initializing the attributes.
- test_axial_hoop_stress_check()
Unit test of check of axial hoop stress exceeding yield strength.
- Raises:
Warning – If the axial hoop stress exceeds the yield strength.
- test_axial_hoop_stress_state_specification()
Unit test of internal axial hoop stress state specification.
- test_calc_G_parameters_finite_length_full_depth()
Unit test to check that interpolation of Table 9B12 produces expected G values (hand calc) for single of crack at full depth.
- test_calc_G_parameters_finite_length_other_point()
Unit test to check that interpolation of Table 9B12 produces expected G values (hand calc) for single of crack at specified point.
- test_calc_G_parameters_finite_length_surface()
Unit test to check that interpolation of Table 9B12 produces expected G values (hand calc) for single of crack at surface.
- test_check_anderson_solution_assumptions_a_over_t_violation()
- Unit test for function checking for catching violations of
a/t <= 0.8 assumption in Anderson method.
- Raises:
UserWarning – If the a/t ratio exceeds 0.8.
- test_check_anderson_solution_assumptions_r_i_over_t_violation()
Unit test for function checking for catching violation of 5 <= R_i/t <= 20 assumption in Anderson method.
- Raises:
UserWarning – If the R_i/t ratio is outside the range [5, 20].
- test_check_api_solution_assumptions_a_over_t_violation()
- Unit test for function checking for catching violations of
a/t <= 0.8 assumption in API 579-1 method.
- Raises:
UserWarning – If the a/t ratio exceeds 0.8.
- test_interp_table_parameters_Table_9B10_single_inputs_external()
Unit test to check that interpolation of Table 9B10 produces expected G values (hand calc) for single external crack.
- test_interp_table_parameters_Table_9B10_single_inputs_internal()
Unit test to check that interpolation of Table 9B10 produces expected values (hand calc) for single internal crack.
- test_interp_table_parameters_Table_9B12_single_inputs()
Unit test to check that interpolation of Table 9B12 produces expected A values (hand calc) for single crack.
- test_interp_table_parameters_Table_9B13_single_inputs()
Unit test to check that interpolation of Table 9B13 produces expected A values (hand calc) for single crack.
- test_ref_stress_api()
Unit test to check default behavior of API reference stress solution method for typical inputs.
- test_stress_intensity_factor_anderson_external()
Unit test to check that axial hoop stress intensity factor calculated with Anderson’s equation produces error message for external crack.
- Raises:
ValueError – If the Anderson stress intensity method is used for an external crack.
- test_stress_intensity_factor_anderson_internal()
Unit test to check that axial hoop stress intensity factor calculated with Anderson’s equation produces expected values (hand calc) for internal crack.
- test_stress_intensity_factor_api_external()
Unit test to check that axial hoop stress intensity factor calculated with API method produces expected value (hand calc) for external crack.
- test_stress_intensity_factor_api_internal()
Unit test to check that axial hoop stress intensity factor calculated with API method produces expected value (hand calc) for internal crack.
- class helpr.tests.integration_tests.test_stress_state_integration.StressStateTestCase(methodName='runTest')
Bases:
TestCaseClass for unit tests of stress state module.
- max_pressure
Maximum pressure value used in the tests.
- Type:
float
- min_pressure
Minimum pressure value used in the tests.
- Type:
float
- temperature
Temperature value used in the tests.
- Type:
float
- flaw_depth
Depth of the flaw used in the tests.
- Type:
float
- flaw_length
Length of the flaw used in the tests.
- Type:
float
- fracture_resistance
Fracture resistance value used in the tests.
- Type:
float
- yield_strength
Yield strength value used in the tests.
- Type:
float
- stress_intensity_method
Stress intensity method used in the tests.
- Type:
str
- internal_defect
Internal defect specification used in the tests.
- Type:
- external_defect
External defect specification used in the tests.
- Type:
- material
Material specification used in the tests.
- Type:
- environment
Environment specification used in the tests.
- Type:
- setUp()
Sets up the test case by initializing the attributes.
- test_calc_combined_stress_intensity_factor()
Unit test that the combined K solution returns the correct value for spot-checked values.
- test_calc_r_ratio()
Unit test of r ratio calculation.
- test_circumferential_longitudinal_stress_check()
Unit test of check of axial longitudinal stress exceeding yield strength.
- Raises:
Warning – If the axial longitudinal stress exceeds the yield strength.
- test_circumferential_longitudinal_stress_intensity_factor()
Unit test of check of axial longitudinal stress exceeding yield strength.
- test_circumferential_longitudinal_stress_state_specification()
Unit test of longitudinal stress states specification.
- test_generic_stress_state_specification()
Unit test of generic stress state state specification.
- Raises:
ValueError – If the generic stress state specification is invalid.
- test_open_nc_table()
Unit test to check that the NetCDF4 tables successfully generate a DataArray object.
Verification Tests
These tests validate HELPR’s numerical predictions against known results or benchmarks.
test_verification_crack_growth_rate docu
Verifies that computed crack growth rates match known reference data.
- class helpr.tests.verification_tests.test_verification_crack_growth_rate.VerificationCrackGrowth(methodName='runTest')
Bases:
TestCaseClass for verification tests of crack growth rate calculations.
- mean_error_metric
Mean error metric for verification tests (%)
- Type:
float
- max_error_metric
Maximum error metric for verification tests (%)
- Type:
float
- outer_diameter
Outer diameter of the pipe (m)
- Type:
Uncertainty.DeterministicCharacterization
- wall_thickness
Thickness of the pipe wall (m)
- Type:
Uncertainty.DeterministicCharacterization
- flaw_depth
Depth of the flaw (%)
- Type:
Uncertainty.DeterministicCharacterization
- max_pressure
Maximum pressure (MPa)
- Type:
Uncertainty.DeterministicCharacterization
- temperature
Temperature (K)
- Type:
Uncertainty.DeterministicCharacterization
- yield_strength
Yield strength (ksi)
- Type:
Uncertainty.DeterministicCharacterization
- fracture_resistance
Fracture resistance
- Type:
Uncertainty.DeterministicCharacterization
- flaw_length
Length of the flaw (m)
- Type:
Uncertainty.DeterministicCharacterization
- calculate_crack_evolution_error(truth, simulation_data)
Function for calculating % rel. err. between predictions and data.
- Parameters:
truth (pandas.DataFrame) – Truth data.
simulation_data (list of pandas.DataFrame) – Simulation data.
- Returns:
error – % relative error.
- Return type:
float
- calculate_error_metrics(truth, simulation_data)
Function for calculating error metrics.
- Parameters:
truth (pandas.DataFrame) – Truth data.
simulation_data (list of pandas.DataFrame) – Simulation data.
- Returns:
max_error (float) – Maximum error.
mean_error (float) – Mean error.
- setUp()
Set up common inputs for verification tests.
- tearDown()
Teardown function.
- test_dataset_1()
“Verification test using dataset 1.
- test_dataset_2()
Verification test using dataset 2.
- test_dataset_3()
Verification test using dataset 3.
- verification_raw_comparison_plot(verification_data, simulation_data, condition)
Function for creating verification comparison plots.
- Parameters:
verification_data (pandas.DataFrame) – Verification data.
simulation_data (list of pandas.DataFrame) – Simulation data.
condition (str) – Condition for plot title.