“常用公式”在线计算,“设计手册”在线查询
隋博士好,我在用Fluent 14.0计算两车交会的动网格中编写了两个类似的UDF(car1.c和car2.c)(UDF中主要用到了DEFINE_CG_MOTION和Compute_Force_And_Moment)来定义两车的相向运动,同时添加到fluent 14 中编译运行,通过运行后生成“car1的位移.txt”和“car2的位移.txt”文件分析,fluent 14 将car1.c运行了一遍,car2.c运行了两遍,因为“car1的位移.txt”文件里面每个t时刻的位移数据写了一遍(参见附件中的图2),而“car2的位移.txt”文件里面每个t时刻的位移数据写了两遍(参见附件中的图1),并且第二遍的数值和第一遍的稍有不同(参见附件中的图3),car1.c并且“car1.txt”文件大小为122k,而“car2.txt”文件大小为236k。隋博士能否解答下问题可能出现在哪些方面啊?在此先行表示感谢!
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 支持支持 反对反对

共 3 个关于本帖的回复 最后回复于 2013-7-8 18:27

沙发
陈琳 八品司务 发表于 2013-7-8 10:39:28 | 只看该作者
研发埠培训中心
附件可以下载了
板凳
高永川 认证专家 发表于 2013-7-8 18:15:30 | 只看该作者
研发埠人才中心
测试了下,确实是这样,但没找到原因,估计跟DEFINE_CG_MOTION本身的调用方式有关。。建议在每个源文件下加一个DEFINE_EXECUTE_AT_END这样保证不会出歧义。#include "udf.h"#include<stdio.h>#define jidou2_mass 10700  //the mass of the jidou2static real jidou2_inertial[3]={83896.92,1199.83,85096.75}; //moments of inertia in 3D, here you can change the initial valuestatic real jidou2_vel_prev[3]={0,0,0};//velocity of the jidou2, here you can change the initial valuestatic real jidou2_omega_prev[3]={0,0,0};//angular velocity of the jidou2, here you can change the initial valuestatic real jidou2_dis_prev[3]={0,0,0};//displacement of the jidou2, here you can change the initial valuestatic real jidou2_theta_prev[3]={0,0,0};//angular displacement of the jidou2, here you can change the initial valuestatic real jidou2_acc[3]={0,0,0};static real jidou2_rotacc[3]={0,0,0};static real jidou2_centroid[3]={0.58,4.85,0}; //centroid of the jidou2, here you can change the initia]valueint i=1;DEFINE_EXECUTE_AT_END(at_end){ real time; FILE *fp2;  FILE *fp1;  time = RP_Get_Real("flow-time");   fp2=fopen("ca1","a");   fp1=fopen("count0","a");  fprintf(fp2,"%.6e  %.8f  %.8f  %.8f  %.8f  %.8f  %.8f
",time,jidou2_dis_prev[0],jidou2_theta_prev[2],jidou2_vel_prev[0],jidou2_omega_prev[2],jidou2_acc[0],jidou2_rotacc[2]);  fprintf(fp1,"%.6e%6i
",time,i);  i=i+1;  Message("this is the firt time
");  fclose(fp2);    fclose(fp1); }DEFINE_CG_MOTION(JiDou2,dt,vel,omega,time,dtime){  Thread *tread;  Domain *domin;  face_t f;  real force[3];//the total force on the jidou2.  real moment[3];//the total momentum on the jidou2  real d_vel[3];  real d_omega[3];  real jidou2_k1;  real jidou2_k2;  real h=4.85; //h定义为箕斗高度的一半  real L=440; //暂取井道深度m  real jidou2_s=0; // jidou2_s定义为箕斗的提升行程  real s20=195.75; // s20定义为t=0时箕斗距罐道绳顶部的距离, s10=220-19.4-4.85=195.75  real n2=4; // n2定义为箕斗两侧罐道绳的数量  real Q=5650; // Q为每根罐道绳底部张紧重锤的质量;  real q=8.94; // q为罐道绳单位长度的重量,Φ查标准YB/T 5295-2006密封钢丝绳表  real g=9.81; // g为重力加速度;  FILE *fp2;  FILE *fp1;   fp2=fopen("ca3","a");   fp1=fopen("count1","a");  fprintf(fp2,"%.6e  %.8f  %.8f  %.8f  %.8f  %.8f  %.8f
",time,jidou2_dis_prev[0],jidou2_theta_prev[2],jidou2_vel_prev[0],jidou2_omega_prev[2],jidou2_acc[0],jidou2_rotacc[2]);  fprintf(fp1,"%.6e%6i
",time,i);  i=i+1;  Message("this is the firt time
");  fclose(fp2);    fclose(fp1);  tread=DT_THREAD(dt); //get the thread pointer for which this motion is defined  domin=THREAD_DOMAIN(tread); //DT_THREAD(t): pointer to face thread;  Compute_Force_And_Moment(domin,tread,jidou2_centroid,force,moment,FALSE);  //the macro for the calculation of total force and total momentum on the jidou2.if(time<=1.0)  {    vel[1]=-time*9.7;    jidou2_s=-vel[1]*time/2;   }  else  {    vel[1]=-9.7;    jidou2_s=-vel[1]*time-9.7/2;   }   jidou2_k1=(n2*Q*g+n2*q*(L-s20-jidou2_s+h)*g+ jidou2_mass*g)/(s20+jidou2_s-h);   jidou2_k2=(n2*Q*g+n2*q*(L-s20-jidou2_s-h)*g)/(L-s20-jidou2_s-h);   jidou2_dis_prev[0]=jidou2_dis_prev[0]+jidou2_vel_prev[0]*dtime;   jidou2_theta_prev[2]=jidou2_theta_prev[2]+jidou2_omega_prev[2]*dtime;   jidou2_acc[0]=(force[0]-jidou2_k1*(jidou2_dis_prev[0]-h*jidou2_theta_prev[2])-jidou2_k2*(jidou2_dis_prev[0]+h*jidou2_theta_prev[2]))/jidou2_mass;   d_vel[0]=jidou2_acc[0]*dtime;   //get the accelaration of the jidou2 with Newton’s second 1aw.   jidou2_vel_prev[0]=jidou2_vel_prev[0]+d_vel[0];//v+dv get the new translational velocity   vel[0]=jidou2_vel_prev[0];   jidou2_rotacc[2]=(moment[2]+jidou2_k1*(jidou2_dis_prev[0]-h* jidou2_theta_prev[2])*h-jidou2_k2*(jidou2_dis_prev[0]+h*jidou2_theta_prev[2])*h)/jidou2_inertial[2];   d_omega[2]=jidou2_rotacc[2]*dtime;   //get the accelaration of the jidou2 with Newton’s second law.   jidou2_omega_prev[2]=jidou2_omega_prev[2]+d_omega[2];//ω+dωget the new rotational velocity   omega[2]=jidou2_omega_prev[2];   Message("%.6e  %.8f  %.8f  %.8f  %.8f  %.8f  %.8f
",time,jidou2_dis_prev[0],jidou2_theta_prev[2],jidou2_vel_prev[0],jidou2_omega_prev[2],jidou2_acc[0],jidou2_rotacc[2]);}
地板
鲁仁 新来的 发表于 2013-7-8 18:27:42 | 只看该作者
谢谢你啊!是不是跟模型有关啊?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注我们

360网站安全检测平台