24小时热门版块排行榜    

CyRhmU.jpeg
查看: 1421  |  回复: 16

gyctju

金虫 (正式写手)

【答案】应助回帖

★ ★
感谢参与,应助指数 +1
xiegangmai(金币+2): 谢谢应助! 2012-01-08 22:58:47
可能你想法错了。边界条件部分不应该跟累加传热量的循环放在一起,这样的实际效果跟你想的是不一样的。
还有边界条件设定时应该用begin-f-loop
建议修改成如下形式试试
#include "udf.h"
real Q_tot=0;
DEFINE_PROFILE (unsteady_heatflux, thread, position)
{
Domain *d;
real cp=880;
real density=2180;
real tempn, templ, volume, Q;
Thread *t;
cell_t c;
d= Get_Domain(1); /*Get the domain using Fluent utility *//*Loop over all cell threads in the domain*/
real time= RP_Get_Real("flow-time";
real b=(int)(time/3600)+1;
int i=(int)((b-1)/24);
real Heat[3]={278.5, 280.7, 278.5};
thread_loop_c(t,d) /*Compute Q */ /*Loop over all cells */
begin_c_loop(c,t)
{

volume=C_VOLUME(c,t); /* get cell volume */
templ=C_T_M1(c,t); /*Get cell tempertuare of previous step*/
tempn=C_T(c,t); /*Get cell tempertuare*/
Q=cp*density*volume*(tempn-templ);
Q_tot +=Q;  
}
end_c_loop(c,t)
}
begine_f_loop(c,t,)
{
if (Q_tot<= Heat )
F_PROFILE(c,t,position)=60;
else F_PROFILE(c,t,position)=0;
}
end_f_loop
11楼2012-01-08 21:11:19
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xiaoguai3

新虫 (初入文坛)

引用回帖:
: Originally posted by gyctju at 2012-01-08 21:11:19:
可能你想法错了。边界条件部分不应该跟累加传热量的循环放在一起,这样的实际效果跟你想的是不一样的。
还有边界条件设定时应该用begin-f-loop
建议修改成如下形式试试
#include "udf.h"
real Q_t ...

谢谢回复~请问累加传热量该怎么处理呢?
12楼2012-01-09 09:29:51
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

gyctju

金虫 (正式写手)


xiegangmai(金币+1): 谢谢参与! 2012-01-09 21:27:48
第一个循环就是累加热量的
13楼2012-01-09 10:42:57
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

gyctju

金虫 (正式写手)

引用回帖:
12楼: Originally posted by xiaoguai3 at 2012-01-09 09:29:51:
谢谢回复~请问累加传热量该怎么处理呢?

我上边回复的那个修改大括号那块出错了,把begine_f_loop前面的大括号挪到最后去
14楼2012-01-09 10:45:24
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xiaoguai3

新虫 (初入文坛)

引用回帖:
: Originally posted by gyctju at 2012-01-09 10:45:24:
我上边回复的那个修改大括号那块出错了,把begine_f_loop前面的大括号挪到最后去

你好,我累加放在边界里面是因为需要加一个判断语句,用到REAL_TIME等参数,累加到一定情况Q归零重新开始加。
15楼2012-01-09 11:26:19
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

gyctju

金虫 (正式写手)


xiegangmai(金币+1): 谢谢参与! 2012-01-09 21:28:09
again,边界条件用begin_f_loop
估计你都没看我修改后的语句。
16楼2012-01-09 19:16:54
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xiaoguai3

新虫 (初入文坛)

引用回帖:
16楼: Originally posted by gyctju at 2012-01-09 19:16:54:
again,边界条件用begin_f_loop
估计你都没看我修改后的语句。

我在自己程序中改了。试图用fprintf将计算的Q值存入文件,但运行后发现TXT文件中数字一直是零,不知道哪里出错了。
CODE:
#include "udf.h"
#define cp 800.
#define density 2180.
FILE *fp;

DEFINE_PROFILE(unsteady_temp,t,index)
{
float tempn,templ,volume,Q,Q_tot,time,a,b,tempad;
int i;
float Heat[5]={2780000.,        280.7,        278.5,        280.5,        285.};  
Domain *d;
Thread *ct,*t0;
cell_t c,c0;
face_t f;
time = RP_Get_Real("flow-time");
a = time/3600;
b = a/24;
d = Get_Domain(1);
i=(int)(((int)a)/24);

if (b==(int)b)   
Q_tot=0;
else
{
fp=fopen("Q_tot.txt","r");
fscanf(fp,"%f",Q_tot);
fclose(fp);
}
thread_loop_c(ct,d)  
{
        begin_c_loop(c,ct) /*Loop over all cells循环所有THREAD上所有CELL */
       {
volume=C_VOLUME(c,ct); /* get cell volume */
templ=C_T_M1(c,ct); /*Get cell tempertuare of previous step有问题!!!!!!!!*/
tempn=C_T(c,ct);   /*Get cell tempertuare*/
Q=cp*density*volume*(tempn-templ);
Q_tot +=Q;
       }
     end_c_loop(c,ct)
}
fp=fopen("Q_tot.txt","w");
  fprintf(fp,"%f",Q_tot);    /*写入累加后Q_tot值 */
fclose(fp);
if (Q_tot<= Heat[i])
  begin_f_loop(f,t)
{   
    F_PROFILE(f,t,index)=333;  /*BC:Temp=333K*/
}
end_f_loop(f,t)
else
begin_f_loop(f,t)
{   
c0 = F_C0(f,t);
t0 = THREAD_T0(t);
tempad=C_T(c0,t0); /*temperature of adjacent cell*/
F_PROFILE(f,t,index)=tempad;
}
end_f_loop(f,t)
}

17楼2012-01-09 21:21:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 xiaoguai3 的主题更新
信息提示
请填处理意见