# UDF for heat and mass transfer

 Register Blogs Members List Search Today's Posts Mark Forums Read September 1, 2018, 01:31 UDF for heat and mass transfer #1 New Member   Akash Siddique Join Date: Apr 2018 Posts: 10 Rep Power: 6 Hi everyone!! Im working on a problem related to heat and mass transfer phenomena between adsorbent material and air. When humid air passes over the adsorbent material, heat and mass transfer happen. I want to write 3simple UDFs for inlet boundary condition for heat and mass transfer. Equation 1 Variable Air Temperature = 1162  (100/z), (z = distance along axis=0.01-0.4m) Equation 2 Variable Adsorbent Temperature = .06+ (.05/t^.19), (t=time =0-3600) Equation 3 Variable Air Humidity Ratio = -22(41*t^.1)-.625(4/z), (z= distance along axis, t=time) Capture.PNG I Hope you guys will cooperate You can ask me for any additional information New Email address- afzalkhangm001@gmail.com   September 1, 2018, 03:12 #2 Senior Member   Join Date: Aug 2011 Posts: 421 Blog Entries: 1 Rep Power: 20 I look the word up in my dictionary and still do not know what cooperate means, but I will tell you how to deal with it anyway. Code: ```#include "udf.h" real T_air(real z) { return 1162.0 - 100.0/z; } real T_adsorbent(real t) { return 0.06+0.05/pow(t, 0.19); } real humidity_ratio(real z, real t) { return -22.0*(41.0*pow(t, 0.1))-0.625*(4.0/z); } DEFINE_PROFILE(inlet_T_air, thread, position) { real NV_VEC(x), NV_VEC(origin), NV_VEC(axis), NV_VEC(rvec); face_t f; real r; real t = CURRENT_TIME; /* origin is a point on the axis and axis is the direction vector*/ NV_S(origin, =, 0.0); NV_D(axis, =, 0.3, 0.4, 0.5); r = NV_MAG(axis); NV_VS(axis, =, axis, /, r); /* normalize to unit vector */ begin_f_loop(f,thread) { F_CENTROID(x, f, thread); NV_VV(x, =, x, -, origin); NV_CROSS(rvec, axis, x); r = NV_MAG(rvec); F_PROFILE(f, thread, position) = T_air(r); } end_f_loop(f, thread) }``` Akash Siddique likes this.   September 1, 2018, 03:35 #3
New Member

Akash Siddique
Join Date: Apr 2018
Posts: 10
Rep Power: 6 Quote:
 Originally Posted by blackmask I look the word up in my dictionary and still do not know what cooperate means, but I will tell you how to deal with it anyway. Code: ```#include "udf.h" real T_air(real z) { return 1162.0 - 100.0/z; } real T_adsorbent(real t) { return 0.06+0.05/pow(t, 0.19); } real humidity_ratio(real z, real t) { return -22.0*(41.0*pow(t, 0.1))-0.625*(4.0/z); } DEFINE_PROFILE(inlet_T_air, thread, position) { real NV_VEC(x), NV_VEC(origin), NV_VEC(axis), NV_VEC(rvec); face_t f; real r; real t = CURRENT_TIME; /* origin is a point on the axis and axis is the direction vector*/ NV_S(origin, =, 0.0); NV_D(axis, =, 0.3, 0.4, 0.5); r = NV_MAG(axis); NV_VS(axis, =, axis, /, r); /* normalize to unit vector */ begin_f_loop(f,thread) { F_CENTROID(x, f, thread); NV_VV(x, =, x, -, origin); NV_CROSS(rvec, axis, x); r = NV_MAG(rvec); F_PROFILE(f, thread, position) = T_air(r); } end_f_loop(f, thread) }```
I'm extremely thankful for your quick response and effort

but now I'm facing another difficulty. I think I need three (3) separate program for boundary condition with respect to each equation. Please make three separate programs with each equation and correct me if I'm wrong.

