找回密码
 注册
查看: 2959|回复: 14

udf如何实现平板转动

[复制链接]
发表于 2012-8-20 11:10:33 | 显示全部楼层 |阅读模式

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

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

x
本人初学Fluent,而且UDF的编写基本一窍不通。有没有相类似的例子。请高手指导一下。有的话给我发一个。万分感谢啊。shang1989@hotmail.com。DEFINE_CG_MOTION(****, dt, vel, omega, time, dtime)
未命名.jpg
 楼主| 发表于 2012-8-21 14:36:58 | 显示全部楼层
#include "udf.h"
#include <mem.h>
static real omega_calc = 0.0;
static real theta=0.697777777;
/*extern real omega_out=0.0; */
DEFINE_CG_MOTION(move_flapper,dt,vel,omega,time,dtime)
{
NV_S(omega, =, 0.0);
real torque, torque_w, torque_p,domega, omega_prev, omega_dot, omega_out;
const real inertia = 0.1875;
/* Compute the torque due to pressure P and weight W */
/*-----------------------------------------------------------------------*/
torque_w= -10.06506 * sin(theta); /* -g*L*W*sin(theta) */
torque_p= 81.61488* cos(theta);
torque= torque_p + torque_w;
domega = dtime * torque / inertia;
omega_dot= torque / inertia;
/* Calculate the angular velocity */
/*-----------------------------------------------------------------------*/
omega_prev = omega_calc;
omega_calc = omega_calc + domega;
omega_out = omega_calc;
/* Calculate the angle theta (Taylor expansion) */
/*-----------------------------------------------------------------------*/
theta=theta + 0.5*dtime*(omega_prev+omega_calc);
#if !RP_NODE
Message ("\ntorque_p = %f, torque_W = %f, torque = %f, domega = %f, omega_calc=%f\n", torque_p, torque_W, torque, domega, omega_calc);
Message ("\n---------------------------------------");
Message ("\ntheta: %f\n", theta);
#endif
/* Resitrictions, make it stop at the end points*/
/*-----------------------------------------------------------------------*/
if (theta < 0.0872664626*1.1) /* Corresponds to 5.5 degrees */
{
omega_out=0;
omega_calc=0;
domega=0;
theta=0.0872664626*1.1;
Message("\nSTOP - Almost closed!");
}
if (theta >0.697777777)
{
omega_out=0;
omega_calc=0;
domega=0;
theta=0.697777777;
Message("\nSTOP - Fully open!");
}
#if !RP_NODE
/* Saving the values*/
/*-----------------------------------------------------------------------*/
FILE *fd_time;
FILE *fd_torque;
FILE *fd_omega;
FILE *fd_theta;

fd_time = fopen("data_time.txt","a");
fd_torque = fopen("data_torque.txt","a");
fd_omega = fopen("data_omega.txt","a");
fd_theta = fopen("data_theta.txt","a");

fprintf(fd_time, "%f \n", time);
fprintf(fd_torque, "%f \n", torque);
fprintf(fd_omega, "%f \n", omega_out);
fprintf(fd_theta, "%f \n", theta);

fclose(fd_time);
fclose(fd_torque);
fclose(fd_omega);
fclose(fd_theta);

Message ("\nomega: %f\n ", omega_out) ;
Message ("\n---------------------------------------\n");
#endif
omega[1]=omega_out;
}
 楼主| 发表于 2012-8-21 14:38:30 | 显示全部楼层
大家看看我编的那段程序里面有什么问题。。。求高手帮忙啊。往fluent软件里编译的时候总是说第三行出错。不知道是什么错误。line 3: parse error。高手帮帮忙。教教我啊。。。
 楼主| 发表于 2012-8-21 14:39:36 | 显示全部楼层
大家看看我编的那段程序里面有什么问题。。。求高手帮忙啊。往fluent软件里编译的时候总是说第三行出错。不知道是什么错误。line 3: parse error。高手帮帮忙。教教我啊。。。
 楼主| 发表于 2012-8-22 14:18:58 | 显示全部楼层
大家帮帮忙啊。
 楼主| 发表于 2012-8-24 15:45:27 | 显示全部楼层
)(system "move user_nt.udf libudf\ntx86\2d"0
(system "copy C:\Fluent.Inc\fluent6.1.22\src\makefile_nt.udf libudf\ntx86\2d\makefile"已复制 1 个文件。
0
(chdir "libudf"()
(chdir "ntx86\2d"()
'nmake' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
'nmake' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
Done.
 楼主| 发表于 2012-8-24 15:45:38 | 显示全部楼层
)(system "move user_nt.udf libudf\ntx86\2d"0
(system "copy C:\Fluent.Inc\fluent6.1.22\src\makefile_nt.udf libudf\ntx86\2d\makefile"已复制 1 个文件。
0
(chdir "libudf"()
(chdir "ntx86\2d"()
'nmake' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
'nmake' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
Done.
 楼主| 发表于 2012-8-24 15:46:21 | 显示全部楼层
出现了这样的问题。。。看网上的解决办法都是环境变量的问题。。。可是我改了之后还是不行啊。。。怎么弄啊。。。求帮助啊。。。
发表于 2012-9-3 08:23:17 | 显示全部楼层
重装系统,再重装软件
发表于 2012-9-3 09:51:57 | 显示全部楼层

回复 8# shang1989 的帖子

windows下编译问题,可以到网上下个小软件,或者不知道这个用解释行不行?
发表于 2012-11-14 12:10:12 | 显示全部楼层
重装VC,设置环境变量。这些在百度上都能找到办法!
发表于 2012-12-3 19:10:43 | 显示全部楼层

回复 6# shang1989 的帖子

这是说明你c语言环境装的不对。在开始-程序-运行里面   打出cl.exe 会出现 microsoft 32-bit c/c++ optimizing compiler version 12.00.8168 for 80*86 copyright <c> mircosoft corp 1984-1998 。all rights reserved 。 usage :cl[option...] filename ...[/ link linkoption...] 这样才行。 请问你的udf是你自己编写的吗?我想请问一个不规则物体的重心(三分之一型心)坐标在fluent中怎么知道??怎么读取。
 楼主| 发表于 2012-12-4 10:20:46 | 显示全部楼层

回复 12# dragonship2011 的帖子

你这个好解决。你导入fluent的时候是二维的还是三维的。比如说二维的,你把某一点作为原点(即与坐标原点重合),然后你把你的图形做成面域,找重心就好了。
 楼主| 发表于 2012-12-4 10:21:42 | 显示全部楼层

回复 12# dragonship2011 的帖子

我还想问一下你知道不知道如何进行监测动网格中某点的压力啊、速度啊什么的。
 楼主| 发表于 2012-12-4 10:22:06 | 显示全部楼层

回复 10# fly100fly100 的帖子

我还想问一下你知道不知道如何进行监测动网格中某点的压力啊、速度啊什么的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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