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

Surface Incident Radiation Macro

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 28, 2018, 15:27
Default Surface Incident Radiation Macro
  #1
New Member
 
Alejandro
Join Date: Aug 2015
Posts: 9
Rep Power: 11
axelosc is on a distinguished road
Hi Everybody!!

I´m working with UDF along with the Discrete Ordinate model radiation and i need to know how to obtain the surface incident radiation by an UDF.

Currently, i know that the C_DO_IRRAD(c,t,nb) macro give me the incident radiation, but i need the incident radiation in a surface by an UDF (given in the GUI by Wall Fluxes-Surface Incident Radiation).

If any want can help me, I would really appreciate it.

Thank you very much.
axelosc is offline   Reply With Quote

Old   May 28, 2018, 21:41
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
may be
Code:
F_DO_IRRAD_SHELL(f,t,nb)
best regards
AlexanderZ is offline   Reply With Quote

Old   May 29, 2018, 15:16
Default
  #3
New Member
 
Alejandro
Join Date: Aug 2015
Posts: 9
Rep Power: 11
axelosc is on a distinguished road
Thanks for your reply, I´ll try and i´ll let you know if it works.
axelosc is offline   Reply With Quote

Old   May 30, 2018, 10:29
Default
  #4
New Member
 
Alejandro
Join Date: Aug 2015
Posts: 9
Rep Power: 11
axelosc is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
may be
Code:
F_DO_IRRAD_SHELL(f,t,nb)
best regards
I tried with the macro F_DO_IRRAD_SHELL(f,t,nb), however, I have a zero result . Here is my simple code:

#include "udf.h"

DEFINE_ON_DEMAND(F_DO)
{
Domain *d=Get_Domain(1);
int ID = 16; /*Boundary condition ID*/
Thread *t = Lookup_Thread(d,ID);
face_t f;
real temp=0;
real sum=0;

begin_f_loop(f,t) /*Loop over all faces*/

{
temp=F_DO_IRRAD_SHELL(f,t,0);
sum+=temp;
}
end_f_loop(f,t)

}

When i call the variable sum, it gives me a zero result.
Can anyone help me?

Thanks
axelosc is offline   Reply With Quote

Old   May 30, 2018, 22:31
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
How did you call variable sum?
You have nothing in your code regarding output

best regards
AlexanderZ is offline   Reply With Quote

Old   May 31, 2018, 10:20
Default
  #6
New Member
 
Alejandro
Join Date: Aug 2015
Posts: 9
Rep Power: 11
axelosc is on a distinguished road
Sorry for copy the code incomplete...

#include "udf.h"

DEFINE_ON_DEMAND(F_DO)
{
Domain *d=Get_Domain(1);
int ID = 16; /*Boundary condition ID*/
Thread *t = Lookup_Thread(d,ID);
face_t f;
real temp=0;
real sum=0;

begin_f_loop(f,t) /*Loop over all faces*/

{
temp=F_DO_IRRAD_SHELL(f,t,0);
sum+=temp;
}
end_f_loop(f,t)
printf("Suma1 temp: %f\n",sum);
}


Thanks
axelosc is offline   Reply With Quote

Old   November 9, 2020, 17:41
Default
  #7
New Member
 
Mostafa
Join Date: Sep 2014
Posts: 9
Rep Power: 12
sasa mohamed is on a distinguished road
Dear axelosc,

Did u find what's the error in ur code? If u got it, please share it here. Thanks in advance

BR
sasa
sasa mohamed is offline   Reply With Quote

Old   November 30, 2022, 16:00
Default
  #8
New Member
 
Moe
Join Date: Jul 2021
Posts: 14
Rep Power: 5
shadymody is on a distinguished road
anyone got a solution? im trying to define incident radiation using the expression above to use it in another equation but I'm getting errors
shadymody is offline   Reply With Quote

Old   December 1, 2022, 00:59
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Originally Posted by shadymody View Post
anyone got a solution? im trying to define incident radiation using the expression above to use it in another equation but I'm getting errors
specify your question clear
code above should be:
Code:
#include "udf.h"

DEFINE_ON_DEMAND(F_DO)
{
Domain *d;
int ID = 16; /*Boundary condition ID*/
Thread *t = Lookup_Thread(d,ID);
face_t f;
d=Get_Domain(1)
real temp=0;
real sum=0;

begin_f_loop(f,t) /*Loop over all faces*/

{
temp=F_DO_IRRAD_SHELL(f,t,0);
sum+=temp;
}
end_f_loop(f,t)
sum = PRF_GRSUM1(sum);
Message("Suma1 temp: %f\n",sum);
}
take into account that ID = 16 is id of wall, which is different for your case, check correct ID for your case in fluent GUI
__________________
best regards


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

Old   December 2, 2022, 07:04
Default
  #10
New Member
 
