CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Two-phase Eulerian UDF problem (http://www.cfd-online.com/Forums/fluent/126664-two-phase-eulerian-udf-problem.html)

 zayafish November 22, 2013 16:31

Two-phase Eulerian UDF problem

Hi,

I am developing an Eulerian two-phase axisymmetric model to predict the dynamic flow system in magnetic separation process. So I wrote a UDF for the source term for the force on magnetic particles (phase 2) due to the magnetic field. In my code, I defined several UDSs, which were just used as variables to store the FIXED values regarding the magnetic field strength or gradient. So these UDSs should be independent of time. However, after the simulation started running, the UDSs were perfectly showing the expected values for the first several seconds, and then it started to deform with time. As shown in the following figure, near the top two corners, the UDS 0 (magnetic field strength) values became zero. The two bubbles started from a small region (probably from one cell) and then grew bigger with time. If the simulation kept running, it just ruined all the values.

Since I am using UDSs to store the fixed values, the unsteady/convection/diffusion/sources in the main function of UDS should not be calculated. So in the User-Defined Scalars dialog box, I did switch the Flux Function and Unsteady Function to NONE. But this did not fix the deformation problem with time.

Here I attached my code. Can anyone help me figure out where I did wrong? How to resolve this deformation problem?

DEFINE_ADJUST(adjust_def,d)
{
Thread *t;
cell_t c;
real PI = 3.1415926;
real L = 0.04; /*Length of the tube*/
real MUO = 4*PI*pow(10,-7.);
real M = 1.220703;
real x;
real y;
real r1;
real r2;
real xc[ND_ND];
real origin[ND_ND];
origin[0]=0.0;
origin[1]=0.0;

thread_loop_c(t,d)
{
begin_c_loop_all(c,t)
{
C_CENTROID(xc,c,t);
xc[0]-=origin[0];
xc[1]-=origin[1];
x = xc[0];
y = xc[1];
r1 = pow(x+0.00625,2)+pow(y,2);
r2 = pow(x-(L+0.00625),2)+pow(y,2);
C_UDSI(c,t,0) = M/(4.0*PI*sqrt(pow(r1,3)))*sqrt(3.0*pow(y,2)/r1+1.0) + M/(4.0*PI*sqrt(pow(r2,3)))*sqrt(3.0*pow(y,2)/r2+1.0);
C_UDSI(c,t,1) = C_UDSI(c,t,0)*MUO;
C_UDSI(c,t,2) = pow(C_UDSI(c,t,0),2);
}
end_c_loop_all(c,t)
}
}

Many thanks in advance!!

Jin

https://www.dropbox.com/s/56u6z34pti...%20problem.jpg

 All times are GMT -4. The time now is 23:16.