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 Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 26, 2014, 07:09
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.

Code:
#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 temp;
temp = F_T(f,t);  
real flow_time = RP_Get_Real("flow-time");
begin_f_loop(f, t)
{
if((temp>Tam) && (temp<Tm)
F_PROFILE(f,t,i) = Ul*(temp-Tam)*flow_time+Eta*It*flow_time+m*cs*(temp-Tam);
else if(temp==Tm) 
F_PROFILE(f,t,i) = Ul*(temp-Tam)*flow_time+Eta*It*flow_time+m*cs*(Tm-Tam)+H;
elseif(temp>Tm) 
F_PROFILE(f,t,i) = Ul*(temp-Tam)*flow_time+Eta*It*flow_time+m*cs*(Tm-Tam)+H+m*cl*(temp-Tm);
}
end_f_loop(f,t)
}


B.Hamada is offline   Reply With Quote

Old   July 26, 2014, 18:43
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
It would be helpful if you would add the errors that you get. The errors give hints about what is wrong.

Regardless: I immediately see there is a problem with your line "temp = F_T(f,t); ": you try to use face f where it has not been initialized yet. I think this line should be further down, just above your if-statement.
pakk is offline   Reply With Quote

Old   July 26, 2014, 21:18
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 pakk View Post
It would be helpful if you would add the errors that you get. The errors give hints about what is wrong.

Regardless: I immediately see there is a problem with your line "temp = F_T(f,t); ": you try to use face f where it has not been initialized yet. I think this line should be further down, just above your if-statement.
Hi, thank you for your help, and this is the errors below

temp definition shadows previous definition
Error: C:\Users\Mohamed\Desktop\prof.c: line 16: parse error.
Error: C:\Users\Mohamed\Desktop\prof.c: line 20: temp: no function prototype
B.Hamada is offline   Reply With Quote

Old   July 29, 2014, 09:36
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
These are the kind of errors you see when you interpret. In your question, you were talking about compile. Please be more accurate in the future.

In addition to the mistake I mentioned before, you made two mistakes:
*In line 19 you missed one bracket ")".
*In line 23 you missed one space (elseif should be else if)

Some compilers might accept "elseif", but if it gives errors then just change it.

If you change this, your code will compile (and be interpreted). I did not check if it will do what you expect from it.
pakk is offline   Reply With Quote

Old   July 29, 2014, 10:07
Smile
  #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 pakk View Post
These are the kind of errors you see when you interpret. In your question, you were talking about compile. Please be more accurate in the future.

In addition to the mistake I mentioned before, you made two mistakes:
*In line 19 you missed one bracket ")".
*In line 23 you missed one space (elseif should be else if)

Some compilers might accept "elseif", but if it gives errors then just change it.

If you change this, your code will compile (and be interpreted). I did not check if it will do what you expect from it.
Thank you for help.
B.Hamada is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 11:18
UDF for a time varying heat flux boundary condition B.Hamada Fluent UDF and Scheme Programming 9 August 8, 2018 13:51
chtMultiRegionFoam heat flux sailor79 OpenFOAM Running, Solving & CFD 0 September 27, 2013 09:08
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 07:28
udf for transient heat flux BC isaac FLUENT 1 June 3, 2004 17:29


All times are GMT -4. The time now is 14:11.