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

problem in temperature and liquid fraction value in the udf

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 23, 2018, 01:52
Default problem in temperature and liquid fraction value in the udf
  #1
Member
 
Durgesh
Join Date: Oct 2018
Posts: 34
Rep Power: 7
durg is on a distinguished road
Hello everyone!!
I am writing udf for calculating liquid fraction during solidification. I have defined initial temperature 650K but during the calculation fluent giving more than 650K which is an error. Earlier I was trying to modify temperature in the code by adjusting in C_T(c,t) but now I am storing in the UDM and still, I am getting more than 650K in fluent temperature. I am attaching below code to help me where is the problem in the code. Also for a negative value of g, in the code(if(1>g>0)) is getting evaluated whereas it should not enter in the if condition.
The problem is occurring when the species concentration is getting evaluated due to which Teq(equilibrium temperature) value is changing. From this g value is calculated. Please help me out in the code.

Thank you

#include "udf.h"

DEFINE_INIT(my_init_func, d)
{
cell_t c;
Thread *t;
/* loop over all cell threads in the domain */
d = Get_Domain(1);
thread_loop_c (t,d)
{
/* loop over all cells */
begin_c_loop_all(c,t)
{
C_UDMI(c,t,0)=1; // Liquid fraction previous step value
C_UDMI(c,t,1)=1; // Liquid fraction current value
C_UDMI(c,t,2)=650; // Temperature previous value
C_UDMI(c,t,3)=650; //Temperature current step value
C_UDMI(c,t,4)=0;
//C_UDMI(c,t,4)=0.40; //Species value
}
end_c_loop_all(c,t)
}
}

//---------------------------Defining constant values for adjust macros-----------------------------------------------

#define rho 11340 // constant density
#define L 24700 // Latent Heat
#define cl 154.9 // Liquid specific heat
#define cs 128 // Solid specific heat
#define Tf 600.5 //Fusion Temperature of Lead
#define Tf1 504.9 // Fusion Temperature of Tin
#define Te 456.14 //Eutectic Temperature
#define C_eut 0.619 //Eutectic concentration
#define Msn 118.7 //mass of tin
#define rhol 9202.8
#define rhos 9728
DEFINE_ADJUST(liquid_fraction,d)
{
cell_t c;
Thread *t;
//printf("Hello");
real rhoH,rhocp,rhocpm,rhom,rhoHm,tf,m;
real g,Cl_n,Cl_old,Cl,i;
real lamda,delx,n,NewT;
real Teq,B,y,s,Teq1;
//printf("Hello");
tf=0.0;
s=0;
delx=0.01;
m=(Te-Tf1)/C_eut;
Cl_old=0.4;
d = Get_Domain(1);
//printf("Hello");
thread_loop_c (t,d)
{
begin_c_loop(c,t)
{
rhom=(1-C_UDMI(c,t,0))*rhos+(C_UDMI(c,t,0)*rhol);
Cl_n=Cl_old+((rhom*C_YI(c,t,0))-(rhom*C_YI_M1(c,t,0)))/(rhol*C_UDMI(c,t,0));
Cl_old=Cl_n;
printf("conc:%f\n",Cl_n);
Teq=Tf+m*Cl_n;
printf("Teq:%f\n",Teq);
// printf("Old_conc:%f\n",C_YI_M1(c,t,0));
//printf("New_conc:%f\n",C_YI(c,t,0));
//printf("Check:%f\n",C_UDMI(c,t,0));
if(N_TIME>=2)
{

C_UDMI(c,t,2)=NewT;
}
NewT=C_T(c,t);
printf("B:%f\n",C_UDMI(c,t,2));
printf("Lqfrac:%f\n",C_UDMI(c,t,1));
printf("AnsysLqfrac:%f\n",C_LIQF(c,t));
printf("New_T:%f\n",NewT);
rhocp= (C_UDMI(c,t,0)*rhol*cl)+((1-C_UDMI(c,t,0))*rhos*cs);
printf("Value of rhocp: %f\n",rhocp);
rhoH=rhocp*C_T(c,t)+(C_UDMI(c,t,0)*rhol*L);
printf("Value of rhoH: %f\n",rhoH);
g=(rhoH-(rhol*cl*Teq))/(rhol*L);
printf("Value of g is: %f\n",g);
if(g>=1)
{
C_LIQF(c,t)=1;
C_UDMI(c,t,3)=(rhoH-(rhol*L))/(rhol*cl);
// C_T(c,t)=C_UDMI(c,t,3);
printf("New_Temp:%f\n",C_UDMI(c,t,3));
}
else if((1>g)&&(g>0))
{
repeat:
//rhocpm=((rhol*C_UDMI(c,t,0)*cl)+((1-C_UDMI(c,t,0))*rhos*cs));
//rhoHm=rhocpm*C_T(c,t)+(C_UDMI(c,t,0)*L*rhol);
// printf("Mix_Cp:%f\n",rhocpm);
C_UDMI(c,t,0)=C_UDMI(c,t,1);
C_UDMI(c,t,1)=0.5*C_UDMI(c,t,0)+0.5*(rhoH-(rhocp*C_UDMI(c,t,2)))/(rhol*L);
printf("New_liqf:%f\n",C_UDMI(c,t,1));
printf("Old_liqf:%f\n",C_UDMI(c,t,0));

if((C_UDMI(c,t,1)-C_UDMI(c,t,0)<0.0001))
{
C_LIQF(c,t)=C_UDMI(c,t,1);
//printf("Liq_fract:%f\n",C_LIQF(c,t));
tf=tf+0.01;
lamda=pow(10,((1.25+0.36*log(tf))/log(10)));
// printf("Value of lamda: %f\n",lamda);
n=(1-C_UDMI(c,t,0))*lamda/delx;
// printf("Value of solidification time: %f\n",tf);
for(i=1.0;i<n;i++)
s+=(rhos*C_YI(c,t,0)/(1-C_UDMI(c,t,1)))*(delx/lamda);
Cl=(rhom*C_YI(c,t,0)-s)/(rhol*C_UDMI(c,t,1));
C_UDMI(c,t,4)=Cl;
//C_YI(c,t,0)=C_LIQF(c,t)*Cl;
printf("NewConc:%f\n",Cl);
Teq1=Tf+m*Cl;
// printf("Change_Teq:%f\n",Teq1);
}

else
goto repeat;
}

else
{
g=0;
C_LIQF(c,t)=0;
C_UDMI(c,t,3)=rhoH/(rhos*cs);
//C_T(c,t)=C_UDMI(c,t,3);
printf("New_solid_temp:%f\n",C_UDMI(c,t,3));
}
//C_UDMI(c,t,2)=C_T(c,t);
}
end_c_loop(c,t)
//C_UDMI(c,t,2)=C_T(c,t);
}

}
durg 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
Wrong flow in ratating domain problem Sanyo CFX 17 August 15, 2015 06:20
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 06:27
Water subcooled boiling Attesz CFX 7 January 5, 2013 03:32
UDF for mass fraction (spilled organic liquid) Klemens Schatka FLUENT 4 July 28, 2009 01:27
Need some help for total liquid fraction linus FLUENT 0 December 19, 2006 03:29


All times are GMT -4. The time now is 14:53.