# UDF of linear distribution of temperature in a 2D tank

 Register Blogs Members List Search Today's Posts Mark Forums Read

 August 18, 2010, 16:04 UDF of linear distribution of temperature in a 2D tank #1 New Member   Arailos Join Date: Aug 2010 Posts: 4 Rep Power: 8 Hi all, I am simulating heat transfer from a cylindrical source immersed in a rectangular cavity and I am trying to find out how can I write a UDF in order to have thermally stratified layers with linear distribution of temperature in the whole domain of the tank at the initialization of the simulation. I am really new to UDF and this is my first attempt. So far I have written this code but.... /////////////////////////////////////// #include "udf.h" DEFINE_INIT(linear_temp,d) { cell_t c; Thread *t; real x[ND_ND]; real Tt=338., Tb=288.; real xb=0.,xt=-0.5; real dT=(Tt-Tb)/(xt-xb); /* loop over all cell threads in the domain */ thread_loop_c(t,d) { /* loop over all cells */ begin_c_loop_all(c,t) { C_CENTROID(xc,c,t); C_T(c,t) = Tb+(x-xb)dT ; } end_c_loop_all(c,t) } } /////////////////////////////// My tank has a height of 0.5m and is placed horizontally with the gravity vector pointing to the positive of x axis...The bottom temp is 288K and the top temp of the tank is 338K...I can clarify any details needed... The tank is place horizontally because I am going to solve it axisymmetrically and the axis boundary condition should have x-axis direction... Thanks in advance.... Last edited by arailos; August 19, 2010 at 14:33.

 August 19, 2010, 14:14 Code found #2 New Member   Arailos Join Date: Aug 2010 Posts: 4 Rep Power: 8 hey all, finally I did it...This is the appropriate code for my case... //////////////////// #include "udf.h" DEFINE_INIT(linear_temp,d) { cell_t c; Thread *t; real xc[ND_ND]; real myx; real Tt=338., Tb=288.; real xb=0.,xt=-0.5; real dT=(Tt-Tb)/(xt-xb); /* loop over all cell threads in the domain */ thread_loop_c(t,d) { /* loop over all cells */ begin_c_loop_all(c,t) { C_CENTROID(xc,c,t); myx=xc[0] C_T(c,t) = Tb+(myx-xb)dT ; } end_c_loop_all(c,t) } } //////////////////// I just post it in case anyone is looking for something similar... hwangpo and azna like this.

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Souviktor Fluent UDF and Scheme Programming 3 July 11, 2015 15:49 Raj FLUENT 3 February 1, 2009 19:29 Fabian FLUENT 1 May 29, 2003 20:18 McGregor FLUENT 4 April 10, 2003 04:28 Blackadder Main CFD Forum 1 March 27, 2003 12:32

All times are GMT -4. The time now is 15:35.