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

temperature at a point

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 11, 2011, 09:10
Default temperature at a point
  #1
Member
 
EH
Join Date: Dec 2010
Posts: 61
Rep Power: 15
ehooi is on a distinguished road
Hi,
Does anyone know how to write the UDF to calculate the temperature at a point? I know surface monitors allow me to check the temperature at a point. However, the temperature at the particular point is needed to change the boundary condition.

Thank you.


Sincerely,
EH
ehooi is offline   Reply With Quote

Old   January 11, 2011, 11:31
Default
  #2
New Member
 
Sangeeta
Join Date: Mar 2009
Posts: 3
Rep Power: 17
Sangeeta is on a distinguished road
Quote:
Originally Posted by ehooi View Post
Hi,
Does anyone know how to write the UDF to calculate the temperature at a point? I know surface monitors allow me to check the temperature at a point. However, the temperature at the particular point is needed to change the boundary condition.

Thank you.


Sincerely,
EH
DO u want to keep cahnging the BC depending on temperature?
Sangeeta is offline   Reply With Quote

Old   January 11, 2011, 11:36
Default
  #3
Member
 
EH
Join Date: Dec 2010
Posts: 61
Rep Power: 15
ehooi is on a distinguished road
Quote:
Originally Posted by Sangeeta View Post
DO u want to keep cahnging the BC depending on temperature?
Yes and it is time-dependent. I am hoping to specify the BC to be something like (syntax no accounted):

if (Tpoint < 333)
F_PROFILE(f,t,i)=10000
else
F_PROFILE(f,t,i)=0
end

Kind of like a heater to ensure that the temperature of the domain is always greater than a specified level. I know the coordinates where Tpoint is to be determined but how do I calculate it in UDF.
ehooi is offline   Reply With Quote

Old   January 11, 2011, 22:14
Default
  #4
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
ehooi,

