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

Inlet temperature as a function of outlet temperature UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 5, 2018, 09:44
Default Inlet temperature as a function of outlet temperature UDF
  #1
New Member
 
William Harvey
Join Date: Jan 2018
Location: Montréal, Québec
Posts: 5
Rep Power: 8
wimblo is on a distinguished road
Hi,

I am currently working on a project where cooling towers need to be simulated.

The cooling towers work the following way:
-A constant flow of air enters the side of the tower at a certain temperature
-The same flow of air exits the top of the tower at a higher temperature

I'd like to use a UDF to impose a relationship between the temperature parameters (ex: T_outlet = avg(T_inlet)+30).

I have UDFs where the temperature varies in time, but none where the temperature varies with respect to some other temperature in the domain.

Does anybody know how I could achieve this?

Thanks in advance.
wimblo is offline   Reply With Quote

Old   November 23, 2021, 12:05
Default
  #2
New Member
 
Join Date: Oct 2021
Posts: 15
Rep Power: 5
James_mCFD is on a distinguished road
It's a shame this didn't get a reply.

I'm having similar issues as I need to define an outlet temperature to equal the temperature of the fluid body immediately prior to the outlet. My simulation uses an oscillating fluid flow so defining a constant outlet temperature affects my simulation greatly.

My C knowledge is minimal; I can write the basic programs to compute "hello world", convert Celsius to Fahrenheit and determine whether a number is prime or not; but composing some C-code for a UDF is a different kettle of fish entirely.

#include "udf.h"

DEFINE_PROPERTY(outlet_temperature)

{

Domain *d;

real tavg =0.;
real temp, volume, vol_tot;
Thread *t;
face_t f;
d = Get_Domain(1)

begin_f_loop(c,t)

{

volume = C_VOLUME(f,t); /* face volumes */
temp = F_T(f,t); /* face temperatures */

vol_tot += volume;
tavg += temp*volume;

}

end_f_loop(c,t)

tavg /=vol_tot

}

This is something that I have butchered from the UDF manual. I don't think it is even close to being correct. What I want the code to do is define the outlet temperature as equal to the temperature immediately prior to the outlet. If this is how "faces" work, then what I'd want is to define the temperature of the final face as equal to the temperature of the preceding face.

I am using a laminar solver and a transient fluid flow with a defined inlet temperature, with an oscillating fluid velocity.

Any help would be greatly appreciated.
James_mCFD is offline   Reply With Quote

Old   November 24, 2021, 03:44
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
#include "udf.h"

DEFINE_PROFILE(outlet_temperature,t,i)
{	
	face_t f;
	real temperature;
	
	begin_f_loop(f,t)
	{
		c0 = F_C0(f,t);						/*get pointer to cell adjusted to face*/
		t0 = THREAD_T0(t);					/*get pointer to thred adjusted to face*/
		temperature = C_T(c0,t0);			/*get temperature in cell adjusted to face*/
		F_PROFILE(f,t,i) = temperature;		/*apply temperature from cell adjusted to face to that face*/
	}
	end_f_loop(f,t)
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 24, 2021, 12:54
Default
  #4
New Member
 
Join Date: Oct 2021
Posts: 15
Rep Power: 5
James_mCFD is on a distinguished road
Hi AlexanderZ. Many thanks for your sample code, with very helpful code comments.

Apologies for the follow-up questions;

Did you define t0 and c0 as real?

When I try to interpret the function using ansys I get the following two errors:

invalid type conversion: pointer to structure -> double (for t0 = THREAD_TO(t); )

invalid type conversion: double -> pointer to char (for temperature = C_T(c0,t0); )

I am also running this simulation with parallel processing, will this be an issue?

Thank you

James
James_mCFD is offline   Reply With Quote

Old   November 24, 2021, 22:21
Default
  #5
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
I forgot to define c0,t0
compile code

Code:
#include "udf.h"

DEFINE_PROFILE(outlet_temperature,t,i)
{	
	face_t f;
cell_t c0;
thread *t0;
	real temperature;
	
	begin_f_loop(f,t)
	{
		c0 = F_C0(f,t);						/*get pointer to cell adjusted to face*/
		t0 = THREAD_T0(t);					/*get pointer to thred adjusted to face*/
		temperature = C_T(c0,t0);			/*get temperature in cell adjusted to face*/
		F_PROFILE(f,t,i) = temperature;		/*apply temperature from cell adjusted to face to that face*/
	}
	end_f_loop(f,t)
}
James_mCFD likes this.
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 25, 2021, 07:06
Default
  #6
New Member
 
Join Date: Oct 2021
Posts: 15
Rep Power: 5
James_mCFD is on a distinguished road
Works perfectly, thank you!
James_mCFD is offline   Reply With Quote

Reply

Tags
fluent - udf, fluent 14.5, temperature bc, temperature calculation


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
Reversed flow using pressure inlet and outlet? here_for_help FLUENT 0 September 28, 2018 16:20
Inlet temperature = outlet temperature + offset? GerHan OpenFOAM Pre-Processing 5 November 14, 2016 07:36
UDF profile: Fluent method for coupling inlet and outlet I-mech Fluent UDF and Scheme Programming 0 May 10, 2014 11:36
[blockMesh] BlockMesh FOAM warning gaottino OpenFOAM Meshing & Mesh Conversion 7 July 19, 2010 15:11
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 01:35


All times are GMT -4. The time now is 12:59.