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

Get maximum Temperature

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 31, 2021, 17:04
Default Get maximum Temperature
  #1
New Member
 
Erfan
Join Date: Oct 2021
Posts: 14
Rep Power: 4
erfan2000 is on a distinguished road
Hello dear all
I have a case that consists of several parts. I want to get the maximum temperature in each time step and if it is over 320K I want to increase my inlet velocity. would you please help me to get the maximum temperature of all zones as tmax?
thanks a lot
Here is my UDF until now:
Code:
DEFINE_PROFILE(InletVelocity, t, i)
{
face_t f;
begin_f_loop (f,t)
{
	if (tmax>=320)
		F_PROFILE(f,t,i) = 0.005;
	else
		F_PROFILE(f,t,i) = 0.002;
}
end_f_loop(f,t)
}
erfan2000 is offline   Reply With Quote

Old   October 31, 2021, 18:41
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you may find the example to start with in ansys fluent customization manual
look for DEFINE_ON_DEMAND
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 1, 2021, 04:10
Default
  #3
New Member
 
Erfan
Join Date: Oct 2021
Posts: 14
Rep Power: 4
erfan2000 is on a distinguished road
Thank you dear Alexander
I changed my code to this:
Code:
real tmax = 0.;

DEFINE_ON_DEMAND(on_demand_calc)
{
Domain *d; /* declare domain pointer since it is not passed as an
argument to the DEFINE macro */
real temp,volume,vol_tot;
Thread *t;
cell_t c;
d = Get_Domain(34); /* Get the domain using ANSYS Fluent utility */
/* Loop over all cell threads in the domain */
thread_loop_c(t,d)
{
/* Compute max, min, volume-averaged temperature */
/* Loop over all cells */
begin_c_loop(c,t)
{
volume = C_VOLUME(c,t); /* get cell volume */
temp = C_T(c,t); /* get cell temperature */
if (temp > tmax || tmax == 0.) tmax = temp;
}
end_c_loop(c,t)
printf("\n  Tmax = %g",tmax);
}
} 

DEFINE_PROFILE(InletVelocity, t, i)
{
face_t f;
begin_f_loop (f,t)
{
	if (tmax>=320)
		F_PROFILE(f,t,i) = 0.005;
	else
		F_PROFILE(f,t,i) = 0.002;
}
end_f_loop(f,t)
}
Is everything OK?
thanks for helping
erfan2000 is offline   Reply With Quote

Old   November 2, 2021, 23:16
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
to check if your UDF is OK or not you should:
1. compile code
2. run it
3. read log in console

few modifications were made on assumption that under Get_Domain(34) you wanted to check the temperature of zone 34
that id must be the the id of zone not boundary, because you are using loop over cells (volumes) but not faces, in case id 34 belongs to boundary you should change begin_c_loop to begin_f_loop

compile code

Code:
#include "udf.h"
real tmax = 0.;

DEFINE_ON_DEMAND(on_demand_calc)
{
Domain *d;
real temp;
int ID = 34;
Thread *t;
cell_t c;
d = Get_Domain(1); /* Get the domain using ANSYS Fluent utility */
t = Lookup_Thread(domain, ID);
/* Loop over all cell threads in the domain */

begin_c_loop(c,t)
{
temp = C_T(c,t); /* get cell temperature */
if (temp > tmax || tmax == 0.) tmax = temp;
}
end_c_loop(c,t)
# if RP_NODE /* Perform node synchronized actions here. Does nothing in Serial */
tmax = PRF_GRHIGH1(tmax);
# endif /* RP_NODE */
Message0("\n  Tmax = %g",tmax);
} 

DEFINE_PROFILE(InletVelocity, t, i)
{
face_t f;
begin_f_loop (f,t)
{
	if (tmax>=320)
		F_PROFILE(f,t,i) = 0.005;
	else
		F_PROFILE(f,t,i) = 0.002;
}
end_f_loop(f,t)
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 3, 2021, 05:24
Default
  #5
New Member
 
Erfan
Join Date: Oct 2021
Posts: 14
Rep Power: 4
erfan2000 is on a distinguished road
I’m so grateful for your help. It was a challenging time but you made it easier. Thank you.
erfan2000 is offline   Reply With Quote

Old   November 19, 2021, 07:47
Default
  #6
New Member
 
Erfan
Join Date: Oct 2021
Posts: 14
Rep Power: 4
erfan2000 is on a distinguished road
Dear Alexander
I face this error: "MPT_gdhigh1: no function prototype" in the line
Code:
tmax = PRF_GRHIGH1(tmax);
do you know how can I fix it?
thank in advanced
erfan2000 is offline   Reply With Quote

Old   November 19, 2021, 13:02
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
That sounds like an error message when you interpret. You should not interpret, you should compile.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Reply

Tags
temparature, udf, velocity

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Problem with zeroGradient wall BC for temperature - Total temperature loss cboss OpenFOAM 12 October 1, 2018 06:36
Specifying output parameter as Maximum temperature st_vespucci FLUENT 1 January 25, 2018 15:36
Difficulty In Setting Boundary Conditions Moinul Haque CFX 4 November 25, 2014 17:30
fluid flow but temperature raises from nowhere? mxcfd STAR-CCM+ 5 September 16, 2014 05:46
the maximum value of granular temperature haijj FLUENT 0 August 25, 2008 05:02


All times are GMT -4. The time now is 07:04.