Try something like the following.
Code:
DEFINE_PROFILE(heat_flux_profile,t,i)
{
	real thermostat_coordinate[ND_ND];
	real set_point_temperature;
	real heat_flux;
	real lower_bound_x,upper_bound_x;
	real lower_bound_y,upper_bound_y;
	real lower_bound_z,upper_bound_z;
	cell_t c;
	real x,y,z;
	real cutoff_temperature;
	
	heat_flux=10000;
	cutoff_temperature=333.;
	
	lower_bound_x=1.;upper_bound_x=2.;
	lower_bound_y=1.;upper_bound_y=2.;
	lower_bound_z=1.;upper_bound_z=2.;
	
	begin_c_loop(c,t)
	{
		C_CENTROID(thermostat_coordinate,c,t);
		
		x=thermostat_coordinate[0];
		y=thermostat_coordinate[1];
		z=thermostat_coordinate[2];
		
		if(((x>=lower_bound_x)&&(x<=upper_bound_x))&&((y>=lower_bound_y)&&(y<=upper_bound_y))&&((z>=lower_bound_z)&&(z<=upper_bound_z))
		{
			if(C_T(c,t)<=cutoff_temperature)
			{
				F_PROFILE(c,t,i)=heat_flux;
			}
		}
		
	}
}
I haven't checked this code for syntax, but the logic is there.

See the following thread for time dependent flow:
Time-dependent flows

You can modify the code I've posted to account for transient heat flux, temperature cutoffs, etc. You'll also need to modify the lower and upper bounds on the x,y, and z coordinates.

ComputerGuy
ComputerGuy is offline   Reply With Quote

Old   January 12, 2011, 04:26
Default
  #5
Member
 
EH
Join Date: Dec 2010
Posts: 61
Rep Power: 15
ehooi is on a distinguished road
Quote:
Originally Posted by ComputerGuy View Post
ehooi,

Try something like the following.
Code:
DEFINE_PROFILE(heat_flux_profile,t,i)
{
    real thermostat_coordinate[ND_ND];
    real set_point_temperature;
    real heat_flux;
    real lower_bound_x,upper_bound_x;
    real lower_bound_y,upper_bound_y;
    real lower_bound_z,upper_bound_z;
    cell_t c;
    real x,y,z;
    real cutoff_temperature;
 
    heat_flux=10000;
    cutoff_temperature=333.;
 
    lower_bound_x=1.;upper_bound_x=2.;
    lower_bound_y=1.;upper_bound_y=2.;
    lower_bound_z=1.;upper_bound_z=2.;
 
    begin_c_loop(c,t)
    {
        C_CENTROID(thermostat_coordinate,c,t);
 
        x=thermostat_coordinate[0];
        y=thermostat_coordinate[1];
        z=thermostat_coordinate[2];
 
        if(((x>=lower_bound_x)&&(x<=upper_bound_x))&&((y>=lower_bound_y)&&(y<=upper_bound_y))&&((z>=lower_bound_z)&&(z<=upper_bound_z))
        {
            if(C_T(c,t)<=cutoff_temperature)
            {
                F_PROFILE(c,t,i)=heat_flux;
            }
        }
 
    }
}
I haven't checked this code for syntax, but the logic is there.

See the following thread for time dependent flow:
Time-dependent flows

You can modify the code I've posted to account for transient heat flux, temperature cutoffs, etc. You'll also need to modify the lower and upper bounds on the x,y, and z coordinates.

ComputerGuy
Hello ComputerGuy,
Thank you very much. This is very helpful. Let me see if I interpret this correctly. The 'begin_c_loop' basically calculates the centroid of every cell in my domain.

The upper and lower bounds of x, y and z basically defines the limits or the region where the specific point which I want to calculate the temperature is located.

So when the x, y and z is within the bounds, and when the temperature is less than the cutoff temperature, F_PROFILE specifies the required heat flux.

In this case, I guess set_point_temperature is redundant?

Am I right?

Thank you again for your guidance.
ehooi is offline   Reply With Quote

Old   January 12, 2011, 07:05
Default
  #6
Member
 
EH
Join Date: Dec 2010
Posts: 61
Rep Power: 15
ehooi is on a distinguished road
Hi ComputerGuy,
I have tried ammending the codes that you have shown earlier and I came up with this:

Code:
 
#include "udf.h"
/* Obtain the mean temperature at the location of thermocouple */
/* Thermocouple located at coordinates (x,y,z) = (0.275,0.27,-.900) */
DEFINE_EXECUTE_AT_END(tsensor)
{
real thermosensor_coordinate[ND_ND];
real thermosensor_temperature;
real xmin;
real xmax;
real ymin; 
real ymax;
real zmin; 
real zmax;
real x,y,z,nt;
 
cell_t c;
Domain *d;
Thread *t;
d = Get_Domain(1);
 
 
xmin=0.273;
xmax=0.277;
ymin=0.268;
ymax=0.272;
zmin=-0.898;
zmax=-0.90;
/* Begin loop to determine the temperature at the centroid of cells near the thermocouple */
 
thread_loop_c(t,d)
{
nt=0.0;
begin_c_loop(c,t)
{
C_CENTROID(thermosensor_coordinate,c,t);
 
x=thermosensor_coordinate[0];
y=thermosensor_coordinate[1];
z=thermosensor_coordinate[2];
 
 
if ((x >= xmin) and (x <= xmax)) /* line 49 */
{ 
if ((y >= ymin) and (y <= ymax))
{
if ((z >= zmin) and (z <= zmax))
{
thermosensor_temperature=thermosensor_temperature + C_T(c,t) /* get thermocouple temperature */
nt=nt+1.0 /* count number */
}
}
}
}
end_c_loop(c,t)
}
thermosensor_temperature=thermosensor_temperature/nt
}
DEFINE_PROFILE(heater_bc,t,i)
{
real cutoff_temperature;
real heater_on; /* line 71 */
real heater_off; /* line 74 */
 
face_t f; /* line 74 */
cutoff_temperature=333.0; 
heater_on=15923.5;
heater_off=0.0;
if (thermosensor_temperature<=cutoff_temperature)
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = heater_on
}
end_f_loop(f,t)
}
else
{
begin_f_loop(f,t)
{
F_PROFILE(f,t,i) = heater_off
}
end_f_loop
}
}
Since I am intending to check the value at the end of each time step, I have used the DEFINE_EXECUTE_AT_END. Is that correct?

