|
[Sponsors] |
UDF for thermal conductivity relation of nano fluid |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 31, 2016, 06:33 |
UDF for thermal conductivity relation of nano fluid
|
#1 |
Member
NGP
Join Date: Mar 2016
Posts: 33
Rep Power: 10 |
Hi
I am not familiar with C language for UDF code, I need your help to define a code for the attached correlation of thermal conductivity depend on density, volume fraction, temp., Prandtl Number and Brinkman Number. Please let me know if you have any suggestion . I attached the correlation. Thanks Last edited by ngonbadipoor@yahoo.com; April 11, 2016 at 18:12. |
|
March 31, 2016, 11:23 |
|
#2 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Quote:
|
||
April 8, 2016, 13:08 |
|
#3 |
Member
NGP
Join Date: Mar 2016
Posts: 33
Rep Power: 10 |
hi
how could i loop all the zone to specify the conductivity function. |
|
April 9, 2016, 08:00 |
|
#4 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Did you look in the manual to see how they specify conductivity in a udf?
|
|
April 10, 2016, 06:50 |
|
#5 |
Member
NGP
Join Date: Mar 2016
Posts: 33
Rep Power: 10 |
Hi
I wrote this : could you please advise me> DEFINE_PROPERTY(knew,c,t) { real knf; real pos[ND_ND]; real y; real fip; /* volume concentration*/ real ronf; /* density of nanofluid*/ real robf; /* density of base fluid*/ real rop; /* density of particle*/ real cpp; /*specific heat of particle*/ real cpbf; /* specific heat of base fluid*/ real cpnf; /* specific heat of nanofluid*/ real a; real b; real dp; /* nanoparticle size*/ real Rep; /* reynolds number of particle*/ real kp; /* thermal conductivity of particle*/ real nunf; /*the viscosity of nanofluids*/ real NBRp; /* Brinkman number*/ Domain *d; Thread *t; cell_t c; real temp = C_T(c,t); thread_loop_c(t,d) { begin_c_loop(c,t) { cpnf= (fip*rop*cpp+(1-fip)*robf*cpbf)/(ronf); /* specific heat of nanofluid*/ nunf=-0.3513+0.462*fip-0.135*fip*fip+0.0125*fip*fip*fip +(24.662+2.316*fip-0.4959*fip*fip)/(temp-273)+30.979*(fip*fip)/((temp-273)*(temp-273)) +(995.388-3205.016*fip+8.667*fip*fip)/((temp-273)*(temp-273)*(temp-273))+ (fip/(dp*dp))*(dp*(3.937-1.194*fip)+fip*(20.502-0.8086*fip)); /* viscosity of nanofluid which depends on nanoparticle size and temperature */ prp=(nubf*cpp/kp); /* prandtl of particle*/ prbf= nubf*cpbf/kbf; /* prandtl of base fluid*/ a= -3.516+0.0227*temp-0.000036*temp*temp+(105.1-0.691*temp+0.0011*temp*temp)/(dp)+36.63/(dp*dp); /* a is a function of teprature and nanoparticle size*/ b= (-5.095+8.181* fip-0.066*fip*fip)/(dp); NBRp= double sqrt (double nubf*V*V/(kp*temp)) ; knf=1.698*pow (fip, a) * pow ((temp/273),b)* pow (prp,0.0645)* pow(prbf,-0.106 )* pow (Rep/pow (NBRp,0.5), -0.00463)* kbf; /*thermal conductivity of nanofluid*/ } end_c_loop(c,t) } return ktc; } |
|
April 11, 2016, 04:27 |
|
#6 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Advise: try it in Fluent and see if it does what you want.
|
|
April 11, 2016, 11:41 |
|
#7 |
Member
NGP
Join Date: Mar 2016
Posts: 33
Rep Power: 10 |
hi, the errors are: i gave some values to constants but only viscosity, a, b, and thermal conductivity must be calculated.
Error: C:\\Users\\pc\\Desktop\\thermal con.c: line 1: parse error. Error: GENERAL-CAR-CDR: invalid argument [1]: improper list Error Object: () |
|
April 11, 2016, 12:11 |
|
#8 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Quote:
#include "udf.h" second, in the list of variables you created, you basically said that those variables exist, but no value were assigned for it. third, there is no need to loop throught all the thread and cells. The DEFINE_PROPERTY does it automatically (this is said in the manual) fourth, in the following line, there is no need to say it is double (again). NBRp= double sqrt (double nubf*V*V/(kp*temp)) ; These are the things that I noticed overlooking your UDF. Change it, try it again and see what happens. |
||
April 11, 2016, 18:08 |
|
#9 |
Member
NGP
Join Date: Mar 2016
Posts: 33
Rep Power: 10 |
Hi
Thanks, I did what you said here are the errors: t definition shadows previous definition c definition shadows previous definition Error: C:\\Users\\pc\\Desktop\\thermal con.c: line 38: parse error. Error: C:\\Users\\pc\\Desktop\\thermal con.c: line 39: parse error. i put no loop this time. |
|
April 11, 2016, 18:15 |
|
#10 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Quote:
|
||
April 11, 2016, 18:27 |
|
#11 |
Member
NGP
Join Date: Mar 2016
Posts: 33
Rep Power: 10 |
there is no loop any more, but still the errors are the same as the last time.
#include "udf.h" DEFINE_PROPERTY(knew,c,t) { real knf; real pos[ND_ND]; real V=1; real fip=0.01; /* volume concentration*/ real ronf=1027; /* density of nanofluid*/ real robf=1000; /* density of base fluid*/ real rop=3720; /* density of particle*/ real cpp=1; /*specific heat of particle*/ real cpbf=.5; /* specific heat of base fluid*/ real cpnf=257.6; /* specific heat of nanofluid*/ real a; real b; real dp=40e-9; /* nanoparticle size*/ real Rep=1000; /* reynolds number of particle*/ real kp=18; /* thermal conductivity of particle*/ real nunf; /*the viscosity of nanofluids*/ real NBRp; /* Brinkman number*/ real nubf=8.9e-4; real kbf=0.6; Domain *d; Thread *t; cell_t c; real temp = C_T(c,t); /* cpnf= (fip*rop*cpp+(1-fip)*robf*cpbf)/(ronf); specific heat of nanofluid*/ nunf=-0.3513+0.462*fip-0.135*fip*fip+0.0125*fip*fip*fip +(24.662+2.316*fip-0.4959*fip*fip)/(temp-273)+30.979*(fip*fip)/((temp-273)*(temp-273)) +(995.388-3205.016*fip+8.667*fip*fip)/((temp-273)*(temp-273)*(temp-273))+ (fip/(dp*dp))*(dp*(3.937-1.194*fip)+fip*(20.502-0.8086*fip)); /* viscosity of nanofluid which depends on nanoparticle size and temperature */ real prp=(nubf*cpp/kp); /* prandtl of particle*/ real prbf= nubf*cpbf/kbf; /* prandtl of base fluid*/ a= -3.516+0.0227*temp-0.000036*temp*temp+(105.1-0.691*temp+0.0011*temp*temp)/(dp)+36.63/(dp*dp); /* a is a function of teprature and nanoparticle size*/ b= (-5.095+8.181* fip-0.066*fip*fip)/(dp); NBRp= sqrt ( nubf*V*V/(kp*temp)) ; knf=1.698*pow (fip, a) * pow ((temp/273),b)* pow (4,0.0645)* pow(5,-0.106 )* pow (Rep/pow (NBRp,0.5), -0.00463)* kbf; /*thermal conductivity of nanofluid*/ return knf; } |
|
April 11, 2016, 18:30 |
|
#12 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Quote:
Domain *d; Thread *t; cell_t c; |
||
April 12, 2016, 13:40 |
|
#13 |
Member
NGP
Join Date: Mar 2016
Posts: 33
Rep Power: 10 |
thanks for your reply, what are this 2 errors?
Error: C:\\Users\\pc\\Desktop\\thermal con2.c: line 34: parse error. Error: C:\\Users\\pc\\Desktop\\thermal con2.c: line 35: parse error. |
|
April 12, 2016, 15:31 |
|
#14 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
It means there are problems on lines 34 and 35. Count in your script to see which lines these are.
|
|
April 13, 2016, 12:58 |
|
#15 |
Member
NGP
Join Date: Mar 2016
Posts: 33
Rep Power: 10 |
thanks
when there is 2 function, eg. one for conductivity and the other one for viscosity. I define 2 different UDF for each one, when i interpret them; it only could find one of the function in the material property section. when i run the solution the following message comes: ((Error: chip-exec: function "visco" not found.)) where visco is the other function name! what is the problem? |
|
April 13, 2016, 22:57 |
|
#16 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Quote:
|
||
April 18, 2016, 19:11 |
|
#17 |
Member
NGP
Join Date: Mar 2016
Posts: 33
Rep Power: 10 |
Hi
I have problem in my udf. 1, as i only could interpret one udf to my solver for material property and i have 2 function (thermal conductivity and viscosity) ,is the following udf correct? #include "udf.h" DEFINE_PROPERTY(knew,c,t) { real knf; real pos[ND_ND]; real V=0.05; real fip=0.01; /* volume concentration*/ real ronf=1027; /* density of nanofluid*/ real robf=1000; /* density of base fluid*/ real rop=3720; /* density of particle*/ real cpp=1; /*specific heat of particle*/ real cpbf=.5; /* specific heat of base fluid*/ real cpnf=257.6; /* specific heat of nanofluid*/ real a; real b; real dp=40e-9; /* nanoparticle size*/ real Rep=1000; /* reynolds number of particle*/ real kp=18; /* thermal conductivity of particle*/ real nunf=C_MU_L(c,t); /*the viscosity of nanofluids*/ real NBRp; /* Brinkman number*/ real nubf=8.9e-4; real kbf=0.6; real prp=0.1; /* prandtl of particle*/ real prbf= 0.01; /* prandtl of base fluid*/ real tempo = C_T(c,t); nunf=..... ; /* viscosity of nano fluid which depends on nano particle size and temperature */ a= ..... ; /* a is a function of temperature and nano particle size*/ b= ..... ; NBRp= ..... ; knf=..... /*thermal conductivity of nanofluid*/ return knf; /* for thermal conductivity*/ return nubf; /* for viscosity of nanofluid*/ } 2, I am using following scheme for simulation -Energy--on -Steady -Laminar viscosity -SIMPLE -Pressure based solver-- velocity inlet -Outlet----Pressure outlet -Mesh--Maximum Ortho Skew = 7.00310e-01 Maximum Aspect Ratio = 2.00322e+01 After doing all above stuff, solution is not proceeding ahead, facing errors like # Divergence detected in AMG solver: temperature -> Increasing relaxation sweeps! #reversed flow in 177 faces on pressure-outlet 7. please advise me. is that because of mesh size or relaxation factor? what should i do? thanks |
|
April 18, 2016, 19:22 |
|
#18 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
What is your complete UDF? Are you trying to return the thermal conductivity before the viscosity every time, or is this procedure different in your actual UDF?
|
|
April 19, 2016, 06:50 |
|
#19 | |
Senior Member
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 13 |
Quote:
|
||
April 20, 2016, 14:05 |
|
#20 |
Member
NGP
Join Date: Mar 2016
Posts: 33
Rep Power: 10 |
Hi
this is my UDF for a nano fluid : #include "udf.h" DEFINE_PROPERTY(knew,c,t) { real knf; /* nanofluid thermal conductivity*/ real pos[ND_ND]; real V=.05; /* V is the inlet velocity*/ real fip=0.01; /* volume concentration*/ real ronf=1027; /* density of nanofluid*/ real robf=1000; /* density of base fluid*/ real rop=3720; /* density of particle*/ real cpp=1; /*specific heat of particle*/ real cpbf=.5; /* specific heat of base fluid*/ real cpnf=257.6; /* specific heat of nanofluid*/ real a; real b; real dp=40e-9; /* nanoparticle size*/ real Rep=1000; /* reynolds number of particle*/ real kp=18; /* thermal conductivity of particle*/ real nunf=C_MU_L(c,t); /*the viscosity of nanofluids*/ real NBRp; /* Brinkman number*/ real nubf=8.9e-4; real kbf=0.6; real prp=0.1; /* prandtl of particle*/ real prbf= 0.01; /* prandtl of base fluid*/ real tempo = C_T(c,t); /* cpnf= (fip*rop*cpp+(1-fip)*robf*cpbf)/(ronf); specific heat of nanofluid*/ nunf=-0.3513+0.462*fip-0.135*fip*fip+0.0125*fip*fip*fip +(24.662+2.316*fip-0.4959*fip*fip)/(tempo-273)+30.979*(fip*fip)/((tempo-273)*(tempo-273)) +(995.388-3205.016*fip+8.667*fip*fip)/((tempo-273)*(tempo-273)*(tempo-273))+ (fip/(dp*dp))*(dp*(3.937-1.194*fip)+fip*(20.502-0.8086*fip)); /* viscosity of nanofluid which depends on nanoparticle size and temperature */ a= -3.516+0.0227*tempo-0.000036*tempo*tempo+(105.1-0.691*tempo+0.0011*tempo*tempo)/(dp)+36.63/(dp*dp); /* a is a function of teprature and nanoparticle size*/ b= (-5.095+8.181* fip-0.066*fip*fip)/(dp); NBRp= sqrt ( nubf*V*V/(kp*tempo)) ; knf=1.698*pow (fip, a) * pow ((tempo/273),b)* pow (4,0.0645)* pow(5,-0.106 )* pow (Rep/pow (NBRp,0.5), -0.00463)* kbf; /*thermal conductivity of nanofluid*/ return knf; } DEFINE_PROPERTY(visco,c,t) { real knf; real pos[ND_ND]; real V=.05; real fip=0.01; /* volume concentration*/ real ronf=1027; /* density of nanofluid*/ real robf=1000; /* density of base fluid*/ real rop=3720; /* density of particle*/ real cpp=1; /*specific heat of particle*/ real cpbf=.5; /* specific heat of base fluid*/ real cpnf=257.6; /* specific heat of nanofluid*/ real a; real b; real dp=40e-9; /* nanoparticle size*/ real Rep=1000; /* reynolds number of particle*/ real kp=18; /* thermal conductivity of particle*/ real nunf=C_MU_L(c,t); /*the viscosity of nanofluids*/ real NBRp; /* Brinkman number*/ real nubf=8.9e-4; real kbf=0.6; real prp=0.1; /* prandtl of particle*/ real prbf= 0.01; /* prandtl of base fluid*/ real tempo = C_T(c,t); /* cpnf= (fip*rop*cpp+(1-fip)*robf*cpbf)/(ronf); specific heat of nanofluid*/ nunf=-0.3513+0.462*fip-0.135*fip*fip+0.0125*fip*fip*fip +(24.662+2.316*fip-0.4959*fip*fip)/(tempo-273)+30.979*(fip*fip)/((tempo-273)*(tempo-273)) +(995.388-3205.016*fip+8.667*fip*fip)/((tempo-273)*(tempo-273)*(tempo-273))+ (fip/(dp*dp))*(dp*(3.937-1.194*fip)+fip*(20.502-0.8086*fip)); /* viscosity of nanofluid which depends on nanoparticle size and temperature */ a= -3.516+0.0227*tempo-0.000036*tempo*tempo+(105.1-0.691*tempo+0.0011*tempo*tempo)/(dp)+36.63/(dp*dp); /* a is a function of teprature and nanoparticle size*/ b= (-5.095+8.181* fip-0.066*fip*fip)/(dp); NBRp= sqrt ( nubf*V*V/(kp*tempo)) ; knf=1.698*pow (fip, a) * pow ((tempo/273),b)* pow (4,0.0645)* pow(5,-0.106 )* pow (Rep/pow (NBRp,0.5), -0.00463)* kbf; /*thermal conductivity of nanofluid*/ return nubf; } but it diverged: # Divergence detected in AMG solver: temperature -> Increasing relaxation sweeps! # You may try the enhanced divergence recovery with (rpsetvar 'amg/protective-enhanced? #t) Error: Divergence detected in AMG solver: temperature Error: Divergence detected in AMG solver: temperature Error Object: #f please help me |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF to modify inlet fluid temperature | Vipul_Patel | Fluent UDF and Scheme Programming | 0 | February 22, 2016 22:11 |
Error in Two phase (condensation) modeling | adilsyyed | CFX | 15 | June 24, 2015 20:42 |
UDF for thermal conductivity | ayoub1989 | Fluent UDF and Scheme Programming | 5 | August 18, 2014 06:15 |
UDF to simulate an object moving in a fluid? | charlestan88 | Fluent UDF and Scheme Programming | 0 | October 25, 2013 10:37 |
Terrible Mistake In Fluid Dynamics History | Abhi | Main CFD Forum | 12 | July 8, 2002 10:11 |