|
[Sponsors] |
June 2, 2019, 12:05 |
udf for source term in UDS equation
|
#1 |
New Member
deepak
Join Date: Sep 2013
Posts: 5
Rep Power: 13 |
Hi all,
I have problem with my UDF. I am modelling a problem where apart from continuity and momentum, I have to solve energy, species transport and one UDS equation (for the volume fraction of Nano particle). The properties of nano fluid are calculated through UDF which depends on (UDS)Volume fraction of nano particle. The energy, species transport and UDS equations have Source term(in red color in attached Image) having terms like properties which are function of variable and other variable are being solve. Some part of the UDF code is written below it is giving parse error for the line C_UDSI(c,t,2)= dtc * (C_YI_G(c,t,0)[0]); C_UDSI(c,t,3)= dtc * (C_YI_G(c,t,0)[1]); c_source= dct*(C_UDSI_G(c,t,4)[0] + C_UDSI_G(c,t,5)[1]); while interpreting.I know that something is wrong with udf. (to calculate laplace of C and T). Also I do not have much idea about how to define unsteady term phi (Volume Fraction) instead of (phi * density) or User defined memory allocation. I don't know how exactly do it I will be grateful for your help. DEFINE_ADJUST(adjust_UDS,domain) { Thread *t; cell_t c; face_t f; domain = Get_Domain(domain_ID); /*Fill UDS with the variable*/ thread_loop_c (t,domain) { begin_c_loop (c,t) { C_UDSI(c,t,0) = C_VOF(c,t); } end_c_loop (c,t) } } DEFINE_DIFFUSIVITY(UDS_diffusivity,c,t,i) { real gamma_UDS,temp,phi,mu_nf,rho_nf,d_b; temp = C_T(c, t); /*cell value of temperature*/ phi=C_UDSI(c,t,0); mu_nf=mu_bf/pow((1-phi),2.5); rho_nf=phi*rho_p+(1-phi)*rho_bf; d_b=(k_b * temp)/(3*pi*mu_nf*d_p); gamma_UDS=d_b; return gamma_UDS; } DEFINE_SOURCE(UDS_source,c,t) { real x[ND_ND],vof_source,temp,phi,mu_nf,rho_nf,D_T; temp = C_T(c, t); /*cell value of temperature*/ phi = C_UDSI(c,t,0); mu_nf=mu_bf/pow((1-phi),2.5); rho_nf = phi*rho_p + (1-phi)*rho_bf; D_T = 0.26*(k_bf/(2*k_bf+k_p*rho_nf))*(mu_nf/rho_nf)*phi; C_UDSI(c,t,1)=D_T/temp; vof_source = C_UDSI_G(c,t,1)[0] + C_UDSI_G(c,t,1)[1]; return vof_source; } DEFINE_SOURCE(temp_source,c,t) { real x[ND_ND],t_source,temp,phi,d_b,hcr,term1,term11,term12, term2,term3,term4,D_T,rho_nf,alpha_nf,C_P_nf,mu_nf ; temp = C_T(c, t); phi = C_UDSI(c,t,0); hcr = (rho_p * C_P_p)/(rho_nf/C_P_nf); d_b=(k_b * temp)/(3*pi*mu_nf*d_p); term11=d_b*(C_UDSI_G(c,t,0)[0]*C_T_G(c,t)[0]); term12=d_b*(C_UDSI_G(c,t,0)[1]*C_T_G(c,t)[1]); term1=term11+term12; D_T = 0.26*(k_bf/(2*k_bf + k_p*rho_nf))*(mu_nf/rho_nf)*phi; term2=hcr*(D_T/temp)*(SQR(C_T_G(c,t)[0])+ SQR(C_T_G(c,t)[1])); C_UDSI(c,t,2)= dtc * (C_YI_G(c,t,0)[0]); C_UDSI(c,t,3)= dtc * (C_YI_G(c,t,0)[1]); term3= (C_UDSI_G(c,t,2)[0]); term4= (C_UDSI_G(c,t,3)[1]);[/COLOR] t_source = term1 + term2 + term2 + term4; return t_source; } DEFINE_SOURCE(conc_source,c,t,dS,equ) { real x[ND_ND],c_source; C_UDSI(c,t,4)= C_T_G(c,t)[0]; C_UDSI(c,t,5)= C_T_G(c,t)[1]; c_source= dct*(C_UDSI_G(c,t,4)[0] + C_UDSI_G(c,t,5)[1]); return c_source; } |
|
June 2, 2019, 23:38 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
first of all compile your UDF instead of interpret,
next Code:
DEFINE_ADJUST(adjust_UDS,domain) { Thread *t; cell_t c; thread_loop_c (t,domain) { begin_c_loop (c,t) { C_UDSI(c,t,0) = C_VOF(c,t); } end_c_loop (c,t) } } Code:
C_UDSI(c,t,2)= dtc * (C_YI_G(c,t,0)[0]); C_UDSI(c,t,3)= dtc * (C_YI_G(c,t,0)[1]); probably, code has other problems, compile it and show log best regards |
|
June 4, 2019, 03:48 |
|
#3 |
New Member
deepak
Join Date: Sep 2013
Posts: 5
Rep Power: 13 |
Thank you Sir,
I have implemented the suggestion given by you. After compiling the code I am getting error message like.. Copied C:\Users\Deepak\Desktop\RaT=7E6_Rrho=6_900x900_del T=0.05Sec_SCNHM_1/UDF_SCNHM.c to libudf\src Creating user_nt.udf file for 2ddp_host ... (system "copy "C:\PROGRA~1\ANSYSI~1\v194\fluent"\fluent19.4.0\sr c\udf\makefile_nt.udf "libudf\win64\2ddp_host\makefile" ") 1 file(s) copied. (chdir "libudf")(chdir "win64\2ddp_host")# Generating ud_io1.h UDF_SCNHM.c ..\..\src\UDF_SCNHM.c(184) : error C2059: syntax error : '=' ..\..\src\UDF_SCNHM.c(185) : error C2059: syntax error : '=' ..\..\src\UDF_SCNHM.c(193) : error C2061: syntax error : identifier 'con_source' ..\..\src\UDF_SCNHM.c(193) : error C2059: syntax error : ';' ..\..\src\UDF_SCNHM.c(193) : error C2059: syntax error : 'type' Creating user_nt.udf file for 2ddp_node ... (system "copy "C:\PROGRA~1\ANSYSI~1\v194\fluent"\fluent19.4.0\sr c\udf\makefile_nt.udf "libudf\win64\2ddp_node\makefile" ") 1 file(s) copied. (chdir "libudf")(chdir "win64\2ddp_node")# Generating ud_io1.h UDF_SCNHM.c ..\..\src\UDF_SCNHM.c(184) : error C2059: syntax error : '=' ..\..\src\UDF_SCNHM.c(185) : error C2059: syntax error : '=' ..\..\src\UDF_SCNHM.c(193) : error C2061: syntax error : identifier 'con_source' ..\..\src\UDF_SCNHM.c(193) : error C2059: syntax error : ';' ..\..\src\UDF_SCNHM.c(193) : error C2059: syntax error : 'type' Done. The full udf that I have compiled is as below.. #include "udf.h" #define s0 0 /* Initial Salinity of Mixture*/ #define t0 300 /* Initial Temperature of Mixture Unit:K*/ #define beta_t 0.0002 /*Coef of ther exp (base fluid) Unit:/degC*/ #define beta_s 0.0008 /*Coef of Salinity(base fluid) Unit:%(-1)*/ #define beta_t_p 0.0000008 /*Coef of ther exp(N-P)Unit:/degC*/ #define ks 0.0000000014 /*Mass Diffusivity Unit: m^2/s */ #define rho_bf 1000 /* Density of base fluid waterUnit:kg/m^3*/ #define rho_p 3950 /*Density of Nano-Particle Unit:kg/m^3 */ #define k_bf 0.5974 /*Ther Cond of base fluidUnit:w/m-k*/ #define k_p 40 /*Ther Cond of Nano-ParticleUnit:w/m-k*/ #define C_P_bf 4182 /*Sp Heat of base fluid Unit: J/kg-K*/ #define C_P_p 765 /* Sp Heat of Nano-Particle Unit: J/kg-K*/ #define mu_bf 0.000955 /* Dy Visco of base fluid Unit: kg/m-s*/ /* #define phi 0.0002 /* Vol Frac of Nano-Particle*/ #define n 3 /* N-P shapefactor=3 forspherNP*/ #define k_b 1.38064852e-23 /*Boltz Const UNIT:m^2kgs^-2K^-1*/ #define d_p 0.00000008 /* Nano-Particle Diameter*/ #define pi 3.14 /* pi */ #define dtc = 0.000000001 /* Assumed */ #define dct = 0.0000000009 /* Assumed */ #define S 0.5 /* Soret Parameter (Assumed)*/ #define D_f 0.5 /* Dufour parameter (Assumed) */ #define g 9.81 /*#define Th 308*/ /*Hot Fluid or Wall Temp(B.C or patching)*/ /*to calculate dct and dtc UNIT:K*/ /*#define Tc 300*/ /*Cold Fluid or WallTemp(B.C or patching)*/ /*to calculate dct and dtc UNIT: K*/ /* #define Ch 1*/ /*Hot Fluid or Wall Conc(B.C or patching)*/ /*(to calculate dct and dtc)*/ /* #define Cc 0*/ /*Cold Fluid or Wall Conc(B.C or patching)*/ /*to calculate dct and dtc*/ # define domain_ID 1 DEFINE_ADJUST(adjust_UDS,domain) { Thread *t; cell_t c; thread_loop_c (t,domain) { begin_c_loop (c,t) { C_UDSI(c,t,0) = C_VOF(c,t); } end_c_loop (c,t) } } DEFINE_PROPERTY(nf_density,c,t) { real rho_nf,phi; phi = C_UDSI(c,t,0); rho_nf = phi*rho_p + (1-phi)*rho_bf; /*density of Nano-Fluid*//*beta2 UNITS:%(-1)*/ return rho_nf; } DEFINE_PROPERTY(nf_thermalexpansioncoeff,c,t) { real beta_t_nf,rho_nf,phi; beta_t_nf=((1-phi)*rho_bf*beta_t+phi*rho_p*beta_t_p)/rho_nf; return beta_t_nf; } DEFINE_PROPERTY(nf_diffusivity,c,t) { real gamma,delta_t,delta_s,phi; gamma=ks; /*MassDiffusivity Unit:m^2/s*/ return gamma; } DEFINE_PROPERTY(nf_spheat,c,t) { real C_P_nf,rho_nf,delta_t,delta_s,conc_salt,temp,phi; temp=C_T(c,t); conc_salt=C_YI(c,t,0); delta_t=temp-t0; delta_s=conc_salt-s0; phi=C_UDSI(c,t,0); rho_nf=phi*rho_p +(1-phi)*rho_bf; C_P_nf=((1-phi)*rho_bf*C_P_bf+phi*rho_p*C_P_p)/rho_nf; return C_P_nf; } DEFINE_PROPERTY(nf_th_conductivity,c,t) { real k_nf,k_nf_d,k_nf_n,phi; phi=C_UDSI(c,t,0); k_nf_d=k_bf*(k_p +(n-1)*k_bf-phi*(n-1)*(k_bf-k_p)); k_nf_n=(k_p+(n-1)*k_bf+phi*(k_bf-k_p)); k_nf=k_nf_d/k_nf_n; return k_nf; } DEFINE_PROPERTY(nf_viscosity,c,t) { real mu_nf,phi; phi=C_UDSI(c,t,0); mu_nf=mu_bf/pow((1-phi),2.5); return mu_nf; } DEFINE_PROPERTY(nf_th_diffusivity,c,t) { real alpha_nf,k_nf,k_nf_d,k_nf_n,rho_nf,C_P_nf; real delta_t,delta_s,conc_salt,temp,phi; temp=C_T(c,t); conc_salt=C_YI(c, t, 0); delta_t=temp - t0; delta_s=conc_salt-s0; phi=C_UDSI(c,t,0); rho_nf = phi*rho_p + (1-phi)*rho_bf; k_nf_d=k_bf*(k_p +(n-1)*k_bf-phi*(n-1)*(k_bf-k_p)); k_nf_n=(k_p+(n-1)*k_bf+phi*(k_bf-k_p)); k_nf=k_nf_d/k_nf_n; alpha_nf= k_nf/(rho_nf*C_P_nf); return alpha_nf; } DEFINE_DIFFUSIVITY(UDS_diffusivity,c,t,i) { real gamma_UDS,temp,phi,mu_nf,rho_nf,d_b; temp = C_T(c, t); /*cell value of temperature*/ phi=C_UDSI(c,t,0); mu_nf=mu_bf/pow((1-phi),2.5); rho_nf=phi*rho_p+(1-phi)*rho_bf; /*densityofNano-Fluid*//*beta2 UNITS:%(-1)*/ d_b=(k_b * temp)/(3*pi*mu_nf*d_p); /*d_b Brownian Diffusion Coefficient UNIT:m^2/s*/ gamma_UDS=d_b; return gamma_UDS; } DEFINE_SOURCE(ymom_source,c,t,dS,eqn) { real source,delta_t,delta_s,conc_salt,temp,phi,rho_nf,b eta_t_nf; temp = C_T(c, t); /* cell value of temperature */ conc_salt = C_YI(c, t, 0); /* cell value of concentration */ delta_t = temp - t0; /* temperature difference */ delta_s = conc_salt - s0; phi=C_UDSI(c,t,0); rho_nf=phi*rho_p +(1-phi)*rho_bf; /* C_CENTROID(x,c,t);*/ source = -rho_nf * (1 - beta_t_nf * delta_t + beta_s * delta_s)*g; return source; } DEFINE_SOURCE(UDS_source,c,t,dS,eqn) { real vof_source,temp,phi,mu_nf,rho_nf,D_T; temp = C_T(c, t); /*cell value of temperature*/ phi = C_UDSI(c,t,0); mu_nf=mu_bf/pow((1-phi),2.5); rho_nf = phi*rho_p + (1-phi)*rho_bf; D_T = 0.26*(k_bf/(2*k_bf+k_p*rho_nf))*(mu_nf/rho_nf)*phi; C_UDSI(c,t,1)=D_T/temp; vof_source = C_UDSI_G(c,t,1)[0] + C_UDSI_G(c,t,1)[1]; /*D_T = 0.26*(k_bf/(2*k_bf+k_p*rho_nf))*(mu_nf/rho_nf)*phi;*/ /*D_T thermophoresis Diffusion Coefficient UNIT:m^2/s*/ /*C_CENTROID(x,c,t);*/ return vof_source; } DEFINE_SOURCE(temp_source,c,t,dS,eqn) { real tm_source,temp,phi,d_b,hcr,term1,term11,term12, term2,term3,term4,D_T,rho_nf,alpha_nf,C_P_nf,mu_nf ; temp = C_T(c, t); phi = C_UDSI(c,t,0); /*dtc = D_f*alpha_nf*(Th-Tc)/(Ch-Cc);*/ /*dtc Diffusivity of Dufour TypeUNIT:m^2/s*/ hcr = (rho_p * C_P_p)/(rho_nf/C_P_nf); d_b= (k_b * temp)/(3*pi*mu_nf*d_p); term11= d_b*(C_UDSI_G(c,t,0)[0]*C_T_G(c,t)[0]); term12= d_b*(C_UDSI_G(c,t,0)[1]*C_T_G(c,t)[1]); term1= term11+term12; D_T= 0.26*(k_bf/(2*k_bf + k_p*rho_nf))*(mu_nf/rho_nf)*phi; /*D_T thermophoresis Diffusion Coefficient UNIT:m^2/s*/ /*term2=hcr*(D_T/temp)*((pow(C_T_G(c,t)[0]),2)+(pow(C_T_G(c,t)[1]),2));*/ term2= hcr*(D_T/temp)*(SQR(C_T_G(c,t)[0])+ SQR(C_T_G(c,t)[1])); C_UDSI(c,t,2) = dtc * (C_YI_G(c,t,0)[0]); C_UDSI(c,t,3) = dtc * (C_YI_G(c,t,0)[1]); term3 = (C_UDSI_G(c,t,2)[0]); term4 = (C_UDSI_G(c,t,3)[1]); /*C_CENTROID(x,c,t);*/ tm_source = term1 + term2 + term3 + term4; return tm_source; } DEFINE_SOURCE(con_source,c,t,dS,eqn) { real con_source; /*dct = -(S*beta_t_nf)*(ks/beta_s);*/ /*dct Diffusivity of Soret TypeUNIT:m^2/s*/ /*C_CENTROID(x,c,t);*/ C_UDSI(c,t,4)= C_T_G(c,t)[0]; C_UDSI(c,t,5)= C_T_G(c,t)[1]; con_source= dct*(C_UDSI_G(c,t,4)[0] + C_UDSI_G(c,t,5)[1]); return con_source; } Also i need some insight for the part.. C_UDSI(c,t,2) = dtc * (C_YI_G(c,t,0)[0]); C_UDSI(c,t,3) = dtc * (C_YI_G(c,t,0)[1]); term3 = (C_UDSI_G(c,t,2)[0]); term4 = (C_UDSI_G(c,t,3)[1]); and C_UDSI(c,t,4)= C_T_G(c,t)[0]; C_UDSI(c,t,5)= C_T_G(c,t)[1]; con_source= dct*(C_UDSI_G(c,t,4)[0] + C_UDSI_G(c,t,5)[1]); Is this the right way to do the same?? I have read udf manuals and other related threads on this forum, but still unable to get rid of this problem. |
|
June 4, 2019, 22:33 |
|
#4 | |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
DEFINE_SOURCE(con_source,c,t,dS,eqn) { real con_source; Code:
C_UDSI(c,t,2) = dtc * (C_YI_G(c,t,0)[0]); C_UDSI(c,t,3) = dtc * (C_YI_G(c,t,0)[1]); All other parts seems correct and compiler didnt show other errors. By the way - it is very very bad, when you have space in folder names. Quote:
I don't go deep into your code, don't check if it is correct in terms of equations. I assume you know, what you are doing. So I'm trying to help you with syntax best regards |
||
June 15, 2019, 13:26 |
|
#5 |
New Member
deepak
Join Date: Sep 2013
Posts: 5
Rep Power: 13 |
ehat is the meaning of this error?
999999: mpt_accept: error: accept failed: No such file or directory |
|
June 17, 2019, 03:27 |
|
#6 | |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
line 260
Code:
Error: No user-defined functions of type udf-type-specific-heat have been loaded. Error Object: #f Quote:
|
||
June 17, 2019, 06:02 |
|
#7 |
New Member
deepak
Join Date: Sep 2013
Posts: 5
Rep Power: 13 |
Dear Sir,
I have attached my udf and error that i am getting. The error comes before the first iteration.There is no problem with Interpretation of udf. There is no problem with initialization (and patching the domain ). I have also set the (rpsetvar 'species/save-gradients? #t). I think the problem is related with parallel processing or might be related with Environment Variable. Kindly guide me to find the problem and to do the same. |
|
June 17, 2019, 07:37 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
C:/Users/WORKSTATION-2/Desktop/scnhm3_rev/scnhm_rev.c:60: macro `DEFINE_DIFFUSIVITY' used with only 3 args Code:
DEFINE_DIFFUSIVITY(nf_diffusivity, c, t) |
|
June 18, 2019, 11:26 |
|
#9 |
New Member
deepak
Join Date: Sep 2013
Posts: 5
Rep Power: 13 |
hi..
This is the mass diffusivity in Species Transport equation. Should it be defined by Define Property ? |
|
June 19, 2019, 01:07 |
|
#10 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
no
the answer is: this is an error, which was clearly reported in YOUR log file read your logs should be Code:
DEFINE_DIFFUSIVITY(nf_diffusivity, c, t, i) |
|
August 19, 2019, 02:10 |
|
#11 |
New Member
hailin
Join Date: Aug 2019
Posts: 1
Rep Power: 0 |
Hi,I have some question with your code of the second derivative of the Temperature:
C_UDSI(c,t,5) = C_T_G(c,t)[0]; C_UDSI(c,t,6) = C_T_G(c,t)[1]; concentration_source = density_nf * d_soret * ((C_UDSI_G(c,t,5)[0]) + (C_UDSI_G(c,t,6)[1])); Is that right to do so? |
|
August 19, 2019, 08:55 |
|
#12 |
New Member
Uttar Pradesh
Join Date: Aug 2019
Posts: 5
Rep Power: 7 |
Hello everyone...
The modified code has been successfully compiled and initialised. But during iteration, following message shows and iteration does not start: Node 0: Process 5584: Received signal SIGSEGV MPI application rank 0 exited before MPI_Finalise () with status 2 The f1 process could not be started. Please help in rectifying it. |
|
August 19, 2019, 08:57 |
|
#13 |
New Member
Uttar Pradesh
Join Date: Aug 2019
Posts: 5
Rep Power: 7 |
please elaborate the steps followed for complete iteration.
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Fluent do not use my velocity field(by UDF) to solve energy equation | tangleiplus | Fluent UDF and Scheme Programming | 6 | January 21, 2019 22:28 |
Source Term UDF VS Porous Media Model | pchoopanya | Fluent UDF and Scheme Programming | 1 | August 28, 2013 07:12 |
Need help! UDS equation is divergence in first iteration | tompa | Fluent UDF and Scheme Programming | 2 | November 28, 2010 23:57 |
[Q] Convection term treatment in UDS | Ryan, Lee | FLUENT | 4 | October 18, 2004 11:20 |
UDF sourse term for VOF equation | ROOZBEH | FLUENT | 5 | April 22, 2003 07:56 |