fluent 如何udf控制多入口逐个进气? 20
浏览:1444 回答:3
有2个进气口,如何控制入口1进气1s然后关闭,入口2进气1s然后关闭,然后循环作用。尝试学udf控制,但失败了(从效果图看还是两个口同时进气)。请教大神们如何编写udf或有什么招。
我的udf如下:
#include "udf.h"
DEFINE_PROFILE(inlet1_pressure, thread, position)
{
real t;
face_t f;
begin_f_loop(f, thread)
{
t=RP_Get_Real("flow-time");
if (0<t<=1 || 2<t<=3)
{
F_PROFILE(f,thread,position) = 300000;
}
else
{
F_PROFILE(f,thread,position) = 0;
}
}
end_f_loop(f,thread)
}
DEFINE_PROFILE(inlet2_pressure, thread, position)
{
real t;
face_t f;
begin_f_loop(f, thread)
{
t=RP_Get_Real("flow-time");
if (1<t<=2 || 3<t<=4)
{
F_PROFILE(f,thread,position) = 300000;
}
else
{
F_PROFILE(f,thread,position) = 0;
}
}
end_f_loop(f,thread)
}
程序if语句错了,写成如下格式就行
begin_f_loop(f, thread)
{
if (t>0&&t<=0.5 )
{
F_PROFILE(f,thread,position) = 400000;
}
else if (t>2&&t<=2.5 )
{
F_PROFILE(f,thread,position) = 400000;
}
else if (t>4&&t<=4.5 )
{
F_PROFILE(f,thread,position) = 400000;
}
else if (t>6&&t<=6.5 )
{
F_PROFILE(f,thread,position) = 400000;
}
else if (t>8&&t<=8.5 )
{
F_PROFILE(f,thread,position) = 400000;
}
else if (t>10&&t<=10.5 )
{
F_PROFILE(f,thread,position) = 400000;
}
else if (t>12&&t<=12.5 )
{
F_PROFILE(f,thread,position) = 400000;
}
else if (t>14&&t<=14.5 )
{
F_PROFILE(f,thread,position) = 400000;
}
else if (t>16&&t<=16.5 )
{
F_PROFILE(f,thread,position) = 400000;
}
else if (t>18&&t<=18.5 )
{
F_PROFILE(f,thread,position) = 400000;
}
else
{
F_PROFILE(f,thread,position) = 0;
}
}
end_f_loop(f,thread)