| 5 | 2/1 | 返回列表 |
| 查看: 3106 | 回復: 15 | ||
| 當前只顯示滿足指定條件的回帖,點擊這里查看本話題的所有回帖 | ||
13386846246銅蟲 (小有名氣)
|
[求助]
udf不能正確調用顆粒的宏的值進行計算
|
|
|
采用多表面燃燒模型模擬煤顆粒燃燒,使用DEFINE_PR_RATE計算顆粒反應,并讀取顆粒質量P_INIT_MASS(p),和顆粒溫度P_T(p),以監(jiān)測計算過程。 用fprintf(fpOut2,"%f\n",P_T(p));和fprintf(fpOut1,"%f\n",P_INIT_MASS(p));輸出, 可是導出的P_T(p)數(shù)據(jù)與在material面板中設置的顆粒密度值相等,P_INIT_MASS數(shù)據(jù)與在離散相中設置的顆粒直徑數(shù)值相等,其他顆粒的宏輸出也不正確。 udf不能正確地調用P_INIT_MASS(p)與P_T(p)的值。請教下各位,這是為什么? #include "udf.h" #define A1 10.6313 #define E1 5.1811e+07 DEFINE_PR_RATE(user_pr_rate,c,t,r,mw,pp,p,sf,dif_i,cat_i,rr) { real ash_mass = P_INIT_MASS(p)*(1.-1./3.); real one_minus_conv1 = MAX(0.,3*(P_MASS(p)-ash_mass)/P_INIT_MASS(p)); real one_minus_conv = 3.*exp(2.*log(one_minus_conv1)/3.); real rate = A1*exp(-E1/UNIVERSAL_GAS_CONSTANT/P_T(p)); *rr = -rate*P_INIT_MASS(p)*one_minus_conv; FILE *fpOut1 = fopen("P_INIT_MASS(p).txt","a" ;fprintf(fpOut1,"%f\n",P_INIT_MASS(p)); fclose(fpOut1); FILE *fpOut2 = fopen("P_T(p).txt","a" ;fprintf(fpOut2,"%f\n",P_T(p)); fclose(fpOut2); FILE *fpOut3 = fopen("P_MASS(p).txt","a" ;fprintf(fpOut3,"%f\n",P_MASS(p)); fclose(fpOut3); } |
|
首先P_INIT_MASS(p),是初始質量,如果你想調用的質量是當前質量應該用P_MASS(p),另進入當前cell時的質量是P_MASS0(p) 對于你的問題,可能是由于沒有告訴程序正在追蹤的顆粒,在最開始加入 Tracked_Particle *p試一試。 好久沒寫UDF了,可能說的不對。具體你還是看一下UDF手冊。 以下內容百度來的,供參考: DEFINE_PR_RATE(name,c,t,r,mw,ci,p,sf,dif index,cat index,rr) symbol name---- UDF name. cell t c---- Cell index of current particle. Thread *t---- Pointer to cell thread for particle. Reaction *r---- Pointer to data structure that represents the current reaction. real *mw---- Pointer to array containing gaseous and surface species molecular weights real *ci---- Pointer to array containing gas partial pressures. Tracked Particle *p---- Pointer to Tracked Particle data structure that contains data related to the particle being tracked. real *sf---- Pointer to array containing mass fractions of the solid species in the particle char mass at the current time step. int dif_index---- Diffusion controlled species as defined in the Reactions panel for the current reaction. int cat_index---- Catalyst species as defined in the Reactions panel for the current reaction. |
銅蟲 (小有名氣)
|
謝謝您的回復,加入Tracked_Particle *p 后進行編譯,出現(xiàn)redefinition of formal parameter 'p'問題,應該是DEFINE_PR_RATE(name,c,t,r,mw,ci,p,sf,dif index,cat index,rr)中已經(jīng)聲明了*p。 有些地方不明白,想問下: (1)P_INIT_MASS(p) 在面板中并沒設置參數(shù),那P_INIT_MASS(p)的數(shù)值是怎么得到的,是根據(jù)P_INIT_DIAM(p)與P_INIT_RHO(p)計算的么? (2)P_MASS0(p)與P_INIT_MASS(p)是什么關系? |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 一志愿 西北大學 ,070300化學學碩,總分287,雙非一本,求調劑。 +4 | 晨昏線與星海 2026-03-20 | 4/200 |
|
|---|---|---|---|---|
|
[考研] 求調劑 一志愿 本科 北科大 化學 343 +4 | 13831862839 2026-03-24 | 5/250 |
|
|
[考研] 07化學280分求調劑 +7 | 722865 2026-03-23 | 7/350 |
|
|
[考研] 281求調劑 +3 | Koxui 2026-03-24 | 4/200 |
|
|
[考研] 食品專碩 一志愿雙一流 328 +3 | xiaom99 2026-03-21 | 4/200 |
|
|
[考研] 300分,材料,求調劑,英一數(shù)二 +5 | 超贊的 2026-03-24 | 5/250 |
|
|
[考研] 材料學碩333求調劑 +3 | 北道巷 2026-03-24 | 3/150 |
|
|
[考研]
|
黃粱一夢千年 2026-03-24 | 3/150 |
|
|
[考研] 081700 調劑 267分 +9 | 迷人的哈哈 2026-03-23 | 9/450 |
|
|
[考研] 求調劑 +7 | 十三加油 2026-03-21 | 7/350 |
|
|
[考研] 284求調劑 +3 | yanzhixue111 2026-03-23 | 6/300 |
|
|
[考研] 336求調劑 +4 | 收到VS 2026-03-20 | 4/200 |
|
|
[考研] 333求調劑 +6 | 87639 2026-03-21 | 10/500 |
|
|
[考研] 求調劑 +7 | Auroracx 2026-03-22 | 7/350 |
|
|
[考研]
|
Grand777 2026-03-21 | 3/150 |
|
|
[考研] 313求調劑 +4 | 肆叁貳壹22 2026-03-19 | 4/200 |
|
|
[考研] 一志愿重慶大學085700資源與環(huán)境總分308求調劑 +7 | 墨墨漠 2026-03-20 | 7/350 |
|
|
[考研] 南昌大學材料專碩311分求調劑 +6 | 77chaselx 2026-03-20 | 6/300 |
|
|
[考研] 南京大學化學376求調劑 +3 | hisfailed 2026-03-19 | 6/300 |
|
|
[考研] 一志愿武漢理工材料工程專碩調劑 +9 | Doleres 2026-03-19 | 9/450 |
|