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 temperature profile (https://www.cfd-online.com/Forums/fluent-udf/113104-udf-temperature-profile.html)

B.Hamada July 12, 2014 11:24

Quote:

Originally Posted by ghost82 (Post 501275)
Ok, but since we cannot read the future :) you can only evaluate temperatures at time t and t-deltat and not deltat+t.

Again, start writing some code, someone will help you to go through your code.

Daniele

Thank you brother, i'll try

B.Hamada July 13, 2014 21:18

Hi Friends

I wrote this code, please can someone tell me if my UDF was correct, and if there are errors, you could fix it.
thank you

PHP Code:

/#include "udf.h"
DEFINE_PROFILE(heatflux_profileti)    
{              
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 Tpv;
real time;
begin_f_loop(fthread)
 {   
    
Tpv C_T(c,t);
    
time RP_Get_Real("physical-time-step"); 
    if(
Tam<Tpv<Tm
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam) *time+Eta*It*Time+m*cs*(Tpv-Tam);
    else if(
Tpv=Tm)
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H;
    else(
Tpv>Tm)
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H+m*cl*(Tpv-Tm);
 }
end_f_loop(f,thread)


When I compiled my UDF, an error occurred, but I can not fix it.
help me please
error line 16: c: undeclared variable.

I-mech July 14, 2014 03:05

Quote:

Originally Posted by B.Hamada (Post 501353)
Hi Friends

I wrote this code, please can someone tell me if my UDF was correct, and if there are errors, you could fix it.
thank you

PHP Code:

/#include "udf.h"
DEFINE_PROFILE(heatflux_profileti)    
{              
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 Tpv;
real time;
begin_f_loop(fthread)
 {   
    
Tpv C_T(c,t);
    
time RP_Get_Real("physical-time-step"); 
    if(
Tam<Tpv<Tm
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam) *time+Eta*It*Time+m*cs*(Tpv-Tam);
    else if(
Tpv=Tm)
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H;
    else(
Tpv>Tm)
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H+m*cl*(Tpv-Tm);
 }
end_f_loop(f,thread)


When I compiled my UDF, an error occurred, but I can not fix it.
help me please
error line 16: c: undeclared variable.

you have used t in your second line DEFINE_PROFILE(heatflux_profile, t, i)
and then you have used thread in begin_f_loop(f, thread) and in end_f_loop(f,thread).
You have to decide. Use t or thread in both.

Let's try as follow, it should work. I hope :p
PHP Code:

/#include "udf.h"
DEFINE_PROFILE(heatflux_profileti)    
{              
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 Tpv;
real time;
begin_f_loop(ft)
 {   
    
Tpv C_T(c,t);
    
time RP_Get_Real("physical-time-step"); 
    if(
Tam<Tpv<Tm
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam) *time+Eta*It*Time+m*cs*(Tpv-Tam);
    else if(
Tpv=Tm)
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H;
    else(
Tpv>Tm)
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H+m*cl*(Tpv-Tm);
 }
end_f_loop(f,t)



ghost82 July 14, 2014 08:02

Quote:

Originally Posted by B.Hamada (Post 501353)
Hi Friends

I wrote this code, please can someone tell me if my UDF was correct, and if there are errors, you could fix it.
thank you

PHP Code:

/#include "udf.h"
DEFINE_PROFILE(heatflux_profileti)    
{              
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 Tpv;
real time;
begin_f_loop(fthread)
 {   
    
Tpv C_T(c,t);
    
time RP_Get_Real("physical-time-step"); 
    if(
Tam<Tpv<Tm
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam) *time+Eta*It*Time+m*cs*(Tpv-Tam);
    else if(
Tpv=Tm)
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H;
    else(
Tpv>Tm)
           
F_PROFILE(f,t,i) = Ul*(Tpv*Tam)*time+Eta*It*Time+m*cs*(Tm-Tam)+H+m*cl*(Tpv-Tm);
 }
end_f_loop(f,thread)


When I compiled my UDF, an error occurred, but I can not fix it.
help me please
error line 16: c: undeclared variable.

Hi,
your equations look completely different in respect of what you posted before..
You are using c in the C_T(c,t) which is your cell temperature but you are not declaring what is c (as the description of error); you are using c (cell) inside and f (face) loop.
If you want the mean of the temperature of the pcm domain you have to first do a c loop over the pcm domain and calculate the mean temperature, then use the f loop to calculate the boundary profile.
Also this "if(Tam<Tpv<Tm)" should be "if (Tpv>Tam) && (Tpv<Tm)".
And also C langiage is case sensitive: time is different than Time, and you are not declaring what is Time.
"Tpv=Tm" assigns Tm to Tpv: it should be Tpv==Tm.

Daniele

PS: Condition Tam<Tpv<Tm will never be possible because you defined Tm<Tam!!

B.Hamada July 14, 2014 17:48

1 Attachment(s)
Hi

I changed the equation for the heat flux exerted on the pvhotovoltaique PANEL, an attached image shows the equation

B.Hamada July 17, 2014 16:55

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)
}


GM_XIII July 18, 2014 07:16

Do you keep getting the same error?

B.Hamada July 18, 2014 12:16

Quote:

Originally Posted by GM_XIII (Post 502143)
Do you keep getting the same error?

Hi

Yes the same error.

sircorp June 21, 2015 03:08

Quote:

Originally Posted by flotus1 (Post 441502)
Since you refuse to be more descriptive, I have to make some assumptions ;)
With "degrees" you mean °C, so I change the temperature variation from 298K-323K.
The x-axis coincides with the axis of the cylinder and the y-axis is from "bottom" to "top".
Thus the temperature varies linearly with the y-axis, with the highest temperature at the greatest positive y-extent of the surface.

Code:

#include "udf.h"

DEFINE_PROFILE(temp_linear, thread, position)
{
real x[ND_ND];
face_t f;
real tmin, tmax, d;

tmin = 298.0;
tmax = 323.0;
d = 0.47;

  begin_f_loop(f, thread)
    {
      F_CENTROID(x,f,thread);
      F_PROFILE(f, thread, position) = (tmin+tmax)/2.0 + (tmax-tmin)/d*x[1];
    }
  end_f_loop(f, thread)
}


Is "d" a constant or a diameter of the pipe who surface temperature we are trying to create a profile. In case irregular geometry it is better to put d = 1( i mean avoid "d" altogether ( default d= 1))

Thanks

Shane

Ericson June 21, 2015 10:47

1 Attachment(s)
Need help!!
i got this message when i'm trying to compile my udf
can anyone solve this error message?

pakk June 22, 2015 04:01

Yes. Look at you code, and check lines 3, 4 and 11, something is wrong there.

Ericson June 22, 2015 08:57

1 Attachment(s)
This is my code, i don't know what is wrong here..
can you find the mistakes sir?

Ericson June 22, 2015 08:59

I'm trying to make code for rolling motion of ship..

pakk June 22, 2015 09:19

Yes I can, and I can show you how. Just read the error messages!

The first error you get says that there are not enough actual parameters in line 3.
So, go ahead, count how many parameters you have (hint: "roll" is a parameter, "dt" is a parameter, "omega" is a parameter, "time" is a parameter and "dtime" is a parameter.) Then look up in the help how many parameters there should be, and you will see something you did wrong.

Ericson June 22, 2015 09:57

can you fix my code please?
i can't see what i must doing in help..

pakk June 22, 2015 10:01

Seriously?
Ok, you are using the macro "DEFINE_CG_MOTION". Look up in the help how many parameters that needs...

Ericson June 23, 2015 01:00

1 Attachment(s)
i've trying to fixed my codes but when i'm compiling i have another error like this...

pakk June 23, 2015 02:44

I don't understand why you send me a private message telling that you use notepad.
Using notepad does not prevent you from opening the Fluent manual, and looking at how the macro "DEFINE_CG_MOTION" should be used.

Do you know how to open the Fluent manual?
Do you know how to search in the Fluent manual?

Ericson June 23, 2015 08:31

yes i can,, i have seen fluent manual and i have fixed my code..
but when i'm compiling the code again, i got error messages above..
what should i do?

pakk June 23, 2015 08:49

I am not paranormal, so if you don't show your code I can never know what is wrong.


All times are GMT -4. The time now is 18:13.