24小时热门版块排行榜    

查看: 1670  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 266求调剂 +5 阳阳哇塞 2026-03-14 10/500 2026-03-19 15:08 by 阳阳哇塞
[考研] 一志愿西安交通大学材料工程专业 282分求调剂 +5 枫桥ZL 2026-03-18 7/350 2026-03-19 14:52 by 功夫疯狂
[考研] 281求调剂(0805) +9 烟汐忆海 2026-03-16 19/950 2026-03-19 11:42 by laoshidan
[考研] 354求调剂 +4 Tyoumou 2026-03-18 7/350 2026-03-18 21:45 by Tyoumou
[考研] 344求调剂 +6 knight344 2026-03-16 7/350 2026-03-18 20:13 by walc
[考研] 08工科 320总分 求调剂 +5 梨花珞晚风 2026-03-17 5/250 2026-03-18 14:49 by haxia
[考研] 0854可跨调剂,一作一项核心论文五项专利,省、国级证书40+数一英一287 +8 小李0854 2026-03-16 8/400 2026-03-18 14:35 by 搏击518
[考研] 收复试调剂生 +4 雨后秋荷 2026-03-18 4/200 2026-03-18 14:16 by elevennnne
[考研] 280求调剂 +6 咕噜晓晓 2026-03-18 7/350 2026-03-18 11:25 by 无际的草原
[考研] 301求调剂 +4 A_JiXing 2026-03-16 4/200 2026-03-17 17:32 by ruiyingmiao
[考研] 332求调剂 +6 Zz版 2026-03-13 6/300 2026-03-17 17:03 by ruiyingmiao
[考研] 药学383 求调剂 +3 药学chy 2026-03-15 4/200 2026-03-16 20:51 by 元子^0^
[考研] 333求调剂 +3 文思客 2026-03-16 7/350 2026-03-16 18:21 by 文思客
[考研] 085600调剂 +5 漾漾123sun 2026-03-12 6/300 2026-03-16 15:58 by 漾漾123sun
[考研] 一志愿华中师范071000,325求调剂 +6 RuitingC 2026-03-12 6/300 2026-03-16 14:50 by 可淡不可忘
[考研] 328求调剂 +3 5201314Lsy! 2026-03-13 6/300 2026-03-14 15:31 by hyswxzs
[考研] 330求调剂 +3 ?酱给调剂跪了 2026-03-13 3/150 2026-03-14 10:13 by JourneyLucky
[考研] 0856材料与化工301求调剂 +5 奕束光 2026-03-13 5/250 2026-03-13 22:00 by 星空星月
[硕博家园] 085600 260分求调剂 +3 天空还下雨么 2026-03-13 5/250 2026-03-13 18:46 by 天空还下雨么
[考研] 321求调剂(食品/专硕) +3 mxcz321 2026-03-12 6/300 2026-03-13 08:45 by xc321
信息提示
请填处理意见