concatenates_txt_files_sampling_algorithm_structural_analysis

Concatenates .txt files generated by the sampling algorithm for structural reliability analysis, and calculates failure probabilities and reliability indices (beta) based on the data.

results_about_data, failure_prob_list, beta_list = concatenates_txt_files_sampling_algorithm_structural_analysis(setup)

Input variables

Name Description Type
setup A dictionary containing the settings for the numerical model, including the folder path with the .txt files, the number of state limit functions or constraints, and the simulation name. Dictionary

Output variables

Name Description Type
results_about_data A DataFrame containing the concatenated results from the .txt files. DataFrame
failure_prob_list A list containing the calculated failure probabilities for each indicator function. List
beta_list A list containing the calculated reliability indices (beta) for each indicator function. List

Here is an example explaining the structure of the .txt file that should be used as input in the function concatenates_txt_files_sampling_algorithm_structural_analysis. This file contains columns of random variables, limit state functions (or constraints), and indicator functions (I_), which are used to assess failure probability and reliability index.

File structure

The file should contain columns representing random variables (X_0, X_1, …), limit state functions (G_0, G_1, …), and indicator functions (I_0, I_1, …). Each row represents a sample from the experiment. The input .txt file should have the following format, with columns separated by tab (\t):

X_0    X_1    X_2    G_0    G_1    I_0    I_1
43.519 11.223 0.190  200.0  -2.0   0      1
40.185 11.044 0.247  225.0  -3.0   0      1
46.269 10.586 0.238  -10.0  -10.0  1      1
36.370 9.523  0.276  300.0  300.0  0      0
40.089 9.728  0.261  325.0  325.0  0      0
45.000 10.000 0.250  -50.0  50.0   1      0
40.000 10.000 0.250  0.01   0.5    0      0

¹X_0, X_1, X_2: Random variables representing inputs to the numerical model. And, G_0, G_1: Limit state functions, indicating whether a structure is in a safe state or failure (positive values indicate safety, negative values indicate failure).

¹ I_0, I_1: Indicator functions, based on the limit state functions, where 0 represents a safe state and 1 indicates failure.

Using the file in the function

Here’s an example of how to organize the directory structure for the input files and code used in the concatenates_txt_files_sampling_algorithm_structural_analysis function:

 └── PAREPY
       └── concatenates_txt_files_sampling_algorithm_structural_analysis.py
       └── exemple_notebook.ipynb
       └── concat_exemples
            └── file_0.txt
            └── file_1.txt
            └── file_2.txt
            ...
            └── file_n-1.txt
            └── file_n.txt

The .txt files must be in the directory specified in the 'folder_path' parameter of the setup, and it should follow the structure described above. The function concatenates_txt_files_sampling_algorithm_structural_analysis will read all .txt files in the folder, concatenate the data, and calculate the failure probability (pf) and reliability index (beta) for each I_ column.

Example 1

This example demonstrates how the concatenates_txt_files_sampling_algorithm_structural_analysis function processes a folder containing .txt files.

import os
import pandas as pd
from tabulate import tabulate
from parepy_toolbox import concatenates_txt_files_sampling_algorithm_structural_analysis

setup = {
    'folder_path': 'concat_exemples', 
    'number of state limit functions or constraints': 1,
    'numerical model': {
        'model sampling': 'MCS-TIME' 
    },
    'name simulation': 'simulation_results'  
}

results_about_data, failure_prob_list, beta_list = concatenates_txt_files_sampling_algorithm_structural_analysis(setup)

print(f'pf:\n{tabulate(failure_prob_list, headers="keys", tablefmt="pretty", showindex=False)}')
print(f'ϐ:\n{tabulate(beta_list, headers="keys", tablefmt="pretty", showindex=False)}')

Example Output:

13:10:54 - Uploading files!
13:10:59 - Finished Upload in 4.43e+00 seconds!
13:10:59 - Started evaluation beta reliability index and failure probability...
13:10:59 - Finished evaluation beta reliability index and failure probability in 1.99e-02 seconds!
13:11:14 - Voilà!!!!....simulation results saved in simulation_results_MCS-TIME_20240910-131059.txt
pf:
+-----------------------+
|          I_0          |
+-----------------------+
| 0.0018821428571428572 |
| 0.0025428571428571427 |
|        0.0031         |
| 0.0036321428571428572 |
| 0.003939285714285715  |
+-----------------------+
ϐ:
+--------------------+
|        I_0         |
+--------------------+
| 2.8972675555698797 |
| 2.8015539115836514 |
| 2.7370121664846363 |
| 2.684479412315009  |
| 2.6572298171875497 |
+--------------------+

¹The function expects to find multiple .txt files in the folder_path directory. Ensure that the file format follows the described structure, with columns separated by tabs (\t) and necessary columns (X_, G_, I_). This format ensures that the function can correctly concatenate the data and perform the expected calculations.