鎭鈊爱你 发表于 2018-11-5 11:25:55

fluent中MHD模块用UDF添加外部磁场

用udf的形式给MHD模块中外部磁场赋值,赋值的效果想跟自带的MHD模块一样,结果计算的时候发现,外部磁场赋值成功了,计算的时候却发散了
我计算的问题是磁流体泵;变化的磁场驱动流体运动。
我的udf:
#include "udf.h"
DEFINE_INIT(my_init_BO_y,domain)
{
      cell_t c;
      Thread *t;
      real xc;
      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<1.0) C_UDMI(c,t,2)=cos(2*3.1415*60.0/360.0);
                        else if(xc<2.0) C_UDMI(c,t,2)=cos(2*3.1415*120.0/360.0);
                        else if(xc<3.0) C_UDMI(c,t,2)=cos(2*3.1415*180.0/360.0);
                        else if(xc<4.0) C_UDMI(c,t,2)=cos(2*3.1415*240.0/360.0);
                        else if(xc<5.0) C_UDMI(c,t,2)=cos(2*3.1415*300.0/360.0);
                        elseC_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;
      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<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.0) C_UDMI(c,t,2)=cos(2*3.1415*120.0/360.0+2.0*3.1415*current_time);
                        else if(xc<3.0) C_UDMI(c,t,2)=cos(2*3.1415*180.0/360.0+2.0*3.1415*current_time);
                        else if(xc<4.0) C_UDMI(c,t,2)=cos(2*3.1415*240.0/360.0+2.0*3.1415*current_time);
                        else if(xc<5.0) C_UDMI(c,t,2)=cos(2*3.1415*300.0/360.0+2.0*3.1415*current_time);
                        elseC_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)
      }

}


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

鎭鈊爱你 发表于 2018-11-5 11:27:16


这个是附图,供大家参考



http://forum.simwe.com/data/attachment/forum/201804/15/102054o3n3h865388w5bki.jpg


http://forum.simwe.com/data/attachment/forum/201804/15/102101ctoe4flnlrfn369n.jpg


页: [1]
查看完整版本: fluent中MHD模块用UDF添加外部磁场