| 查看: 1838 | 回复: 20 | |||
| 当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖 | |||
huangkai1新虫 (小有名气)
|
[求助]
udf代码求助 已有3人参与
|
||
|
各位老师同学好,最近在在做毕设,遇到一个问题实在不知如何解决,特来求助,先谢谢各位的帮助。 我做的主要是固定床反应器的模拟,在不加载udf源项时,能够得到模拟结果,但当加载源项后,就出现Sample Text的错误,现附上自己的cas和代码,希望大家能够指导,献上所有金币。 #include "udf.h" /*动力学参数常量*/ #define PRE_EXP1 865.609 /*指前因子 单位mol/g.h.kpa2*/ #define PRE_EXP2 6275.871 /*指前因子 单位mol/g.h.kpa2*/ #define PRE_EXP3 1.60375e+05 /*指前因子 单位mol/g.h.kpa*/ #define PRE_EXP4 3277.5722 /*指前因子 单位mol/g.h.kpa*/ #define PRE_EXP5 13481.3718 /*指前因子 单位mol/g.h.kpa*/ #define ACTIVE1 6.04e+04 /*活化能 J/mol*/ #define ACTIVE2 6.24e+04 /*活化能 J/mol*/ #define ACTIVE3 6.66e+04 /*活化能 J/mol*/ #define ACTIVE4 2.64e+04 /*活化能 J/mol*/ #define ACTIVE5 5.42e+04 /*活化能 J/mol*/ #define BETA 0.0 /*温度指数*/ double arrhenius_rate1(real temp) { return PRE_EXP1*pow(temp,BETA)*exp(-ACTIVE1/(UNIVERSAL_GAS_CONSTANT*temp)); } double arrhenius_rate2(real temp) { return PRE_EXP2*pow(temp,BETA)*exp(-ACTIVE2/(UNIVERSAL_GAS_CONSTANT*temp)); } double arrhenius_rate3(real temp) { return PRE_EXP3*pow(temp,BETA)*exp(-ACTIVE3/(UNIVERSAL_GAS_CONSTANT*temp)); } double arrhenius_rate4(real temp) { return PRE_EXP4*pow(temp,BETA)*exp(-ACTIVE4/(UNIVERSAL_GAS_CONSTANT*temp)); } double arrhenius_rate5(real temp) { return PRE_EXP5*pow(temp,BETA)*exp(-ACTIVE5/(UNIVERSAL_GAS_CONSTANT*temp)); } #define P_C8H10 0 #define O_C8H10 1 #define M_C8H10 2 #define C6H6 3 #define C2H4 4 #define H20 5 #define CH3OH 6 #define C7H8 7 double reaction_rate1(cell_t c, Thread *cthread,real mw[],real yi[]) { real concenC7H8 = C_R(c,cthread)*yi[C7H8]/mw[C7H8]; real concenCH3OH = C_R(c,cthread)*yi[CH3OH]/mw[CH3OH]; return arrhenius_rate1(C_T(c,cthread))*pow(concenC7H8,1)*pow(concenCH3OH,1)*pow((UNIVERSAL_GAS_CONSTANT*C_T(c,cthread)),2); } double reaction_rate2(cell_t c, Thread *cthread,real mw[],real yi[]) { real concenCH3OH = C_R(c,cthread)*yi[CH3OH]/mw[CH3OH]; return arrhenius_rate2(C_T(c,cthread))*pow(concenCH3OH,2)*pow((UNIVERSAL_GAS_CONSTANT*C_T(c,cthread)),2); } double reaction_rate3(cell_t c, Thread *cthread,real mw[],real yi[]) { real concenC7H8 = C_R(c,cthread)*yi[C7H8]/mw[C7H8]; return arrhenius_rate3(C_T(c,cthread))*pow(concenC7H8,1)*pow((UNIVERSAL_GAS_CONSTANT*C_T(c,cthread)),1); } double reaction_rate4(cell_t c, Thread *cthread,real mw[],real yi[]) { real concenP_C8H10 = C_R(c,cthread)*yi[P_C8H10]/mw[P_C8H10]; return arrhenius_rate4(C_T(c,cthread))*pow(concenP_C8H10,1)*pow((UNIVERSAL_GAS_CONSTANT*C_T(c,cthread)),1); } double reaction_rate5(cell_t c, Thread *cthread,real mw[],real yi[]) { real concenP_C8H10 = C_R(c,cthread)*yi[P_C8H10]/mw[P_C8H10]; return arrhenius_rate5(C_T(c,cthread))*pow(concenP_C8H10,1)*pow((UNIVERSAL_GAS_CONSTANT*C_T(c,cthread)),1); } /*定义能量方程源项*/ DEFINE_SOURCE(energy_source,c,t,dS,eqn) { real delt_h1,delt_h2,delt_h3,delt_h4,delt_h5, source,mw[8],yi[8]; /*下面是五个反应的生成焓 单位kJ/mol*/ delt_h1=-73.682; delt_h2=-14.430; delt_h3=-47.772; delt_h4=59.252; delt_h5=0.862; source=(delt_h1*reaction_rate1(c,t,mw,yi)+delt_h2*reaction_rate2(c,t,mw,yi)+delt_h3*reaction_rate3(c,t,mw,yi)+delt_h4*reaction_rate4(c,t,mw,yi)+delt_h5*reaction_rate5(c,t,mw,yi))*1000*235.785;/*计算所有反应的反应热 单位kj/h*/ dS=0; return source; } /*定义C7H8组分方程源项*/ DEFINE_SOURCE(c7h8_source,c,t,dS,eqn) { real source,mw[8],yi[8]; source=(0-reaction_rate1(c,t,mw,yi)-reaction_rate3(c,t,mw,yi)+reaction_rate4(c,t,mw,yi))*mw[C7H8]*0.2385785; /*计算甲苯的消耗速度 单位g/h)*/ dS=0; return source; } /*定义CH3OH组分方程源项*/ DEFINE_SOURCE(ch3oh_source,c,t,dS,eqn) { real source,mw[8],yi[8]; source=(-reaction_rate1(c,t,mw,yi)-reaction_rate2(c,t,mw,yi))*mw[CH3OH]*0.235785; /*计算CH30H的消耗速度 单位g/h*/ dS=0; return source; } /*定义C6H6组分方程源项*/ DEFINE_SOURCE(C6H6,c,t,dS,eqn) { real source,mw[8],yi[8]; source=0.5*(reaction_rate3(c,t,mw,yi))*mw[C6H6]*0.235785; /*计算CO2的生成速度 单位g/h*/ dS=0; return source; } /*定义H20组分方程源项*/ DEFINE_SOURCE(h2o_source,c,t,dS,eqn) { real source,mw[8],yi[8]; source=(reaction_rate1(c,t,mw,yi)+reaction_rate2(c,t,mw,yi))*mw[H2O]*0.235785;/*计算H2O的生成速度 单位g/h*/ dS=0; return source; } /*定义P-X组分方程源项*/ DEFINE_SOURCE(P_C810source,c,t,dS,eqn) { real source,mw[8],yi[8]; source=(reaction_rate1(c,t,mw,yi)-reaction_rate4(c,t,mw,yi)-reaction_rate5(c,t,mw,yi))*mw[P_C8H10]*0.235785; /*计算P-X的生成速度 单位g/h*/ dS=0; return source; } /*定义O-X组分方程源项*/ DEFINE_SOURCE(O_C8H10source,c,t,dS,eqn) { real source,mw[8],yi[8]; source=0.5*reaction_rate5(c,t,mw,yi)*mw[O_C8H10]*0.235785; /*计算O-X的生成速度 单位g/h*/ dS=0; return source; } /*定义M-X组分方程源项*/ DEFINE_SOURCE(M_C8H10source,c,t,dS,eqn) { real source,mw[8],yi[8]; source=0.5*reaction_rate5(c,t,mw,yi)*mw[M_C8H10]*0.235785; /*计算M-X的生成速度 单位g/h*/ dS=0; return source; } /*定义GH组分方程源项*/ DEFINE_SOURCE(GHsource,c,t,dS,eqn) { real source,mw[8],yi[8]; source=0.5*(reaction_rate2(c,t,mw,yi)+reaction_rate4(c,t,mw,yi))*mw[C2H4]*0.235785; /*计算M-X的生成速度 单位g/h*/ dS=0; return source; } |
» 本帖附件资源列表
-
欢迎监督和反馈:小木虫仅提供交流平台,不对该内容负责。
本内容由用户自主发布,如果其内容涉及到知识产权问题,其责任在于用户本人,如对版权有异议,请联系邮箱:xiaomuchong@tal.com - 附件 1 : fanyinqimoxing.cas
2015-05-25 16:55:43, 735.67 K
» 猜你喜欢
国社科系统bug了,是不是要放榜了?
已经有4人回复
申博发邮件
已经有6人回复
各位大神,目前国内有哪些比较好用的逆合成软件?
已经有7人回复
售一区SCI文章T0P,我:8O.551.O54,科目全,可十急
已经有4人回复
售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急
已经有3人回复
售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急
已经有3人回复
售SCI文章,我:8O.5.5.1O.54,科目全,可十急
已经有3人回复
售SCI文章,我:8O.5.5.1O.54,科目全,可十急
已经有3人回复
售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急
已经有4人回复
售SCI一区T0P文章,我:8.O.55.1.O.54,科目齐全,可+急
已经有4人回复
huangkai1
新虫 (小有名气)
- 应助: 2 (幼儿园)
- 金币: 22.1
- 散金: 200
- 帖子: 173
- 在线: 166.1小时
- 虫号: 2694682
- 注册: 2013-10-01
- 专业: 天体力学和人造卫星动力学
|
出现Divergence detected in AMG solver: species-0的错误,udf应该是通过了,不过有这样的warning:temp definition shadows previous definition temp definition shadows previous definition temp definition shadows previous definition temp definition shadows previous definition temp definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition mw definition shadows previous definition yi definition shadows previous definition 肯定是哪里有问题了,不过我真是小白。 |
13楼2015-05-26 14:02:04
huangkai1
新虫 (小有名气)
- 应助: 2 (幼儿园)
- 金币: 22.1
- 散金: 200
- 帖子: 173
- 在线: 166.1小时
- 虫号: 2694682
- 注册: 2013-10-01
- 专业: 天体力学和人造卫星动力学
2楼2015-05-25 16:58:03
nickma
至尊木虫 (著名写手)
- 应助: 17 (小学生)
- 金币: 10796.7
- 散金: 1987
- 红花: 3
- 帖子: 1436
- 在线: 2321.4小时
- 虫号: 336250
- 注册: 2007-04-01
- 专业: 体育史
4楼2015-05-25 18:26:28
huangkai1
新虫 (小有名气)
- 应助: 2 (幼儿园)
- 金币: 22.1
- 散金: 200
- 帖子: 173
- 在线: 166.1小时
- 虫号: 2694682
- 注册: 2013-10-01
- 专业: 天体力学和人造卫星动力学
5楼2015-05-25 19:30:10










回复此楼