- **Fluent UDF and Scheme Programming**
(*http://www.cfd-online.com/Forums/fluent-udf/*)

- - **UDF of linear distribution of temperature in a 2D tank**
(*http://www.cfd-online.com/Forums/fluent-udf/79281-udf-linear-distribution-temperature-2d-tank.html*)

UDF of linear distribution of temperature in a 2D tankHi 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.... |

Code foundhey 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... |

All times are GMT -4. The time now is 01:01. |