|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本帖最后由 ender-x 于 2015-5-5 20:56 编辑
想在fluent中通过滑移网格模拟轮机在水流作用下的自由旋转,用DEFINE_ZONE_MOTION宏和Compute_Force_And_Moment函数写了如下udf:
#include "udf.h"
#include "f_wall.h"
static real theta=0.0;
static real omega_calc=0.0;
int flag=0;
DEFINE_ZONE_MOTION(turbinemotion,omega,axis,origin,velocity,time,dtime)
{
const real inertia =1.38;
Domain *small=Get_Domain(3);
Thread *face_rotor=Lookup_Thread(small,9);
real force_rotor[ND_ND],moment_rotor[ND_ND];
real point_rotor[ND_ND];
real axis_rotor[3]={0.0, 0.0, 1.0}; /* shaft axis directional vector */
real torque_rotor;
real torque,domega,omega_prev,omega_dot,omega_out,power;
FILE *fd;
int i;
for(i=0;i<=ND_ND;i++)
{
force_rotor=0;
moment_rotor=0;
point_rotor=0;
}
Compute_Force_And_Moment(small,face_rotor,point_rotor,force_rotor,moment_rotor,1);
torque_rotor=NV_DOT(moment_rotor,axis_rotor);
torque=torque_rotor;
domega=dtime*torque/inertia;
omega_dot=torque/inertia;
omega_prev=omega_calc;
omega_calc=omega_calc + domega;
omega_out=omega_calc;
theta=theta+0.5*dtime*(omega_prev+omega_calc);
power=torque*omega_out;
Message ("\npoint4 %f\n ", theta) ;
N3V_D (velocity,=,0.0,0.0,0.0);
N3V_D(axis,=,0.0,0.0,1.0);
if ( flag !=N_TIME)
{
fd=fopen("data.txt","a+");
if(flag==0)
{
fprintf(fd,"time torque omega theta power\n");
}
flag=N_TIME;
fprintf(fd," %g %g %g %g %g\n",CURRENT_TIME,torque,omega_out,theta,power);
fclose(fd);
}
Message ("\nomega: %f\n ", omega_out) ;
Message ("\n---------------------------------------\n");
*omega=omega_out;
}
该udf在fluent中可以正常加载,但是在计算过程中会出现下图的问题:
最终确定是运行到上述背景黄色行时出现的问题,但却不知如何解决了。请教大家有什么办法?先谢过了。
|
|