在ANSYSFluent中建三维管道模型后,需要利用UDF将入口速度写为抛物线型,可教案上都是二维,我不会UDF,能否有人帮写一个三维的UDF做参考,假定管道入口直径为0.1m,速度为2m/s。
我抄写的UDF如下:
#include "udf.h"
DEFINE_PROFILE(x_velocity,thread,nv)
{
float x;
float y;
face_t f;
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x;
F_PROFILE(f, thread, nv)
= 2*(1-y*y/(0.04*0.04));
}
end_f_loop(f, thread)
}
UDF帮助上的例子(入口速度为20m/s)
#include "udf.h"
DEFINE_PROFILE(inlet_x_velocity, thread, position)
{
realx[ND_ND];
real y;
face_t f;
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1];
F_PROFILE(f, thread, position) = 20 -y*y/(.0745*.0745)*20;
}
end_f_loop(f, thread)
}
三维的抛物线速度入口(本例是圆管入口,速度1.23m/s, 入口尺寸为直径6mm):
#include "udf.h"
DEFINE_PROFILE(inlet_x_velocity, thread, position)
{
floatx[ND_ND];
float y,z;
face_t f;
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1];
z = x[2];
F_PROFILE(f, thread, position) = 1.23- y*y/(0.003*0.003)*1.23-z*z/(0.003*0.003)*1.23;
}
end_f_loop(f, thread)
}
小木虫网友应助:
#include "udf.h"
DEFINE_PROFILE(inlet_x_velocity, thread, index)
{
real x[ND_ND];
real y,z;
face_t f;
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
// x=x[0];
y=x[1];
z=x[2];
F_PROFILE(f, thread, index)=0.2*(1-y*y/(0.01*0.01)-z*z/(0.01*0.01));
}
end_f_loop(f, thread)
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。