|
[Sponsors] |
June 18, 2010, 03:24 |
UDF for Heat Exchanger model
|
#1 |
New Member
francois
Join Date: Jun 2010
Location: Stellenbosch
Posts: 9
Rep Power: 16 |
Hi,
I'm trying to solve a model in fluent 12 where I have a fan, plenum chamber and heat exchanger model at the end of the chamber, making a "fan-unit". A udf was written to model the heat transfer. What it basically does is extract the temperatures on the fan face and defines it as the inlet temperatures to the heat exchanger. The udf goes ons to calculate the heat transfer source term and ascribes the source term to the cells in the heat transfer model. I thus defined two faces fort referencing. On face (fan face) for temperature extraction and one face (he exchanger face) to reference which cells the source terms should be added to. My udf works fine if I am looking at one "fan-unit". I however want to simulate multiple fan units simultaneously and thus require the udf to reference different faces in the model as many times as there is "fan units" so that each "fan-unit" calculates it's own heat transfer with it's own fan inlet temperatures. I thought I could do this by just adding a for loop to my udf, but I am receiving a "parse error" at line 44, which is the beginning of the for loop. The for loop would be extremely beneficial otherwize I must interpret a udf for each of the "fan units", which becomes tedious. My code is attached. If anyone could help me getting it started I would appreciate it. If my manner of arguing is totally wrong, i would appreciate some advice regarding this as well. Thank you Francois Louw Code:
#include "udf.h" /********************************************* Energy source term for heat exchanger *********************************************/ /* Declare global variables*/ real m; real Ry_1; real Ry_2; real Ny_1; real Ny_2; real UA_1; real UA_2; real e1; real e2; real T_ai1; real T_ao2; real Vcell; real Acell; real heat_sink; /* Declare global constants*/ real A_fr = 20; real nb = 8; real n_tb1 = 12; real n_tb2 = 13; real rho = 1.0717; real k = 0.026; real mu = 1.83235e-5; real cp = 1006.8; real Pr = 0.749; real T_s = 323.15; real Lz = 0.2; real Afactor = 1.4983; /* Declare applicable face id's*/ int n = 2; // Length of array int ID_fan[2] = {30071, 30063}; // Fan face id's int ID_he[2] = {30067, 30062}; // HE face id's /* Loop for each fanunit seperately */ int i; for (i = 0 ; i < n ; i++) { real Sum_Tai = 296.85; real j = 1; DEFINE_ADJUST(property_calc, domain) { face_t f; cell_t c0, c1; Thread *t0, *t1; int zone_ID = ID_fan[i]; /* Zone ID of fan for air temperature extraction */ Thread *f_thread = Lookup_Thread(domain, zone_ID); /* Identify face threads at fan */ /* Loop over fan face to extract air temp */ begin_f_loop(f, f_thread) { c0 = F_C0(f,f_thread); /* Find cell */ t0 = THREAD_T0(f_thread); /* Find adjacent cell thread */ j += 1; /* Cell counter */ Sum_Tai += C_T(c0, t0); /* Inlet temp taken at fan face and summed */ } end_f_loop(f, f_thread) T_ai1 = Sum_Tai/j; } DEFINE_ADJUST(property_calc2, domain) { face_t f; /* Face identifier*/ cell_t c0, c1; Thread *t0, *t1; int zone_ID = ID_he[i]; /* Zone ID for boundary between plenum and HE */ Thread *f_thread = Lookup_Thread(domain, zone_ID); /* Identify face threads at boundary */ /* Loop over faces in face thread */ begin_f_loop(f, f_thread) /* Loops over faces in a face thread */ { /* Find adjacent cells */ c0 = F_C0(f,f_thread); /* First find upstream cell (in this case c0 is upstream but it not always the case */ t0 = THREAD_T0(f_thread); /* Find adjacent cell thread */ c1 = F_C1(f,f_thread); t1 = THREAD_T1(f_thread); m = F_FLUX(f, f_thread); /* Mass flow rate */ Vcell = C_VOLUME(c1,t1); /* Volume flow rate */ Acell = Afactor*Vcell/Lz; /* Equivalent area of cell */ /* Get upstream temperature */ Ry_1 = (fabs(m))/(mu*Acell*n_tb1/n_tb2); /* Characteristic flow parameter: 1st row */ Ry_2 = (fabs(m))/(mu*Acell); /* Characteristic flow parameter: 2nd row */ Ny_1 = 200*pow(Ry_1, 0.3); /* Characteristic heat transfer parameter: 1st row */ Ny_2 = 1000*pow(Ry_2, 0.3); /* Characteristic heat transfer parameter: 2nd row */ UA_1 = k*pow(Pr, 0.333)*Acell*Ny_1; /* Heat transfer coefficient: 1st row */ UA_2 = k*pow(Pr, 0.333)*Acell*Ny_2; /* Heat transfer coefficient: 2nd row */ e1 = 1 - exp(-UA_1/((fabs(m))*cp)); /* Effectiveness: 1st row */ e2 = 1 - exp(-UA_2/((fabs(m))*cp)); /* Effectiveness: 2nd row */ T_ao2 = e2*T_s + (1 - e2)*(e1*T_s + (1 - e1)*T_ai1); /* Heat exchanger outlet temp */ heat_sink = fabs(m)*cp*(T_ao2 - T_ai1)/Vcell; /* Source term */ /*printf("Tao2 = %12.4f\n", T_ao2); printf("Se = %12.4f\n", heat_sink); printf("Vcell = %12.4f\n", Vcell); printf("ma = %12.4f\n", m); printf("Tai1 = %12.4f\n", T_ai1); /* Store the values of the source term in the UDMI of the downstream cell */ C_UDMI(c1,t1,0)=heat_sink; } end_f_loop(f, f_thread) } DEFINE_SOURCE(energy_source, c, c_thread, dS, eqn) { real source; /* Source term variable */ source = C_UDMI(c,c_thread,0); return source; } } |
|
July 15, 2010, 16:15 |
|
#2 |
New Member
Paul
Join Date: May 2009
Location: Santa Clara, CA
Posts: 9
Rep Power: 17 |
Francois,
I believe I am modeling a similar problem. I am using a recirculation boundary condition which is accessible in Fluent if you type the following in the terminal user interface: (rpsetvar 'icepak? #t) (models-changed) Can this help in any way? As a side question pertaining to my problem: Are you using the simple effectiveness heat exchanger model? If so, have you written a UDF to allow the auxiliary fluid to be colder than the primary fluid or written a UDF for enthalpy vs temperature for a phase change problem? I could use some help with this. Paul |
|
July 16, 2010, 02:21 |
|
#3 |
New Member
francois
Join Date: Jun 2010
Location: Stellenbosch
Posts: 9
Rep Power: 16 |
Paul
The model I'm simulating is an air-cooled condenser model, which works with finned tubes in practice, but simulated with a porous model in Fluent. The temperature of the fluid inside the heat exchanger thus stays the same (T_s = 323.15 in the udf), but the air temperature of the cooling air flowing across it rises as heat is drawn from the finned tubes. The heat transfer is calculated by the effectiveness-NTU method, yes. I got the udf working with somes help from our support guys, but made some changes to it as well. Part of the problem was that Fluent orientates the reference faces by itself and up until now, not me or the support guys know how to get all the faces alligned with all their normals looking in the same direction. Fluent only allows the user to reference the cells immediately upstream and downstream of the specified face, which are c0 and c1. I changed the udf to first identify on which side cells c0 and c1 are along the reference faces and then ascribe the heat source term to the downstream cells, whether it is c0 or c1. I hope this helps in some way. If not, I would be glad to give some more input. Regards Francois |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
any question about heat exchanger model | egry | FLUENT | 0 | October 25, 2008 20:14 |
Problem with UDF in VOF model | vijay | FLUENT | 0 | April 18, 2006 01:06 |
Convective Heat Transfer - Heat Exchanger | Mark | CFX | 6 | November 15, 2004 15:55 |
UDF for VOF model | Kunal Ashar | FLUENT | 0 | September 8, 2004 13:13 |
How to use Heat Exchanger model? | Johnny | FLUENT | 0 | August 9, 2004 07:44 |