CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for time dependent heat flux (https://www.cfd-online.com/Forums/fluent-udf/164509-udf-time-dependent-heat-flux.html)

rontgen5 December 23, 2015 13:00

UDF for time dependent heat flux
 
Hello!

I am very new to ANSYS. I am modeling a simple conduction + convection model. Although the heat source in this is more like a PULSE. In a 300 msec cycle, a heat pulse of 10 msec long is sent at 50th msec. All the time except for the pulse duration is for cooling.

I have written an UDF, that can be seen below (with my negligible knowledge of writing an UDF). When I try to interpret it, I am getting an errors: 1. line 35:parse error, 2. f_loop_last: undeclared variable. I am not able to understand the cause of these errors. I tried looking at other threads, but I still couldn't understand what's wrong.

Can some one please have a look and give me some kind of feedback?

I highly appreciate your time, thank you very much.


Code:

# include "udf.h"
# include "unsteady.h"

DEFINE_EXECUTE_AT_END (execute_loop)
{
face_t f;
Thread *t;
real c_time=0.0000;
real q;
c_time=CURRENT_TIME;

if (c_time<0.05)
{
q=0;
}

if ((c_time>=0.05)&&(c_time<=0.06))
{
q=10000;
}

if (c_time>0.06)
{
q=0;
}

DEFINE_PROFILE(HeatPulse, t, i)
{
begin_f_loop (f,t)
F_PROFILE(f,t,i) = q;
end_f_loop(f,t)
}
}

`e` January 2, 2016 17:53

Are you sure you're interpreting the code you've copied above? There are less than 35 lines of code (your first error mentions an error on line 35) and "f_loop_last" (your second error) is not found in your code.

Try compiling instead of interpreting UDFs (more stable) and the pulse can be applied within the DEFINE_PROFILE macro without using the second macro (CURRENT_TIME is available at each step the profile is applied to the boundary).

rontgen5 January 2, 2016 18:29

Sorry about that, I did not copy the comments at the beginning of the code, which I had written for my benefit.

Thank you very much for your help. But, I figured out yesterday that DEFINE_PROFILE with CURRENT_TIME was all I needed. So I was able to interpret the UDF. Although now, I am trying to find a way to check if the pulse was applied or not. So its its more like a question of reading the data.

Let's see what happens, once I figure out how to read if the pulse was applied at the instances I wanted.

Azim07 August 7, 2019 02:20

Rontgen can you please send your UDF which ran without error?

AlexanderZ August 8, 2019 00:56

Code:

#include "udf.h"
DEFINE_PROFILE(HeatPulse, t, i)
{
face_t f;
real time=0;
real q;
time=CURRENT_TIME;
if ((time>=0.05)&&(time<=0.06))
        q=10000;
else
        q=0;
begin_f_loop (f,t)
{
        F_PROFILE(f,t,i) = q;
}
end_f_loop(f,t)

}

best regards

Azim07 August 8, 2019 03:04

Thanks a lott Alaxender


All times are GMT -4. The time now is 21:47.