API Reference
This section contains the auto-generated documentation from the helper functions for LSA of each FMG-FMG and FMM-FMG models (lsa_api.md). Tasks raning from generating the derivative-based normalized local sensitivity indices and loading parameter to performing the monte-carlo simulation for calculating the indices and visualizing them are executed separately by various functions.
FMG-FMG Model
scripts.LSA.fmg_lsa_utils
generate_derivatives()
Defines symbolic equations and returns lambdified derivative functions. Returns: funcs_dEp (dict): Dictionary of lambdified functions for derivatives of storage modulus. funcs_dEpp (dict): Dictionary of lambdified functions for derivatives of loss modulus.
Source code in scripts/LSA/fmg_lsa_utils.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
load_parameter_bounds(file_path, rows, cols, gnp_index, std_fctr=0.05)
Loads Excel data and calculates uniform distribution bounds. Args: file_path (dict): Dictionary containing paths to Excel files. rows (dict): A dictionary containing the start and end rows for reading the optimized parameters. cols (dict): A dictionary containing the column indices for reading the optimized parameters. gnp_index (int): Index for the GnP parameter set to extract means from. std_fctr (float): Standard deviation factor for calculating bounds. Returns: bounds (list): List of tuples containing (a, b) bounds for uniform distribution.
Source code in scripts/LSA/fmg_lsa_utils.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
run_monte_carlo(funcs_dEp, funcs_dEpp, bounds, params_list, w_freq, n_mc=10 ** 3, batch_size=50000)
Executes the MC simulation and returns result arrays. Args: funcs_dEp (dict): Dictionary of lambdified functions for derivatives of storage modulus. funcs_dEpp (dict): Dictionary of lambdified functions for derivatives of loss modulus. bounds (list): List of tuples containing lower and upper bounds for uniform distribution. w_freq (ndarray): Array of frequency values used in the simulation. n_mc (int): Number of Monte Carlo iterations. Returns: realized_indices (dict): Dictionary containing arrays of sensitivity indices for all moduli.
Source code in scripts/LSA/fmg_lsa_utils.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
save_statistics_npz(realized_indices, params, w_freq, HS, GnP, file_path)
Calculates mean and standard deviation of sensitivity indices, and L1 norm of mean sensitivity indices, followed by saving to a compressed NumPy archive. Args: realized_indices (dict): Dictionary containing arrays of sensitivity indices for all moduli. params (list): List of parameter names. w_freq (ndarray): Array of frequency values used in the simulation. HS (int): Heat treatment condition. GnP (str): GnP loading condition. file_path (dict): Dictionary containing paths to save the data.
Source code in scripts/LSA/fmg_lsa_utils.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
scripts.LSA.fmg_lsa_vis_utils
plot_local_sensitivity_indices(E_type, HS, GnP_list, file_path)
Plots the local sensitivity indices for the specified modulus type. Args: E_type (str): Type of modulus ('Ep', 'Epp', or 'Ecomplex'). HS (int): Heat treatment condition. GnP_list (list): List of GnP loading conditions. file_path (dict): Dictionary containing paths to save the plot and load data.
Source code in scripts/LSA/fmg_lsa_vis_utils.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
read_excel_range(filename, cell_range)
Read a specified range of cells from an Excel file and return it as a NumPy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the Excel file. |
required |
cell_range
|
str
|
Range of cells to read. |
required |
Returns:
| Type | Description |
|---|---|
|
np.ndarray: A NumPy array containing the values from the specified cell range. |
Source code in scripts/LSA/fmg_lsa_vis_utils.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
plot_L1_grouped(mean_S, std_S, ylabel, params_list=['$E_{c_1}$', '$\\tau_{c_1}$', '$\\alpha_1$', '$\\beta_1$', '$E_{c_2}$', '$\\tau_{c_2}$', '$\\alpha_2$'], legend_labels=('20% HSWF', '30% HSWF', '40% HSWF'), figsize=(6, 4), save_path=None)
Plot the L-infinity norm of the sensitivity indices for each parameter, grouped by GnP content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean_S
|
ndarray
|
Array of mean sensitivity indices. |
required |
std_S
|
ndarray
|
Array of standard deviations of sensitivity indices. |
required |
ylabel
|
str
|
Label for the y-axis. |
required |
params_list
|
list
|
List of parameter names. |
['$E_{c_1}$', '$\\tau_{c_1}$', '$\\alpha_1$', '$\\beta_1$', '$E_{c_2}$', '$\\tau_{c_2}$', '$\\alpha_2$']
|
legend_labels
|
tuple
|
Labels for the legend. |
('20% HSWF', '30% HSWF', '40% HSWF')
|
figsize
|
tuple
|
Figure size. |
(6, 4)
|
save_path
|
str
|
Path to save the plot. Defaults to None. |
None
|
Source code in scripts/LSA/fmg_lsa_vis_utils.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
FMM-FMG Model
scripts.LSA.fmm_lsa_utils
generate_derivatives()
Defines symbolic equations and returns lambdified derivative functions. Returns: funcs_dEp (dict): Dictionary of lambdified functions for derivatives of storage modulus. funcs_dEpp (dict): Dictionary of lambdified functions for derivatives of loss modulus.
Source code in scripts/LSA/fmm_lsa_utils.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
load_parameter_bounds(file_path, rows, cols, gnp_index, std_fctr=0.05)
Loads Excel data and calculates uniform distribution bounds. Args: file_path (dict): Dictionary containing paths to Excel files. rows (dict): A dictionary containing the start and end rows for reading the optimized parameters. cols (dict): A dictionary containing the column indices for reading the optimized parameters. gnp_index (int): Index for the GnP parameter set to extract means from. std_fctr (float): Standard deviation factor for calculating bounds. Returns: bounds (list): List of tuples containing (a, b) bounds for uniform distribution.
Source code in scripts/LSA/fmm_lsa_utils.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
run_monte_carlo(funcs_dEp, funcs_dEpp, bounds, params_list, w_freq, n_mc=10 ** 3, batch_size=50000)
Executes the MC simulation and returns result arrays. Args: funcs_dEp (dict): Dictionary of lambdified functions for derivatives of storage modulus. funcs_dEpp (dict): Dictionary of lambdified functions for derivatives of loss modulus. bounds (list): List of tuples containing lower and upper bounds for uniform distribution. w_freq (ndarray): Array of frequency values used in the simulation. n_mc (int): Number of Monte Carlo iterations. Returns: realized_indices (dict): Dictionary containing arrays of sensitivity indices for all moduli.
Source code in scripts/LSA/fmm_lsa_utils.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
save_statistics_npz(realized_indices, params, w_freq, HS, GnP, file_path)
Calculates mean and standard deviation of sensitivity indices, and L1 norm of mean sensitivity indices, followed by saving to a compressed NumPy archive. Args: realized_indices (dict): Dictionary containing arrays of sensitivity indices for all moduli. params (list): List of parameter names. w_freq (ndarray): Array of frequency values used in the simulation. HS (int): Heat treatment condition. GnP (str): GnP loading condition. file_path (dict): Dictionary containing paths to save the data.
Source code in scripts/LSA/fmm_lsa_utils.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
scripts.LSA.fmm_lsa_vis_utils
plot_local_sensitivity_indices(E_type, HS, GnP_list, file_path)
Plots the local sensitivity indices for the specified modulus type. Args: E_type (str): Type of modulus ('Ep', 'Epp', or 'Ecomplex'). HS (int): Heat treatment condition. GnP_list (list): List of GnP loading conditions. file_path (dict): Dictionary containing paths to save the plot and load data.
Source code in scripts/LSA/fmm_lsa_vis_utils.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
read_excel_range(filename, cell_range)
Read a specified range of cells from an Excel file and return it as a NumPy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the Excel file. |
required |
cell_range
|
str
|
Range of cells to read. |
required |
Returns:
| Type | Description |
|---|---|
|
np.ndarray: A NumPy array containing the values from the specified cell range. |
Source code in scripts/LSA/fmm_lsa_vis_utils.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
plot_L1_grouped(mean_S, std_S, ylabel, params_list=['$E_{c_1}$', '$\\tau_{c_1}$', '$\\alpha_1$', '$\\beta_1$', '$E_{c_2}$', '$\\tau_{c_2}$', '$\\alpha_2$'], legend_labels=('20% HSWF', '30% HSWF', '40% HSWF'), figsize=(6, 4), save_path=None)
Plot the L-infinity norm of the sensitivity indices for each parameter, grouped by GnP content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean_S
|
ndarray
|
Array of mean sensitivity indices. |
required |
std_S
|
ndarray
|
Array of standard deviations of sensitivity indices. |
required |
ylabel
|
str
|
Label for the y-axis. |
required |
params_list
|
list
|
List of parameter names. |
['$E_{c_1}$', '$\\tau_{c_1}$', '$\\alpha_1$', '$\\beta_1$', '$E_{c_2}$', '$\\tau_{c_2}$', '$\\alpha_2$']
|
legend_labels
|
tuple
|
Labels for the legend. |
('20% HSWF', '30% HSWF', '40% HSWF')
|
figsize
|
tuple
|
Figure size. |
(6, 4)
|
save_path
|
str
|
Path to save the plot. Defaults to None. |
None
|
Source code in scripts/LSA/fmm_lsa_vis_utils.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |