Coupon Module#
Data prepration#
To install struct_post:
(.venv) $ pip install struct_post
Reading Coupon test data#
To read coupon test data, you can use struct_post.coupon.coupon_csvdata_read() function.
Functions#
- struct_post.coupon.coupon_csvdata_read(testdata_file_name, force_index, strain_index)[source]#
Read tensile coupon test data from a CSV file and extract force and strain columns.
- Parameters:
testdata_file_name (str) – Path to the CSV file containing the test data.
force_index (int) – 1-based column index for the force data.
strain_index (int) – 1-based column index for the strain data.
- Returns:
sample_name (str) – Name of the sample extracted from the file name.
df_new (pd.DataFrame) – DataFrame containing only ‘Force’ and ‘Strain’ columns.
Notes
CSV must have a header in the first row; second row is skipped.
First column is treated as index.
Force and strain columns are extracted based on 1-based indices.
- struct_post.coupon.coupon_test_analysis(sample_name, Force, Strain, thickness=2.5, width=10, showfig=True, savefig=False, low_bound=0.1, up_bound=0.3)[source]#
Post-process a tensile coupon test and plot stress-strain curve.
To active with Jupyter Lab, ‘%matplotlib widget’ is required
- Parameters:
Thickness (float) – Specimen thickness in mm.
Width (float) – Specimen width in mm.
file_name (str) – CSV file containing test data.
low_bound (float) – Lower bound of elastic region as fraction of UTS.
upper_bound (float) – Upper bound of elastic region as fraction of UTS.
sample_name (str)
Force (float)
Strain (float)
thickness (float)
width (float)
showfig (bool)
savefig (bool)
up_bound (float)
- Returns:
Figure object containing the plot.
- Return type:
fig (matplotlib.figure.Figure)
- struct_post.coupon.coupon_sample_geodata_read(Excelfile_name)[source]#
Reads sample geometric properties from an Excel file.
- Parameters:
Excelfile_name (str) – The name of the Excel file to read, located in the current working directory.
- Returns:
A list containing: - sample_file_name (sample name from cell A2 with “.csv” extension) - thickness (value from cell C2) - width (value from cell B2)
- Return type:
list
- struct_post.coupon.coupon_batch_analysis(Coupon_geodata, force_index, strain_index, showfig=True, savefig=False)[source]#
Perform batch analysis on a list of tensile coupon samples and return their results.
- Parameters:
Coupon_geodata (list of coupon_SampleDetails) –
A list of SampleDetails objects, each containing: - sample_file_name : str
Path to the sample CSV file.
- thicknessfloat
Sample thickness (mm).
- widthfloat
Sample width (mm)
force_index (int) – Column index of the Force data in the CSV file (1-based)
strain_index (int) – Column index of the Strain data in the CSV file (1-based)
showfig (bool, optional) – Whether to display stress-strain plots. Default is True
savefig (bool, optional) – Whether to save the stress-strain plots. Default is False
- Returns:
A list of SampleAnalysisResults objects, each containing:
- sample_namestr
Name of the processed sample
- modulus_of_elasticityfloat
Elastic modulus (E_GPa)
- ultimate_tensile_strengthfloat
Ultimate tensile strength (UTS_MPa)
- yield_strengthfloat
Yield strength (Yield_Strength_MPa)
- Return type:
list of coupon_SampleAnalysisResults
- struct_post.coupon.coupon_results_save(Excelfile_name, analysis_results)[source]#
Save a list of sample analysis results into an Excel file, matching by sample name.
- Parameters:
Excelfile_name (str) – Path to the Excel file to save the results.
analysis_results (list) – A list of SampleAnalysisResults objects, each containing: - sample_name - modulus_of_elasticity - ultimate_tensile_strength - yield_Strength
Notes
Assumes the Excel file has sample names in column A, starting from row 2.
Data will be written starting from column D (fourth column).
Overwrites the original Excel file.