当前位置: 首页 > 仿真模拟 >FLUENT UDF求助

FLUENT UDF求助

作者 ichabod
来源: 小木虫 250 5 举报帖子
+关注

模拟的目标:使用了fluent14.5的dpm模型中的multicomponent颗粒,模拟尿素水溶液的喷雾干燥过程,想自定义颗粒表面的传质面积
使用的方法:使用宏DEFINE_DPM_HEAT_MASS,将fluent udf manual中DEFINE_DPM_HEAT_MASS的example复制过来修改
出现的问题:直接复制DEFINE_DPM_HEAT_MASS的example导入fluent编译,提示出现语法错误,于是我把75行的 if (P_total c->pressure && dydt[0] > 0.) 改为if (P_total > c->pressure && dydt[0] > 0.) ,根据物理意义当气体的饱和蒸汽压大于外界压力时液体沸腾,所以加了一个大于号。编译挂载没问题了,计算的时候就出错,显示如下
DPM Iteration ....
MPI Application rank 1 exited before MPI_Finalize() with status -1073741819
999999 (..\src\mpsystem.c@1172): mpt_read: failed: errno = 10054
999999: mpt_read: error: read failed trying to read 4 bytes: No such file or directory
The fl process could not be started.

PS:编译环境应该没问题,因为编译挂载过另一个udf是没问题的。udf如下,也可以参见fluent14.5 udf manual 2.5.4   177页或者附件的pdf。
/***********************************************************************
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,Z,dydt,dzdt)
{
int ns;
Material *sp;
real dens_total = 0.0; /* total vapor density*/
real P_total = 0.0; /* vapor pressure */
int nc = TP_N_COMPONENTS(p); /* number of particle components */
Thread *t0 = P_CELL_THREAD(p); /* thread where the particle is in*/
Material *gas_mix = THREAD_MATERIAL(DPM_THREAD(t0, p)); /* gas mixture
material */
Material *cond_mix = P_MATERIAL(p); /* particle mixture material*/
cphase_state_t *c = &(p->cphase); /* cell information 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;
mixture_species_loop(gas_mix,sp,ns)
{
molwt[ns] = MATERIAL_PROP(sp,PROP_mwi); /* molecular weight of gas
species */
molwt_bulk += c->yi[ns] / molwt[ns]; /* average molecular weight */
}
/* prevent division by zero */
molwt_bulk = MAX(molwt_bulk,DPM_SMALL);
for (ns = 0; ns < nc; ns++)
{
int gas_index = TP_COMPONENT_INDEX_I(p,ns); /* gas species index of
vaporization */
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 (ideal gas) */
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);
/* no vaporization below vaporization temperature, no condensation */
if (Tp < vap_temp || vap_rate < 0.0)
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;
P_total += cvap_surf[ns];
dens_total += cvap_surf[ns] * molwt[gas_index];
}
}
/* multicomponent boiling */
P_total *= Z * UNIVERSAL_GAS_CONSTANT * Tp;
if (P_total > c->pressure && dydt[0] > 0.)
{
real h_boil = dydt[0] * mp * Cp;
/* keep particle temperature constant */
dydt[0] = 0.;
for (ns = 0; ns < nc; ns++)
{
int gas_index = TP_COMPONENT_INDEX_I(p,ns);
if (gas_index >= 0)
{
real boil_rate = h_boil / hvap[gas_index] * cvap_surf[ns] *
molwt[gas_index] / dens_total;
/* particle component mass source term */
dydt[1+ns] -= boil_rate;
/* fluid species source */
dzdt->species[gas_index] += boil_rate;
/* fluid energy source */
dzdt->energy += hgas[gas_index] * boil_rate;
}
}
}
}

 返回小木虫查看更多

今日热帖
  • 精华评论
  • ichabod

    自己顶一个

  • cpl6618

    1. 首先,你得确定是你UDF的问题,unload 你的udf,改用常规的计算模型或者方法,会不会出现同上的问题,有时不一定UDF的问题,是你其他方面的设置出现问题。
    2. 如果是UDF的问题,那么就要好好检查你的UDF了,用UDF时,最好严格按照UDF指导内的宏 进行编写,不要以常规C编写习惯来写。
    3. UDF 中必须明确你声明 的或者用过的每一个变量,保证不除0,变量最好先声明,不出现没有赋值的情况,同时你的值得确保在合理的范围内。
    4. 数据类型要合理,采用双精度求解器。
    4. 以上你出现的错误,个人认为可能在读取数据 时出现了问题,不过你首先的排除是不是其他地方出现了问题

  • ichabod

    引用回帖:
    3楼: Originally posted by cpl6618 at 2015-04-30 21:45:14
    1. 首先,你得确定是你UDF的问题,unload 你的udf,改用常规的计算模型或者方法,会不会出现同上的问题,有时不一定UDF的问题,是你其他方面的设置出现问题。
    2. 如果是UDF的问题,那么就要好好检查你的UDF了,用UD ...

    谢谢你的回复,不好意思国庆出去玩没有及时回复。
    不用udf的时候计算是没有问题的,尝试使用双精度还是一样不行。不知道你说的读取数据是指 read case & data 的时候出问题吗?
    这个udf是udf manual 里面的,我小白,自己还不会编写。找不到udf方面容易入手的教程,感觉大部分教程的讲解都不是太清楚,很多函数都不知道怎么来的

  • lijuncai0217

    楼主你好,能告诉我这个udf怎么编译吗?

  • 疯狂的稻草人

    楼主,您好。请问您的问题解决了吗?我现在也遇到类似地问题。用UDF manual里面自带的DEFIEN_HEAT_MASS,宏,出现报错,觉着有可能是数据读取错误,但是找不出解决办法

猜你喜欢
下载小木虫APP
与700万科研达人随时交流
  • 二维码
  • IOS
  • 安卓