Moe
Join Date: Jul 2021
Posts: 14
Rep Power: 5
shadymody is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
specify your question clear
code above should be:
Code:
#include "udf.h"

DEFINE_ON_DEMAND(F_DO)
{
Domain *d;
int ID = 16; /*Boundary condition ID*/
Thread *t = Lookup_Thread(d,ID);
face_t f;
d=Get_Domain(1)
real temp=0;
real sum=0;

begin_f_loop(f,t) /*Loop over all faces*/

{
temp=F_DO_IRRAD_SHELL(f,t,0);
sum+=temp;
}
end_f_loop(f,t)
sum = PRF_GRSUM1(sum);
Message("Suma1 temp: %f\n",sum);
}
take into account that ID = 16 is id of wall, which is different for your case, check correct ID for your case in fluent GUI


Dear,

here is what my ending of the code looks like

Code:
    
    UREF = urefData[induref];
    TACREF = tacrefData[indtacref];
    RHREF = rhrefData[indrhref];

    l1 = log((zrefu - (2 / 3) * hgrass) / (0.123 * hgrass));
    l2 = log((zrefh - (2 / 3) * hgrass) / (0.0123 * hgrass));
    ra = (l1 * l2) / (pow(k, 2) * UREF);
    lamda = 1.91846 * pow(10, 6) * pow(((TACREF + 273.15) / (TACREF + 239.24)), 2);
    delta = (4098 * 610.8 * exp((17.27 * TACREF) / (TACREF + 237.3))) / pow((TACREF + 237.3), 2);
    esat = (1.0007 + 3.46 * pow(10, -8) * patm) * 611.21 * exp(((18.678 - TACREF / 234.5) * TACREF) / (257.14 + TACREF));
    D = (1 - RHREF) * esat;
    gamma = patm * aircp * pow((0.622 * lamda), -1);

    begin_f_loop(f, thread)
    {
        F_CENTROID(x, f, thread);
        y = x[1];
        Incedent_Radiation= C_DO_IRRAD(x,f,thread);
        E = (delta * Incedent_Radiation + 1.225 * aircp * D / ra) / (delta + gamma * (1 + rs / ra));
        F_PROFILE(f, thread, position) = E;
    }
    end_f_loop(f, thread)
}
if you look at the E equation, I have Incedent_Radiation variable which I want to use the value to the walls that I am applying this UDF to.

I'm getting error BCS Incident_Radiation is not defined. Do I just plug your code above this section?
shadymody is offline   Reply With Quote

Old   December 5, 2022, 02:12
Default
  #11
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
I'm getting error BCS Incident_Radiation is not defined.
where did you get it? why did you put part of code?

are C_DO_IRRAD(x,f,thread); and F_DO_IRRAD_SHELL(f,t,0); the same? (no)
you need
Code:
F_DO_IRRAD_SHELL(f,t,0);
inside face loop

probably "Incident_Radiation" is not defined just because you didn't define that variable in your code
shadymody likes this.
__________________
best regards


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

Old   December 5, 2022, 16:03
Default
  #12
New Member
 
Moe
Join Date: Jul 2021
Posts: 14
Rep Power: 5
shadymody is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
where did you get it? why did you put part of code?

are C_DO_IRRAD(x,f,thread); and F_DO_IRRAD_SHELL(f,t,0); the same? (no)
you need
Code:
F_DO_IRRAD_SHELL(f,t,0);
inside face loop

probably "Incident_Radiation" is not defined just because you didn't define that variable in your code
Dear, sorry for the inconvenience.

I did not include the complete code because I thought that it was too long to be displayed here, sorry for that

I will include it below after following your advice, I'm not actually sure of what I did, so please tell me if this should work as intended.

I did not get any errors when interpreting this one so I hope it works as intended. i spent a lot of time on this bcs I have no background on UDFs and could not find a clear reference.

thanks in advance

Code:
#include "udf.h"

double rs=83.33;
double zrefu=30.0;
double zrefh=30.0;
double hgrass=0.1;
double patm=101325.0;
double aircp=1008.0;
double k=0.42;

float UREF;
float TACREF;
float RHREF;

int induref;
int indtacref;
int indrhref;

float urefData[24] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
float tacrefData[24] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
float rhrefData[24] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};

