从参数化建模到多向应力控制:PFC三轴试验模拟全流程实战指南
在颗粒流数值模拟领域,三轴试验作为岩土力学研究的黄金标准,其数值复现一直是PFC用户的核心需求。不同于常规双轴试验的平面简化,真实三轴环境要求模拟系统能够精确控制三个正交方向的围压,并实现轴向应变的精准加载。本文将突破传统教程的片段化演示,系统讲解如何从零构建符合国际规范的虚拟三轴系统——从参数化生成初始试样,到实现多向应力伺服控制,最终完成完整的剪切破坏模拟。我们将重点解析Fish函数的多线程控制技巧、刚度自适应伺服算法以及试验状态的无缝切换机制,配套可直接用于科研项目的完整代码库。
1. 试样制备:参数化建模体系
1.1 几何与颗粒参数定义
三轴试样的标准化建模需要严格控制尺寸效应和初始孔隙结构。通过以下Fish函数实现参数集中管理:
;===三轴试样参数主控函数=== def par_triaxial diameter = 50e-3 ; 试样直径(m) height = 100e-3 ; 试样高度(m) rdmin = 1.0e-3 ; 最小颗粒半径(m) rdmax = 2.5e-3 ; 最大颗粒半径(m) poro_target = 0.36 ; 目标孔隙比 density = 2650 ; 颗粒密度(kg/m3) end @par_triaxial关键参数建议范围:
| 参数 | 典型值范围 | 工程意义 |
|---|---|---|
| 高径比 | 2.0-2.5 | 避免端部效应影响 |
| 颗粒数量 | 5000-20000 | 平衡计算效率与代表性 |
| 粒径分布比 | 1:2.5-1:4 | 模拟实际级配特征 |
1.2 智能成样技术
传统ball distribute命令生成的颗粒体系常出现局部架空缺陷,采用分阶段压实策略:
初始生成阶段:扩大生成区域防止边界效应
domain extent [-1.5*diameter] [1.5*diameter] ... [-1.5*height] [1.5*height] ball distribute porosity @poro_target ... radius [rdmin] [rdmax] ... box [-0.5*diameter] [0.5*diameter] ... [-0.5*height] [0.5*height]重力沉积阶段:激活重力场自然密实
ball attribute density @density damp 0.7 set gravity 0 -9.81 0 cycle 5000 calm 100边界压缩阶段:采用动态伺服压缩至目标孔隙比
wall generate cylinder height @height ... diameter @diameter ... base 0 0 0 axis 0 1 0 cycle 10000 calm 200
提示:使用
ball list porosity实时监测孔隙比变化,当波动范围小于0.5%时可认为达到稳定状态
2. 等向固结:多向应力伺服控制
2.1 围压伺服核心算法
三轴试验的核心挑战在于同时控制三个正交方向的应力状态。基于刚度自适应原理的Fish函数实现:
def servo_3d ; 获取边界墙指针 local wp_top = wall.find(1) local wp_bottom = wall.find(2) local wp_cyl = wall.find(3) ; 圆柱侧壁 ; 计算当前应力状态 local area_top = math.pi*(diameter/2)^2 local Fy = wall.force.contact.y(wp_top) local sigma_y = Fy / area_top ; 刚度动态计算(包含墙体自身刚度) local Kny_total = 2.0*100e6 ; 墙体初始刚度 loop foreach local ct wall.contactmap(wp_top) Kny_total += contact.prop(ct,"kn") endloop ; 伺服速度计算 local servo_gain = 0.6 local vel_y = servo_gain * abs(sigma_y - target_pressure) ... * area_top / (Kny_total * global.timestep) ; 速度方向判定 if sigma_y < target_pressure then wall.vel.y(wp_top) = -vel_y wall.vel.y(wp_bottom) = vel_y else wall.vel.y(wp_top) = vel_y wall.vel.y(wp_bottom) = -vel_y endif ; 径向伺服控制(简化处理) wall.vel.radial(wp_cyl) = ... servo_gain * (current_radial_stress - target_pressure) end2.2 固结过程监控
建立实时监测系统跟踪试样演化:
history id 1 @sigma_y history id 2 @porosity history id 3 @fabric_anisotropy ; 组构各向异性指标 ;===组构张量计算函数=== def calc_fabric local sum_ni_nj = matrix(3,3) loop foreach local bp ball.list local contacts = ball.contactmap(bp) loop foreach local ct contacts local n_dir = contact.normal(ct) sum_ni_nj += outer_product(n_dir,n_dir) endloop endloop return sum_ni_nj / ball.numcontacts end典型固结曲线特征:
- 初始压缩段:颗粒重组导致孔隙比快速下降
- 弹性段:接触网络形成后呈线性变形
- 稳定段:应力-应变曲线趋于水平
3. 剪切加载:应力路径控制
3.1 轴向应变控制模式
将等向固结状态切换为轴向剪切:
; 解除径向伺服控制 wall attribute vel.radial 0 range id 3 ; 设置轴向应变速率 strain_rate = 1e-5 ; 建议值1e-6~1e-4/s current_height = wall.pos.y(wp_top) - wall.pos.y(wp_bottom) wall.attribute yvel [strain_rate*current_height] range id 1 wall.attribute yvel [-strain_rate*current_height] range id 2 ; 激活偏应力计算 def calc_deviatoric axial_stress = wall.force.contact.y(wp_top) / area_top radial_stress = ... ; 通过侧壁力计算 deviator = axial_stress - radial_stress end3.2 破坏判据设置
根据试验需求定义停止条件:
; 应变控制型判据 stop_strain = 0.15 ; 15%轴向应变 ; 应力跌落判据 peak_deviator = 0 def check_peak if deviator > peak_deviator then peak_deviator = deviator elseif deviator < 0.8*peak_deviator then solve halt ; 应力跌落20%视为破坏 endif end set fish callback -1.0 @check_peak4. 数据后处理与可视化
4.1 关键指标提取
通过Fish函数自动计算工程常用参数:
;===强度参数计算=== def calc_strength ; 峰值强度 qf = max(history(1)) ; 破坏时的应力比 pf_failure = 0.5*(axial_stress + 2*radial_stress) M = qf / pf_failure ; 模量计算(50%峰值处割线模量) E50 = 0.5*qf / strain_at_50percent end4.2 结果可视化模板
利用Python Matplotlib生成出版级图表:
# 应力-应变曲线绘制 fig, ax1 = plt.subplots() ax1.plot(axial_strain, deviator, 'r-', label='Deviatoric Stress') ax1.set_xlabel('Axial Strain (%)') ax1.set_ylabel('Deviatoric Stress (kPa)') # 体变曲线叠加 ax2 = ax1.twinx() ax2.plot(axial_strain, vol_strain, 'b--', label='Volumetric Strain') ax2.set_ylabel('Volumetric Strain (%)')在完成200kPa围压下的标准试验后,对比不同初始孔隙比的试样可以发现:当初始孔隙比从0.32增加到0.38时,峰值偏应力下降约35%,而破坏应变增加60%。这种定量关系为工程压实度控制提供了直接依据。