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

entropy generation with UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 7, 2010, 06:25
Default entropy generation with UDF
  #1
Member
 
mohammad
Join Date: Apr 2010
Posts: 42
Rep Power: 16
mohammadkm is on a distinguished road
Dear all
I want to compute entropy generation in tube with constant heat flux.
I wrote a udf to compute gradient temperature:
# include "udf.h"
# include "math.h"
DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;
face_t f;
domain = Get_Domain(1);
/* Fill UDS with the variable. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDSI(c,t,0) = C_T(c,t);
}
end_c_loop (c,t)
}
thread_loop_f (t,domain)
{
if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
begin_f_loop (f,t)
{
F_UDSI(f,t,0) = F_T(f,t);
}
end_f_loop (f,t)
}
}
DEFINE_ON_DEMAND(store_gradient)
{
Domain *domain;
cell_t c;
Thread *t;
domain=Get_Domain(1);
/* Fill the UDM with magnitude of gradient. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,0) =(pow(NV_MAG(C_UDSI_G(c,t,0)),2));
}
end_c_loop (c,t)
}
}
////////////////////////////////
after the iteration in custom field function, i defined:
dissip=(2 * ((daxial-velocity-dx) ^ 2)) + ((daxial-velocity-dy) ^ 2)
S(generation)=((thermal-conductivity-lam * udm-0) / temperature ^ 2) + ((viscosity-lam * dissip) / temperature)
with this way i compute entropy generation in fluent.I can compile my code and get answer without any problem but my result is wrong(not validated with paper). I think my code for compute gradient temperature is incomplete and i need to compute gradient temperature in face too, but i dont know how can i do that?
please help with this problem
thanks
Attached Images
File Type: bmp untitled.bmp (96.1 KB, 237 views)
mohammadkm is offline   Reply With Quote

Old   May 7, 2010, 07:32
Default
  #2
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
I think you can easyly skip all the troubles by directly using the temperature gradient provided by fluent?
However, to be able to access gradients you need to tell fluent to store them (check the udf manual section 3.2.3 - solve/set/expert).
A suggestion:
instead of
Code:
C_UDMI(c,t,0) =(pow(NV_MAG(C_UDSI_G(c,t,0)),2));
you could use
Code:
C_UDMI(c,t,0) =NV_MAG2(C_UDSI_G(c,t,0));
dmoroian is offline   Reply With Quote

Old   May 7, 2010, 12:43
Default
  #3
Member
 
mohammad
Join Date: Apr 2010
Posts: 42
Rep Power: 16
mohammadkm is on a distinguished road
Dear dragos
How can i directly use gradient temperature provided with fluent? there was no gradient temperature(dT/dx) in custom field function panel to use!!
I did that(solve/set/expert) but my result was not changed.
I tried this code to compute gradient face temperature:
# include "udf.h"
# include "math.h"
DEFINE_ADJUST(adjust_gradient, domain)
{
Thread *t;
cell_t c;
face_t f;
domain = Get_Domain(1);
/* Fill UDS with the variable. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDSI(c,t,0) = C_T(c,t);
}
end_c_loop (c,t)
}
thread_loop_f (t,domain)
{
if (THREAD_STORAGE(t,SV_UDS_I(0))!=NULL)
begin_f_loop (f,t)
{
F_UDSI(f,t,0) = F_T(f,t);
}
end_f_loop (f,t)
}
}
DEFINE_ON_DEMAND(store_gradient)
{
Domain *domain;
cell_t c;
Thread *t;
face_t f;
domain=Get_Domain(1);
/* Fill the UDM with magnitude of gradient. */
thread_loop_c (t,domain)
{
begin_c_loop (c,t)
{
C_UDMI(c,t,0) =(pow(NV_MAG(C_UDSI_G(c,t,0)),2));
}
end_c_loop (c,t)
}
thread_loop_f(t, domain)
{
begin_f_loop(f,t)
{
F_UDMI(f,t,0) =(pow(NV_MAG(F_UDSI_G(f,t,0)),2));
}
end_f_loop(f, t)
}
}
/////////////////////////
but i got this error:
..\..\src\test.c(48) : error C2109: subscript requires array or pointer type
..\..\src\test.c(48) : error C2109: subscript requires array or pointer type
..\..\src\test.c(48) : error C2109: subscript requires array or pointer type
..\..\src\test.c(48) : error C2109: subscript requires array or pointer type
///////////////////////////////////////////////
please help me i don't know how to solve my problem. i am reletively new to UDF.
thanks
mohammadkm is offline   Reply With Quote