DEFINE_PROFILE(PME_profile, thread, position)
{
    float x[ND_ND];
    float y;
    float E, ra, lamda, gamma, delta, D, esat, l1, l2, Incedent_Radiation;
    face_t f;

    real current_time;
    current_time = CURRENT_TIME;
    current_time /= 60;


    if (current_time < 60)
    {
        induref = 0;
        indtacref = 0;
        indrhref = 0;
    }
    else if (current_time < 120)
    {
        induref = 1;
        indtacref = 1;
        indrhref = 1;
    }
    else if (current_time < 180)
    {
        induref = 2;
        indtacref = 2;
        indrhref = 2;
    }
    else if (current_time < 240)
    {
        induref = 3;
        indtacref = 3;
        indrhref = 3;
    }
    else if (current_time < 300)
    {
        induref = 4;
        indtacref = 4;
        indrhref = 4;
    }
    else if (current_time < 360)
    {
        induref = 5;
        indtacref = 5;
        indrhref = 5;
    }
    else if (current_time < 420)
    {
        induref = 6;
        indtacref = 6;
        indrhref = 6;
    }
    else if (current_time < 480)
    {
        induref = 7;
        indtacref = 7;
        indrhref = 7;
    }
    else if (current_time < 540)
    {
        induref = 8;
        indtacref = 8;
        indrhref = 8;
    }
    else if (current_time < 600)
    {
        induref = 9;
        indtacref = 9;
        indrhref = 9;
    }
    else if (current_time < 660)
    {
        induref = 10;
        indtacref = 10;
        indrhref = 10;
    }
    else if (current_time < 720)
    {
        induref = 11;
        indtacref = 11;
        indrhref = 11;
    }
    else if (current_time < 780)
    {
        induref = 12;
        indtacref = 12;
        indrhref = 12;
    }
    else if (current_time < 840)
    {
        induref = 13;
        indtacref = 13;
        indrhref = 13;
    }
    else if (current_time < 900)
    {
        induref = 14;
        indtacref = 14;
        indrhref = 14;
    }
    else if (current_time < 960)
    {
        induref = 15;
        indtacref = 15;
        indrhref = 15;
    }
    else if (current_time < 1020)
    {
        induref = 16;
        indtacref = 16;
        indrhref = 16;
    }
    else if (current_time < 1080)
    {
        induref = 17;
        indtacref = 17;
        indrhref = 17;
    }
    else if (current_time < 1140)
    {
        induref = 18;
        indtacref = 18;
        indrhref = 18;
    }
    else if (current_time < 1200)
    {
        induref = 19;
        indtacref = 19;
        indrhref = 19;
    }
    else if (current_time < 1260)
    {
        induref = 20;
        indtacref = 20;
        indrhref = 20;
    }
    else if (current_time < 1320)
    {
        induref = 21;
        indtacref = 21;
        indrhref = 21;
    }
    else if (current_time < 1380)
    {
        induref = 22;
        indtacref = 22;
        indrhref = 22;
    }
    else
    {
        induref = 23;
        indtacref = 23;
        indrhref = 23;
    }

    UREF = urefData[induref];
    TACREF = tacrefData[indtacref];
    RHREF = rhrefData[indrhref];

    l1 = log((zrefu - (2 / 3) * hgrass) / (0.123 * hgrass));
    l2 = log((zrefh - (2 / 3) * hgrass) / (0.0123 * hgrass));
    ra = (l1 * l2) / (pow(k, 2) * UREF);
    lamda = 1.91846 * pow(10, 6) * pow(((TACREF + 273.15) / (TACREF + 239.24)), 2);
    delta = (4098 * 610.8 * exp((17.27 * TACREF) / (TACREF + 237.3))) / pow((TACREF + 237.3), 2);
    esat = (1.0007 + 3.46 * pow(10, -8) * patm) * 611.21 * exp(((18.678 - TACREF / 234.5) * TACREF) / (257.14 + TACREF));
    D = (1 - RHREF) * esat;
    gamma = patm * aircp * pow((0.622 * lamda), -1);

    begin_f_loop(f, thread)
    {
        F_CENTROID(x, f, thread);
        y = x[1];
        Incedent_Radiation= F_DO_IRRAD_SHELL(f,thread,0);
        E = (delta * Incedent_Radiation + 1.225 * aircp * D / ra) / (delta + gamma * (1 + rs / ra));
        F_PROFILE(f, thread, position) = E;
    }
    end_f_loop(f, thread)
}
shadymody is offline   Reply With Quote

Old   December 6, 2022, 00:31
Default
  #13
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
the code you've showed last is correct.
what errors do you have?
__________________
best regards


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

Old   December 6, 2022, 09:05
Default
  #14
New Member
 
Moe
Join Date: Jul 2021
Posts: 14
Rep Power: 5
shadymody is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
the code you've showed last is correct.
what errors do you have?
I did not get any errors. I was just asking if its "technically" correct.
shadymody is offline   Reply With Quote

Reply

Tags
incident radiation, macro, radiation do model, udf


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
Modeling the flow of solar radiation as the heat flux from the surface. Gebbels FLUENT 0 March 25, 2012 15:39
Surface incident radiation Pipiola FLUENT 0 August 11, 2009 16:46
Incident Radiation Nicki CFX 1 April 17, 2009 09:18
Fluent incident radiation problem Michael Schwarz Main CFD Forum 0 October 21, 1999 06:56


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