CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS

udf for help

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 2, 2011, 23:57
Red face udf for help
  #1
New Member
 
Alexander lee
Join Date: May 2011
Posts: 2
Rep Power: 0
sqsq220 is on a distinguished road
when I use this udf,there is some problem,it dosen't calculate.I don't know why?Can somebody help me?
#include "udf.h"
#include "math.h"
real C_Diff;
real N_eq,N_1;
real Ct;
real Q,A3;
real P1,P2;
real IIs,IIw,IIIs,IV;
real beta,beta_eq,beta_1,beta_3,beta_4,beta_6,beta_9;
real UU,VV,WW,UV,UW,VW;
DEFINE_SOURCE(u_source, c, t, dS, eqn)
{
real source;
dS[eqn]=0.0;
source=-C_R(c,t)*(C_UDSI_G(c,t,UU)[0]+C_UDSI_G(c,t,UV)[1]+C_UDSI_G(c,t,UW)[2]);
return source;
}
DEFINE_SOURCE(v_source, c, t, dS, eqn)
{
real source;
dS[eqn]=0.0;
source=-C_R(c,t)*(C_UDSI_G(c,t,UV)[0]+C_UDSI_G(c,t,VV)[1]+C_UDSI_G(c,t,VW)[2]);
return source;
}
DEFINE_SOURCE(w_source, c, t, dS, eqn)
{
real source;
dS[eqn]=0.0;
source=-C_R(c,t)*(C_UDSI_G(c,t,UW)[0]+C_UDSI_G(c,t,VW)[1]+C_UDSI_G(c,t,WW)[2]);
return source;
}
DEFINE_ADJUST(kw_adjust,domain)
{
Thread *t;
cell_t c;
real T;
real sign;
real S11, S12, S13, S21, S22, S23, S31, S32, S33;
real W11, W12, W13, W21, W22, W23, W31, W32, W33;
thread_loop_c(t,domain)
if (FLUID_THREAD_P(t))
{
begin_c_loop(c,t)
{
T=MAX(1.0/(beta*C_O(c,t)),Ct*sqrt(C_MU_L(c,t)/(C_R(c,t)*beta*C_K(c,t)*C_O(c,t))));
S11=0.5*(C_DUDX(c,t)+C_DUDX(c,t))*T;
S12=0.5*(C_DUDY(c,t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S21*S12*S22+S21*S13*S32+S22*S21*S12+S 22*S22*S22+S22*S23*S32+S23*S31*S12+S23*S32*S22+S23 *S33*S32
+S31*S11*S13+S31*S12*S23+S31*S13*S33+S32*S21*S13+S 32*S22*S23+S32*S23*S33+S33*S31*S13+S33*S32*S23+S33 *S33*S33;
IV=S11*W11*W11+S11*W12*W21+S11*W13*W31+S12*W21*W11 +S12*W22*W21+S12*W23*W31+S13*W31*W11+S13*W32*W21+S 13*W33*W31
+S21*W11*W12+S21*W12*W22+S21*W13*W32+S22*W21*W12+S 22*W22*W22+S22*W23*W32+S23*W31*W12+S23*W32*W22+S23 *W33*W32
+S31*W11*W13+S31*W12*W23+S31*W13*W33+S32*W21*W13+S 32*W22*W23+S32*W23*W33+S33*W31*W13+S33*W32*W23+S33 *W33*W33;
beta_eq=-6.0/5.0*N_eq/(N_eq*N_eq-2*IIw);
beta_1=-N_1*(2*N_1*N_1-7*IIw)/Q;
beta_3=-12*IV/(N_1*Q);
beta_4=-2*(N_1*N_1-2*IIw)/Q;
beta_6=-6.0*N_1/Q;
beta_9=6.0/Q;
sign=P1-sqrt(P2);
if(sign>=0)
{sign=1.0;}
else
{sign=-1.0;}
if(P2>=0)
{N_1=A3/3.0+pow(P1+sqrt(P2)*1.0,1.0/3)+sign*pow(abs(P1-sqrt(P2))*1.0,1.0/3);}
else
{N_1=A3/3.0+2*pow((P1*P1-P2*1.0),1.0/6)*cos(1.0/3*acos(P1/(sqrt(P1*P1-P2))));}
C_UDSI(c,t,UU)=beta_3*(W11*W11+W12*W21+W13*W31-1.0/3*IIw)+beta_4*(S11*W11+S12*W21+S13*W31-
W11*S11-W12*S21-W13*S31)+beta_6*(S11*W11*W11+S11*W12*W21+S11*W13*W 31+S12*W21*W11+S12*W22*W21+
S12*W23*W31+S13*W31*W11+S13*W32*W21+S13*W33*W31+W1 1*W11*S11+W11*W12*S21+W11*W13*S31+W12*W21*S11+
W12*W22*S21+W12*W23*S31+W13*W31*S11+W13*W32*S21+W1 3*W33*S31-IIw*S11-2.0/3*IV)+beta_9*(W11*S11*(W11*W11+
W12*W21+W13*W31)+W11*S12*(W21*W11+W22*W21+W23*W31) +W11*S13*(W31*W11+W32*W21+W33*W31)+W12*S21*(W11*W1 1+
W12*W21+W13*W31)+W12*S22*(W21*W11+W22*W21+W23*W31) +W12*S23*(W31*W11+W32*W21+W33*W31)+W13*S31*(W11*W1 1+
W12*W21+W13*W31)+W13*S32*(W21*W11+W22*W21+W23*W31) +W13*S33*(W31*W11+W32*W21+W33*W31)-W11*W11*(S11*W11+
S12*W21+S13*W31)-W11*W12*(S21*W11+S22*W21+S23*W31)-W11*W13*(S31*W11+S32*W21+S33*W31)-W12*W21*(S11*W11+
S12*W21+S13*W31)-W12*W22*(S21*W11+S22*W21+S23*W31)-W12*W23*(S31*W11+S32*W21+S33*W31)-W13*W31*(S11*W11+
S12*W21+S13*W31)-W13*W32*(S21*W11+S22*W21+S23*W31)-W13*W33*(S31*W11+S32*W21+S33*W31));
C_UDSI(c,t,VV)=beta_3*(W21*W12+W22*W22+W23*W32-1.0/3*IIw)+beta_4*(S21*W12+S22*W22+S23*W32-
W21*S12-W22*S22-W23*S32)+beta_6*(S21*W11*W12+S21*W12*W22+S21*W13*W 32+S22*W21*W12+S22*W22*W22+
S22*W23*W32+S23*W31*W12+S23*W32*W22+S23*W33*W32+W2 1*W11*S12+W21*W12*S22+W21*W13*S32+W22*W21*S12+
W22*W22*S22+W22*W23*S32+W23*W31*S12+W23*W32*S22+W2 3*W33*S32-IIw*S22-2.0/3*IV)+beta_9*(W21*S11*(W11*W12+
W12*W22+W13*W32)+W21*S12*(W21*W12+W22*W22+W23*W32) +W21*S13*(W31*W12+W32*W22+W33*W32)+W22*S21*(W11*W1 2+
W12*W22+W13*W32)+W22*S22*(W21*W12+W22*W22+W23*W32) +W22*S23*(W31*W12+W32*W22+W33*W32)+W23*S31*(W11*W1 2+
W12*W22+W13*W32)+W23*S32*(W21*W12+W22*W22+W23*W32) +W23*S33*(W31*W12+W32*W22+W33*W32)-W21*W11*(S11*W12+
S12*W22+S13*W32)-W21*W12*(S21*W12+S22*W22+S23*W32)-W21*W13*(S31*W12+S32*W22+S33*W32)-W22*W21*(S11*W12+
S12*W22+S13*W32)-W22*W22*(S21*W12+S22*W22+S23*W32)-W22*W23*(S31*W12+S32*W22+S33*W32)-W23*W31*(S11*W12+
S12*W22+S13*W32)-W23*W32*(S21*W12+S22*W22+S23*W32)-W23*W33*(S31*W12+S32*W22+S33*W32));
C_UDSI(c,t,WW)=beta_3*(W31*W13+W32*W23+W33*W33-1.0/3*IIw)+beta_4*(S31*W13+S32*W23+S33*W33-
W31*S13-W32*S23-W33*S33)+beta_6*(S31*W11*W13+S31*W12*W23+S31*W13*W 33+S32*W21*W13+S32*W22*W23+
S32*W23*W33+S33*W31*W13+S33*W32*W23+S33*W33*W33+W3 1*W11*S13+W31*W12*S23+W31*W13*S33+W32*W21*S13+
W32*W22*S23+W32*W23*S33+W33*W31*S13+W33*W32*S23+W3 3*W33*S33-IIw*S33-2.0/3*IV)+beta_9*(W31*S11*(W11*W13+
W12*W23+W13*W33)+W31*S12*(W21*W13+W22*W23+W23*W33) +W31*S13*(W31*W13+W32*W23+W33*W33)+W32*S21*(W11*W1 3+
W12*W23+W13*W33)+W32*S22*(W21*W13+W22*W23+W23*W33) +W32*S23*(W31*W13+W32*W23+W33*W33)+W33*S31*(W11*W1 3+
W12*W23+W13*W33)+W33*S32*(W21*W13+W22*W23+W23*W33) +W33*S33*(W31*W13+W32*W23+W33*W33)-W31*W11*(S11*W13+
S12*W23+S13*W33)-W31*W12*(S21*W13+S22*W23+S23*W33)-W31*W13*(S31*W13+S32*W23+S33*W33)-W32*W21*(S11*W13+
S12*W23+S13*W33)-W32*W22*(S21*W13+S22*W23+S23*W33)-W32*W23*(S31*W13+S32*W23+S33*W33)-W33*W31*(S11*W13+
S12*W23+S13*W33)-W33*W32*(S21*W13+S22*W23+S23*W33)-W33*W33*(S31*W13+S32*W23+S33*W33));

C_UDSI(c,t,UV)=beta_3*(W11*W12+W12*W22+W13*W32)+be ta_4*(S11*W12+S12*W22+S13*W32-
W11*S12-W12*S22-W13*S32)+beta_6*(S11*W11*W12+S11*W12*W22+S11*W13*W 32+S12*W21*W12+S12*W22*W22+
S12*W23*W32+S13*W31*W12+S13*W32*W22+S13*W33*W32+W1 1*W11*S12+W11*W12*S22+W11*W13*S32+W12*W21*S12+
W12*W22*S22+W12*W23*S32+W13*W31*S12+W13*W32*S22+W1 3*W33*S32-IIw*S12)+beta_9*(W11*S11*(W11*W12+
W12*W22+W13*W32)+W11*S12*(W21*W12+W22*W22+W23*W32) +W11*S13*(W31*W12+W32*W22+W33*W32)+W12*S21*(W11*W1 2+
W12*W22+W13*W32)+W12*S22*(W21*W12+W22*W22+W23*W32) +W12*S23*(W31*W12+W32*W22+W33*W32)+W13*S31*(W11*W1 2+
W12*W22+W13*W32)+W13*S32*(W21*W12+W22*W22+W23*W32) +W13*S33*(W31*W12+W32*W22+W33*W32)-W11*W11*(S11*W12+
S12*W22+S13*W32)-W11*W12*(S21*W12+S22*W22+S23*W32)-W11*W13*(S31*W12+S32*W22+S33*W32)-W12*W21*(S11*W12+
S12*W22+S13*W32)-W12*W22*(S21*W12+S22*W22+S23*W32)-W12*W23*(S31*W12+S32*W22+S33*W32)-W13*W31*(S11*W12+
S12*W22+S13*W32)-W13*W32*(S21*W12+S22*W22+S23*W32)-W13*W33*(S31*W12+S32*W22+S33*W32));
C_UDSI(c,t,UW)=beta_3*(W11*W13+W12*W23+W13*W33)+be ta_4*(S11*W13+S12*W23+S13*W33-
W11*S13-W12*S23-W13*S33)+beta_6*(S11*W11*W13+S11*W12*W23+S11*W13*W 33+S12*W21*W13+S12*W22*W23+
S12*W23*W33+S13*W31*W13+S13*W32*W23+S13*W33*W33+W1 1*W11*S13+W11*W12*S23+W11*W13*S33+W12*W21*S13+
W12*W22*S23+W12*W23*S33+W13*W31*S13+W13*W32*S23+W1 3*W33*S33-IIw*13)+beta_9*(W11*S11*(W11*W13+
W12*W23+W13*W33)+W11*S12*(W21*W13+W22*W23+W23*W33) +W11*S13*(W31*W13+W32*W23+W33*W33)+W12*S21*(W11*W1 3+
W12*W23+W13*W33)+W12*S22*(W21*W13+W22*W23+W23*W33) +W12*S23*(W31*W13+W32*W23+W33*W33)+W13*S31*(W11*W1 3+
W12*W23+W13*W33)+W13*S32*(W21*W13+W22*W23+W23*W33) +W13*S33*(W31*W13+W32*W23+W33*W33)-W11*W11*(S11*W13+
S12*W23+S13*W33)-W11*W12*(S21*W13+S22*W23+S23*W33)-W11*W13*(S31*W13+S32*W23+S33*W33)-W12*W21*(S11*W13+
S12*W23+S13*W33)-W12*W22*(S21*W13+S22*W23+S23*W33)-W12*W23*(S31*W13+S32*W23+S33*W33)-W13*W31*(S11*W13+
S12*W23+S13*W33)-W13*W32*(S21*W13+S22*W23+S23*W33)-W13*W33*(S31*W13+S32*W23+S33*W33));
C_UDSI(c,t,VW)=beta_3*(W21*W13+W22*W23+W23*W33)+be ta_4*(S21*W13+S22*W23+S23*W33-
W21*S13-W22*S23-W23*S33)+beta_6*(S21*W11*W13+S21*W12*W23+S21*W13*W 33+S22*W21*W13+S22*W22*W23+
S22*W23*W33+S23*W31*W13+S23*W32*W23+S23*W33*W33+W2 1*W11*S13+W21*W12*S23+W21*W13*S33+W22*W21*S13+
W22*W22*S23+W22*W23*S33+W23*W31*S13+W23*W32*S23+W2 3*W33*S33-IIw*S23)+beta_9*(W21*S11*(W11*W13+
W12*W23+W13*W33)+W21*S12*(W21*W13+W22*W23+W23*W33) +W21*S13*(W31*W13+W32*W23+W33*W33)+W22*S21*(W11*W1 3+
W12*W23+W13*W33)+W22*S22*(W21*W13+W22*W23+W23*W33) +W22*S23*(W31*W13+W32*W23+W33*W33)+W23*S31*(W11*W1 3+
W12*W23+W13*W33)+W23*S32*(W21*W13+W22*W23+W23*W33) +W23*S33*(W31*W13+W32*W23+W33*W33)-W21*W11*(S11*W13+
S12*W23+S13*W33)-W21*W12*(S21*W13+S22*W23+S23*W33)-W21*W13*(S31*W13+S32*W23+S33*W33)-W22*W21*(S11*W13+
S12*W23+S13*W33)-W22*W22*(S21*W13+S22*W23+S23*W33)-W22*W23*(S31*W13+S32*W23+S33*W33)-W23*W31*(S11*W13+
S12*W23+S13*W33)-W23*W32*(S21*W13+S22*W23+S23*W33)-W23*W33*(S31*W13+S32*W23+S33*W33));
}
end_c_loop(c,t)
}
}
sqsq220 is offline   Reply With Quote

Old   May 6, 2011, 13:06
Default
  #2
New Member
 
Join Date: Jan 2011
Posts: 25
Rep Power: 15
zhenglun.wei is on a distinguished road
mind me ask what the error message?
zhenglun.wei is offline   Reply With Quote

Old   May 6, 2011, 22:37
Default udf-hlep
  #3
New Member
 
Alexander lee
Join Date: May 2011
Posts: 2
Rep Power: 0
sqsq220 is on a distinguished road
iter continuity x-velocity y-velocity z-velocity k omega time/iter
100 9.1994e-03 5.1518e-08 6.9043e-09 6.9100e-09 5.2052e-08 5.4165e-08 0:00:00 100
! 101 solution is converged
101 1.#QNBe+00 1.#QNBe+00 1.#QNBe+00 1.#QNBe+00 1.#QNBe+00 1.#QNBe+00 0:04:57 99


this is the error message.in fact ,it doesn't converge and stop calculate.i don't know why?
sqsq220 is offline   Reply With Quote

Old   May 7, 2011, 00:21
Wink
  #4
New Member
 
Join Date: Jan 2011
Posts: 25
Rep Power: 15
zhenglun.wei is on a distinguished road
Oh, I really have not met this problem before. But, I have an idea that may help you. I've noticed that your source term has a purely explicity expression. Its convergence may be dependent on the grid size and the time step size. For example, if your grid is fine while your time step size is not small enough, the simulation may not converge at all. So, please play with them to see if you can get better results.

best
zhenglun.wei is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 08:37
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 22:38
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 05:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


All times are GMT -4. The time now is 22:01.