|
[Sponsors] |
UDF for mass and heat source with heat transfer |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 4, 2017, 16:26 |
UDF for mass and heat source with heat transfer
|
#1 |
New Member
Join Date: Jun 2017
Posts: 19
Rep Power: 9 |
Dear Friends,
I am trying to solve heat transfer problem. The geometry is shell and tube type. please see attachment for the picture of model. Problem description: heat is generation takes place in tube and it is to be transferred to the shell side through the cylinder wall. There is no problem when I am trying to solve the problem in fluent (workbench project) by giving constant heat source as input. BUT when I am trying to calculate mass generation and heat generation with the help of UDF, fluent says: fluent received fatal signal (access_violation). I have tried different ways to rectify the error but failed so far. Boundary conditions are, gas inlet (tube (inner) inlet) at 20e+05 Pa. pressure, 300 K temp. gas outlet (tube (inner) outlet) adiabatic wall (so there is no outlet only inlet on tube side) coolant inlet (shell side (annular section)) 300 K temp. coolant outlet (shell side (annular section)) Convetive wall (inner cylinder surface) Convetive wall Shadow (inner cylinder surface) Adiabatic wall (outer cylinder surface) I have coupled convective wall and its shadow in boundary conditions. Also tried to calculate heat flux on the convective wall using DEFINE_HEAT_FLUX macro. I have tried to give initial values using DEFINE_INIT MACRO in the gas tube because I want uniform pressure in the tube. I am trying to calculate mass source and hence heat source using DEFINE_SOURCE MACRO I am using Interpreted UDF. It gets interpreted, in fluent initialization gets done but it again gives same error ie. "fluent received fatal signal (access_violation)". I need help from you guys, please see the code and tell me where I am wrong, I will be very grateful for you suggestions. UDF CODE: /************************************************** ************* UDF for initializing flow field variables ************************************************** **********/ DEFINE_INIT(my_init_func,d) { cell_t c; Thread *t; real xc[ND_ND]; /* loop over all cell threads in the domain */ thread_loop_c(t,d) { /* loop over all cells */ begin_c_loop_all(c,t) { C_CENTROID(xc,c,t); C_T(c,t) = 300.; C_P(c,t) = 2000000.; C_U(c,t) = 0.; C_V(c,t) = 0.; C_W(c,t) = 0.; } end_c_loop_all(c,t) } } /************************************************** ************/ /* UDF for specifying an absorption source term in a pressure and temperature*/ DEFINE_EXECUTE_AT_END(source_calculation) { Domain *d; Thread *t; cell_t c; real time = CURRENT_TIME; real temp, Pg, Peqa, mab, m; int zone=7; d=Get_Domain(1); t=Lookup_Thread(d,zone); begin_c_loop(c,t) { temp=C_T(c,t); Pg=C_P(c,t); Peqa=1000*exp(Aab-Bab/temp); mab=-Ca*exp(-Ea/(Rg*temp))*log(Pg/Peqa)*(Psat-Pemp-C_UDMI(c,t,2)); /* mass rource kg/m^3 S*/ m=mab; C_UDMI(c,t,0) = m; C_UDMI(c,t,1) = 0.0; /*derivative term in mass source*/ C_UDMI(c,t,2) = -C_UDMI(c,t,0)*CURRENT_TIMESTEP+C_UDMI(c,t,2); C_UDMI(c,t,3) = C_UDMI(c,t,0)*(delta_H+temp*(C_pg-C_ps)); C_UDMI(c,t,4) = 0.0;/*derivative term in energy source*/ } end_c_loop(c,t); } DEFINE_SOURCE(mass_source,c,t,dS,eqn) { dS[eqn] = C_UDMI(c,t,1); return C_UDMI(c,t,0); } DEFINE_SOURCE(energy_source,c,t,dS,eqn) { dS[eqn] = C_UDMI(c,t,4); return C_UDMI(c,t,3); } /************************************************** ***********/ /**************udf for Wall Heat flux on convective wall *************************** */ real h = 0.0; /* heat transfer coefficient (W/m^2 K) */ DEFINE_ADJUST(htc_adjust, domain) { /* Define the heat transfer coefficient. */ h = 120; } (heat_flux, f, t, c0, t0, cid, cir) { cid[0] = 0.; cid[1] = h; cid[2] = h; cid[3] = 0.; } I thank you in advance. |
|
June 6, 2017, 05:07 |
|
#2 |
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
Have you defined the UDM in Fluent?
|
|
June 6, 2017, 09:57 |
|
#3 |
New Member
Join Date: Jun 2017
Posts: 19
Rep Power: 9 |
Dear KaLium,
Thank you very much for showing interest to help me. I do not think that I have defined UDM in fluent. How can I define UDM, by using DEFINE_ON_DEMAND macro or in FLUENT --->define--->user defined--->memory (500) locations? |
|
June 6, 2017, 13:02 |
|
#4 |
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
I simply ment this: http://jullio.pe.kr/fluent6.1/help/html/udf/node139.htm
Your code needs 5 memory locations |
|
June 6, 2017, 13:45 |
|
#5 |
New Member
Join Date: Jun 2017
Posts: 19
Rep Power: 9 |
okay, so I have to choose 5 in the number of UDM locations. right?
|
|
June 6, 2017, 14:58 |
|
#6 |
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
||
June 6, 2017, 15:05 |
|
#7 |
New Member
Join Date: Jun 2017
Posts: 19
Rep Power: 9 |
okay. Do I need do define different arrays for different macros?
|
|
June 6, 2017, 15:32 |
|
#8 |
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
You can use same location in different macros. Just remember that if a macro saves something in to udm, it will overwrite the old data.
|
|
June 7, 2017, 05:19 |
|
#9 |
New Member
Join Date: Jun 2017
Posts: 19
Rep Power: 9 |
I have tried as you suggested. solution ran upto 20 iterations but later stopped.
Now I am trying to incorporate heat flux macro .....and again getting fatal error. I have to calculate heat flux on cylinder wall (transient analysis), will the following code suffice for same... DEFINE_EXECUTE_AT_END(flux_calculation) { face_t f; //Index that identifies a wall face. Thread *t; //Pointer to wall face thread on which heat flux function is to be applied. cell_t c0; //Cell index that identifies the cell next to the wall. Thread *t0; //Pointer to the adjacent cell’s thread. real cid[4]; //Array of fluid-side diffusive heat transfer coefficients. real cir[4]; //Array of radiative heat transfer coefficients. real h=120.0; DEFINE_HEAT_FLUX(heat_flux, f, t, c0, t0, cid, cir) { real h=120.0; real x[ND_ND]; cid[0] = 0.0; cid[1] = h; cid[2] = h; cid[3] = 0.0; } anything wrong with this? |
|
June 7, 2017, 05:30 |
|
#10 |
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
When I said, you can use same memory location for different macros, I ment that that you can use the same fluent UDM location. Not all variables can be used the same way.
What are you trying to do with DEFINE_EXECUTE_AT_END(flux_calculation)? The "}" is missing. |
|
June 7, 2017, 06:09 |
|
#11 | |
New Member
Join Date: Jun 2017
Posts: 19
Rep Power: 9 |
Quote:
Yes, let me tell you what I understood from your suggestion: I must ensure before using C_UDMI that I have assigned memory to it. for other variables such as real a,b,c I need not define memory. am I right? |
||
June 7, 2017, 06:12 |
|
#12 |
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
Yes. Other variables work the same way as in normal C-programming.
Last edited by KaLium; June 7, 2017 at 07:50. |
|
June 7, 2017, 06:22 |
|
#13 |
New Member
Join Date: Jun 2017
Posts: 19
Rep Power: 9 |
thank you very much for your quick replies.
okay, so the code i have mentioned in comment to calculate heat flux is correct? Do I need anything in addition to it ...like defining heat transfer coefficient at each cell on surface of cylinder? or just real h=some value is enough? |
|
June 7, 2017, 06:50 |
|
#14 |
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
Atleast your code looks quite similar than the code in guide:
http://jullio.pe.kr/fluent6.1/help/html/udf/node66.htm http://jullio.pe.kr/fluent6.1/help/h...on-application I don't know what the results will be. Last edited by KaLium; June 7, 2017 at 08:00. |
|
June 7, 2017, 06:54 |
|
#15 |
New Member
Join Date: Jun 2017
Posts: 19
Rep Power: 9 |
yes, let me try to apply it again I will let you know once I get something.
|
|
June 8, 2017, 01:10 |
|
#16 | |
New Member
Join Date: Jun 2017
Posts: 19
Rep Power: 9 |
Quote:
The code worked but only for 20 iterations, after that solution stopped. with no increase in temperature anywhere in the zones. also, tried to plot UDM but it is zero everywhere. so this means nothing is getting stored in UDM locations. Do you have any idea why is this happening? |
||
June 8, 2017, 02:35 |
|
#17 |
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
||
June 8, 2017, 04:02 |
|
#18 | |
New Member
Join Date: Jun 2017
Posts: 19
Rep Power: 9 |
Quote:
The formula is correct. I am now trying to input constant value instead of formula. |
||
June 8, 2017, 04:27 |
|
#19 |
Senior Member
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9 |
I wonder if there are some limitations with DEFINE_EXECUTE_AT_END - type macro.
I usually use DEFINE_ADJUST for this kind of things. |
|
June 8, 2017, 05:26 |
|
#20 |
New Member
Join Date: Jun 2017
Posts: 19
Rep Power: 9 |
I have found rise in temperature with constant mass source input. But solution stopping after every iteration. may be I shall check the formula again. But again there is nothing stored in UDM.
I am not really sure whether I shall use DEFINE_EXECUTE_AT_END or DEFINE_ON_DEMAND. please put some light .......what I know is that former is executed at the end of time step and later in the beginning. Can I define initial values to in C_UDMI using DEFINE_INIT macro? |
|
Tags |
define_init, define_source, heat flux udf, mass source term, source energy term |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF for heat transfer coeff. in porous media | parvaz747 | FLUENT | 0 | November 16, 2016 13:35 |
Difficulty In Setting Boundary Conditions | Moinul Haque | CFX | 4 | November 25, 2014 18:30 |
Problem in UDF time dependent vloumetric heat source | eng_yasser_2020 | Fluent UDF and Scheme Programming | 0 | March 30, 2014 09:07 |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 07:28 |
UDF - Heat transfer coefficient | kulasekharan | FLUENT | 3 | August 12, 2004 08:09 |