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

Heat flux profile UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 16, 2014, 21:13
Default Heat flux profile UDF
  #1
Member
 
Mohamed
Join Date: Jan 2011
Location: Algeria
Posts: 46
Rep Power: 15
B.Hamada is on a distinguished road
Hi everyone, I want to write an UDF that allow me to change the profile of the heat flux on a solar PANEL, using an equation as shown in the attached image, and another shows the computational domain and the boundary conditions .
Well, I wrote a UDF but when I compiled present errors, I can not fix them.
So please help me to find the right text of my UDF.
Greetings.

HTML Code:
#include "udf.h"
DEFINE_PROFILE(heatflux_profile, t, F, i)    
{              
face_t f; 
real It=750;                       
real H=232000;
real Tam=300;
real Tm=298.6;
real Ul=20;
real Eta=0.16;
real m=2;
real cs=1.4;
real cl=1.8;
real temp;
temp = F_T(f,t);
real Time;
Time = RP_Get_Real("physical-time-step");
begin_f_loop(f, t)
 {   
    if((temp>Tam) && (temp<Tm)
           F_PROFILE(f,t,i) = Ul*(temp*Tam) *time+Eta*It*Time+m*cs*(temp-Tam);
    else if(temp==Tm)
           F_PROFILE(f,t,i) = Ul*(temp*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H;
    else(temp>Tm)
           F_PROFILE(f,t,i) = Ul*(temp*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H+m*cl*(temp-Tm);
 }
end_f_loop(f,t)
}
Attached Images
File Type: jpg equation.jpg (48.3 KB, 18 views)
File Type: jpg BIPV.jpg (30.6 KB, 17 views)
B.Hamada is offline   Reply With Quote

Old   July 17, 2014, 18:26
Default
  #2
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by B.Hamada View Post
Hi everyone, I want to write an UDF that allow me to change the profile of the heat flux on a solar PANEL, using an equation as shown in the attached image, and another shows the computational domain and the boundary conditions .
Well, I wrote a UDF but when I compiled present errors, I can not fix them.
So please help me to find the right text of my UDF.
Greetings.

HTML Code:
#include "udf.h"
DEFINE_PROFILE(heatflux_profile, t, F, i)    
{              
face_t f; 
real It=750;                       
real H=232000;
real Tam=300;
real Tm=298.6;
real Ul=20;
real Eta=0.16;
real m=2;
real cs=1.4;
real cl=1.8;
real temp;
temp = F_T(f,t);
real Time;
Time = RP_Get_Real("physical-time-step");
begin_f_loop(f, t)
 {   
    if((temp>Tam) && (temp<Tm)
           F_PROFILE(f,t,i) = Ul*(temp*Tam) *time+Eta*It*Time+m*cs*(temp-Tam);
    else if(temp==Tm)
           F_PROFILE(f,t,i) = Ul*(temp*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H;
    else(temp>Tm)
           F_PROFILE(f,t,i) = Ul*(temp*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H+m*cl*(temp-Tm);
 }
end_f_loop(f,t)
}
Hi,
Define_profile should only have three arguments. So you must delete "F" from the argument list of the macro.
Goodluck
syavash is offline   Reply With Quote

Old   July 17, 2014, 20:37
Default
  #3
Member
 
Mohamed
Join Date: Jan 2011
Location: Algeria
Posts: 46
Rep Power: 15
B.Hamada is on a distinguished road
Quote:
Originally Posted by syavash View Post
Hi,
Define_profile should only have three arguments. So you must delete "F" from the argument list of the macro.
Goodluck
Thank you for your reply, but when I delete F, and when I interpreted Fluent UDF. message appears as follows:

temp definition shadows previous definition
Error: C:\Users\khaoula\Desktop\prof.c: line 16: parse error.
Error: C:\Users\khaoula\Desktop\prof.c: line 17: Time: undeclared variable

Please tell me what i supposed to do.
B.Hamada is offline   Reply With Quote

Old   July 18, 2014, 06:40
Default
  #4
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by B.Hamada View Post
Thank you for your reply, but when I delete F, and when I interpreted Fluent UDF. message appears as follows:

temp definition shadows previous definition
Error: C:\Users\khaoula\Desktop\prof.c: line 16: parse error.
Error: C:\Users\khaoula\Desktop\prof.c: line 17: Time: undeclared variable

Please tell me what i supposed to do.
Just try to rename "temp" to something else; e.g. temp1.
Bests
syavash is offline   Reply With Quote

Old   July 18, 2014, 12:26
Default
  #5
Member
 
Mohamed
Join Date: Jan 2011
Location: Algeria
Posts: 46
Rep Power: 15
B.Hamada is on a distinguished road
Quote:
Originally Posted by syavash View Post
Just try to rename "temp" to something else; e.g. temp1.
Bests
I do it, but now this error appear.
HTML Code:
Error: C:\Users\khaoula\Desktop\prof.c: line 16: c_t: undeclared variable
B.Hamada is offline   Reply With Quote

Old   July 18, 2014, 14:26
Default
  #6
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by B.Hamada View Post
I do it, but now this error appear.
HTML Code:
Error: C:\Users\khaoula\Desktop\prof.c: line 16: c_t: undeclared variable
Modify your UDF as follows:


#include "udf.h"
DEFINE_PROFILE(heatflux_profile, t, i)
{
face_t f;
real It=750;
real H=232000;
real Tam=300;
real Tm=298.6;
real Ul=20;
real Eta=0.16;
real m=2;
real cs=1.4;
real cl=1.8;
real temp1;
real Time;
Time = RP_Get_Real("physical-time-step");
begin_f_loop(f, t)
{

temp1 = F_T(f,t);
if((temp>Tam) && (temp<Tm)
F_PROFILE(f,t,i) = Ul*(temp*Tam) *time+Eta*It*Time+m*cs*(temp-Tam);
else if(temp==Tm)
F_PROFILE(f,t,i) = Ul*(temp*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H;
elseif(temp>
Tm)
F_PROFILE(f,t,i) = Ul*(temp*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H+m*cl*(temp-Tm);
}
end_f_loop(f,t)
}
syavash is offline   Reply With Quote

Old   July 18, 2014, 17:38
Default
  #7
Member
 
Mohamed
Join Date: Jan 2011
Location: Algeria
Posts: 46
Rep Power: 15
B.Hamada is on a distinguished road
Quote:
Originally Posted by syavash View Post
Modify your UDF as follows:


#include "udf.h"
DEFINE_PROFILE(heatflux_profile, t, i)
{
face_t f;
real It=750;
real H=232000;
real Tam=300;
real Tm=298.6;
real Ul=20;
real Eta=0.16;
real m=2;
real cs=1.4;
real cl=1.8;
real temp1;
real Time;
Time = RP_Get_Real("physical-time-step");
begin_f_loop(f, t)
{

temp1 = F_T(f,t);
if((temp>Tam) && (temp<Tm)
F_PROFILE(f,t,i) = Ul*(temp*Tam) *time+Eta*It*Time+m*cs*(temp-Tam);
else if(temp==Tm)
F_PROFILE(f,t,i) = Ul*(temp*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H;
elseif(temp>
Tm)
F_PROFILE(f,t,i) = Ul*(temp*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H+m*cl*(temp-Tm);
}
end_f_loop(f,t)
}
Thank you friend for your help.
So, a new error now appear.

HTML Code:
Error: C:\Users\khaoula\Desktop\prof.c: line 22: temp: no function prototype
B.Hamada is offline   Reply With Quote

Old   July 18, 2014, 18:07
Default
  #8
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by B.Hamada View Post
Thank you friend for your help.
So, a new error now appear.

HTML Code:
Error: C:\Users\khaoula\Desktop\prof.c: line 22: temp: no function prototype
I forgot to rename all the "temp" in your code. Just rename the remaining "temp"s to "temp1".
syavash is offline   Reply With Quote

Old   July 18, 2014, 18:11
Default
  #9
Member
 
Mohamed
Join Date: Jan 2011
Location: Algeria
Posts: 46
Rep Power: 15
B.Hamada is on a distinguished road
Quote:
Originally Posted by syavash View Post
I forgot to rename all the "temp" in your code. Just rename the remaining "temp"s to "temp1".
Hi, i do this but now a new error.
PHP Code:
ErrorC:\Users\khaoula\Desktop\prof.cline 17Timeundeclared variable 
B.Hamada is offline   Reply With Quote

Old   July 18, 2014, 18:34
Default
  #10
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by B.Hamada View Post
Hi, i do this but now a new error.
PHP Code:
ErrorC:\Users\khaoula\Desktop\prof.cline 17Timeundeclared variable 
Please change "time" to "Time" everywhere in your code.
P.S.: Remember that C/C++ language is case sensitive.
syavash is offline   Reply With Quote

Old   July 18, 2014, 20:10
Default
  #11
Member
 
Mohamed
Join Date: Jan 2011
Location: Algeria
Posts: 46
Rep Power: 15
B.Hamada is on a distinguished road
Quote:
Originally Posted by syavash View Post
Please change "time" to "Time" everywhere in your code.
P.S.: Remember that C/C++ language is case sensitive.
the same problem.
B.Hamada is offline   Reply With Quote

Old   July 18, 2014, 21:39
Default
  #12
Senior Member
 
Syavash Asgari
Join Date: Apr 2010
Posts: 473
Rep Power: 18
syavash is on a distinguished road
Quote:
Originally Posted by B.Hamada View Post
the same problem.
OK, try to rename all the "Time" to something else, like "Time1".
syavash is offline   Reply With Quote

Reply


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
UDF code for arc as heat flux in simulation Alireza Kohandehghan Fluent UDF and Scheme Programming 5 April 18, 2019 10:18
UDF for a time varying heat flux boundary condition B.Hamada Fluent UDF and Scheme Programming 9 August 8, 2018 12:51
chtMultiRegionFoam heat flux sailor79 OpenFOAM Running, Solving & CFD 0 September 27, 2013 08:08
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 06:28
udf for transient heat flux BC isaac FLUENT 1 June 3, 2004 16:29


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