RELIABILITY: RESISTANCE VS. STRESS (R-S)¶
This example showcases the application of different reliability analysis methods available in UQLab to the simple R-S example.
Package imports¶
from uqpylab import sessions
import numpy as np
Start a remote UQCloud session¶
# Start the session
mySession = sessions.cloud()
# (Optional) Get a convenient handle to the command line interface
uq = mySession.cli
# Reset the session
mySession.reset()
Processing .
.
 done!
 uqpylab.sessions :: INFO     :: This is UQ[py]Lab, version 1.00, running on https://uqcloud.ethz.ch. 
                                 UQ[py]Lab is free software, published under the open source BSD 3-clause license.
                                 To request special permissions, please contact:
                                  - Stefano Marelli (marelli@ibk.baug.ethz.ch).
                                 A new session (98d4b6d653154f489649141f9795f9b0) started.
uqpylab.sessions :: INFO :: Reset successful.
Set the random seed for reproducibility¶
uq.rng(100,'twister');
COMPUTATIONAL MODEL¶
The R-S function is defined as: $$g(\mathbf{x}) = R - S,$$
where $\mathbf{x} = \{R,S\}$. $R$ and $S$ are the resistance and stress variables, respectively.
Create a limit state function model using a string, written below in a vectorized operation:
ModelOpts = { 
    'Type': 'Model', 
    'mString': 'X(:,1) - X(:,2)',
    'isVectorized': 1
}
myModel = uq.createModel(ModelOpts)
PROBABILISTIC INPUT MODEL¶
The probabilistic input model consists of two independent Gaussian random variables: $$R \sim \mathcal{N}(5, 0.8), \; S \sim \mathcal{N}(2, 0.6)$$
Specify the probabilistic input model for $R$ and $S$:
InputOpts = {
    "Marginals": [
        {"Name": "R",               # Resistance
         "Type": "Gaussian",
         "Moments": [5.0 , 0.8]
        },
        {"Name": "S",               # Stress
         "Type": "Gaussian",
         "Moments": [2.0 , 0.6]
        }
    ]
}
Create an INPUT object based on the specified marginals:
myInput = uq.createInput(InputOpts)
RELIABILITY ANALYSIS¶
Failure event is defined as $g(\mathbf{x}) \leq 0$. The failure probability is then defined as $P_f = P[g(\mathbf{x}) \leq 0]$.
Reliability analysis is performed with the following methods:
- Monte Carlo simulation
 - First-order reliability method (FORM)
 - Importance sampling (IS)
 - Subset simulation
 - Adaptive Kriging-Monte Carlo Simulation (AK-MCS)
 
Monte Carlo simulation (MCS)¶
Select the Reliability module and the Monte Carlo simulation (MCS) method:
MCSOpts = {
    "Type": "Reliability",
    "Method":"MCS"
}
Specify the maximum sample size:
MCSOpts["Simulation"] = {
    "MaxSampleSize":1e5
}
Run reliability analysis with MCS:
MCSAnalysis = uq.createAnalysis(MCSOpts)
Print out a report of the results:
uq.print(MCSAnalysis)
--------------------------------------------------- Monte Carlo simulation --------------------------------------------------- Pf 1.5300e-03 Beta 2.9616 CoV 0.0808 ModelEvaluations 100000 PfCI [1.2878e-03 1.7722e-03] BetaCI [2.9161e+00 3.0143e+00] ---------------------------------------------------
Create a graphical representation of the results:¶
uq.display(MCSAnalysis);
FORM¶
Select FORM as the reliability analysis method:
FORMOpts = {
    "Type": "Reliability",
    "Method":"FORM"
}
Run the FORM analysis:
FORMAnalysis = uq.createAnalysis(FORMOpts)
Print out a report of the results:
uq.print(FORMAnalysis)
--------------------------------------------------- FORM --------------------------------------------------- Pf 1.3499e-03 BetaHL 3.0000 ModelEvaluations 8 --------------------------------------------------- Variables R S Ustar -2.400000 1.800000 Xstar 3.08e+00 3.08e+00 Importance 0.640000 0.360000 ---------------------------------------------------
Create a graphical representation of the results:¶
uq.display(FORMAnalysis);
Importance sampling (IS)¶
Select importance sampling (IS) as the reliability analysis method:
ISOpts = {
    "Type": "Reliability",
    "Method":"IS"
}
Run the IS reliability analysis:
ISAnalysis = uq.createAnalysis(ISOpts)
Print out a report of the results:
uq.print(ISAnalysis)
--------------------------------------------------- Importance Sampling --------------------------------------------------- Pf 1.3662e-03 Beta 2.9963 CoV 0.0569 ModelEvaluations 1008 PfCI [1.2139e-03 1.5186e-03] BetaCI [2.9639e+00 3.0322e+00] ---------------------------------------------------
Create a graphical representation of the results:¶
uq.display(ISAnalysis);
Subset simulation¶
Select subset simulation as the reliability analysis method:
SubsetSimOpts = {
    "Type": "Reliability",
    "Method":"Subset"
}
Run the subset simulation:
SubsetSimAnalysis = uq.createAnalysis(SubsetSimOpts)
Print out a report of the results:
uq.print(SubsetSimAnalysis)
--------------------------------------------------- Subset simulation --------------------------------------------------- Pf 1.3800e-03 Beta 2.9933 CoV 0.2303 ModelEvaluations 2693 PfCI [7.5702e-04 2.0030e-03] BetaCI [2.8777e+00 3.1720e+00] ---------------------------------------------------
Create a graphical representation of the results:¶
uq.display(SubsetSimAnalysis);
Adaptive Kriging-Monte Carlo Simulation (AK-MCS)¶
Select subset simulation as the reliability analysis method:
AKMCSOpts = {
    "Type": "Reliability",
    "Method":"AKMCS"
}
Run the AK-MCS simulation:
AKMCSAnalysis = uq.createAnalysis(AKMCSOpts)
Processing .
done!
Print out a report of the results:
uq.print(AKMCSAnalysis)
--------------------------------------------------- AK-MCS --------------------------------------------------- Pf 1.1600e-03 Beta 3.0459 CoV 0.0928 ModelEvaluations 18 PfCI [9.4903e-04 1.3710e-03] BetaCI [2.9953e+00 3.1057e+00] PfMinus/Plus [1.1600e-03 1.1600e-03] ---------------------------------------------------
Create a graphical representation of the results:¶
uq.display(AKMCSAnalysis);
Stochastic spectral embedding-based reliability (SSER)¶
Select stochastic spectral embedding-based reliability as the reliability analysis method
SSEROpts = {
    "Type": "Reliability",
    "Method": "SSER"
}
Run the SSER simulation:
SSERAnalysis = uq.createAnalysis(SSEROpts)
Processing .
.
.
done!
Print out a report of the results:
uq.print(SSERAnalysis)
--------------------------------------------------- Stochastic spectral embedding-based reliability --------------------------------------------------- Pf 1.2906e-03 Beta 3.0137 CoV 0.0000 ModelEvaluations 80 PfCI [1.2906e-03 1.2906e-03] BetaCI [3.0137e+00 3.0137e+00] ---------------------------------------------------
Create a graphical representation of the results:¶
uq.display(SSERAnalysis);
Processing .
.
.
.
.
.
.
done!
Terminate the remote UQCloud session:¶
mySession.quit()
uqpylab.sessions :: INFO :: Session 98d4b6d653154f489649141f9795f9b0 terminated.
True