CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for heat and mass transfer (https://www.cfd-online.com/Forums/fluent-udf/206201-udf-heat-mass-transfer.html)

Akash Siddique September 1, 2018 00:31

UDF for heat and mass transfer
 
1 Attachment(s)
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)


Attachment 65436

I Hope you guys will cooperate
You can ask me for any additional information
New Email address- afzalkhangm001@gmail.com

blackmask September 1, 2018 02:12

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 September 1, 2018 02:35

Quote:

Originally Posted by blackmask (Post 704918)
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...:)

blackmask September 1, 2018 02:50

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)
}


Akash Siddique September 1, 2018 03:07

Quote:

Originally Posted by blackmask (Post 704920)
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
second for Variable Adsorbent Temperature
third for Variable Air Humidity Ratio

I'm presenting here my limited understanding of UDF.. what do you say ??

blackmask September 1, 2018 03:47

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 September 1, 2018 03:51

Quote:

Originally Posted by blackmask (Post 704926)
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.

I appreciate your effort.

Please, can you help me understand that one program will do all the things that three separate programs were supposed to do ???


All times are GMT -4. The time now is 10:20.