After interpreting this code, I obtain the following error:
cpp -I"C:\PROGRA~1\ANSYSI~1\v121\fluent\fluent12.1.4/src" -I"C:\PROGRA~1\ANSYSI~1\v121\fluent\fluent12.1.4/cortex/src" -I"C:\PROGRA~1\ANSYSI~1\v121\fluent\fluent12.1.4/client/src" -I"C:\PROGRA~1\ANSYSI~1\v121\fluent\fluent12.1.4/multiport/src" -I. -DUDF
ONFIG_H="<C:/Users/EHOOI/AppData/Local/Temp/udfconfig-node1.h>" "C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c"
Error: C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c: line 49: parse error.
Error: C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c: line 71: parse error.
Error: C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c: line 72: parse error.
Error: C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c: line 74: parse error.
Error: C:/Users/EHOOI/AppData/Local/Temp/udfex1.c.1.c: line 76: cutoff_temperature: undeclared variable

The lines where the error are located are pointed out as comments in the code. I cant detect the error that is mentioned.

Could you please help me with this?

Thank you.
ehooi is offline   Reply With Quote

Old   January 12, 2011, 08:28
Default
  #7
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
First, use && instead of "and" in your logic. Not sure if "and" actually works (I get my languages jumbled).

Next, in the following lines:
thermosensor_temperature=thermosensor_temperature + C_T(c,t) /* get thermocouple temperature */
nt=nt+1.0 /* count number */

You need semicolons after each line, before the comment. Additionally, why are you adding a thermosensor temperature to the cell temperature? Perhaps I'm confused about the logic, but wouldn't it just be
thermosensor_temp=C_T(c,t);?

Try and fix those things and see how it goes.

ComputerGuy
ComputerGuy is offline   Reply With Quote

Old   January 12, 2011, 08:39
Default
  #8
Member
 
EH
Join Date: Dec 2010
Posts: 61
Rep Power: 15
ehooi is on a distinguished road
I add them up and divide it by the number of added values to obtain the average. My logic behind it is that there may be more than one cell within the lower and upper bounds specified (I may not be right in this assumption). Hence, I calculate the average of it.

Thanks for your pointers. I will try them out now. Can't believe I overlooked the semi-colons there
ehooi is offline   Reply With Quote

Old   January 12, 2011, 09:05
Default
  #9
Member
 
EH
Join Date: Dec 2010
Posts: 61
Rep Power: 15
ehooi is on a distinguished road
Hi ComputerGuy,
I have successfully interpreted the code. Couldn;t run it at the moment because my model still needs some tweaking but the successful interpretation of the code is a good sign.

In case anyone else is interested, the code is listed here:
Code:
 
