多场耦合优化-主题045-不确定性量化与可靠性分析
主题045:不确定性量化与可靠性分析
1. 引言
1.1 工程中的不确定性
在实际工程问题中,不确定性无处不在:
材料参数的不确定性
- 材料属性的分散性(弹性模量、密度、热导率等)
- 制造公差导致的几何尺寸变化
- 材料缺陷和微观结构不均匀性
载荷条件的不确定性
- 环境载荷的随机性(风载、地震、波浪等)
- 使用载荷的变异性
- 边界条件的近似性
模型不确定性
- 数学模型的简化假设
- 数值离散误差
- 模型参数识别误差

1.2 不确定性量化的重要性
设计决策支持
- 评估设计的安全裕度
- 优化设计参数
- 权衡性能与可靠性
风险评估
- 计算失效概率
- 识别关键失效模式
- 制定风险缓解策略
认证与合规
- 满足安全标准
- 提供统计置信度
- 支持监管决策
1.3 应用领域
- 航空航天:飞行器结构可靠性、气动不确定性
- 土木工程:桥梁安全评估、地震风险分析
- 核工程:核反应堆安全分析、放射性物质扩散
- 机械工程:疲劳寿命预测、磨损分析
- 电子工程:电路参数容差分析、热可靠性
2. 不确定性来源与分类
2.1 不确定性的类型
2.1.1 偶然不确定性(Aleatory Uncertainty)
定义:固有的、不可减少的随机性
特征:
- 源于物理系统的内在随机性
- 无法通过增加数据消除
- 可用概率模型描述
例子:
- 材料微观结构的随机分布
- 环境载荷的随机波动
- 制造过程中的随机误差
2.1.2 认知不确定性(Epistemic Uncertainty)
定义:由于知识不足导致的不确定性
特征:
- 可通过增加数据或改进模型减少
- 反映信息的不完整性
- 可用区间分析或证据理论描述
例子:
- 模型参数估计误差
- 数学模型的简化假设
- 缺乏足够实验数据
2.2 不确定性表征方法
2.2.1 概率方法
概率密度函数(PDF)
pX(x)≥0,∫−∞∞pX(x)dx=1p_X(x) \geq 0, \quad \int_{-\infty}^{\infty} p_X(x) dx = 1pX(x)≥0,∫−∞∞pX(x)dx=1
累积分布函数(CDF)
FX(x)=P(X≤x)=∫−∞xpX(t)dtF_X(x) = P(X \leq x) = \int_{-\infty}^{x} p_X(t) dtFX(x)=P(X≤x)=∫−∞xpX(t)dt
常用分布类型
| 分布类型 | 概率密度函数 | 应用场景 |
|---|---|---|
| 正态分布 | p(x)=1σ2πe−(x−μ)22σ2p(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}p(x)=σ2π1e−2σ2(x−μ)2 | 测量误差、材料属性 |
| 对数正态分布 | p(x)=1xσ2πe−(lnx−μ)22σ2p(x) = \frac{1}{x\sigma\sqrt{2\pi}} e^{-\frac{(\ln x-\mu)^2}{2\sigma^2}}p(x)=xσ2π1e−2σ2(lnx−μ)2 | 疲劳寿命、颗粒尺寸 |
| 均匀分布 | p(x)=1b−a,a≤x≤bp(x) = \frac{1}{b-a}, a \leq x \leq bp(x)=b−a1,a≤x≤b | 公差范围、设计参数 |
| 威布尔分布 | p(x)=kλ(xλ)k−1e−(x/λ)kp(x) = \frac{k}{\lambda}(\frac{x}{\lambda})^{k-1}e^{-(x/\lambda)^k}p(x)=λk(λx)k−1e−(x/λ)k | 强度、可靠性分析 |
| 指数分布 | p(x)=λe−λxp(x) = \lambda e^{-\lambda x}p(x)=λe−λx | 泊松过程、等待时间 |
2.2.2 区间方法
区间变量
x∈[x‾,x‾]x \in [\underline{x}, \overline{x}]x∈[x,x]
区间运算
[a,b]+[c,d]=[a+c,b+d][a, b] + [c, d] = [a+c, b+d][a,b]+[c,d]=[a+c,b+d]
[a,b]×[c,d]=[min(ac,ad,bc,bd),max(ac,ad,bc,bd)][a, b] \times [c, d] = [\min(ac, ad, bc, bd), \max(ac, ad, bc, bd)][a,b]×[c,d]=[min(ac,ad,bc,bd),max(ac,ad,bc,bd)]
应用场景:
- 认知不确定性主导时
- 数据稀缺情况
- 保守安全评估
2.2.3 模糊方法
隶属度函数
μA(x)∈[0,1]\mu_A(x) \in [0, 1]μA(x)∈[0,1]
模糊运算
- 模糊加法、乘法
- 模糊微分方程
- 模糊优化
应用场景:
- 专家知识量化
- 语言变量描述
- 主观不确定性
2.3 不确定性建模流程
┌─────────────────┐
│ 识别不确定性源 │
└────────┬────────┘
↓
┌─────────────────┐
│ 选择表征方法 │
│ (概率/区间/模糊) │
└────────┬────────┘
↓
┌─────────────────┐
│ 参数估计与验证 │
└────────┬────────┘
↓
┌─────────────────┐
│ 不确定性传播 │
└────────┬────────┘
↓
┌─────────────────┐
│ 结果分析与决策 │
└─────────────────┘
3. 概率统计基础
3.1 随机变量与分布
3.1.1 数字特征
期望值(均值)
μX=E[X]=∫−∞∞xpX(x)dx\mu_X = E[X] = \int_{-\infty}^{\infty} x p_X(x) dxμX=E[X]=∫−∞∞xpX(x)dx
方差
σX2=Var[X]=E[(X−μX)2]=∫−∞∞(x−μX)2pX(x)dx\sigma_X^2 = Var[X] = E[(X-\mu_X)^2] = \int_{-\infty}^{\infty} (x-\mu_X)^2 p_X(x) dxσX2=Var[X]=E[(X−μX)2]=∫−∞∞(x−μX)2pX(x)dx
标准差
σX=Var[X]\sigma_X = \sqrt{Var[X]}σX=Var[X]
变异系数
δX=σXμX\delta_X = \frac{\sigma_X}{\mu_X}δX=μXσX
3.1.2 多元随机变量
联合概率密度
pXY(x,y)=pX(x)pY∣X(y∣x)p_{XY}(x, y) = p_X(x) p_{Y|X}(y|x)pXY(x,y)=pX(x)pY∣X(y∣x)
协方差
Cov[X,Y]=E[(X−μX)(Y−μY)]Cov[X, Y] = E[(X-\mu_X)(Y-\mu_Y)]Cov[X,Y]=E[(X−μX)(Y−μY)]
相关系数
ρXY=Cov[X,Y]σXσY\rho_{XY} = \frac{Cov[X, Y]}{\sigma_X \sigma_Y}ρXY=σXσYCov[X,Y]
协方差矩阵
C=[σX12ρ12σX1σX2⋯ρ21σX2σX1σX22⋯⋮⋮⋱]\mathbf{C} = \begin{bmatrix} \sigma_{X_1}^2 & \rho_{12}\sigma_{X_1}\sigma_{X_2} & \cdots \\ \rho_{21}\sigma_{X_2}\sigma_{X_1} & \sigma_{X_2}^2 & \cdots \\ \vdots & \vdots & \ddots \end{bmatrix}C= σX12ρ21σX2σX1⋮ρ12σX1σX2σX22⋮⋯⋯⋱
3.2 统计推断
3.2.1 参数估计
矩估计法
用样本矩估计总体矩:
μ^=xˉ=1n∑i=1nxi\hat{\mu} = \bar{x} = \frac{1}{n}\sum_{i=1}^n x_iμ^=xˉ=n1i=1∑nxi
σ^2=s2=1n−1∑i=1n(xi−xˉ)2\hat{\sigma}^2 = s^2 = \frac{1}{n-1}\sum_{i=1}^n (x_i - \bar{x})^2σ^2=s2=n−11i=1∑n(xi−xˉ)2
最大似然估计
θ^=argmaxθL(θ;x1,...,xn)=argmaxθ∏i=1np(xi;θ)\hat{\theta} = \arg\max_\theta L(\theta; x_1, ..., x_n) = \arg\max_\theta \prod_{i=1}^n p(x_i; \theta)θ^=argθmaxL(θ;x1,...,xn)=argθmaxi=1∏np(xi;θ)
贝叶斯估计
p(θ∣D)=p(D∣θ)p(θ)p(D)p(\theta|D) = \frac{p(D|\theta) p(\theta)}{p(D)}p(θ∣D)=p(D)p(D∣θ)p(θ)
3.2.2 假设检验
正态性检验
- Kolmogorov-Smirnov检验
- Shapiro-Wilk检验
- Anderson-Darling检验
拟合优度检验
- 卡方检验
- 似然比检验
3.3 随机过程
3.3.1 平稳随机过程
定义:统计特性不随时间平移改变
自相关函数
RX(τ)=E[X(t)X(t+τ)]R_X(\tau) = E[X(t)X(t+\tau)]RX(τ)=E[X(t)X(t+τ)]
功率谱密度
SX(ω)=∫−∞∞RX(τ)e−jωτdτS_X(\omega) = \int_{-\infty}^{\infty} R_X(\tau) e^{-j\omega\tau} d\tauSX(ω)=∫−∞∞RX(τ)e−jωτdτ
3.3.2 高斯随机过程
性质:
- 任意有限维分布都是联合高斯分布
- 完全由均值函数和协方差函数确定
- 线性变换保持高斯性
Karhunen-Loève展开
X(t)=μ(t)+∑i=1∞λiξiϕi(t)X(t) = \mu(t) + \sum_{i=1}^{\infty} \sqrt{\lambda_i} \xi_i \phi_i(t)X(t)=μ(t)+i=1∑∞λiξiϕi(t)
其中 ξi\xi_iξi 是标准正态随机变量,λi\lambda_iλi 和 ϕi(t)\phi_i(t)ϕi(t) 是协方差核的特征值和特征函数。
4. 不确定性传播方法
4.1 蒙特卡洛模拟
4.1.1 基本方法
算法流程
def monte_carlo_simulation(n_samples, input_distributions, model):
"""
蒙特卡洛模拟
参数:
n_samples: 样本数量
input_distributions: 输入变量分布列表
model: 仿真模型函数
返回:
output_samples: 输出样本
"""
output_samples = []
for i in range(n_samples):
# 1. 从输入分布采样
x = [dist.rvs() for dist in input_distributions]
# 2. 运行模型
y = model(x)
# 3. 保存输出
output_samples.append(y)
return np.array(output_samples)
统计估计
均值估计:
μ^Y=1N∑i=1Nyi\hat{\mu}_Y = \frac{1}{N} \sum_{i=1}^N y_iμ^Y=N1i=1∑Nyi
方差估计:
σ^Y2=1N−1∑i=1N(yi−μ^Y)2\hat{\sigma}_Y^2 = \frac{1}{N-1} \sum_{i=1}^N (y_i - \hat{\mu}_Y)^2σ^Y2=N−11i=1∑N(yi−μ^Y)2
失效概率估计:
P^f=1N∑i=1NI(g(xi)≤0)\hat{P}_f = \frac{1}{N} \sum_{i=1}^N I(g(x_i) \leq 0)P^f=N1i=1∑NI(g(xi)≤0)
其中 I(⋅)I(\cdot)I(⋅) 是指示函数。
4.1.2 方差缩减技术
重要性采样
Pf=∫I(g(x)≤0)pX(x)qX(x)qX(x)dxP_f = \int I(g(x) \leq 0) \frac{p_X(x)}{q_X(x)} q_X(x) dxPf=∫I(g(x)≤0)qX(x)pX(x)qX(x)dx
选择重要性密度 qX(x)q_X(x)qX(x) 在失效域附近有更多采样。
分层采样
将输入空间划分为若干层,每层独立采样:
μ^Y=∑j=1Lwjyˉj\hat{\mu}_Y = \sum_{j=1}^L w_j \bar{y}_jμ^Y=j=1∑Lwjyˉj
拉丁超立方采样(LHS)
确保样本在输入空间中均匀分布,减少聚类。
def latin_hypercube_sampling(n_samples, n_dims):
"""拉丁超立方采样"""
# 生成排列
samples = np.zeros((n_samples, n_dims))
for i in range(n_dims):
perm = np.random.permutation(n_samples)
samples[:, i] = (perm + np.random.rand(n_samples)) / n_samples
return samples
拟蒙特卡洛方法
使用低差异序列(如Sobol序列)代替伪随机数:
from scipy.stats import qmc
def sobol_sampling(n_samples, n_dims):
"""Sobol序列采样"""
sampler = qmc.Sobol(d=n_dims, scramble=True)
samples = sampler.random(n=n_samples)
return samples
4.2 谱方法
4.2.1 多项式混沌展开(PCE)
Wiener-Askey方案
将随机输出展开为随机变量的多项式:
Y(ξ)=∑α∈AyαΨα(ξ)Y(\xi) = \sum_{\alpha \in \mathcal{A}} y_\alpha \Psi_\alpha(\xi)Y(ξ)=α∈A∑yαΨα(ξ)
其中:
- ξ\xiξ:标准随机变量(高斯、均匀等)
- Ψα\Psi_\alphaΨα:正交多项式(Hermite、Legendre等)
- yαy_\alphayα:展开系数
正交多项式族
| 输入分布 | 多项式类型 | 正交性 |
|---|---|---|
| 高斯分布 | Hermite | ∫Hm(x)Hn(x)e−x2/2dx=2πn!δmn\int H_m(x)H_n(x)e^{-x^2/2}dx = \sqrt{2\pi}n!\delta_{mn}∫Hm(x)Hn(x)e−x2/2dx=2πn!δmn |
| 均匀分布 | Legendre | ∫−11Pm(x)Pn(x)dx=22n+1δmn\int_{-1}^1 P_m(x)P_n(x)dx = \frac{2}{2n+1}\delta_{mn}∫−11Pm(x)Pn(x)dx=2n+12δmn |
| Gamma分布 | Laguerre | ∫0∞Lm(x)Ln(x)e−xdx=δmn\int_0^\infty L_m(x)L_n(x)e^{-x}dx = \delta_{mn}∫0∞Lm(x)Ln(x)e−xdx=δmn |
| Beta分布 | Jacobi | ∫−11(1−x)α(1+x)βJm(x)Jn(x)dx=δmn\int_{-1}^1 (1-x)^\alpha(1+x)^\beta J_m(x)J_n(x)dx = \delta_{mn}∫−11(1−x)α(1+x)βJm(x)Jn(x)dx=δmn |
系数计算
投影法:
yα=⟨Y,Ψα⟩⟨Ψα,Ψα⟩=E[YΨα]E[Ψα2]y_\alpha = \frac{\langle Y, \Psi_\alpha \rangle}{\langle \Psi_\alpha, \Psi_\alpha \rangle} = \frac{E[Y\Psi_\alpha]}{E[\Psi_\alpha^2]}yα=⟨Ψα,Ψα⟩⟨Y,Ψα⟩=E[Ψα2]E[YΨα]
回归法:
minyα∑i=1N(yi−∑αyαΨα(ξi))2\min_{y_\alpha} \sum_{i=1}^N \left(y_i - \sum_\alpha y_\alpha \Psi_\alpha(\xi_i)\right)^2yαmini=1∑N(yi−α∑yαΨα(ξi))2
统计矩计算
均值:μY=y0\mu_Y = y_0μY=y0
方差:σY2=∑α≠0yα2E[Ψα2]\sigma_Y^2 = \sum_{\alpha \neq 0} y_\alpha^2 E[\Psi_\alpha^2]σY2=∑α=0yα2E[Ψα2]
4.2.2 随机配点法
基本思想
在配点上精确满足方程,通过插值获得全局近似。
配点选择
- 全张量积配点
- 稀疏网格配点(Smolyak算法)
Smolyak稀疏网格
A(q,d)=∑q−d+1≤∣i∣≤q(−1)q−∣i∣(d−1q−∣i∣)(Ui1⊗⋯⊗Uid)A(q, d) = \sum_{q-d+1 \leq |i| \leq q} (-1)^{q-|i|} \binom{d-1}{q-|i|} (U^{i_1} \otimes \cdots \otimes U^{i_d})A(q,d)=q−d+1≤∣i∣≤q∑(−1)q−∣i∣(q−∣i∣d−1)(Ui1⊗⋯⊗Uid)
4.3 矩方法
4.3.1 一阶矩方法(FOSM)
泰勒展开
Y≈g(μX)+∑i=1n∂g∂Xi∣μX(Xi−μXi)Y \approx g(\mu_X) + \sum_{i=1}^n \frac{\partial g}{\partial X_i}\bigg|_{\mu_X} (X_i - \mu_{X_i})Y≈g(μX)+i=1∑n∂Xi∂g μX(Xi−μXi)
均值估计
μY≈g(μX)\mu_Y \approx g(\mu_X)μY≈g(μX)
方差估计
σY2≈∑i=1n∑j=1n∂g∂Xi∂g∂XjCov[Xi,Xj]\sigma_Y^2 \approx \sum_{i=1}^n \sum_{j=1}^n \frac{\partial g}{\partial X_i}\frac{\partial g}{\partial X_j} Cov[X_i, X_j]σY2≈i=1∑nj=1∑n∂Xi∂g∂Xj∂gCov[Xi,Xj]
对于独立变量:
σY2≈∑i=1n(∂g∂Xi)2σXi2\sigma_Y^2 \approx \sum_{i=1}^n \left(\frac{\partial g}{\partial X_i}\right)^2 \sigma_{X_i}^2σY2≈i=1∑n(∂Xi∂g)2σXi2
4.3.2 二阶矩方法(SOSM)
包含二阶项:
Y≈g(μX)+∑i=1n∂g∂Xi(Xi−μXi)+12∑i=1n∑j=1n∂2g∂Xi∂Xj(Xi−μXi)(Xj−μXj)Y \approx g(\mu_X) + \sum_{i=1}^n \frac{\partial g}{\partial X_i}(X_i - \mu_{X_i}) + \frac{1}{2}\sum_{i=1}^n\sum_{j=1}^n \frac{\partial^2 g}{\partial X_i \partial X_j}(X_i - \mu_{X_i})(X_j - \mu_{X_j})Y≈g(μX)+i=1∑n∂Xi∂g(Xi−μXi)+21i=1∑nj=1∑n∂Xi∂Xj∂2g(Xi−μXi)(Xj−μXj)
均值修正
μY≈g(μX)+12∑i=1n∂2g∂Xi2σXi2\mu_Y \approx g(\mu_X) + \frac{1}{2}\sum_{i=1}^n \frac{\partial^2 g}{\partial X_i^2} \sigma_{X_i}^2μY≈g(μX)+21i=1∑n∂Xi2∂2gσXi2
4.4 代理模型方法
4.4.1 高斯过程回归
模型
Y(x)=f(x)Tβ+Z(x)Y(x) = f(x)^T \beta + Z(x)Y(x)=f(x)Tβ+Z(x)
其中 Z(x)Z(x)Z(x) 是零均值高斯过程:
Cov[Z(x),Z(x′)]=σ2R(x,x′)Cov[Z(x), Z(x')] = \sigma^2 R(x, x')Cov[Z(x),Z(x′)]=σ2R(x,x′)
常用核函数
高斯核:
R(x,x′)=exp(−∑i=1dθi(xi−xi′)2)R(x, x') = \exp\left(-\sum_{i=1}^d \theta_i (x_i - x'_i)^2\right)R(x,x′)=exp(−i=1∑dθi(xi−xi′)2)
Matérn核:
R(x,x′)=1Γ(ν)2ν−1(2ν∣x−x′∣l)νKν(2ν∣x−x′∣l)R(x, x') = \frac{1}{\Gamma(\nu)2^{\nu-1}}\left(\frac{2\sqrt{\nu}|x-x'|}{l}\right)^\nu K_\nu\left(\frac{2\sqrt{\nu}|x-x'|}{l}\right)R(x,x′)=Γ(ν)2ν−11(l2ν∣x−x′∣)νKν(l2ν∣x−x′∣)
4.4.2 多项式响应面
一阶模型
Y^=β0+∑i=1nβiXi\hat{Y} = \beta_0 + \sum_{i=1}^n \beta_i X_iY^=β0+i=1∑nβiXi
二阶模型
Y^=β0+∑i=1nβiXi+∑i=1nβiiXi2+∑i<jβijXiXj\hat{Y} = \beta_0 + \sum_{i=1}^n \beta_i X_i + \sum_{i=1}^n \beta_{ii} X_i^2 + \sum_{i<j} \beta_{ij} X_i X_jY^=β0+i=1∑nβiXi+i=1∑nβiiXi2+i<j∑βijXiXj
5. 可靠性分析方法
5.1 失效概率计算
5.1.1 极限状态函数
定义
g(X)={>0安全=0极限状态<0失效g(X) = \begin{cases} > 0 & \text{安全} \\ = 0 & \text{极限状态} \\ < 0 & \text{失效} \end{cases}g(X)=⎩ ⎨ ⎧>0=0<0安全极限状态失效
失效概率
Pf=P(g(X)≤0)=∫g(x)≤0pX(x)dxP_f = P(g(X) \leq 0) = \int_{g(x) \leq 0} p_X(x) dxPf=P(g(X)≤0)=∫g(x)≤0pX(x)dx
可靠度指标
β=−Φ−1(Pf)\beta = -\Phi^{-1}(P_f)β=−Φ−1(Pf)
其中 Φ−1\Phi^{-1}Φ−1 是标准正态CDF的逆函数。
5.1.2 蒙特卡洛可靠性分析
直接模拟
def mc_reliability_analysis(n_samples, input_dist, limit_state):
"""
蒙特卡洛可靠性分析
参数:
n_samples: 样本数
input_dist: 输入分布
limit_state: 极限状态函数
返回:
pf: 失效概率估计
cov: 变异系数
"""
n_fail = 0
for i in range(n_samples):
x = input_dist.rvs()
if limit_state(x) <= 0:
n_fail += 1
pf = n_fail / n_samples
cov = np.sqrt((1 - pf) / (n_samples * pf))
return pf, cov
样本量估计
对于目标变异系数 COVtargetCOV_{target}COVtarget:
N=1−PfPf⋅COVtarget2N = \frac{1 - P_f}{P_f \cdot COV_{target}^2}N=Pf⋅COVtarget21−Pf
对于小失效概率(如 Pf=10−6P_f = 10^{-6}Pf=10−6),需要大量样本。
5.2 一阶可靠性方法(FORM)
5.2.1 标准正态空间变换
Rosenblatt变换
对于独立随机变量:
ui=Φ−1(FXi(xi))u_i = \Phi^{-1}(F_{X_i}(x_i))ui=Φ−1(FXi(xi))
Nataf变换
对于相关随机变量:
u=L−1zu = L^{-1} zu=L−1z
其中 LLL 是相关矩阵的Cholesky分解,zi=Φ−1(FXi(xi))z_i = \Phi^{-1}(F_{X_i}(x_i))zi=Φ−1(FXi(xi))。
5.2.2 最可能失效点(MPP)
优化问题
minu∥u∥s.t.g(u)=0\min_{u} \|u\| \quad \text{s.t.} \quad g(u) = 0umin∥u∥s.t.g(u)=0
HL-RF算法
def hl_rf_algorithm(u0, g, dg, tol=1e-6, max_iter=100):
"""
HL-RF算法求解MPP
参数:
u0: 初始点
g: 极限状态函数
dg: 梯度函数
tol: 收敛容差
max_iter: 最大迭代次数
返回:
u_star: MPP点
beta: 可靠度指标
"""
u = u0
for i in range(max_iter):
# 计算函数值和梯度
g_val = g(u)
grad = dg(u)
grad_norm = np.linalg.norm(grad)
# 更新方向
alpha = grad / grad_norm
# 更新MPP估计
u_new = -alpha * (g_val / grad_norm - np.dot(alpha, u))
# 检查收敛
if np.linalg.norm(u_new - u) < tol:
break
u = u_new
beta = np.linalg.norm(u)
return u, beta
5.2.3 FORM近似
失效概率估计
Pf≈Φ(−β)P_f \approx \Phi(-\beta)Pf≈Φ(−β)
误差来源
- 极限状态函数的非线性
- 高阶效应忽略
5.3 二阶可靠性方法(SORM)
5.3.1 曲率近似
Breitung公式
Pf≈Φ(−β)∏i=1n−1(1+βκi)−1/2P_f \approx \Phi(-\beta) \prod_{i=1}^{n-1} (1 + \beta \kappa_i)^{-1/2}Pf≈Φ(−β)i=1∏n−1(1+βκi)−1/2
其中 κi\kappa_iκi 是极限状态函数在MPP点的主曲率。
曲率计算
通过Hessian矩阵的特征值分解获得主曲率。
5.3.2 点拟合SORM
在MPP点周围拟合二次曲面:
g(u)≈β−αTu+12(u−u∗)TH(u−u∗)g(u) \approx \beta - \alpha^T u + \frac{1}{2}(u - u^*)^T H (u - u^*)g(u)≈β−αTu+21(u−u∗)TH(u−u∗)
5.4 重要性抽样
5.4.1 最优重要性密度
q∗(x)=I(g(x)≤0)pX(x)Pfq^*(x) = \frac{I(g(x) \leq 0) p_X(x)}{P_f}q∗(x)=PfI(g(x)≤0)pX(x)
由于 PfP_fPf 未知,使用近似:
q(x)≈pX(x∣g(x)≤0)q(x) \approx p_X(x | g(x) \leq 0)q(x)≈pX(x∣g(x)≤0)
5.4.2 基于FORM的重要性抽样
以MPP为中心构建重要性密度:
q(x)=ϕn(u−u∗)∣∂u∂x∣q(x) = \phi_n(u - u^*) \left|\frac{\partial u}{\partial x}\right|q(x)=ϕn(u−u∗) ∂x∂u
失效概率估计
P^f=1N∑i=1NI(g(xi)≤0)pX(xi)q(xi)\hat{P}_f = \frac{1}{N} \sum_{i=1}^N I(g(x_i) \leq 0) \frac{p_X(x_i)}{q(x_i)}P^f=N1i=1∑NI(g(xi)≤0)q(xi)pX(xi)
6. 敏感性分析
6.1 局部敏感性分析
6.1.1 偏导数法
一阶敏感性系数
Si=∂Y∂Xi∣μXS_i = \frac{\partial Y}{\partial X_i}\bigg|_{\mu_X}Si=∂Xi∂Y μX
标准化敏感性系数
Sistd=σXiσY∂Y∂XiS_i^{std} = \frac{\sigma_{X_i}}{\sigma_Y} \frac{\partial Y}{\partial X_i}Sistd=σYσXi∂Xi∂Y
6.1.2 基于方差的敏感性
FORM敏感性因子
αi=−∂β∂ui=∂g/∂ui∥∇ug∥\alpha_i = -\frac{\partial \beta}{\partial u_i} = \frac{\partial g/\partial u_i}{\|\nabla_u g\|}αi=−∂ui∂β=∥∇ug∥∂g/∂ui
αi2\alpha_i^2αi2 表示第 iii 个变量对总方差的贡献比例。
6.2 全局敏感性分析
6.2.1 Sobol敏感性指数
方差分解
Var[Y]=∑iVi+∑i<jVij+⋯+V12⋯nVar[Y] = \sum_i V_i + \sum_{i<j} V_{ij} + \cdots + V_{12\cdots n}Var[Y]=i∑Vi+i<j∑Vij+⋯+V12⋯n
其中:
Vi=Var[E[Y∣Xi]]V_i = Var[E[Y|X_i]]Vi=Var[E[Y∣Xi]]
Vij=Var[E[Y∣Xi,Xj]]−Vi−VjV_{ij} = Var[E[Y|X_i, X_j]] - V_i - V_jVij=Var[E[Y∣Xi,Xj]]−Vi−Vj
一阶Sobol指数
Si=ViVar[Y]S_i = \frac{V_i}{Var[Y]}Si=Var[Y]Vi
总效应指数
SiT=E[Var[Y∣X∼i]]Var[Y]=1−Var[E[Y∣X∼i]]Var[Y]S_i^T = \frac{E[Var[Y|X_{\sim i}]]}{Var[Y]} = 1 - \frac{Var[E[Y|X_{\sim i}]]}{Var[Y]}SiT=Var[Y]E[Var[Y∣X∼i]]=1−Var[Y]Var[E[Y∣X∼i]]
蒙特卡洛估计
def sobol_indices_mc(n_samples, model, input_dists):
"""
基于蒙特卡洛的Sobol指数估计
使用Saltelli采样方案
"""
n_inputs = len(input_dists)
# 生成两个独立样本矩阵
A = np.array([dist.rvs(n_samples) for dist in input_dists]).T
B = np.array([dist.rvs(n_samples) for dist in input_dists]).T
# 计算模型输出
Y_A = np.array([model(a) for a in A])
Y_B = np.array([model(b) for b in B])
# 总方差
V_Y = np.var(Y_A)
S1 = np.zeros(n_inputs)
ST = np.zeros(n_inputs)
for i in range(n_inputs):
# 创建混合矩阵
A_B = A.copy()
A_B[:, i] = B[:, i]
Y_AB = np.array([model(a_b) for a_b in A_B])
# 一阶指数
S1[i] = np.mean(Y_B * (Y_AB - Y_A)) / V_Y
# 总效应指数
ST[i] = 0.5 * np.mean((Y_A - Y_AB)**2) / V_Y
return S1, ST
6.2.2 Morris方法
基本思想
通过计算"基本效应"来筛选重要参数:
EEi=Y(x1,...,xi+Δ,...,xn)−Y(x)ΔEE_i = \frac{Y(x_1, ..., x_i + \Delta, ..., x_n) - Y(x)}{\Delta}EEi=ΔY(x1,...,xi+Δ,...,xn)−Y(x)
统计量
- μ\muμ:基本效应的均值(总体重要性)
- σ\sigmaσ:基本效应的标准差(非线性/交互作用)
采样策略
在网格上构建轨迹,每个轨迹在 n+1n+1n+1 个点上评估模型。
6.3 基于PCE的敏感性分析
** Sobol指数解析计算**
利用PCE的正交性:
Si=∑α∈Aiyα2E[Ψα2]∑α≠0yα2E[Ψα2]S_i = \frac{\sum_{\alpha \in \mathcal{A}_i} y_\alpha^2 E[\Psi_\alpha^2]}{\sum_{\alpha \neq 0} y_\alpha^2 E[\Psi_\alpha^2]}Si=∑α=0yα2E[Ψα2]∑α∈Aiyα2E[Ψα2]
其中 Ai={α∣αi>0,αj≠i=0}\mathcal{A}_i = \{\alpha | \alpha_i > 0, \alpha_{j \neq i} = 0\}Ai={α∣αi>0,αj=i=0}。
总效应指数
SiT=∑α∈AiTyα2E[Ψα2]∑α≠0yα2E[Ψα2]S_i^T = \frac{\sum_{\alpha \in \mathcal{A}_i^T} y_\alpha^2 E[\Psi_\alpha^2]}{\sum_{\alpha \neq 0} y_\alpha^2 E[\Psi_\alpha^2]}SiT=∑α=0yα2E[Ψα2]∑α∈AiTyα2E[Ψα2]
其中 AiT={α∣αi>0}\mathcal{A}_i^T = \{\alpha | \alpha_i > 0\}AiT={α∣αi>0}。
7. 多物理场问题的不确定性量化
7.1 耦合系统的不确定性传播
7.1.1 分区耦合方法
松耦合
每个物理场独立进行不确定性量化,通过接口传递统计信息:
Y1=M1(X1,Y2),Y2=M2(X2,Y1)Y_1 = M_1(X_1, Y_2), \quad Y_2 = M_2(X_2, Y_1)Y1=M1(X1,Y2),Y2=M2(X2,Y1)
紧耦合
同时考虑所有物理场的不确定性:
Y=M(X),X=[X1,X2,...,Xn]Y = M(X), \quad X = [X_1, X_2, ..., X_n]Y=M(X),X=[X1,X2,...,Xn]
7.1.2 多保真度方法
模型层次
- 高保真模型:CFD/FEA详细仿真
- 低保真模型:降阶模型、代理模型
自适应采样
def adaptive_multi_fidelity_uq(budget, hf_model, lf_model):
"""
自适应多保真度UQ
策略:
1. 大量低保真样本
2. 少量高保真样本修正
3. 自适应分配计算资源
"""
# 低保真模型建立响应面
lf_samples = ...
lf_responses = [lf_model(x) for x in lf_samples]
# 高保真样本用于修正
hf_samples = ...
hf_responses = [hf_model(x) for x in hf_samples]
# 构建修正模型
correction = hf_responses - [lf_model(x) for x in hf_samples]
# 组合预测
return lf_prediction + correction_prediction
7.2 时变可靠性分析
7.2.1 首次穿越问题
定义
计算随机过程首次超过安全边界的概率:
Pf(0,T)=P(∃t∈[0,T]:g(X(t))≤0)P_f(0, T) = P(\exists t \in [0, T]: g(X(t)) \leq 0)Pf(0,T)=P(∃t∈[0,T]:g(X(t))≤0)
解析方法
对于高斯过程,使用Rice公式:
ν+=∫0∞y˙pYY˙(b,y˙)dy˙\nu^+ = \int_0^\infty \dot{y} p_{Y\dot{Y}}(b, \dot{y}) d\dot{y}ν+=∫0∞y˙pYY˙(b,y˙)dy˙
蒙特卡洛方法
def outcrossing_rate_mc(n_samples, process_generator, limit_state, dt):
"""
穿越率蒙特卡洛估计
"""
crossings = 0
for _ in range(n_samples):
# 生成样本路径
trajectory = process_generator()
# 检测穿越
for i in range(len(trajectory)-1):
if limit_state(trajectory[i]) > 0 and limit_state(trajectory[i+1]) <= 0:
crossings += 1
break
return crossings / (n_samples * dt)
7.2.2 极值分布方法
极值统计
关注时间区间内的最大响应:
Ymax=maxt∈[0,T]Y(t)Y_{max} = \max_{t \in [0, T]} Y(t)Ymax=t∈[0,T]maxY(t)
极值分布近似
使用Gumbel分布拟合:
FYmax(y)=exp(−exp(−y−μσ))F_{Y_{max}}(y) = \exp\left(-\exp\left(-\frac{y-\mu}{\sigma}\right)\right)FYmax(y)=exp(−exp(−σy−μ))
7.3 系统可靠性
7.3.1 系统模型
串联系统
Pfsys=1−∏i=1n(1−Pf,i)P_f^{sys} = 1 - \prod_{i=1}^n (1 - P_{f,i})Pfsys=1−i=1∏n(1−Pf,i)
并联系统
Pfsys=∏i=1nPf,iP_f^{sys} = \prod_{i=1}^n P_{f,i}Pfsys=i=1∏nPf,i
混联系统
组合串联和并联结构。
7.3.2 故障树分析
基本事件
- 底事件:基本失效模式
- 顶事件:系统失效
逻辑门
- 与门:所有输入事件同时发生
- 或门:任一输入事件发生
最小割集
导致顶事件的最小底事件组合。
8. Python实现与案例分析
8.1 案例1:蒙特卡洛不确定性传播
"""
案例1:蒙特卡洛方法进行不确定性传播
悬臂梁挠度分析
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
def cantilever_deflection(P, L, E, I, b, h):
"""
计算悬臂梁端部挠度
参数:
P: 端部载荷 (N)
L: 梁长度 (m)
E: 弹性模量 (Pa)
I: 截面惯性矩 (m^4)
b: 截面宽度 (m)
h: 截面高度 (m)
返回:
delta: 端部挠度 (m)
"""
I = b * h**3 / 12
delta = P * L**3 / (3 * E * I)
return delta
def case1_mc_uncertainty_propagation():
"""案例1:蒙特卡洛不确定性传播"""
print("="*60)
print("案例1:蒙特卡洛不确定性传播 - 悬臂梁挠度分析")
print("="*60)
# 定义输入变量的不确定性
# 载荷 P: 正态分布,均值1000N,标准差100N
P_dist = stats.norm(loc=1000, scale=100)
# 长度 L: 正态分布,均值2m,标准差0.02m
L_dist = stats.norm(loc=2.0, scale=0.02)
# 弹性模量 E: 对数正态分布,均值70GPa,变异系数5%
E_dist = stats.lognorm(s=0.05, scale=np.exp(np.log(70e9)))
# 截面宽度 b: 均匀分布,[0.09, 0.11]m
b_dist = stats.uniform(loc=0.09, scale=0.02)
# 截面高度 h: 均匀分布,[0.19, 0.21]m
h_dist = stats.uniform(loc=0.19, scale=0.02)
# 蒙特卡洛模拟
n_samples = 10000
print(f"\n运行蒙特卡洛模拟,样本数: {n_samples}")
# 生成样本
P_samples = P_dist.rvs(n_samples)
L_samples = L_dist.rvs(n_samples)
E_samples = E_dist.rvs(n_samples)
b_samples = b_dist.rvs(n_samples)
h_samples = h_dist.rvs(n_samples)
# 计算输出
delta_samples = np.array([
cantilever_deflection(P, L, E, None, b, h)
for P, L, E, b, h in zip(P_samples, L_samples, E_samples, b_samples, h_samples)
])
# 统计结果
delta_mean = np.mean(delta_samples)
delta_std = np.std(delta_samples)
delta_cov = delta_std / delta_mean
print(f"\n挠度统计结果:")
print(f" 均值: {delta_mean*1000:.4f} mm")
print(f" 标准差: {delta_std*1000:.4f} mm")
print(f" 变异系数: {delta_cov*100:.2f}%")
print(f" 95%置信区间: [{np.percentile(delta_samples, 2.5)*1000:.4f}, {np.percentile(delta_samples, 97.5)*1000:.4f}] mm")
# 可靠性分析(假设允许挠度为5mm)
delta_allow = 0.005 # 5mm
failure_samples = delta_samples > delta_allow
pf_mc = np.sum(failure_samples) / n_samples
beta_mc = -stats.norm.ppf(pf_mc)
print(f"\n可靠性分析 (允许挠度 = {delta_allow*1000}mm):")
print(f" 失效概率: {pf_mc:.6f}")
print(f" 可靠度指标: {beta_mc:.4f}")
# 可视化
fig, axes = plt.subplots(2, 3, figsize=(15, 10))
# 输入分布
axes[0, 0].hist(P_samples, bins=50, density=True, alpha=0.7, color='blue', edgecolor='black')
x_P = np.linspace(P_dist.ppf(0.001), P_dist.ppf(0.999), 100)
axes[0, 0].plot(x_P, P_dist.pdf(x_P), 'r-', linewidth=2)
axes[0, 0].set_title('Load P Distribution')
axes[0, 0].set_xlabel('P (N)')
axes[0, 0].set_ylabel('PDF')
axes[0, 0].grid(True, alpha=0.3)
axes[0, 1].hist(L_samples, bins=50, density=True, alpha=0.7, color='green', edgecolor='black')
axes[0, 1].set_title('Length L Distribution')
axes[0, 1].set_xlabel('L (m)')
axes[0, 1].set_ylabel('PDF')
axes[0, 1].grid(True, alpha=0.3)
axes[0, 2].hist(E_samples/1e9, bins=50, density=True, alpha=0.7, color='orange', edgecolor='black')
axes[0, 2].set_title('Elastic Modulus E Distribution')
axes[0, 2].set_xlabel('E (GPa)')
axes[0, 2].set_ylabel('PDF')
axes[0, 2].grid(True, alpha=0.3)
# 输出分布
axes[1, 0].hist(delta_samples*1000, bins=50, density=True, alpha=0.7, color='purple', edgecolor='black')
axes[1, 0].axvline(delta_mean*1000, color='red', linestyle='--', linewidth=2, label=f'Mean: {delta_mean*1000:.2f}mm')
axes[1, 0].axvline(delta_allow*1000, color='green', linestyle='--', linewidth=2, label=f'Limit: {delta_allow*1000}mm')
axes[1, 0].set_title('Deflection Distribution')
axes[1, 0].set_xlabel('Deflection (mm)')
axes[1, 0].set_ylabel('PDF')
axes[1, 0].legend()
axes[1, 0].grid(True, alpha=0.3)
# CDF
sorted_delta = np.sort(delta_samples)
cdf = np.arange(1, len(sorted_delta)+1) / len(sorted_delta)
axes[1, 1].plot(sorted_delta*1000, cdf, 'b-', linewidth=2)
axes[1, 1].axvline(delta_allow*1000, color='green', linestyle='--', linewidth=2)
axes[1, 1].axhline(1-pf_mc, color='red', linestyle='--', linewidth=2, label=f'Reliability: {1-pf_mc:.4f}')
axes[1, 1].set_title('Cumulative Distribution Function')
axes[1, 1].set_xlabel('Deflection (mm)')
axes[1, 1].set_ylabel('CDF')
axes[1, 1].legend()
axes[1, 1].grid(True, alpha=0.3)
# 收敛分析
sample_sizes = np.logspace(2, 4, 20).astype(int)
means = []
stds = []
for n in sample_sizes:
means.append(np.mean(delta_samples[:n]))
stds.append(np.std(delta_samples[:n]))
axes[1, 2].semilogx(sample_sizes, np.array(means)*1000, 'o-', label='Mean', linewidth=2)
ax2 = axes[1, 2].twinx()
ax2.semilogx(sample_sizes, np.array(stds)*1000, 's-', color='red', label='Std', linewidth=2)
axes[1, 2].set_title('Monte Carlo Convergence')
axes[1, 2].set_xlabel('Number of Samples')
axes[1, 2].set_ylabel('Mean (mm)', color='blue')
ax2.set_ylabel('Std (mm)', color='red')
axes[1, 2].grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('d:\\文档\\500仿真领域\\工程仿真\\多场耦合优化\\主题045\\output\\case1_mc_uncertainty.png', dpi=150)
plt.close()
print("\n案例1完成!")
return delta_samples
# 运行案例1
if __name__ == "__main__":
case1_mc_uncertainty_propagation()
8.2 案例2:可靠性分析与FORM
"""
案例2:一阶可靠性方法(FORM)
悬臂梁可靠性分析
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
from scipy.optimize import minimize
def limit_state_function(x):
"""
极限状态函数
x = [P, L, E, b, h]
g > 0: 安全
g <= 0: 失效
"""
P, L, E, b, h = x
I = b * h**3 / 12
delta = P * L**3 / (3 * E * I)
delta_allow = 0.005 # 允许挠度5mm
return delta_allow - delta
def transform_to_standard(x, dist_params):
"""变换到标准正态空间"""
u = np.zeros_like(x)
for i, (xi, params) in enumerate(zip(x, dist_params)):
dist_type = params['type']
if dist_type == 'normal':
mean, std = params['mean'], params['std']
u[i] = (xi - mean) / std
elif dist_type == 'lognormal':
mean, std = params['mean'], params['std']
sigma_ln = np.sqrt(np.log(1 + (std/mean)**2))
mu_ln = np.log(mean) - 0.5 * sigma_ln**2
u[i] = (np.log(xi) - mu_ln) / sigma_ln
elif dist_type == 'uniform':
a, b = params['a'], params['b']
# 使用Rosenblatt变换
u[i] = stats.norm.ppf((xi - a) / (b - a))
return u
def transform_from_standard(u, dist_params):
"""从标准正态空间变换回来"""
x = np.zeros_like(u)
for i, (ui, params) in enumerate(zip(u, dist_params)):
dist_type = params['type']
if dist_type == 'normal':
mean, std = params['mean'], params['std']
x[i] = mean + ui * std
elif dist_type == 'lognormal':
mean, std = params['mean'], params['std']
sigma_ln = np.sqrt(np.log(1 + (std/mean)**2))
mu_ln = np.log(mean) - 0.5 * sigma_ln**2
x[i] = np.exp(mu_ln + ui * sigma_ln)
elif dist_type == 'uniform':
a, b = params['a'], params['params']['b']
x[i] = a + stats.norm.cdf(ui) * (b - a)
return x
def case2_form_reliability():
"""案例2:FORM可靠性分析"""
print("="*60)
print("案例2:一阶可靠性方法(FORM)")
print("="*60)
# 定义输入分布参数
dist_params = [
{'type': 'normal', 'mean': 1000, 'std': 100}, # P
{'type': 'normal', 'mean': 2.0, 'std': 0.02}, # L
{'type': 'lognormal', 'mean': 70e9, 'std': 3.5e9}, # E
{'type': 'uniform', 'a': 0.09, 'b': 0.11}, # b
{'type': 'uniform', 'a': 0.19, 'b': 0.21} # h
]
# 均值点
x_mean = np.array([1000, 2.0, 70e9, 0.10, 0.20])
# 在标准正态空间定义极限状态函数
def g_u(u):
x = transform_from_standard(u, dist_params)
return limit_state_function(x)
# 使用优化求解MPP
print("\n求解最可能失效点(MPP)...")
def objective(u):
return np.linalg.norm(u)
def constraint(u):
return g_u(u)
# 初始猜测
u0 = np.zeros(5)
# 约束优化
result = minimize(objective, u0, method='SLSQP',
constraints={'type': 'eq', 'fun': constraint})
u_star = result.x
beta = np.linalg.norm(u_star)
x_star = transform_from_standard(u_star, dist_params)
# FORM失效概率
pf_form = stats.norm.cdf(-beta)
print(f"\nFORM结果:")
print(f" 可靠度指标 β = {beta:.4f}")
print(f" 失效概率 Pf = {pf_form:.6f}")
print(f"\nMPP点 (标准空间): {u_star}")
print(f"MPP点 (原始空间):")
print(f" P = {x_star[0]:.2f} N")
print(f" L = {x_star[1]:.4f} m")
print(f" E = {x_star[2]/1e9:.2f} GPa")
print(f" b = {x_star[3]:.4f} m")
print(f" h = {x_star[4]:.4f} m")
# 计算方向余弦(敏感性因子)
alpha = u_star / beta
print(f"\n方向余弦(敏感性因子):")
var_names = ['P', 'L', 'E', 'b', 'h']
for name, a in zip(var_names, alpha):
print(f" {name}: {a:.4f} (贡献: {a**2*100:.2f}%)")
# 蒙特卡洛验证
print("\n蒙特卡洛验证...")
n_mc = 100000
P_samples = stats.norm.rvs(1000, 100, n_mc)
L_samples = stats.norm.rvs(2.0, 0.02, n_mc)
E_samples = stats.lognorm.rvs(0.05, scale=70e9, size=n_mc)
b_samples = stats.uniform.rvs(0.09, 0.02, n_mc)
h_samples = stats.uniform.rvs(0.19, 0.02, n_mc)
g_samples = np.array([
limit_state_function([P, L, E, b, h])
for P, L, E, b, h in zip(P_samples, L_samples, E_samples, b_samples, h_samples)
])
pf_mc = np.sum(g_samples <= 0) / n_mc
print(f" MC失效概率: {pf_mc:.6f}")
print(f" FORM失效概率: {pf_form:.6f}")
print(f" 相对误差: {abs(pf_form - pf_mc)/pf_mc*100:.2f}%")
# 可视化
fig, axes = plt.subplots(2, 2, figsize=(14, 10))
# 标准正态空间中的极限状态面(投影到2D)
u1_range = np.linspace(-4, 4, 100)
u2_range = np.linspace(-4, 4, 100)
U1, U2 = np.meshgrid(u1_range, u2_range)
# 固定其他变量为0,只变化P和L
G_grid = np.zeros_like(U1)
for i in range(len(u1_range)):
for j in range(len(u2_range)):
u_temp = np.array([U1[j,i], U2[j,i], 0, 0, 0])
G_grid[j,i] = g_u(u_temp)
contour = axes[0, 0].contour(U1, U2, G_grid, levels=[0], colors='red', linewidths=2)
axes[0, 0].clabel(contour, inline=True, fontsize=10)
axes[0, 0].plot(u_star[0], u_star[1], 'ro', markersize=10, label='MPP')
axes[0, 0].plot(0, 0, 'go', markersize=8, label='Origin')
axes[0, 0].arrow(0, 0, u_star[0], u_star[1], head_width=0.1, head_length=0.1,
fc='blue', ec='blue', alpha=0.5)
circle = plt.Circle((0, 0), beta, fill=False, color='green', linestyle='--', linewidth=2)
axes[0, 0].add_patch(circle)
axes[0, 0].set_xlabel('u_P (standardized P)')
axes[0, 0].set_ylabel('u_L (standardized L)')
axes[0, 0].set_title('Limit State Surface in Standard Normal Space')
axes[0, 0].legend()
axes[0, 0].grid(True, alpha=0.3)
axes[0, 0].axis('equal')
# 敏感性因子
axes[0, 1].barh(var_names, alpha**2, color='steelblue', alpha=0.7)
axes[0, 1].set_xlabel('Sensitivity Factor α²')
axes[0, 1].set_title('Importance Factors')
axes[0, 1].grid(True, alpha=0.3, axis='x')
# 失效概率对比
methods = ['FORM', 'Monte Carlo']
pf_values = [pf_form, pf_mc]
axes[1, 0].bar(methods, pf_values, color=['orange', 'green'], alpha=0.7)
axes[1, 0].set_ylabel('Failure Probability')
axes[1, 0].set_title('Failure Probability Comparison')
for i, v in enumerate(pf_values):
axes[1, 0].text(i, v + pf_mc*0.1, f'{v:.2e}', ha='center')
axes[1, 0].grid(True, alpha=0.3, axis='y')
# 极限状态函数值分布
axes[1, 1].hist(g_samples, bins=50, density=True, alpha=0.7, color='purple', edgecolor='black')
axes[1, 1].axvline(0, color='red', linestyle='--', linewidth=2, label='Limit State (g=0)')
axes[1, 1].axvline(np.mean(g_samples), color='blue', linestyle='--', linewidth=2,
label=f'Mean: {np.mean(g_samples):.4f}')
axes[1, 1].set_xlabel('g(X)')
axes[1, 1].set_ylabel('PDF')
axes[1, 1].set_title('Limit State Function Distribution')
axes[1, 1].legend()
axes[1, 1].grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('d:\\文档\\500仿真领域\\工程仿真\\多场耦合优化\\主题045\\output\\case2_form_reliability.png', dpi=150)
plt.close()
print("\n案例2完成!")
return beta, pf_form
# 运行案例2
if __name__ == "__main__":
case2_form_reliability()
8.3 案例3:全局敏感性分析
"""
案例3:全局敏感性分析 - Sobol指数
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
from matplotlib.patches import Rectangle
def ishigami_function(x):
"""
Ishigami函数 - 常用于敏感性分析测试
具有强非线性和交互作用
"""
x1, x2, x3 = x
return np.sin(x1) + 7*np.sin(x2)**2 + 0.1*x3**4*np.sin(x1)
def sobol_indices_mc(n_samples, model, n_inputs=3):
"""
基于蒙特卡洛的Sobol指数估计(Saltelli方案)
"""
# 生成两个独立样本矩阵
A = np.random.rand(n_samples, n_inputs) * 2 * np.pi - np.pi
B = np.random.rand(n_samples, n_inputs) * 2 * np.pi - np.pi
# 计算模型输出
Y_A = np.array([model(a) for a in A])
Y_B = np.array([model(b) for b in B])
# 总方差
V_Y = np.var(Y_A)
# 一阶和总效应指数
S1 = np.zeros(n_inputs)
ST = np.zeros(n_inputs)
for i in range(n_inputs):
# 创建混合矩阵 A_B
A_B = A.copy()
A_B[:, i] = B[:, i]
Y_AB = np.array([model(a_b) for a_b in A_B])
# 一阶指数
S1[i] = np.mean(Y_B * (Y_AB - Y_A)) / V_Y
# 总效应指数
ST[i] = 0.5 * np.mean((Y_A - Y_AB)**2) / V_Y
return S1, ST, V_Y
def case3_sobol_sensitivity():
"""案例3:Sobol敏感性分析"""
print("="*60)
print("案例3:全局敏感性分析 - Sobol指数")
print("="*60)
# 使用Ishigami函数进行演示
print("\n使用Ishigami函数进行敏感性分析")
print("Y = sin(X1) + 7*sin(X2)^2 + 0.1*X3^4*sin(X1)")
print("其中 X1, X2, X3 ~ U(-π, π)")
# 解析解(用于验证)
print("\n解析解:")
print(" S1 = 0.3139 (X1)")
print(" S2 = 0.4424 (X2)")
print(" S3 = 0.0000 (X3)")
print(" S12 = 0.2437 (X1-X2交互)")
print(" ST1 = 0.5576")
print(" ST2 = 0.4424")
print(" ST3 = 0.2437")
# 蒙特卡洛估计
n_samples = 10000
print(f"\n蒙特卡洛估计(样本数: {n_samples})...")
S1, ST, V_Y = sobol_indices_mc(n_samples, ishigami_function, 3)
print(f"\n一阶Sobol指数:")
print(f" S1 = {S1[0]:.4f} (X1)")
print(f" S2 = {S1[1]:.4f} (X2)")
print(f" S3 = {S1[2]:.4f} (X3)")
print(f" 总和: {np.sum(S1):.4f}")
print(f"\n总效应指数:")
print(f" ST1 = {ST[0]:.4f} (X1)")
print(f" ST2 = {ST[1]:.4f} (X2)")
print(f" ST3 = {ST[2]:.4f} (X3)")
# 交互作用
S_interaction = ST - S1
print(f"\n交互作用:")
print(f" X1交互: {S_interaction[0]:.4f}")
print(f" X2交互: {S_interaction[1]:.4f}")
print(f" X3交互: {S_interaction[2]:.4f}")
# Morris方法(筛选)
print("\nMorris方法筛选...")
def morris_screening(n_trajectories, n_inputs, delta=0.1):
"""Morris筛选方法"""
EE = np.zeros((n_trajectories, n_inputs))
for t in range(n_trajectories):
# 随机起点
x0 = np.random.rand(n_inputs)
for i in range(n_inputs):
# 创建轨迹
x = x0.copy()
y_base = ishigami_function(x * 2 * np.pi - np.pi)
x[i] = (x[i] + delta) % 1
y_perturbed = ishigami_function(x * 2 * np.pi - np.pi)
EE[t, i] = (y_perturbed - y_base) / delta
# 统计量
mu = np.mean(EE, axis=0)
sigma = np.std(EE, axis=0)
mu_star = np.mean(np.abs(EE), axis=0)
return mu, sigma, mu_star
mu, sigma, mu_star = morris_screening(100, 3)
print(f"\nMorris方法结果:")
print(f" μ* (平均绝对效应):")
print(f" X1: {mu_star[0]:.4f}")
print(f" X2: {mu_star[1]:.4f}")
print(f" X3: {mu_star[2]:.4f}")
print(f" σ (标准差,非线性指标):")
print(f" X1: {sigma[0]:.4f}")
print(f" X2: {sigma[1]:.4f}")
print(f" X3: {sigma[2]:.4f}")
# 可视化
fig, axes = plt.subplots(2, 3, figsize=(15, 10))
var_names = ['X1', 'X2', 'X3']
# Sobol指数对比
x_pos = np.arange(len(var_names))
width = 0.35
axes[0, 0].bar(x_pos - width/2, S1, width, label='First-order', alpha=0.7, color='steelblue')
axes[0, 0].bar(x_pos + width/2, ST, width, label='Total', alpha=0.7, color='coral')
axes[0, 0].set_xlabel('Input Variable')
axes[0, 0].set_ylabel('Sobol Index')
axes[0, 0].set_title('Sobol Sensitivity Indices')
axes[0, 0].set_xticks(x_pos)
axes[0, 0].set_xticklabels(var_names)
axes[0, 0].legend()
axes[0, 0].grid(True, alpha=0.3, axis='y')
# 一阶vs总效应
axes[0, 1].scatter(S1, ST, s=100, alpha=0.7, color='green')
for i, name in enumerate(var_names):
axes[0, 1].annotate(name, (S1[i], ST[i]), xytext=(5, 5),
textcoords='offset points', fontsize=12)
axes[0, 1].plot([0, 1], [0, 1], 'k--', alpha=0.5)
axes[0, 1].set_xlabel('First-order Index S1')
axes[0, 1].set_ylabel('Total Index ST')
axes[0, 1].set_title('First-order vs Total Effect')
axes[0, 1].grid(True, alpha=0.3)
# Morris筛选图
axes[0, 2].scatter(mu_star, sigma, s=100, alpha=0.7, color='purple')
for i, name in enumerate(var_names):
axes[0, 2].annotate(name, (mu_star[i], sigma[i]), xytext=(5, 5),
textcoords='offset points', fontsize=12)
axes[0, 2].set_xlabel('μ* (Mean Absolute Effect)')
axes[0, 2].set_ylabel('σ (Standard Deviation)')
axes[0, 2].set_title('Morris Screening Plot')
axes[0, 2].grid(True, alpha=0.3)
# 输出分布
n_samples_dist = 10000
samples = np.random.rand(n_samples_dist, 3) * 2 * np.pi - np.pi
Y_samples = np.array([ishigami_function(s) for s in samples])
axes[1, 0].hist(Y_samples, bins=50, density=True, alpha=0.7, color='teal', edgecolor='black')
axes[1, 0].set_xlabel('Output Y')
axes[1, 0].set_ylabel('PDF')
axes[1, 0].set_title('Output Distribution')
axes[1, 0].grid(True, alpha=0.3)
# 散点图矩阵
sample_size = 500
idx = np.random.choice(n_samples_dist, sample_size, replace=False)
# X1 vs Y
axes[1, 1].scatter(samples[idx, 0], Y_samples[idx], alpha=0.5, s=10, color='blue')
axes[1, 1].set_xlabel('X1')
axes[1, 1].set_ylabel('Y')
axes[1, 1].set_title('Scatter: X1 vs Y')
axes[1, 1].grid(True, alpha=0.3)
# X2 vs Y
axes[1, 2].scatter(samples[idx, 1], Y_samples[idx], alpha=0.5, s=10, color='red')
axes[1, 2].set_xlabel('X2')
axes[1, 2].set_ylabel('Y')
axes[1, 2].set_title('Scatter: X2 vs Y')
axes[1, 2].grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('d:\\文档\\500仿真领域\\工程仿真\\多场耦合优化\\主题045\\output\\case3_sobol_sensitivity.png', dpi=150)
plt.close()
print("\n案例3完成!")
return S1, ST
# 运行案例3
if __name__ == "__main__":
case3_sobol_sensitivity()
8.4 案例4:时变可靠性分析
"""
案例4:时变可靠性分析
随机振动系统的首次穿越问题
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
from matplotlib.animation import FuncAnimation, PillowWriter
def generate_random_process(t, dt, omega_0, zeta, S0):
"""
生成高斯随机过程(白噪声激励的线性系统响应)
参数:
t: 时间数组
dt: 时间步长
omega_0: 固有频率
zeta: 阻尼比
S0: 白噪声谱密度
返回:
x: 位移响应
v: 速度响应
"""
n_steps = len(t)
x = np.zeros(n_steps)
v = np.zeros(n_steps)
# 白噪声激励
w = np.random.randn(n_steps) * np.sqrt(2 * np.pi * S0 / dt)
# 数值积分(Newmark-beta方法)
for i in range(n_steps - 1):
# 加速度
a = (w[i] - 2 * zeta * omega_0 * v[i] - omega_0**2 * x[i])
# 速度和位移更新
v[i+1] = v[i] + a * dt
x[i+1] = x[i] + v[i+1] * dt
return x, v
def case4_time_dependent_reliability():
"""案例4:时变可靠性分析"""
print("="*60)
print("案例4:时变可靠性分析 - 随机振动系统")
print("="*60)
# 系统参数
omega_0 = 2 * np.pi * 5 # 固有频率 5Hz
zeta = 0.05 # 阻尼比
S0 = 0.1 # 白噪声谱密度
threshold = 0.5 # 位移阈值
# 时间参数
T = 10.0 # 总时间
dt = 0.01 # 时间步长
t = np.arange(0, T, dt)
# 蒙特卡洛模拟
n_samples = 1000
print(f"\n运行蒙特卡洛模拟,样本数: {n_samples}")
print(f"时间范围: 0-{T}s,步长: {dt}s")
trajectories = []
first_passage_times = []
n_failures = 0
for i in range(n_samples):
x, v = generate_random_process(t, dt, omega_0, zeta, S0)
trajectories.append(x)
# 检测首次穿越
exceed_idx = np.where(np.abs(x) > threshold)[0]
if len(exceed_idx) > 0:
first_passage_times.append(t[exceed_idx[0]])
n_failures += 1
else:
first_passage_times.append(None)
# 时变失效概率
failure_times = [fp for fp in first_passage_times if fp is not None]
print(f"\n统计结果:")
print(f" 失效样本数: {n_failures}/{n_samples} ({n_failures/n_samples*100:.2f}%)")
if failure_times:
print(f" 平均首次穿越时间: {np.mean(failure_times):.4f}s")
print(f" 首次穿越时间标准差: {np.std(failure_times):.4f}s")
# 计算时变失效概率
pf_time = np.zeros(len(t))
for i, ti in enumerate(t):
count = sum(1 for fp in first_passage_times if fp is not None and fp <= ti)
pf_time[i] = count / n_samples
# 可视化
fig, axes = plt.subplots(2, 2, figsize=(14, 10))
# 样本轨迹
n_plot = min(50, n_samples)
for i in range(n_plot):
axes[0, 0].plot(t, trajectories[i], alpha=0.3, linewidth=0.5)
axes[0, 0].axhline(threshold, color='red', linestyle='--', linewidth=2, label=f'Threshold = {threshold}')
axes[0, 0].axhline(-threshold, color='red', linestyle='--', linewidth=2)
axes[0, 0].set_xlabel('Time (s)')
axes[0, 0].set_ylabel('Displacement')
axes[0, 0].set_title(f'Sample Trajectories (n={n_plot})')
axes[0, 0].legend()
axes[0, 0].grid(True, alpha=0.3)
# 时变失效概率
axes[0, 1].plot(t, pf_time, 'b-', linewidth=2)
axes[0, 1].set_xlabel('Time (s)')
axes[0, 1].set_ylabel('Failure Probability')
axes[0, 1].set_title('Time-Dependent Failure Probability')
axes[0, 1].grid(True, alpha=0.3)
# 首次穿越时间分布
if failure_times:
axes[1, 0].hist(failure_times, bins=30, density=True, alpha=0.7, color='green', edgecolor='black')
axes[1, 0].set_xlabel('First Passage Time (s)')
axes[1, 0].set_ylabel('PDF')
axes[1, 0].set_title('First Passage Time Distribution')
axes[1, 0].grid(True, alpha=0.3)
# 包络统计
max_values = [np.max(np.abs(traj)) for traj in trajectories]
axes[1, 1].hist(max_values, bins=30, density=True, alpha=0.7, color='purple', edgecolor='black')
axes[1, 1].axvline(threshold, color='red', linestyle='--', linewidth=2, label=f'Threshold = {threshold}')
axes[1, 1].set_xlabel('Maximum Absolute Displacement')
axes[1, 1].set_ylabel('PDF')
axes[1, 1].set_title('Maximum Response Distribution')
axes[1, 1].legend()
axes[1, 1].grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('d:\\文档\\500仿真领域\\工程仿真\\多场耦合优化\\主题045\\output\\case4_time_dependent_reliability.png', dpi=150)
plt.close()
print("\n案例4完成!")
return t, pf_time, trajectories
def create_uncertainty_animation():
"""创建不确定性传播动画"""
print("\n创建不确定性传播动画...")
# 生成样本
n_frames = 50
n_samples_per_frame = 20
# 输入分布
P_dist = stats.norm(loc=1000, scale=100)
L_dist = stats.norm(loc=2.0, scale=0.02)
fig, axes = plt.subplots(1, 2, figsize=(14, 6))
def update(frame):
axes[0].clear()
axes[1].clear()
# 累积样本
n_total = (frame + 1) * n_samples_per_frame
P_samples = P_dist.rvs(n_total)
L_samples = L_dist.rvs(n_total)
# 计算挠度
delta_samples = []
for P, L in zip(P_samples, L_samples):
I = 0.10 * 0.20**3 / 12
delta = P * L**3 / (3 * 70e9 * I)
delta_samples.append(delta * 1000) # 转换为mm
# 左图:输入空间
axes[0].scatter(P_samples, L_samples, alpha=0.5, s=20, c='blue')
axes[0].set_xlabel('Load P (N)')
axes[0].set_ylabel('Length L (m)')
axes[0].set_title(f'Input Space (n={n_total})')
axes[0].grid(True, alpha=0.3)
axes[0].set_xlim(700, 1300)
axes[0].set_ylim(1.9, 2.1)
# 右图:输出分布
axes[1].hist(delta_samples, bins=30, density=True, alpha=0.7,
color='purple', edgecolor='black')
axes[1].axvline(np.mean(delta_samples), color='red', linestyle='--',
linewidth=2, label=f'Mean: {np.mean(delta_samples):.2f}mm')
axes[1].set_xlabel('Deflection (mm)')
axes[1].set_ylabel('PDF')
axes[1].set_title(f'Output Distribution (n={n_total})')
axes[1].legend()
axes[1].grid(True, alpha=0.3)
plt.tight_layout()
return axes
anim = FuncAnimation(fig, update, frames=n_frames, interval=200, blit=False)
writer = PillowWriter(fps=5)
anim.save('d:\\文档\\500仿真领域\\工程仿真\\多场耦合优化\\主题045\\output\\uncertainty_propagation_animation.gif',
writer=writer)
plt.close()
print("动画创建完成!")
def main():
"""主函数"""
print("="*60)
print("主题045:不确定性量化与可靠性分析")
print("="*60)
# 运行所有案例
case1_mc_uncertainty_propagation()
case2_form_reliability()
case3_sobol_sensitivity()
case4_time_dependent_reliability()
create_uncertainty_animation()
print("\n" + "="*60)
print("所有案例完成!")
print("="*60)
print("\n输出文件:")
print(" - case1_mc_uncertainty.png")
print(" - case2_form_reliability.png")
print(" - case3_sobol_sensitivity.png")
print(" - case4_time_dependent_reliability.png")
print(" - uncertainty_propagation_animation.gif")
if __name__ == "__main__":
main()
9. 总结与展望
9.1 方法对比与选择
| 方法 | 优点 | 缺点 | 适用场景 |
|---|---|---|---|
| 蒙特卡洛 | 通用、精确、易并行 | 计算量大 | 复杂模型、高精度要求 |
| FORM/SORM | 计算效率高 | 非线性误差 | 中等非线性、快速评估 |
| PCE | 解析矩计算 | 高维困难 | 光滑响应、多次评估 |
| 代理模型 | 加速计算 | 近似误差 | 昂贵仿真、优化设计 |
9.2 发展趋势
深度学习方法
- 神经网络代理模型
- 深度高斯过程
- 物理信息神经网络
高维问题处理
- 稀疏多项式混沌
- 主动子空间方法
- 流形学习技术
动态可靠性
- 时变可靠性分析
- 退化过程建模
- 剩余寿命预测
多尺度不确定性
- 微观-宏观关联
- 多尺度随机建模
- 异构不确定性融合
9.3 工程应用建议
- 问题识别:明确不确定性来源和类型
- 方法选择:根据问题特点选择合适方法
- 验证确认:通过多种方法交叉验证
- 灵敏度分析:识别关键不确定性因素
- 决策支持:将UQ结果融入设计决策
6 深入理论分析
6.1 数学模型推导
流体力学问题的数学描述基于守恒定律和本构关系。控制方程的一般形式可以表示为:
∂(ρϕ)∂t+∇⋅(ρuϕ)=∇⋅(Γ∇ϕ)+Sϕ\frac{\partial (\rho \phi)}{\partial t} + \nabla \cdot (\rho \mathbf{u} \phi) = \nabla \cdot (\Gamma \nabla \phi) + S_\phi∂t∂(ρϕ)+∇⋅(ρuϕ)=∇⋅(Γ∇ϕ)+Sϕ
其中,ϕ\phiϕ表示通用变量,ρ\rhoρ是密度,u\mathbf{u}u是速度矢量,Γ\GammaΓ是扩散系数,SϕS_\phiSϕ是源项。
对于稳态问题,控制方程简化为:
∇⋅(ρuϕ)=∇⋅(Γ∇ϕ)+Sϕ\nabla \cdot (\rho \mathbf{u} \phi) = \nabla \cdot (\Gamma \nabla \phi) + S_\phi∇⋅(ρuϕ)=∇⋅(Γ∇ϕ)+Sϕ
边界条件的数学表达:
Dirichlet边界条件:
ϕ=ϕspecified在ΓD上\phi = \phi_{specified} \quad \text{在} \quad \Gamma_D \text{上}ϕ=ϕspecified在ΓD上
Neumann边界条件:
−Γ∂ϕ∂n=qspecified在ΓN上-\Gamma \frac{\partial \phi}{\partial n} = q_{specified} \quad \text{在} \quad \Gamma_N \text{上}−Γ∂n∂ϕ=qspecified在ΓN上
Robin边界条件:
−Γ∂ϕ∂n=h(ϕ−ϕ∞)在ΓR上-\Gamma \frac{\partial \phi}{\partial n} = h(\phi - \phi_\infty) \quad \text{在} \quad \Gamma_R \text{上}−Γ∂n∂ϕ=h(ϕ−ϕ∞)在ΓR上
6.2 数值离散方法
有限差分法的离散格式:
时间离散:
- 显式格式:ϕn+1=ϕn+Δt⋅f(ϕn)\phi^{n+1} = \phi^n + \Delta t \cdot f(\phi^n)ϕn+1=ϕn+Δt⋅f(ϕn)
- 隐式格式:ϕn+1=ϕn+Δt⋅f(ϕn+1)\phi^{n+1} = \phi^n + \Delta t \cdot f(\phi^{n+1})ϕn+1=ϕn+Δt⋅f(ϕn+1)
- Crank-Nicolson格式:ϕn+1=ϕn+Δt2[f(ϕn)+f(ϕn+1)]\phi^{n+1} = \phi^n + \frac{\Delta t}2[f(\phi^n) + f(\phi^{n+1})]ϕn+1=ϕn+2Δt[f(ϕn)+f(ϕn+1)]
空间离散:
- 中心差分:∂ϕ∂x≈ϕi+1−ϕi−12Δx\frac{\partial \phi}{\partial x} \approx \frac{\phi_{i+1} - \phi_{i-1}}{2\Delta x}∂x∂ϕ≈2Δxϕi+1−ϕi−1
- 迎风格式:∂ϕ∂x≈ϕi−ϕi−1Δx\frac{\partial \phi}{\partial x} \approx \frac{\phi_i - \phi_{i-1}}{\Delta x}∂x∂ϕ≈Δxϕi−ϕi−1(u>0u>0u>0时)
6.3 稳定性与收敛性分析
Von Neumann稳定性分析:
对于一维热传导方程的显式格式,稳定性条件为:
Fo=αΔt(Δx)2≤12Fo = \frac{\alpha \Delta t}{(\Delta x)^2} \leq \frac12Fo=(Δx)2αΔt≤21
其中FoFoFo是傅里叶数,α\alphaα是热扩散系数。
收敛性条件:
根据Lax等价定理,对于适定的线性初值问题,一致性和稳定性是收敛性的充分必要条件。
误差分析:
截断误差:τ=O(Δt)+O((Δx)2)\tau = O(\Delta t) + O((\Delta x)^2)τ=O(Δt)+O((Δx)2)
累积误差:ϵ=O(Δt)+O((Δx)2)\epsilon = O(\Delta t) + O((\Delta x)^2)ϵ=O(Δt)+O((Δx)2)





AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐

所有评论(0)