CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF for mass and heat source with heat transfer

Register Blogs Community New Posts Updated Threads Search

Like Tree14Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 4, 2017, 16:26
Default UDF for mass and heat source with heat transfer
  #1
New Member
 
Join Date: Jun 2017
Posts: 19
Rep Power: 9
rajendra1 is on a distinguished road
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.
Attached Images
File Type: jpg Capture.JPG (24.6 KB, 42 views)
rajendra1 is offline   Reply With Quote

Old   June 6, 2017, 05:07
Default
  #2
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
Have you defined the UDM in Fluent?
Tleja and rajendra1 like this.
KaLium is offline   Reply With Quote

Old   June 6, 2017, 09:57
Default
  #3
New Member
 
Join Date: Jun 2017
Posts: 19
Rep Power: 9
rajendra1 is on a distinguished road
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?
rajendra1 is offline   Reply With Quote

Old   June 6, 2017, 13:02
Default
  #4
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
I simply ment this: http://jullio.pe.kr/fluent6.1/help/html/udf/node139.htm

Your code needs 5 memory locations
rajendra1 likes this.
KaLium is offline   Reply With Quote

Old   June 6, 2017, 13:45
Default
  #5
New Member
 
Join Date: Jun 2017
Posts: 19
Rep Power: 9
rajendra1 is on a distinguished road
okay, so I have to choose 5 in the number of UDM locations. right?
rajendra1 is offline   Reply With Quote

Old   June 6, 2017, 14:58
Default
  #6
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
Quote:
Originally Posted by rajendra1 View Post
okay, so I have to choose 5 in the number of UDM locations. right?
Yes. That is correct
rajendra1 likes this.
KaLium is offline   Reply With Quote

Old   June 6, 2017, 15:05
Default
  #7
New Member
 
Join Date: Jun 2017
Posts: 19
Rep Power: 9
rajendra1 is on a distinguished road
okay. Do I need do define different arrays for different macros?
rajendra1 is offline   Reply With Quote

Old   June 6, 2017, 15:32
Default
  #8
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
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.
rajendra1 likes this.
KaLium is offline   Reply With Quote

Old   June 7, 2017, 05:19
Default
  #9
New Member
 
Join Date: Jun 2017
Posts: 19
Rep Power: 9
rajendra1 is on a distinguished road
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?
rajendra1 is offline   Reply With Quote

Old   June 7, 2017, 05:30
Default
  #10
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
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.
KaLium is offline   Reply With Quote

Old   June 7, 2017, 06:09
Default
  #11
New Member
 
Join Date: Jun 2017
Posts: 19
Rep Power: 9
rajendra1 is on a distinguished road
Quote:
Originally Posted by KaLium View Post
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.
oh sorry that is nothing that is a mistake while copying the code.
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?
rajendra1 is offline   Reply With Quote

Old   June 7, 2017, 06:12
Default
  #12
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
Yes. Other variables work the same way as in normal C-programming.
rajendra1 likes this.

Last edited by KaLium; June 7, 2017 at 07:50.
KaLium is offline   Reply With Quote

Old   June 7, 2017, 06:22
Default
  #13
New Member
 
Join Date: Jun 2017
Posts: 19
Rep Power: 9
rajendra1 is on a distinguished road
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?
rajendra1 is offline   Reply With Quote

Old   June 7, 2017, 06:50
Default
  #14
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
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.
KaLium is offline   Reply With Quote

Old   June 7, 2017, 06:54
Default
  #15
New Member
 
Join Date: Jun 2017
Posts: 19
Rep Power: 9
rajendra1 is on a distinguished road
yes, let me try to apply it again I will let you know once I get something.
rajendra1 is offline   Reply With Quote

Old   June 8, 2017, 01:10
Default
  #16
New Member
 
Join Date: Jun 2017
Posts: 19
Rep Power: 9
rajendra1 is on a distinguished road
Quote:
Originally Posted by KaLium View Post
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.
Hi KaLium,

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?
rajendra1 is offline   Reply With Quote

Old   June 8, 2017, 02:35
Default
  #17
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
Quote:
Originally Posted by rajendra1 View Post
mab=-Ca*exp(-Ea/(Rg*temp))*log(Pg/Peqa)*(Psat-Pemp-C_UDMI(c,t,2)); /* mass rource kg/m^3 S*/
Are you sure this equation works? Try to replace it with constant value. What happens?

What is "Ca"?
KaLium is offline   Reply With Quote

Old   June 8, 2017, 04:02
Default
  #18
New Member
 
Join Date: Jun 2017
Posts: 19
Rep Power: 9
rajendra1 is on a distinguished road
Quote:
Originally Posted by KaLium View Post
Are you sure this equation works? Try to replace it with constant value. What happens?

What is "Ca"?
Ca is a constant, I have defined it in the beginning of code (not mentioned in the problem description).

The formula is correct.

I am now trying to input constant value instead of formula.
rajendra1 is offline   Reply With Quote

Old   June 8, 2017, 04:27
Default
  #19
Senior Member
 
KaLium's Avatar
 
Kal-El
Join Date: Apr 2017
Location: Finland
Posts: 150
Rep Power: 9
KaLium is on a distinguished road
I wonder if there are some limitations with DEFINE_EXECUTE_AT_END - type macro.

I usually use DEFINE_ADJUST for this kind of things.
rajendra1 likes this.
KaLium is offline   Reply With Quote

Old   June 8, 2017, 05:26
Default
  #20
New Member
 
Join Date: Jun 2017
Posts: 19
Rep Power: 9
rajendra1 is on a distinguished road
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?
rajendra1 is offline   Reply With Quote

Reply

Tags
define_init, define_source, heat flux udf, mass source term, source energy term


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 17:34.