#include "udf.h"
/* Obtain the mean temperature at the location of thermocouple */
/* Thermocouple located at coordinates (x,y,z) = (0.275,0.27,-.900) */
DEFINE_EXECUTE_AT_END(tsensor)
{
 real thermosensor_coordinate[ND_ND];
 real thermosensor_temperature;
 real xmin;
 real xmax;
 real ymin; 
 real ymax;
 real zmin; 
 real zmax;
 real x,y,z,nt;
 
 cell_t c;
 Domain *d;
 Thread *t;
 d = Get_Domain(1);

 
 xmin=0.273;
 xmax=0.277;
 ymin=0.268;
 ymax=0.272;
 zmin=-0.898;
 zmax=-0.90;
 /* Begin loop to determine the temperature at the centroid of cells near the thermocouple */
 
 thread_loop_c(t,d)
 {
 nt=0.0;
 begin_c_loop(c,t)
 {
  C_CENTROID(thermosensor_coordinate,c,t);
  
  x=thermosensor_coordinate[0];
  y=thermosensor_coordinate[1];
  z=thermosensor_coordinate[2];
  
  
  if ((x >= xmin) && (x <= xmax))
  { 
   if ((y >= ymin) && (y <= ymax))
   {
    if ((z >= zmin) && (z <= zmax))
    {
     thermosensor_temperature=thermosensor_temperature + C_T(c,t); /* get thermocouple temperature */
     nt=nt+1.0;       /* count number */
    }
   }
  }
 }
 end_c_loop(c,t)
 }
 thermosensor_temperature=thermosensor_temperature/nt;
}
DEFINE_PROFILE(heater_bc,t,i)
{
 real cutoff_temperature;
 real thermosensor_temperature;
 real heater_on;
 real heater_off;
 
 face_t f;
 cutoff_temperature=333.0;
 
 heater_off = 0.0;
 heater_on = 15923.5;
 if (thermosensor_temperature<=cutoff_temperature)
 {
  begin_f_loop(f,t)
  {
   F_PROFILE(f,t,i) = heater_on;
  }
  end_f_loop(f,t)
 }
 else
 {
  begin_f_loop(f,t)
  {
   F_PROFILE(f,t,i) = heater_off;
  }
  end_f_loop(f,t)
 }
}
Thank you
ehooi is offline   Reply With Quote

Old   January 12, 2011, 22:02
Default
  #10
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
Good job -- glad I could help. I understand the volume averaging scheme on temperature; I just didn't see the piece of code where you divided by the cell count.

Thanks for sharing your final code with us.

ComputerGuy
ComputerGuy is offline   Reply With Quote

Old   January 13, 2011, 11:57
Default
  #11
Member
 
EH
Join Date: Dec 2010
Posts: 61
Rep Power: 15
ehooi is on a distinguished road
Hi ComputerGuy,
In the code that I have written, there are two define macros, DEFINE_ADJUST and DEFINE_PROFILE. In DEFINE_ADJUST, I calculated the value for the variable thermosensor_temperature and in DEFINE_PROFILE, I use the value of thermosensor_temperature.

Can I know if the value of thermosensor_temperature calculated in DEFINE_ADJUST will be automatically stored such that the macro DEFINE_PROFILE can access it or do I have to write some code to store it?

Thanks.


EH
ehooi is offline   Reply With Quote

Old   January 14, 2011, 19:11
Default
  #12
Senior Member
 
Real Name :)
Join Date: Jan 2010
Location: United States
Posts: 192
Rep Power: 16
ComputerGuy is on a distinguished road
It won't be automatically stored as written. You can simply write the value to a user-defined memory location (look up: C_UDMI).

ComputerGuy
ComputerGuy is offline   Reply With Quote

Old   October 28, 2013, 09:49
Default
  #13
Senior Member
 
Moha
Join Date: Mar 2013
Location: EU
Posts: 103
Rep Power: 0
ahvz is on a distinguished road
I tried to used the below code but I have faced with "warning"

warning C4700: uninitialized local variable 'thermosensor_temperature' used
warning C4700: uninitialized local variable 'thermosensor_temperature' used

how to solve this warning? any helps ?

what is the reason of this kind of warnings ?




Code:
/***********************************************************************
udfexample.c 
UDF for specifying the heater 
 ************************************************************************/


