|
[Sponsors] |
October 31, 2021, 18:04 |
Get maximum Temperature
|
#1 |
New Member
Erfan
Join Date: Oct 2021
Posts: 14
Rep Power: 5 |
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) } |
|
October 31, 2021, 19:41 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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 |
|
November 1, 2021, 05:10 |
|
#3 |
New Member
Erfan
Join Date: Oct 2021
Posts: 14
Rep Power: 5 |
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) } thanks for helping |
|
November 3, 2021, 00:16 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
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 |
|
November 3, 2021, 06:24 |
|
#5 |
New Member
Erfan
Join Date: Oct 2021
Posts: 14
Rep Power: 5 |
I’m so grateful for your help. It was a challenging time but you made it easier. Thank you.
|
|
November 19, 2021, 08:47 |
|
#6 |
New Member
Erfan
Join Date: Oct 2021
Posts: 14
Rep Power: 5 |
Dear Alexander
I face this error: "MPT_gdhigh1: no function prototype" in the line Code:
tmax = PRF_GRHIGH1(tmax); thank in advanced |
|
November 19, 2021, 14:02 |
|
#7 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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". |
|
Tags |
temparature, udf, velocity |
|
|
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 07:36 |
Specifying output parameter as Maximum temperature | st_vespucci | FLUENT | 1 | January 25, 2018 16:36 |
Difficulty In Setting Boundary Conditions | Moinul Haque | CFX | 4 | November 25, 2014 18:30 |
fluid flow but temperature raises from nowhere? | mxcfd | STAR-CCM+ | 5 | September 16, 2014 06:46 |
the maximum value of granular temperature | haijj | FLUENT | 0 | August 25, 2008 06:02 |