在日常设计中,经常会遇到阀门关闭的情况,让我们来看下如何在Fluent中模拟这一情况。
一、CAD建模
在CAD软件中建立如下流体域模型(尺寸单位为mm)。该模型中有一个活塞在电机驱动下向右运动,在0.1秒内关关闭阀门。建模完成后存为stp文件。

二、网格和边界指定
在Ansys mesh模块中,命名大端为进水端intlet,小端为出水端outlet,中间的活塞为piston。网格大小为1mm。

流体域网格半透明显示

活塞网格显示
三、边界条件设置
设置压力入口和压力出口,大小分别为20psi和0psi,模拟的流体添加水。

四、动网格设置
因为要模拟活塞移动,所以需要设置piston为动网格。点选Dynamic Mesh,并点选网格光顺Smoothing和网格重建Remeshing。

网格光顺采用模拟的扩散模型:

网格重建采用基于方法的重建,参数选用默认,重建间隔选为1。

五、活塞运动指定
在此案例中,活塞需要从左向右运到大概5mm来关闭阀门,我们采用udf来指定运动。还是跟之前的案例一样,我们使用AI来编写udf。这次使用Calude 3。提示词为 write me a Fluent UDF for the dynamic mesh to move 4mm in x direction within 0.1s then stop, use Define_CG_Motion macro.
#include "udf.h"
#include "math.h"
/* This UDF moves the dynamic mesh in the x-direction by 4 mm within 0.1 s with acceleration and deceleration */
DEFINE_CG_MOTION(my_cg_motion, dt, vel, omega, time, dtime)
{
real x_vel, y_vel, z_vel;
real x_omega, y_omega, z_omega;
real start_time = RP_Get_Real("motion-start-time");
real duration = 0.1; /* duration of motion in seconds */
real x_dist = 4e-3; /* distance to move in x-direction (m) */
real total_time = time + dtime;
/* Calculate the velocity for the current time step */
if (total_time <= start_time + duration)
{
real time_fraction = (total_time - start_time) / duration;
x_vel = (x_dist / duration) * sin(M_PI * time_fraction);
}
else
{
x_vel = 0.0; /* Stop the motion after the desired displacement is achieved */
}
/* Set the translational and rotational velocities */
y_vel = 0.0;
z_vel = 0.0;
x_omega = 0.0;
y_omega = 0.0;
z_omega = 0.0;
/* Assign the velocities to the UDF output arguments */
vel[0] = x_vel;
vel[1] = y_vel;
vel[2] = z_vel;
omega[0] = x_omega;
omega[1] = y_omega;
omega[2] = z_omega;
}
开始AI提供了一个具有加速度的x_vel,位移特别快,后面有让它考虑了加速和加速,它自动添加了sin函数来控制,还是很强的。
大概说一下DEFINE_CG_MOTION这个宏,这里的CG是指center of gravity,区域的重心,这个宏常用来指定网格的位移。
DEFINE_CG_MOTION( name, dt, vel, omega, time, dtime)
- Dynamic_Thread *dt:指向存储已指定(或由 ANSYS FLUENT 计算的)动态网格属性的结构的指针。
- real vel[ ]:线速度。
- real omega[ ]:角速度。
- real time:当前时间。
- real dtime:时间步长。
编译完udf后,将其与piston网格域绑定并定义其中心位置。具体如何编译udf可以参考这篇文章。

六、设置间隙模型(Gap Model)
采用间隙模型可以用来指定当两个区域靠近多少后关闭水流,可以在主菜单的Domain -> Mesh Models -> Gap Model中找到。

设置步骤如下:
1、选择需要创建间隙的两个面域(这里为pistion和wall)。
2、设置间隙大小,靠近多少的时候关闭水流,这里我们设置1.2mm,意思是当活塞靠近壁面1.2毫米的时候Fluent就会认为没有水流从这个间隙经过。类型默认为Flow-blocking(流动阻塞)。
3、点击Create创建。

如果不知道是哪两个面,可以在网格显示那里选择两个面域显示确认。比如这里我们选中了pistion和wall-valve-freeparts_valve。


七、结果监测
在结果中添加Mass Flow rate 以观测阀门是否关闭

八、运行模拟
设置如下瞬态模拟的时间步长和每次迭代次数。在模拟开始前注意保存一下案例,因为动态网格的变化是不可逆的。

模拟结果:可以看到流量逐渐减少,在0.1秒的时候突然变为0,证明阀门关闭了。

变形动画,最后关闭的一下网格破碎了,不知道是怎么回事。