#include "udf.h"
/* Obtain the mean temperature at the location of thermocouple */
/* Thermocouple located at coordinates (x,y,z) = (-0.24,0.185,0.26) */
DEFINE_EXECUTE_AT_END(tsensor)   /* DEFINE_EXECUTE_AT_END is a general-purpose macro that is executed at the end of an iteration in a steady state run, or at the end of a time step in a transient run. You can use DEFINE_EXECUTE_AT_END when you want to calculate flow quantities at these particular times. Note that you do not have to specify whether your execute-at-end UDF gets executed at the end of a time step or the end of an iteration. This is done automatically when you select the steady or unsteady time method in your ANSYS FLUENT model*/
{
 real thermosensor_coordinate[ND_ND];
 real thermosensor_temperature;
 real xmin;
 real xmax;
 real ymin; 
 real ymax;
 real zmin; 
 real zmax;
 real x,y,z,nt;
 
 cell_t c;
 Domain *d;
 Thread *t;
 d = Get_Domain(1);
 xmin=-0.22;
 xmax=-0.26;
 ymin=0.183;
 ymax=0.188;
 zmin=0.25;
 zmax=0.27;
 /* Begin loop to determine the temperature at the centroid of cells near the thermocouple */
 thread_loop_c(t,d)
 {
 nt=0.0;
 begin_c_loop(c,t)
 {
  C_CENTROID(thermosensor_coordinate,c,t);
  
  x=thermosensor_coordinate[0];
  y=thermosensor_coordinate[1];
  z=thermosensor_coordinate[2];
  
  
  if ((x >= xmin) && (x <= xmax))
  { 
   if ((y >= ymin) && (y <= ymax))
   {
    if ((z >= zmin) && (z <= zmax))
    {
     thermosensor_temperature=thermosensor_temperature + C_T(c,t); /* get thermocouple temperature */
     nt=nt+1.0;       /* count number */
    }
   }
  }
 }
 end_c_loop(c,t)
 }
 thermosensor_temperature=thermosensor_temperature/nt;
}
DEFINE_PROFILE(heater_bc,t,i)
{
 real cutoff_temperature;
 real thermosensor_temperature;
 real heater_on;
 real heater_off;
 
 face_t f;
 cutoff_temperature=295.15;
 
 heater_off = 0.0;
 heater_on = 22500;
 if (thermosensor_temperature<=cutoff_temperature)
 {
  begin_f_loop(f,t)
  {
   F_PROFILE(f,t,i) = heater_on;
  }
  end_f_loop(f,t)
 }
 else
 {
  begin_f_loop(f,t)
  {
   F_PROFILE(f,t,i) = heater_off;
  }
  end_f_loop(f,t)
 }
}
ahvz is offline   Reply With Quote

Old   January 22, 2015, 04:24
Default
  #14
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by ahvz View Post
I tried to used the below code but I have faced with "warning"

warning C4700: uninitialized local variable 'thermosensor_temperature' used
warning C4700: uninitialized local variable 'thermosensor_temperature' used

how to solve this warning? any helps ?

what is the reason of this kind of warnings ?
The variable is not initialized when you use it. It does not have a value yet, but at a certain line in your code you say it should increase its value. The solution: initialize the variable:
Code:
real thermosensor_temperature = 0.0;
pakk is offline   Reply With Quote

Old   September 15, 2015, 06:15
Default how to assign temp from first part of program to second part
  #15
New Member
 
Surya
Join Date: Jan 2014
Posts: 20
Rep Power: 12
hariswch2 is on a distinguished road
Quote:
Originally Posted by ehooi View Post
Hi ComputerGuy,
I have successfully interpreted the code. Couldn;t run it at the moment because my model still needs some tweaking but the successful interpretation of the code is a good sign.

In case anyone else is interested, the code is listed here:
Code:
 
