|
[Sponsors] |
problem in temperature and liquid fraction value in the udf |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 23, 2018, 02:52 |
problem in temperature and liquid fraction value in the udf
|
#1 |
Member
Durgesh
Join Date: Oct 2018
Posts: 34
Rep Power: 8 |
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); } } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Wrong flow in ratating domain problem | Sanyo | CFX | 17 | August 15, 2015 07:20 |
Calculation of the Governing Equations | Mihail | CFX | 7 | September 7, 2014 07:27 |
Water subcooled boiling | Attesz | CFX | 7 | January 5, 2013 04:32 |
UDF for mass fraction (spilled organic liquid) | Klemens Schatka | FLUENT | 4 | July 28, 2009 02:27 |
Need some help for total liquid fraction | linus | FLUENT | 0 | December 19, 2006 04:29 |