Old   May 8, 2010, 04:19
Default
  #4
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
It seems either I missunderstood again your problem, or you mixed up concepts.
To clarify: if you need temperature gradient only as a field function, then you don't need udf's. To get the temperature gradient available in field function you have to tell fluent to store it after each iteration (presuming that you have enabled the energy equation first). If you had red the manual page I suggested, you would have found, that storing the gradients is straight forward:
Code:
/solve/set/expert
...
Keep temporary solver memory from being freed? [no] yes
...
After at least 1 iteration you will see three new fields in the derivatives of the field function: dT-dX, dT-dY, and dT-dZ
dmoroian is offline   Reply With Quote

Old   May 9, 2010, 17:12
Default
  #5
Member
 
mohammad
Join Date: Apr 2010
Posts: 42
Rep Power: 16
mohammadkm is on a distinguished road
Dear dragos
you solved my problem, thank for your help.
As you said there is no need to write udf, i just used "/solve/set/expert".
After that i changed criteria of energy from 1e-6 to 1e-12 and my solution was validated.
thanks again
mohammadkm is offline   Reply With Quote

Old   March 12, 2013, 07:14
Default
  #6
Member
 
Satish Gupta
Join Date: Jun 2012
Posts: 30
Rep Power: 13
Rahul123 is on a distinguished road
Hi,
I am solving a 2D problem. I want to write the value of temperature gradient on a surface (I need the values). Can anyone tell me how to do it......I think a udf is to be written but I dont understand which macro to use. I have the end point coordinates of the surface(line)
Rahul123 is offline   Reply With Quote

Old   March 12, 2013, 09:39
Default
  #7
Member
 
mohammad
Join Date: Apr 2010
Posts: 42
Rep Power: 16
mohammadkm is on a distinguished road
you don't need to write udf for calculating the gradient. you should just keed the data by typing a command in the console. I can't remember the command but you can find it in the UDF PDF file.
mohammadkm is offline   Reply With Quote

Old   March 12, 2013, 12:41
Default
  #8
Member
 
Satish Gupta
Join Date: Jun 2012
Posts: 30
Rep Power: 13
Rahul123 is on a distinguished road
I want the gradient value on a wall i.e, surface.....will it be possible
Rahul123 is offline   Reply With Quote

Old   March 14, 2013, 15:35
Default
  #9
Member
 
mohammad
Join Date: Apr 2010
Posts: 42
Rep Power: 16
mohammadkm is on a distinguished road
I think it is possible. And the command to keep the memory is :
/solve/set/expert
...
Keep temporary solver memory from being freed? [no] yes

good luck
mohammadkm is offline   Reply With Quote

Old   February 13, 2014, 12:50
Default
  #10
Member
 
Satish Gupta
Join Date: Jun 2012
Posts: 30
Rep Power: 13
Rahul123 is on a distinguished road
hi,
could you please write the custom field function for entropy generation
Rahul123 is offline   Reply With Quote

Old   February 24, 2014, 14:20
Default
  #11
Member
 
mohammad
Join Date: Apr 2010
Posts: 42
Rep Power: 16
mohammadkm is on a distinguished road
Dear Rahul,
Custom field function can be written based on the formula that I have attached in the first post. For adding gradient temperature you need to type the following statement in the cosole:
/solve/set/expert...Keep temporary solver memory from being freed? [no] yes...Good luck
mohammadkm is offline   Reply With Quote

Old   August 30, 2014, 13:03
Default Regarding Entropy generation
  #12
New Member
 
Ashok
Join Date: Aug 2014
Posts: 1
Rep Power: 0
ashok_iit@hotmail.com is on a distinguished road
I tried to calculate the entropy generation using the command: solve/set/expert
Now, I got the reconstructed dT-dx, dT-dy and dT-dz.
Can these values directly be used in my custom Field function to compute entropy.

Can any one help me out
mail me: ashok_iit@hotmail.com
ashok_iit@hotmail.com is offline   Reply With Quote

Old   September 12, 2014, 13:18
Default how i enter attached equation in custom filed function?
  #13
New Member
 