#include "udf.h"
/* Obtain the mean temperature at the location of thermocouple */
/* Thermocouple located at coordinates (x,y,z) = (0.275,0.27,-.900) */
DEFINE_EXECUTE_AT_END(tsensor)
{
 real thermosensor_coordinate[ND_ND];
 real thermosensor_temperature;
 real xmin;
 real xmax;
 real ymin; 
 real ymax;
 real zmin; 
 real zmax;
 real x,y,z,nt;
 
 cell_t c;
 Domain *d;
 Thread *t;
 d = Get_Domain(1);

 
 xmin=0.273;
 xmax=0.277;
 ymin=0.268;
 ymax=0.272;
 zmin=-0.898;
 zmax=-0.90;
 /* Begin loop to determine the temperature at the centroid of cells near the thermocouple */
 
 thread_loop_c(t,d)
 {
 nt=0.0;
 begin_c_loop(c,t)
 {
  C_CENTROID(thermosensor_coordinate,c,t);
  
  x=thermosensor_coordinate[0];
  y=thermosensor_coordinate[1];
  z=thermosensor_coordinate[2];
  
  
  if ((x >= xmin) && (x <= xmax))
  { 
   if ((y >= ymin) && (y <= ymax))
   {
    if ((z >= zmin) && (z <= zmax))
    {
     thermosensor_temperature=thermosensor_temperature + C_T(c,t); /* get thermocouple temperature */
     nt=nt+1.0;       /* count number */
    }
   }
  }
 }
 end_c_loop(c,t)
 }
 thermosensor_temperature=thermosensor_temperature/nt;
}
DEFINE_PROFILE(heater_bc,t,i)
{
 real cutoff_temperature;
 real thermosensor_temperature;
 real heater_on;
 real heater_off;
 
 face_t f;
 cutoff_temperature=333.0;
 
 heater_off = 0.0;
 heater_on = 15923.5;
 if (thermosensor_temperature<=cutoff_temperature)
 {
  begin_f_loop(f,t)
  {
   F_PROFILE(f,t,i) = heater_on;
  }
  end_f_loop(f,t)
 }
 else
 {
  begin_f_loop(f,t)
  {
   F_PROFILE(f,t,i) = heater_off;
  }
  end_f_loop(f,t)
 }
}
Thank you
.................................................. .................................................. .
Hi ehooi,

Thank you very much for sharing the program with us.

I interpreted your program with some modifications but it was showing udf tsensor and udf heater, both are running fine individually.

while combining both as single program, the thermocouple sensor temperature obtained in the first part of program i.e.,udf tsensor is not assigning as input to second part of program i.e., udf heater.

I would like to know how to assign thermocouple temperate form first part of program (output) to second part of program as a input

Thanks in advance
hariswch2 is offline   Reply With Quote

Old   September 15, 2015, 09:50
Default
  #16
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27
ghost82 will become famous soon enough
Have a look at this post:
http://www.cfd-online.com/Forums/flu...ide-model.html

If I remember well it is an update of this post.

The problem you have is that the variable that is passed to the second block must be defined as global variable.
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   September 15, 2015, 10:24
Default
  #17
New Member
 
Surya
Join Date: Jan 2014
Posts: 20
Rep Power: 12
hariswch2 is on a distinguished road
Quote:
Originally Posted by ghost82 View Post
Have a look at this post:
http://www.cfd-online.com/Forums/flu...ide-model.html

If I remember well it is an update of this post.

The problem you have is that the variable that is passed to the second block must be defined as global variable.
.................................................. .................................................. .
Thank u very much for reply ghost82

I defined as you told but still heater is in on position only after crossing higher limit also.

below is my code....

