24小时热门版块排行榜    

查看: 1091  |  回复: 0

youngxhhhh

新虫 (初入文坛)

[求助] 气相在液相中的扩散

想用fluent模拟气相在液相中的扩散,需要编写关于质量源项的udf,同时还需设定uds,但是没有得到想要的结果,求大神们帮忙~不胜感激~
以下是自己编写的程序,另外就是迭代过程中uds残差一直为零,这样肯定是有问题的,但不知道什地方出了问题,还请大神指点!
#include "udf.h"
real ci=1.0;
real D=1.76e-09;
real rhog=1.8183;
real cl,ug,ul,ur,kl,drb,rb,rb2,a,Vl,sl;

int ts;
DEFINE_SOURCE(liq, cell, thread_l, dS, eqn)
{
    Thread *mix, *thread_g;
        mix=THREAD_SUPER_THREAD(thread_l);
        thread_g=THREAD_SUB_THREAD(mix, 1);
        ts=RP_Get_Integer("time-step";
        if(ts==1)
        {
        sl=0.0;
                dS[eqn]=0.0;
        }
        else
        {
                rb=0.002;
                ug=C_V(cell, thread_g);
                ul=C_V(cell, thread_l);
                ur=ug-ul;
                if(ur!=ug)
                {
                        if(ur!=ul)
                        {
                            cl=C_UDSI(cell, thread_l,0);
                            kl=2*sqrt(D*ur/M_PI/rb/2.0);
                            drb=kl*(ci-cl)/rhog;
                            rb2=rb-drb;
                            a=4.0*M_PI*pow(rb2,2.0);
                            Vl=C_VOLUME(cell,mix);
                            sl=kl*a*(ci-cl)/Vl;
                            dS[eqn]=0.0;
                            rb=rb2;
                        }
                        else
                        {
                            sl=0.0;
                            dS[eqn]=0.0;
                        }
                }
                else
                {
                        sl=0.0;
                        dS[eqn]=0.0;
                }
        }
        return sl;
}


DEFINE_SOURCE(gas, cell, thread_g, dS, eqn)
{
    Thread *mix, *thread_l;
        mix=THREAD_SUPER_THREAD(thread_g);
        thread_l=THREAD_SUB_THREAD(mix, 0);
        ts=RP_Get_Integer("time-step";
        if(ts==1)
        {
        sl=0.0;
                dS[eqn]=0.0;
        }
        else
        {
                rb=0.002;
                ug=C_V(cell, thread_g);
                ul=C_V(cell, thread_l);
                ur=ug-ul;
                if(ur!=ug)
                {
                        if(ur!=ul)
                        {
                            cl=C_UDSI(cell, thread_l,0);
                            kl=2*sqrt(D*ur/M_PI/rb/2.0);
                            drb=kl*(ci-cl)/rhog;
                            rb2=rb-drb;
                            a=4.0*M_PI*pow(rb2,2.0);
                            Vl=C_VOLUME(cell,mix);
                            sl=-kl*a*(ci-cl)/Vl;
                            dS[eqn]=-8.0*M_PI*kl*rb2*(ci-cl)/Vl;
                            rb=rb2;
                        }
                        else
                        {
                            sl=0.0;
                            dS[eqn]=0.0;
                        }
                }
                else
                {
                        sl=0.0;
                        dS[eqn]=0.0;
                }
        }
        return sl;
}

DEFINE_RW_FILE(write, fp)
{
        fprintf(fp, "%d", rb);
}


DEFINE_RW_FILE(reader, fp)
{
        fscanf(fp, "%d", &rb);
}
回复此楼

» 猜你喜欢

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

智能机器人

Robot (super robot)

我们都爱小木虫

相关版块跳转 我要订阅楼主 youngxhhhh 的主题更新
信息提示
请填处理意见