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

Position Dependent Temperature Initialization

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AlexanderZ

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 5, 2020, 11:00
Default Position Dependent Temperature Initialization
  #1
New Member
 
Join Date: Oct 2019
Posts: 20
Rep Power: 7
berkmm is on a distinguished road
Hello everyone,
i'm working on a 2D fluent project. In this project I have a varying temperature gradient profile which changes towards x-axis. I wrote an UDF for this profile but I still dont know some variables. Do you have any UDF learn source about DEFINE macros and variable definitions? Can you please check my UDF? Temperature profile and UDF given in the below.

0 - 100 meter => 283.15+1.4*x
100-1000 meter => 420.93+0.0222*x
1000-1100 meter => -1006.9 + 1.45*x
1100-2000 meter => 557.59 + 0.0278*x
2000-2090 meter => -3164.6 + 1.8889*x
2090-2140 meter => -5068.9 + 2.8*x

#include "udf.h"


DEFINE_INIT(temp_init, domain)
{
cell_t c;
Thread *ct;
real pos[ND_ND];

/* loop over all cell threads in the domain */
thread_loop_c(t,d)
{
begin_c_loop_all(c,ct)
{
C_CENTROID(pos,c,ct);
if ( pos > 0 && pos < 100)
C_T(c,ct) =283.15 + 1.4*pos
else if ( pos >= 100 && pos < 1000)
C_T(c,ct)= 420.91 +0.0222*x
else if (pos >= 1000 && pos < 1100)
C_T = -1006.9 + 1.45*x
else if (pos >= 1100 && pos < 2000)
C_T = 557.59 +0.0278*x
else if ( pos >= 2000 && pos < 2090)
C_T = -3164.6 + 1.8889*x
else
C_T = -5068.9+ 2.9*x
}
end_c_loop_all(c,ct)
}
}
berkmm is offline   Reply With Quote

Old   July 5, 2020, 22:04
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
logic is correct, you have problems with C coding

first use pos or x in your code.
don;t forget ; and the end of each command

I recommend always compile the code, so you will see all problems in log output
berkmm likes this.
__________________
best regards


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

Old   July 6, 2020, 08:09
Default
  #3
New Member
 
Join Date: Oct 2019
Posts: 20
Rep Power: 7
berkmm is on a distinguished road
Thanks for everyone. For those who want to know the solution of this process here is my UDF code
Code:
#include "udf.h"
DEFINE_INIT(my_init_func,d)
{
cell_t c;
face_t f;
Thread *t;
real xc[ND_ND];

/* 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);
if (xc[0] > 0 && xc[0] < 100)
C_T(c,t) = 283.15 + 1.4*xc[0];
else if (xc[0] > 100 && xc[0] < 1000)
C_T(c,t) = 420.91 +0.0222*xc[0];
else if (xc[0] > 1000 && xc[0] < 1100)
C_T(c,t) = -1006.9 + 1.45*xc[0];
else if (xc[0] > 1100 && xc[0] < 2000)
C_T(c,t) = 557.59 +0.0278*xc[0];
else if (xc[0] > 2000 && xc[0] < 2090)
C_T(c,t) = -3164.6 + 1.8889*xc[0];
else 
C_T(c,t) = -5924.9+ 3.2*xc[0];

}
end_c_loop_all(c,t)
}
}
I now want to learn that what might be the difference between face loop and cell loop? which one will be more precise in terms of temperature definition? In patch initialization method, what looping method does it use? Do you have any ideas?
berkmm is offline   Reply With Quote

Old   July 8, 2020, 03:11
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
face loop and cell loop are totally different things
face loop is a loop over faces of boundary
cell loop is a loop over cells inside zones

you may use these macros depends on your needs
For more details look into Ansys Fluent Customization manual

if we speak about patch tool, I believe it use cell loop
__________________
best regards


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

Reply


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
[openSmoke] libOpenSMOKE Tobi OpenFOAM Community Contributions 562 January 25, 2023 10:21
Temperature dependent values in dependence of K? h0rst FLUENT 0 February 2, 2017 14:46
Possible to display temperature dependent material parameters h0rst Structural Mechanics 0 February 1, 2017 02:53
Temperature Dependent Thermal conductivity in chtMultiRegionFoam Mohammad Jam OpenFOAM Programming & Development 3 November 9, 2016 13:50
Temperature dependent propertys and finalIteration in chtMultiRegionFoam waiter120 OpenFOAM 0 February 20, 2013 06:22


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