找回密码
 注册
查看: 2399|回复: 1

fluent的help中的 例子什么意思?麻烦各位帮忙看看!

[复制链接]
发表于 2013-7-6 17:20:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
Concatenated UDFs for the Discrete&nbsphase Model that includes a
   usage of DPM_SWITCH
 ***********************************************************************/
 
 #include "udf.h"
 #include "dpm.h"
 #include "surf.h" /* for macros: RP_Cell() & RP_Thread()  */
 #include "prop.h" /* for function: Saturation_Pressure() (of water) */
 
 static real dpm_relax=1.0; /*dpm source relaxation */
 
 real H2O_Saturation_Pressure(real T)
 {
    real ratio, aTmTp;
    aTmTp = .01 * (T - 338.15);
    ratio = (647.286/T - 1.) *
    (-7.419242 + aTmTp*(.29721 +
       aTmTp*(-.1155286 +
       aTmTp*(8.685635e-3 +
       aTmTp*(1.094098e-3 +
       aTmTp*(-4.39993e-3 +
       aTmTp*(2.520658e-3 -
       aTmTp*5.218684e-4)))))));
 return (22.089e6 * exp(MIN(ratio,35.)));
 }
 
 
 real myHumidity(cell_t c,Thread *t)
 {
    int i;
    Material *m=THREAD_MATERIAL(t), *sp;
    real yi_h2o=0,mw_h2o=1.0;  real r_mix=0.0;
    if(MATERIAL_TYPE(m)==MATERIAL_MIXTURE)
    {
     mixture_species_loop (m,sp,i)
       {
        r_mix += C_YI(c,t,i)/MATERIAL_PROP(sp,PROP_mwi);
        if (0 == strcmp(MIXTURE_SPECIE_NAME(m,i),"h2o") ||
            (0 == strcmp(MIXTURE_SPECIE_NAME(m,i),"H2O")))
            {
             yi_h2o = C_YI(c,t,i);
             mw_h2o = MATERIAL_PROP(sp,PROP_mwi);
            }
         }
    }
    return ((ABS_P(C_P(c,t),op_pres) * yi_h2o / (mw_h2o * r_mix)) /
       H2O_Saturation_Pressure(C_T(c,t))) ;
 }
 
 #define CONDENS 1.0e-4
 
 DEFINE_DPM_LAW(condenshumidlaw,p,coupled)
 {
   real area;
   real mp_dot;
   cell_t c =&nbsp_CELL(p);     /* Get Cell and Thread from */
   Thread *t =&nbsp_CELL_THREAD(p); /* Particle Structure using new macros*/
   area = 4.0* M_PI * (P_DIAM(p)*P_DIAM(p));
   /* Note This law only used if Humidity > 1.0 so mp_dot always positive*/
   mp_dot = CONDENS*sqrt(area)*(myHumidity(c,t)-1.0);
   if(mp_dot>0.0)
     {
       P_MASS(p) = P_MASS(p) + mp_dot*P_DT(p);
       P_DIAM(p) = pow(6.0*P_MASS(p)/(P_RHO(p)* M_PI), 1./3.);
       P_T(p)=C_T(c,t); /* Assume condensing particle is in thermal
          equilibrium with fluid in cell */
     }
 
 }
 
 /* define macro that is not yet standard */
 
 #define C_DPMS_ENERGY(c,t)C_STORAGE_R(c,t,SV_DPMS_ENERGY)
 
 DEFINE_DPM_SOURCE(dpm_source,c,t,S,strength,p)
 {
    real mp_dot;
    Material *sp = P_MATERIAL(p);
 
    /* mp_dot is the (positive) mass source to the continuous phase */
    /* (Difference in mass between entry and exit from cell)   */
    /* multiplied by strength (Number of particles/s in stream)  */
    mp_dot = (P_MASS0(p) - P_MASS(p)) * strength;
   C_DPMS_YI(c,t,0) += mp_dot*dpm_relax;
   C_DPMS_ENERGY(c,t) -= mp_dot*dpm_relax*
   MATERIAL_PROP(sp,PROP_Cp)*(C_T(c,t)-298.15);
   C_DPMS_ENERGY(c,t) -= mp_dot*dpm_relax*
   MATERIAL_PROP(sp,PROP_latent_heat);
 }
 
 
 #define UDM_RH 0
 #define N_REQ_UDM 1
 #define CONDENS_LIMIT 1.0e-10
 
 DEFINE_DPM_SWITCH(dpm_switch,p,coupled)
 {
   cell_t c = P_CELL(p); Thread *t = P_CELL_THREAD(p);
   if(C_UDMI(c,t,UDM_RH) > 1.0)
     P_CURRENT_LAW(p) = DPM_LAW_USER_1;
   else
     {
     &nbsp;if(P_MASS(p) < CONDENS_LIMIT)
       P_CURRENT_LAW(p)&nbsp;=&nbsp;DPM_LAW_INITIAL_INERT_HEATING;
     &nbsp;else
       P_CURRENT_LAW(p)&nbsp;=&nbsp;DPM_LAW_VAPORIZATION;
     }
&nbsp;}
&nbsp;
&nbsp;DEFINE_ADJUST(adj_relhum,domain)
&nbsp;{
   cell_t&nbsp;cell;
   Thread&nbsp;*thread;
   /*&nbsp;set&nbsp;dpm&nbsp;source&nbsp;underrelaxation&nbsp;*/
   dpm_relax&nbsp;=&nbsp;Domainvar_Get_Real(ROOT_DOMAIN_ID,"dpm/relax");
   if(sg_udm<N_REQ_UDM)
     &nbsp;Message("\nNot&nbsp;enough&nbsp;user&nbsp;defined&nbsp;memory&nbsp;allocated. %d required.\n",
     &nbsp;N_REQ_UDM);
   else
     {
     &nbsp;real&nbsp;humidity,min,max;
     &nbsp;min=1e10;
     &nbsp;max=0.0;
     &nbsp;thread_loop_c(thread,domain)
       &nbsp;{
       /*&nbsp;Check&nbsp;if&nbsp;thread&nbsp;is&nbsp;a&nbsp;Fluid&nbsp;thread&nbsp;and&nbsp;has&nbsp;UDMs&nbsp;set&nbsp;up&nbsp;on&nbsp;it&nbsp;*/
         if&nbsp;(FLUID_THREAD_P(thread)&&&nbsp;NNULLP(THREAD_STORAGE(thread,SV_UDM_I)))
           {
           &nbsp;begin_c_loop(cell,thread)
              humidity=myHumidity(cell,thread);
              min=MIN(min,humidity);
              max=MAX(max,humidity);
              C_UDMI(cell,thread,UDM_RH)=humidity;
           &nbsp;end_c_loop(cell,thread)
           }
&nbsp;      }
     &nbsp;Message("\nRelative&nbsp;Humidity&nbsp;set&nbsp;in&nbsp;udm-%d",UDM_RH);
     &nbsp;Message("&nbsp;range%f,%f)\n",min,max);
   }/*&nbsp;end&nbsp;if&nbsp;for&nbsp;enough&nbsp;UDSs&nbsp;and&nbsp;UDMs&nbsp;*/
&nbsp;}
&nbsp;
&nbsp;DEFINE_ON_DEMAND(set_relhum)
&nbsp;{
   adj_relhum(Get_Domain(1));
&nbsp;}&nbsp;

&nbsp;real&nbsp;myHumidity(cell_t&nbsp;c,Thread&nbsp;*t)中
r_mix&nbsp;+=&nbsp;C_YI(c,t,i)/MATERIAL_PROP(sp,PROP_mwi); mw_h2o&nbsp;=&nbsp;MATERIAL_PROP(sp,PROP_mwi);是什么意思?在学习fluent是如何利用help查找这些问题的解释?

[ 本帖最后由 passflame 于 2013-7-6 17:22 编辑 ]
发表于 2013-7-10 09:26:52 | 显示全部楼层

回复 1# passflame 的帖子

楼主  用的到这个udf吗  不知道 弄懂这段udf了吗?看帮助文件是处理Humidity > 1.0 的,需要dpm模型,
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表