Abdul Sattar Dogonchi
Join Date: Sep 2014
Posts: 1
Rep Power: 0
setty is on a distinguished road
Quote:
Originally Posted by mohammadkm View Post
Dear Rahul,
Custom field function can be written based on the formula that I have attached in the first post. For adding gradient temperature you need to type the following statement in the cosole:
/solve/set/expert...Keep temporary solver memory from being freed? [no] yes...Good luck
---------------------------------------------------------
Hi mohammad
how i enter equation that you attached in custom filed function?
please help me about this
thnx
setty is offline   Reply With Quote

Old   July 11, 2015, 12:29
Default entropy generation custom field function
  #14
New Member
 
Rasoul
Join Date: Jun 2015
Posts: 3
Rep Power: 10
Ras0ul is on a distinguished road
Dear all
I entered the entropy generation equation in custom field function.but my result is wrong(not validated with paper). I examined my results and found that Fluent calculate the temperature gradient, but it can not properly calculate the square of the temperature gradient!!!
please help with this problem
thanks
Ras0ul is offline   Reply With Quote

Old   July 14, 2015, 10:05
Default
  #15
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
There are two options:
- Fluent has a bug and calculates the square of the gradient of temperature wrong.
- You did something wrong when you tried to let Fluent calculate the square of the gradient of the temperature.

You seem to think that the second option is very unlikely. I think the first option is very unlikely.
pakk is offline   Reply With Quote

Old   July 14, 2015, 10:58
Default
  #16
New Member
 
Rasoul
Join Date: Jun 2015
Posts: 3
Rep Power: 10
Ras0ul is on a distinguished road
Dear pakk
of course, i think the first option is very unlikely. But I really do not know what's the problem. For a specific position within the computational domain, when i account the entropy based on the components separately, there is difference between the answer with custom field printing result. Interestingly, this difference can be seen when i want to calculate the square of the temperature gradient !
Ras0ul is offline   Reply With Quote

Old   July 14, 2015, 11:16
Default
  #17
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
So you agree that it is possible that you did something wrong when you tried to calculate the square of the temperature gradient, but you don't know what it is you could have done wrong.

And what now? I think it is impossible to get help on which of your steps could be wrong, if you don't say which steps you took. But that is just my opinion.
pakk is offline   Reply With Quote

Old   February 26, 2016, 05:52
Post fluid friction of volumetric entropy generation rate
  #18
New Member
 
Altayyeb kinhar
Join Date: Feb 2016
Location: Bucharest
Posts: 4
Rep Power: 10
A. Kinhar is on a distinguished road
Good day All: i have problem with the fluid friction of volumetric entropy generation rate, i already used the steps of Solve/set/expert

and i get the heat transfer of entropy generation with the accepted results but i have problem with the friction of entropy generation

The results of the friction are so low its around 0.0000029 when the Reynolds number is 100 and the heat flux is 100 000 w

I used this formula in the Custom field function to get the fluid friction ( Viscosity * strain rate^2/static temperature)

will you help me to know why the results are so low .... thanks and kind regards
A. Kinhar is offline   Reply With Quote

Old   February 26, 2016, 09:14
Default I'll posed problem
  #19
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Hello Kinhar,
I cannot answer your question because your problem is not very well described, and I am not knowledgeable enough to guess it.
dmoroian is offline   Reply With Quote

Old   October 13, 2017, 15:06
Default Entropy generated FLUENT
  #20
New Member
 
madan
Join Date: Sep 2017
Posts: 5
Rep Power: 8
madhan is on a distinguished road
Hi.

I have tried using this custom field functions for calculating entropy for 3d conjugated problem. but my values are so high. Could anybody tell me is there any other ways to calculate entropy generated due to heat transfer and viscous dissipation.

There is no clear sources available online for calculating entropy. If anyone could post the procedure it will be helpful for learners like me.

Thanks in advance.
madhan is offline   Reply With Quote

Reply


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 - volumetric heat generation Thiago Castro Fluent UDF and Scheme Programming 1 April 5, 2019 02:15
Entropy Generation in compressible flow Dave FLUENT 0 January 5, 2004 07:12
Latest News in Mesh Generation Robert Schneiders Main CFD Forum 1 February 18, 2000 00:48
Latest new in mesh generation Robert Schneiders Main CFD Forum 0 February 16, 2000 07:12
Latest news in mesh generation Robert Schneiders Main CFD Forum 0 March 2, 1999 04:07


All times are GMT -4. The time now is 08:26.