#include "udf.h"
real p;
/* Obtain the mean temperature at the location of thermocouple */
/* Thermocouple located at coordinates (x,y,z) = (0.115,0.135,0.25) */
DEFINE_EXECUTE_AT_END(tsensor) /* exectued at the end of time step in trasient and iteration in steadddy state*/
{
real thermosensor_coordinate[ND_ND];
real thermosensor_temperature;
real xmin;
real xmax;
real ymin;
real ymax;
real zmin;
real zmax;
real x,y,z;
int nt;

cell_t c;
Domain *d;
Thread *t;
d = Get_Domain(1);


xmin=0.115;
xmax=0.135;
ymin=0.115;
ymax=0.135;
zmin=0.243;
zmax=0.250;

/* Begin loop to determine the temperature at the centroid of cells near the thermocouple */
nt=0;
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
C_CENTROID(thermosensor_coordinate,c,t);

x=thermosensor_coordinate[0];
y=thermosensor_coordinate[1];
z=thermosensor_coordinate[2];

if ((x >= xmin) && (x <= xmax))
{
if ((y >= ymin) && (y <= ymax))
{
if ((z >= zmin) && (z <= zmax))
{
printf("X-cord = %f\n",x);
printf("y-cord = %f\n",y);
printf("Z-cord = %f\n",z);
thermosensor_temperature=thermosensor_temperature + C_T(c,t); /* get thermocouple temperature */
printf("thermosensor_temperature = %f\n",thermosensor_temperature);
nt=nt+1.0; /* count number */
printf("value_nt = %d\n",nt);
}
}
}
}
end_c_loop(c,t)
}
thermosensor_temperature=thermosensor_temperature/nt;
printf("final_temp = %f\n",thermosensor_temperature);
p = thermosensor_temperature;
}


DEFINE_SOURCE(heater,c,t,ds,eqn)
{
real cutoff_temperature;
real source;

cutoff_temperature = 301.0;

if (p <= cutoff_temperature)
{
source = 327680;
}

else
{
source = 0;
}
return source;
}



I dont know what might be the problem

can u plz help me

Thanks in advance
hariswch2 is offline   Reply With Quote

Old   September 15, 2015, 10:30
Default
  #18
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27
ghost82 will become famous soon enough
Look at udf in message #4 of the other post.
I think you have to reinizialize also "p" in the first block (just after of before initializing nt, for example), what I'm calling thermosensor_temperature
Code:
thermosensor_temperature=0.0;
If it doesn't work, adapt your udf to that of message #4, because another difference is that thermosensor_temperature is initialized in first block, but I was passing its value to thermosensor_temperature1 before going to the second block.
__________________
Google is your friend and the same for the search button!
ghost82 is offline   Reply With Quote

Old   September 15, 2015, 11:02
Default
  #19
New Member
 
Surya
Join Date: Jan 2014
Posts: 20
Rep Power: 12
hariswch2 is on a distinguished road
Quote:
Originally Posted by ghost82 View Post
Look at udf in message #4 of the other post.
I think you have to reinizialize also "p" in the first block (just after of before initializing nt, for example), what I'm calling thermosensor_temperature
Code:
thermosensor_temperature=0.0;
If it doesn't work, adapt your udf to that of message #4, because another difference is that thermosensor_temperature is initialized in first block, but I was passing its value to thermosensor_temperature1 before going to the second block.
.................................................. ...............................................

As you told, "p" i defined as global variable and reinitialized as p=0 before the command nt=0 but still the temperature is increasing mode only( heater on only)

i tried to print "p" values in second block but it was showing zero and same "p" value i printed in first block, it was showing correct value.

the problem what i thought was '"p" value is not assigning from first block to second block, even though it is global variable.

Can u plz identify the problem....
hariswch2 is offline   Reply With Quote

Old   September 15, 2015, 11:08
Default
  #20
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27
ghost82 will become famous soon enough
Try to declare nt as real, not integer, maybe the division returns 0 if nt is defined as int.
can you also change name p to something else?maybe 'p' is reserved?
__________________
Google is your friend and the same for the search button!
ghost82 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
free stream temperature qzhu FLUENT 5 June 10, 2015 04:55
CFX Post: Problems with moving point cloud for changing time steps spatialtime CFX 0 December 7, 2009 05:56
field function to point variable temperature Trofrensis STAR-CCM+ 1 November 25, 2009 01:46
Static temperature David FLUENT 2 April 1, 2005 11:57
CFX4.3 -build analysis form Chie Min CFX 5 July 13, 2001 00:19


All times are GMT -4. The time now is 17:16.