24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 3107  |  回复: 15
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

13386846246

铜虫 (小有名气)

[求助] udf不能正确调用颗粒的宏的值进行计算

采用多表面燃烧模型模拟煤颗粒燃烧,使用DEFINE_PR_RATE计算颗粒反应,并读取颗粒质量P_INIT_MASS(p),和颗粒温度P_T(p),以监测计算过程。
用fprintf(fpOut2,"%f\n",P_T(p));和fprintf(fpOut1,"%f\n",P_INIT_MASS(p));输出,
可是导出的P_T(p)数据与在material面板中设置的颗粒密度值相等,P_INIT_MASS数据与在离散相中设置的颗粒直径数值相等,其他颗粒的宏输出也不正确。
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);
}
回复此楼

» 收录本帖的淘帖专辑推荐

实验

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

db0320

铁虫 (初入文坛)

P_MASS0(p)是进入当前CELL时的质量,P_MASS(p)是当前的质量
比如说一个颗粒流入一个正方体,它进入壁面入口时的质量为P_MASS0(p),
从进入正方体到离开正方体的需要一定时间,在这段时间里某一时刻的质量即为P_MASS0(p)。
9楼2017-03-13 16:57:17
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 16 个回答

db0320

铁虫 (初入文坛)

【答案】应助回帖

★ ★ ★
感谢参与,应助指数 +1
13386846246: 金币+3, 有帮助 2017-03-09 15:54:38
首先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.
2楼2017-03-09 13:01:48
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
3楼2017-03-09 13:23:05
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

13386846246

铜虫 (小有名气)

13386846246: 回帖置顶 2017-03-09 16:10:48
13386846246: 取消置顶 2017-03-09 16:11:18
引用回帖:
2楼: Originally posted by db0320 at 2017-03-09 13:01:48
首先P_INIT_MASS(p),是初始质量,如果你想调用的质量是当前质量应该用P_MASS(p),另进入当前cell时的质量是P_MASS0(p)

对于你的问题,可能是由于没有告诉程序正在追踪的颗粒,在最开始加入 Tracked_Particle *p ...

谢谢您的回复,加入Tracked_Particle *p 后进行编译,出现redefinition of formal parameter 'p'问题,应该是DEFINE_PR_RATE(name,c,t,r,mw,ci,p,sf,dif index,cat index,rr)中已经声明了*p。
有些地方不明白,想问下:
(1)P_INIT_MASS(p) 在面板中并没设置参数,那P_INIT_MASS(p)的数值是怎么得到的,是根据P_INIT_DIAM(p)与P_INIT_RHO(p)计算的么?
(2)P_MASS0(p)与P_INIT_MASS(p)是什么关系?
4楼2017-03-09 15:58:14
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[硕博家园] 北京林业大学硕导招生广告 +6 kongweilin 2026-03-26 8/400 2026-03-27 10:18 by FF_16
[考研] 材料学硕,求调剂 6+5 糖葫芦888ll 2026-03-22 10/500 2026-03-27 08:18 by hypershenger
[考研] 081200-11408-276学硕求调剂 +4 崔wj 2026-03-26 4/200 2026-03-27 08:04 by chemisry
[考研] 311求调剂 +5 lin0039 2026-03-26 5/250 2026-03-26 22:43 by 学员8dgXkO
[考研] 求调剂 +5 芦lty 2026-03-25 6/300 2026-03-26 20:49 by 不吃魚的貓
[考研] 324求调剂 +4 wysyjs25 2026-03-21 4/200 2026-03-26 20:38 by fmesaito
[考研] 081200-11408-276学硕求调剂 +3 崔wj 2026-03-26 3/150 2026-03-26 19:57 by nihaoar
[考研] 考研调剂 +8 小蜡新笔 2026-03-26 8/400 2026-03-26 16:18 by dick_runner
[考研] 07化学303求调剂 +5 睿08 2026-03-25 5/250 2026-03-25 22:46 by 418490947
[考研] 321求调剂 +3 璞玉~~ 2026-03-25 3/150 2026-03-25 19:07 by Zhanglab-TJU
[考研] 347求调剂 +4 L when 2026-03-25 4/200 2026-03-25 13:37 by cocolv
[考研] 070300化学求调剂 +9 苑豆豆 2026-03-20 9/450 2026-03-24 17:15 by licg0208
[考研] 材料专硕331求调剂 +4 鲜当牛 2026-03-24 4/200 2026-03-24 15:58 by JourneyLucky
[考研] 335求调剂 +4 yuyu宇 2026-03-23 5/250 2026-03-23 23:49 by Txy@872106
[考研] 336求调剂 +4 收到VS 2026-03-20 4/200 2026-03-23 19:02 by macy2011
[考研] 070300,一志愿北航320求调剂 +3 Jerry0216 2026-03-22 5/250 2026-03-23 09:16 by 。。堂堂
[考研] 275求调剂 +6 shansx 2026-03-22 8/400 2026-03-22 15:27 by barlinike
[考研] 285求调剂 +6 ytter 2026-03-22 6/300 2026-03-22 12:09 by 星空星月
[考研] 一志愿南大,0703化学,分数336,求调剂 +3 收到VS 2026-03-21 3/150 2026-03-21 18:42 by 学员8dgXkO
[考研] 材料 271求调剂 +5 展信悦_ 2026-03-21 5/250 2026-03-21 17:29 by 学员8dgXkO
信息提示
请填处理意见