找回密码
 注册
查看: 5282|回复: 4

求助,关于轮机在水流中旋转的UDF(DEFINE_ZONE_MOTION与Compute_Force_And_Moment)

[复制链接]
发表于 2015-5-5 20:54:10 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

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中可以正常加载,但是在计算过程中会出现下图的问题:
流体.png
最终确定是运行到上述背景黄色行时出现的问题,但却不知如何解决了。请教大家有什么办法?先谢过了。

发表于 2015-9-5 23:48:57 | 显示全部楼层
为何你们的UDF这么复杂?我的模型是旋转轮机,就定义速度和转速,没有力和力矩,那我的UDF这么搞对吗?
发表于 2017-2-16 14:08:54 | 显示全部楼层
"This function needs size of 3 for force and moment. It works in parallel and
the common arguments are the of the same type as your arguments.
In addition you have to pass the domain as first arg and a boolean as
last argument. This boolean has to be TRUE if you also call the function
on the host else it has to be FALSE."
Compute_Force_And_Moment (domain, tf, CG, force, moment, FALSE);
domain = THREAD_DOMAIN (DT_THREAD ((Dynamic_Thread *)dt)); - pointer on Domain
tf = Lookup_Thread(domain, ID); - pointer on the Thread in Domain
I don't know if "force" includes viscose and pressure force or only pressure force!!!
************************************************** **************
compute viscose force in UDF
you have to define in mem.h header or in local c-file this macro:
#define F_VISCOSE(f,tf) F_STORAGE_R_N3V(f,tf,SV_WALL_SHEAR)
Thread *tf = DT_THREAD(dt); /*pointer on thread*/
face_t f; /*number of faces*/
begin_f_loop(f, tf)
{
NV_VS(F_VISC, += , F_VISCOSE(f, tf), *, -1.0 * k); /* compute viscose force vector. k is a factor for depth in 2D computation and -1.0 corrects the sign of viscose force*/
}
end_f_loop(f, tf);
from http://www.cfd-online.com/Forums ... rce_and_moment.html
 楼主| 发表于 2017-11-7 15:51:14 | 显示全部楼层
回来回复一下,力和转矩数组用[ND_ND]建立后不要赋值,否则会出现图示错误
发表于 2017-12-12 10:47:06 | 显示全部楼层
请问你的f_wall.h是另一个UDF文件吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表