-
-
December 2, 2018 at 9:02 am
suraj9735
Subscriber#include "udf.h"
DEFINE_SOURCE(my_heat_source, c, t, dS, eqn)
{
real t = CURRENT_TIME;Â
real temp;
real source;Â
temp = C_T(cell, thread);
dS[eqn] = 0;Â Â Â Â
if (temp <= 453.)Â Â Â Â /* If the temperature is low, Cartridge heater ON */
source = 750000;
else
source = 0;Â Â Â /* Otherwise, Cartridge Heater OFF */
return source;
}
I get error with this UDF. Could you please check it!
 -
December 3, 2018 at 6:05 am
Amine Ben Hadj Ali
Ansys EmployeeAs ANSYS stuff debugging UDF is not our task even for commercial customers. But your UDF is wrong: wrong thread assigned (t is the thread of cells passed by the udf) and the cell index is wrong. Refer to the manual which contains several working examples. -
December 3, 2018 at 6:17 pm
suraj9735
SubscriberThanks a lot!
Your little hint made my day!
I have changed little in UDF and it's working now....
-
December 3, 2018 at 6:20 pm
suraj9735
Subscriber/**************************************************************/
/* User-Defined Functions for temperature-dependent source */
/* FLUENT 19.0 */
/**************************************************************/
#include "udf.h"
DEFINE_SOURCE(my_heat_source, c, t, dS, eqn)
{
real temp;
real source;
temp = C_T(c, t);
if (temp <= 453.)Â Â Â /* If the temperature is low, Cartridge heater ON */
source = 31830988.62;
else source = 0;Â Â /* Otherwise, Cartridge Heater OFF */
dS[eqn] = 0;
return source;
}
Â
Â
-
December 3, 2018 at 6:20 pm
suraj9735
SubscriberNow I have another issue with this UDF.
With current UDF, The problem is some of cells of heater cell zones are giving power and some of them are not. But I want all cells of heater must be ON or OFF simultaneously according to the data of maximum temperature of Cavity surface (It's a interested area of my model).
I want to put a sensor on cavity surface of my heating plate. For that I need to access the data of maximum surface temperature of cavity surface and use that output in UDF to decide my heater (All cells of heater on or off simultaneously) should ON or OFF.
Â
How can I do that? Do I need to use user defined memory/scalar to store the maximum surface temperature data and use in UDF?
-
December 3, 2018 at 7:23 pm
Amine Ben Hadj Ali
Ansys EmployeeIn a Adjust you check for the max. temperature store it and use it (directly or via setting a flag to TRUE: condition fulfilled) in a DEFINE_SOURCE to turn on/off. For the DEFINE_ADJUST you need to be careful with initialization and global reduction.
-
December 8, 2018 at 8:52 pm
suraj9735
SubscriberI am new to the UDF.
I want to store the maximum temperature of a point in DEFINE_ADJUST and directly use in DEFINE_SOURCE. But unable to write the code to store the maximum temperature of a point. Could you please edit my code and send it back as a sample. I also confused about how to hook multiple UDF.
I tried to store the maximum temperature in ADJUST but it loops all over my domain but I want to check at a particular point.
Â
#include "udf.h"
Â
real T_M=0.;
DEFINE_ADJUST(my_adjust,d)
{
Thread *t;
/* Maximum Temperature. */
cell_t c;
thread_loop_c(t,d)
{
begin_c_loop(c,t)
if(T_M
T_M=C_T(c,t);
else
T_M=T_M;
end_c_loop(c,t)
}
printf("T_M: %gn", T_M);
}
Â
DEFINE_SOURCE(my_heat_source, c, t, dS, eqn)
Â
Â
{
Â
real source;Â
Â
if (T_M <= 453.)
   /* If the temperature is low, Cartridge heater ON */
Â
source = 31830988.62;
Â
else
source = 0;
/* Otherwise, Cartridge Heater OFF */
Â
dS[eqn] = 0;
printf("source: %gn", source);
return source;
Â
}
Â
First, How to create a point in Fluent and find out thread pointer of the particular point and calculate its temperature?
Please edit my code as a sample, If you can!
Thanks!
-
December 9, 2018 at 11:57 am
Amine Ben Hadj Ali
Ansys EmployeeIt would require a lot of parallelization to get the the Adjust working. Check the manual to have ideas about global reductions. Start with the on demand from help and make it parallel. ANSYS Staff do not even debug or write UDF's for non academic customersÂ
-
December 9, 2018 at 1:57 pm
suraj9735
Subscriber
In a Adjust you check for the max. temperature store it and use it (directly or via setting a flag to TRUE: condition fulfilled) in a DEFINE_SOURCE to turn on/off. For the DEFINE_ADJUST you need to be careful with initialization and global reduction.
In this post as you said to store the current temp. of a vertex and use it in If Else statement. So what's wrong with this concept. In my new UDF, I just loop over all the domain because I don't know how to get a temp. of a particular vertex. This is completely new bugs for me...
1) Parallelization in UDF.
2) Global Reduction.
Could you please explain more why I need these kinds of stuff!, While I just want to find the temp. of a point.
-
December 9, 2018 at 2:20 pm
Amine Ben Hadj Ali
Ansys EmployeeGlobal reduction are required to reduce values if every more to a single value which might be communicated to the other nodes and just process. It is required for cases like looking into average values or looking into extreme values across the partitions.
-
- The topic ‘how to write conditional source UDF?’ is closed to new replies.
-
2928
-
970
-
852
-
599
-
591
© 2025 Copyright ANSYS, Inc. All rights reserved.