and thanks for the Cooperation...    September 1, 2018, 03:50 #4 Senior Member   Join Date: Aug 2011 Posts: 421 Blog Entries: 1 Rep Power: 20 Well, that is not what I expected, but, hey, why not. Code: ```#include "udf.h" real T_air(real z, real t) { return 1162.0 - 100.0/z; } real T_adsorbent(real z, real t) { return 0.06+0.05/pow(t, 0.19); } real humidity_ratio(real z, real t) { return -22.0*(41.0*pow(t, 0.1))-0.625*(4.0/z); } DEFINE_PROFILE(inlet_T_air, thread, position) { real NV_VEC(x), NV_VEC(origin), NV_VEC(axis), NV_VEC(rvec); face_t f; real r; real t = CURRENT_TIME; NV_S(origin, =, 0.0); NV_D(axis, =, 0.3, 0.4, 0.5); r = NV_MAG(axis); NV_VS(axis, =, axis, /, r); begin_f_loop(f,thread) { F_CENTROID(x, f, thread); NV_VV(x, =, x, -, origin); NV_CROSS(rvec, axis, x); r = NV_MAG(rvec); F_PROFILE(f, thread, position) = T_air(r, r); } end_f_loop(f, thread) } DEFINE_PROFILE(inlet_T_adsorbent, thread, position) { real NV_VEC(x), NV_VEC(origin), NV_VEC(axis), NV_VEC(rvec); face_t f; real r; real t = CURRENT_TIME; NV_S(origin, =, 0.0); NV_D(axis, =, 0.3, 0.4, 0.5); r = NV_MAG(axis); NV_VS(axis, =, axis, /, r); begin_f_loop(f,thread) { F_CENTROID(x, f, thread); NV_VV(x, =, x, -, origin); NV_CROSS(rvec, axis, x); r = NV_MAG(rvec); F_PROFILE(f, thread, position) = T_adsorbent(r, r); } end_f_loop(f, thread) } DEFINE_PROFILE(inlet_humidity_ratio, thread, position) { real NV_VEC(x), NV_VEC(origin), NV_VEC(axis), NV_VEC(rvec); face_t f; real r; real t = CURRENT_TIME; NV_S(origin, =, 0.0); NV_D(axis, =, 0.3, 0.4, 0.5); r = NV_MAG(axis); NV_VS(axis, =, axis, /, r); begin_f_loop(f,thread) { F_CENTROID(x, f, thread); NV_VV(x, =, x, -, origin); NV_CROSS(rvec, axis, x); r = NV_MAG(rvec); F_PROFILE(f, thread, position) = humidity_ratio(r, r); } end_f_loop(f, thread) }``` Oula likes this.   September 1, 2018, 04:07 #5
New Member

Akash Siddique
Join Date: Apr 2018
Posts: 10
Rep Power: 6 Quote:
 Originally Posted by blackmask Well, that is not what I expected, but, hey, why not. Code: ```#include "udf.h" real T_air(real z, real t) { return 1162.0 - 100.0/z; } real T_adsorbent(real z, real t) { return 0.06+0.05/pow(t, 0.19); } real humidity_ratio(real z, real t) { return -22.0*(41.0*pow(t, 0.1))-0.625*(4.0/z); } #define MAKE_PROFILE(func) \ DEFINE_PROFILE(inlet_##func, thread, position) \ {\ real NV_VEC(x), NV_VEC(origin), NV_VEC(axis), NV_VEC(rvec);\ face_t f;\ real r;\ real t = CURRENT_TIME;\ \ NV_S(origin, =, 0.0);\ NV_D(axis, =, 0.3, 0.4, 0.5);\ r = NV_MAG(axis);\ NV_VS(axis, =, axis, /, r); \ \ begin_f_loop(f,thread)\ {\ F_CENTROID(x, f, thread);\ NV_VV(x, =, x, -, origin);\ NV_CROSS(rvec, axis, x);\ r = NV_MAG(rvec);\ F_PROFILE(f, thread, position) = func(r, r);\ }\ end_f_loop(f, thread)\ } MAKE_PROFILE(T_air); MAKE_PROFILE(T_adsorbent); MAKE_PROFILE(humidity_ratio);```
As far as my understanding of Ansys fluent, three separate UDF will be hooking up in boundary condition at three separate location

one for Variable Air Temperature Boundary Condition
third for Variable Air Humidity Ratio

I'm presenting here my limited understanding of UDF.. what do you say ??   September 1, 2018, 04:47 #6 Senior Member   Join Date: Aug 2011 Posts: 421 Blog Entries: 1 Rep Power: 20 My bad, I forget that DEFINE_PROFILE is not only a macro but also is used in an awk script to get the function name. I have edit my post. Akash Siddique likes this.   September 1, 2018, 04:51 #7
New Member

Akash Siddique
Join Date: Apr 2018
Posts: 10
Rep Power: 6 Quote:
 Originally Posted by blackmask My bad, I forget that DEFINE_PROFILE is not only a macro but also is used in an awk script to get the function name. I have edit my post.

Please, can you help me understand that one program will do all the things that three separate programs were supposed to do ???  Thread Tools Search this Thread Show Printable Version Email this Page Search this Thread: Advanced Search Display Modes Linear Mode Switch to Hybrid Mode Switch to Threaded 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 Off Pingbacks are On Refbacks are On Forum Rules Similar Threads Thread Thread Starter Forum Replies Last Post Komon Fluent UDF and Scheme Programming 14 June 21, 2016 03:50 vinita123 Fluent UDF and Scheme Programming 0 December 22, 2015 09:43 Tensian Fluent UDF and Scheme Programming 0 November 16, 2015 11:39 Anna Tian CFX 1 June 16, 2013 07:28

All times are GMT -4. The time now is 04:21.