• 回答数

    1

  • 浏览数

    2293

  • 收藏数

    0

作者:鎭鈊爱你 发表于 2018-11-5 11:25:55
跳转到指定楼层
用udf的形式给MHD模块中外部磁场赋值,赋值的效果想跟自带的MHD模块一样,结果计算的时候发现,外部磁场赋值成功了,计算的时候却发散了
我计算的问题是磁流体泵;变化的磁场驱动流体运动。
我的udf:
#include "udf.h"
DEFINE_INIT(my_init_BO_y,domain)
{
        cell_t c;
        Thread *t;
        real xc[ND_ND];
        real temp1,temp2;
        temp1=0.02;
        temp2=0.2;
        /* loop over all cell threads in the domain */
        thread_loop_c(t,domain)
        {
                /* loop over all cells */
                begin_c_loop_all(c,t)
                {
                        C_CENTROID(xc,c,t);
                        if(xc[2]<1.0) C_UDMI(c,t,2)=cos(2*3.1415*60.0/360.0);
                        else if(xc[2]<2.0) C_UDMI(c,t,2)=cos(2*3.1415*120.0/360.0);
                        else if(xc[2]<3.0) C_UDMI(c,t,2)=cos(2*3.1415*180.0/360.0);
                        else if(xc[2]<4.0) C_UDMI(c,t,2)=cos(2*3.1415*240.0/360.0);
                        else if(xc[2]<5.0) C_UDMI(c,t,2)=cos(2*3.1415*300.0/360.0);
                        else  C_UDMI(c,t,2)=cos(2*3.1415*360.0/360.0);
                        C_UDMI(c,t,4)=sqrt(C_UDMI(c,t,2)*C_UDMI(c,t,2));




                }
                end_c_loop_all(c,t)
        }
}
DEFINE_ADJUST(adjust_b0_y,d)
{
        cell_t c;
        Thread *t;
        real xc[ND_ND];
        real current_time;
        current_time=RP_Get_Real("flow-time");
/*        current_time=CURRENT_TIME;*/
        thread_loop_c(t,d)
        {
                begin_c_loop_all(c,t)
                {
                        C_CENTROID(xc,c,t);
                        if(xc[2]<1.0) C_UDMI(c,t,2)=cos(2*3.1415*60.0/360.0+2.0*3.1415*current_time);
                        else if(xc[2]<2.0) C_UDMI(c,t,2)=cos(2*3.1415*120.0/360.0+2.0*3.1415*current_time);
                        else if(xc[2]<3.0) C_UDMI(c,t,2)=cos(2*3.1415*180.0/360.0+2.0*3.1415*current_time);
                        else if(xc[2]<4.0) C_UDMI(c,t,2)=cos(2*3.1415*240.0/360.0+2.0*3.1415*current_time);
                        else if(xc[2]<5.0) C_UDMI(c,t,2)=cos(2*3.1415*300.0/360.0+2.0*3.1415*current_time);
                        else  C_UDMI(c,t,2)=cos(2*3.1415*360.0/360.0+2.0*3.1415*current_time);
                        C_UDMI(c,t,4)=sqrt(C_UDMI(c,t,2)*C_UDMI(c,t,2));

                        



                }
                end_c_loop_all(c,t)
        }

}


现在主要的问题是:计算几步后就会发散,发现感应磁场不正确
分享:
回复

使用道具

该用户从未签到

新手上路

Rank: 1

积分
40
极客币
66
主题
8
帖子
21
注册时间
2018-10-31
在线时间
1 小时
性别
保密
 楼主| 发表于 2018-11-5 11:27:16 | 显示全部楼层
这个是附图,供大家参考








回复

使用道具 举报

高级模式 评论
您需要登录后才可以回帖 登录 | 立即注册 微信登录