24小时热门版块排行榜    

查看: 3494  |  回复: 12
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

songsny

铜虫 (初入文坛)

[求助] UDF编译出错 DEFINE_DPM_HEAT_MASS 已有2人参与

想用UDF中的宏 DEFINE_DPM_HEAT_MASS来模拟液滴对SO2的吸收,就照着例子自己改了改,可是编译出错,又用原来的例子直接编译,发现同样的错误,代码如下:错误提示为..\..\src\multivap.c(6) : warning C4003: not enough actual parameters for macro 'DEFINE_DPM_HEAT_MASS'
..\..\src\multivap.c(7) : error C2055: expected formal parameter list, not a type list
..\..\src\multivap.c(25) : error C2109: subscript requires array or pointer type
..\..\src\multivap.c(25) : error C2106: '+=' : left operand must be l-value
..\..\src\multivap.c(26) : error C2223: left of '->energy' must point to struct/union
..\..\src\multivap.c(65) : error C2109: subscript requires array or pointer type
..\..\src\multivap.c(65) : error C2106: '-=' : left operand must be l-value
..\..\src\multivap.c(66) : error C2223: left of '->species' must point to struct/union
..\..\src\multivap.c(68) : error C2109: subscript requires array or pointer type
..\..\src\multivap.c(68) : error C2106: '-=' : left operand must be l-value
..\..\src\multivap.c(70) : error C2223: left of '->energy' must point to struct/union
求大神指点怎么修改
CODE:
/***********************************************************************
UDF for defining the heat and mass transport for
multicomponent particle vaporization
***********************************************************************/
#include "udf.h"
DEFINE_DPM_HEAT_MASS(multivap,p,Cp,hgas,hvap,cvap_surf,dydt,dzdt)
{
int ns;
int nc = TP_N_COMPONENTS( p ); /* number of particle components */
cell_t c0 = RP_CELL(&p->cCell); /* cell and thread */
Thread *t0 = RP_THREAD(&p->cCell); /* where the particle is in */
Material *gas_mix = THREAD_MATERIAL( t0 ); /* gas mixture material */
Material *cond_mix = p->injection->material;/* particle mixture material */
cphase_state_t *c = &(p->cphase); /* cell info of particle location */
real molwt[MAX_SPE_EQNS]; /* molecular weight of gas species */
real Tp = P_T(p); /* particle temperature */
real mp = P_MASS(p); /* particle mass */
real molwt_bulk = 0.; /* average molecular weight in bulk gas */
real Dp = DPM_DIAM_FROM_VOL( mp / P_RHO(p) ); /* particle diameter */
real Ap = DPM_AREA(Dp); /* particle surface */
real Pr = c->sHeat * c->mu / c->tCond; /* Prandtl number */
real Nu = 2.0 + 0.6 * sqrt( p->Re ) * pow( Pr, 1./3. ); /* Nusselt number */
real h = Nu * c->tCond / Dp; /* Heat transfer coefficient */
real dh_dt = h * ( c->temp - Tp ) * Ap; /* heat source term */
dydt[0] += dh_dt / ( mp * Cp );
dzdt->energy -= dh_dt;
{
Material *sp;
mixture_species_loop(gas_mix,sp,ns)
{
molwt[ns] = MATERIAL_PROP(sp,PROP_mwi); /* molecular weight of gas species */
molwt_bulk += C_YI(c0,t0,ns) / molwt[ns]; /* average molecular weight */
}
}
/* prevent division by zero */
molwt_bulk = MAX(molwt_bulk,DPM_SMALL);
for( ns = 0; ns < nc; ns++ )
{
/* gas species index of vaporization */
int gas_index = TP_COMPONENT_INDEX_I(p,ns);
if( gas_index >= 0 )
{
/* condensed material */
Material * cond_c = MIXTURE_COMPONENT(cond_mix, ns );
/* vaporization temperature */
real vap_temp = MATERIAL_PROP(cond_c,PROP_vap_temp);
/* diffusion coefficient */
real D = MATERIAL_PROP_POLYNOMIAL( cond_c, PROP_binary_diffusivity, c->temp);
/* Schmidt number */
real Sc = c->mu / ( c->rho * D );
/* mass transfer coefficient */
real k = ( 2. + 0.6 * sqrt(p->Re) * pow( Sc, 1./3. ) ) * D / Dp;

/* bulk gas concentration */
real cvap_bulk = c->pressure / UNIVERSAL_GAS_CONSTANT / c->temp
* c->yi[gas_index] / molwt_bulk / solver_par.molWeight[gas_index];

/* vaporization rate */
real vap_rate = k * molwt[gas_index] * Ap * ( cvap_surf[ns] - cvap_bulk );
/* only condensation below vaporization temperature */
if( 0. < vap_rate && Tp < vap_temp )
vap_rate = 0.;
dydt[1+ns] -= vap_rate;
dzdt->species[gas_index] += vap_rate;
/* dT/dt = dh/dt / (m Cp)*/
dydt[0] -= hvap[gas_index] * vap_rate / ( mp * Cp );
/* gas enthalpy source term */
dzdt->energy += hgas[gas_index] * vap_rate;
}
}
}

回复此楼

» 猜你喜欢

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

wo_不想念

铜虫 (初入文坛)

请问楼主读懂这段程序了吗。。。我也正在研究这段,还没搞懂
我在幸福里等你。。。
10楼2016-03-11 11:35:18
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 13 个回答

3_1415926

金虫 (小有名气)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
songsny: 金币+10, ★★★★★最佳答案 2016-03-09 10:37:33
DEFINE_DPM_HEAT_MASS (name, p, C_p, hgas, hvap, cvap_surf, Z, dydt, dzdt)
你少了个参量Z
real Z,  Compressibility
加上去就没事了
2楼2016-03-04 20:53:34
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

浅浅笑王子

铁虫 (正式写手)

引用回帖:
2楼: Originally posted by 3_1415926 at 2016-03-04 20:53:34
DEFINE_DPM_HEAT_MASS (name, p, C_p, hgas, hvap, cvap_surf, Z, dydt, dzdt)
你少了个参量Z
real Z,  Compressibility
加上去就没事了

real Z,??Compressibility
这一行也写在下面么

发自小木虫Android客户端
3楼2016-03-07 19:17:10
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

3_1415926

金虫 (小有名气)

引用回帖:
3楼: Originally posted by 浅浅笑王子 at 2016-03-07 19:17:10
real Z,??Compressibility
这一行也写在下面么
...

这行不用,是用来说明Z的含义。主要是这个DEFINE_DPM_HEAT_MASS(multivap,p,Cp,hgas,hvap,cvap_surf,dydt,dzdt)少了参量Z,改成DEFINE_DPM_HEAT_MASS (name, p, C_p, hgas, hvap, cvap_surf, Z, dydt, dzdt)就行了
4楼2016-03-08 10:44:09
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见