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 a time varying heat flux boundary condition (https://www.cfd-online.com/Forums/fluent-udf/126623-udf-time-varying-heat-flux-boundary-condition.html)

B.Hamada November 21, 2013 14:38

UDF for a time varying heat flux boundary condition
 
1 Attachment(s)
Hello,

I'm VERY new to Fluent and I'm attempting to write a UDF that will make the heat flux at a wall a function of time. I've never programmed in C before either so I'm having some trouble getting the correct sytax

My function in Attach Files:

Please help me to witre it

I : Heat flux.
A : area of the front surface.
t : Time.
T : Temperature.
h : heat transfer coefficient.
\DeltaX : depth.
Cp: specific heat
\rho: density.

Thank you.

Zaktatir November 21, 2013 16:44

Please look into the UDF documentation there are some examples how to define a profile.

Macro to use is DEFINE_PROFILE(name,thread,nv) and then the function would be over F_PROFILE through the face_centroids in the face thread.

B.Hamada November 21, 2013 18:19

Quote:

Originally Posted by Zaktatir (Post 463001)
Please look into the UDF documentation there are some examples how to define a profile.

Macro to use is DEFINE_PROFILE(name,thread,nv) and then the function would be over F_PROFILE through the face_centroids in the face thread.

Thank you, but can you give me an idea how write it please.

macfly November 22, 2013 13:38

here is an example, I guess you can just apply the profile on your boundary as a heat flux: http://www.cfd-online.com/Forums/flu...tml#post463127

pakk November 27, 2013 03:44

Quote:

Originally Posted by B.Hamada (Post 463015)
Thank you, but can you give me an idea how write it please.

As Zaktatir said, there are examples in the Help. They show you how to write it, you only have to make the appropriate changes.

gouravjee August 5, 2018 04:32

Quote:

Originally Posted by pakk (Post 463689)
As Zaktatir said, there are examples in the Help. They show you how to write it, you only have to make the appropriate changes.

I have to calculate heat transfer losses from radial surface of the cylinder.
I have written a udf for this but it is showing "segmentation fault".
can you tell me where might be the problem ?

Code:

#include "udf.h"


DEFINE_PROFILE(fluxloss,thread,position)
{
real h;
real T_ext;
face_t f;
begin_f_loop(f,thread)
{
h = 10;
T_ext = 300;
F_PROFILE(f,thread,position) =-10*(WALL_TEMP_INNER(f,thread)-T_ext);
}
end_f_loop(f,thread)

}


AlexanderZ August 5, 2018 22:06

try this code
Code:

#include "udf.h"
DEFINE_PROFILE(fluxloss,thread,position)
{
real h;
real T_ext;
face_t f;
Thread *t0=thread->t0;
/* Do nothing if areas are not computed yet or not next to fluid. */
if (!Data_Valid_P() || !FLUID_THREAD_P(t0)) return;
begin_f_loop(f,thread)
{
h = 10;
T_ext = 300;
F_PROFILE(f,thread,position) =-10*(WALL_TEMP_INNER(f,thread)-T_ext);
}
end_f_loop(f,thread)
}

best regards

gouravjee August 7, 2018 12:44

Quote:

Originally Posted by AlexanderZ (Post 701607)
try this code
Code:

#include "udf.h"
DEFINE_PROFILE(fluxloss,thread,position)
{
real h;
real T_ext;
face_t f;
Thread *t0=thread->t0;
/* Do nothing if areas are not computed yet or not next to fluid. */
if (!Data_Valid_P() || !FLUID_THREAD_P(t0)) return;
begin_f_loop(f,thread)
{
h = 10;
T_ext = 300;
F_PROFILE(f,thread,position) =-10*(WALL_TEMP_INNER(f,thread)-T_ext);
}
end_f_loop(f,thread)
}

best regards

can it be used for user defined scalar transport equation as i am not using the default energy equation of fluent?

AlexanderZ August 7, 2018 21:56

DEFINE_PROFILE macro is using to define user-defined boundary condition. You may use it anywhere.

to set this profile as BC for UDS go to boundary conditions-> select face you are interested in -> select UDS tab -> select specified value -> select this profile instead of "constant"

best regards

gouravjee August 8, 2018 12:51

Quote:

Originally Posted by AlexanderZ (Post 701873)
DEFINE_PROFILE macro is using to define user-defined boundary condition. You may use it anywhere.

to set this profile as BC for UDS go to boundary conditions-> select face you are interested in -> select UDS tab -> select specified value -> select this profile instead of "constant"

best regards

thanks for your help!!
it is working fine.
but i have a doubt that the following expression is for heat flux, should i use specified flux instead of specified value?


All times are GMT -4. The time now is 00:29.