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

How to make UDF Initial temperature for more than one zone ID for Conduction?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By AlexanderZ
  • 1 Post By vinerm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 29, 2020, 22:01
Default How to make UDF Initial temperature for more than one zone ID for Conduction?
  #1
Senior Member
 
teguhtf's Avatar
 
teguh hady
Join Date: Aug 2009
Location: Saga, Japan
Posts: 222
Rep Power: 18
teguhtf is on a distinguished road
Dear all,



I simulate ground heat exchanger in Ansys FLUENT 17.2. I divide the main domain into several domain to reduce mesh complexity and different material of the ground (Surface to 15 m depth is sandy and below 15 m is clay). I simulate in transient. Due to temperature distribution in ground, I make UDF for initial temperature. Hoever, I only make for one zone ID. My assumption is no water flow through the ground due to computational limitation. I just want to know the temperature distribution in the ground after several days of heat extraction or injection. For the heat exchanger, I set as a solid body. Hence, I use source term to input heat value based on my previous data. The case is quite complex so In this case, I do only simulation ground. I don't know how to make the other zone id. Do you have any suggestion?

Thank you


Code:
/***********************************************************************

UDF for initializing temperature distribution

************************************************************************/



#include "udf.h"

/* #define SOLID_ID 7 */



DEFINE_INIT(my_init_func,domain)



{

cell_t c;

Thread *t;

real xc[ND_ND];

real y;

Domain *d;

int ID = 7;// ID Ground

 

/* determination of zone ID  */

 

Thread *thread = Lookup_Thread(domain,ID);



/* loop over all cell threads in the domain  */

 

thread_loop_c(t,domain)

 

{

/* loop over all cells  */

begin_c_loop_all(c,t)

{

C_CENTROID(xc,c,t);

y = xc[1]; 



if (-1 < y && y <= 0) /* from 0 to -5m*/

C_T(c,t) = 3 *y*y + 10 * y + 303;

 

else if (-1.5 < y && y <= -1) /* from 0 to -5m*/

C_T(c,t) = 7 * y + 304;



else if (-3 < y && y <= -1.5) /* from -3 to -1.5m*/

C_T(c,t) = 0.2 * y * y + 1.5 * y + 298;

 

else if (-5 < y && y <= -3) /* from -5 to -3m*/

C_T(c,t) = 0.4 * y + 292;



else if (-10 < y && y <= -5) /* from -10 to -5m*/

C_T(c,t) = 0.05 * y + 291;



else            /* from -10 to -20*/

C_T(c,t) = 291;

 

}

end_c_loop_all(c,t)

}

}
__________________
Now Or Never!!!

Last edited by teguhtf; January 30, 2020 at 00:08. Reason: adding explaination about heat exchanger
teguhtf is offline   Reply With Quote

Old   January 30, 2020, 03:17
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
Quote:
I don't know how to make the other zone id
what does it mean?

in code you have
Code:
int ID = 7;// ID Ground
change ID value to any other number
In FLuent GUI you can check ID of each zone in your model:
Setup -> Cell Zone Conditions -> select any zone -> you will see ID value, out this value in UDF

If you want to change apply your code to several zones, for instance for zone 8 -> you can add
Code:
ID = 8;
*thread = Lookup_Thread(domain,ID);
and make additional loop
teguhtf likes this.
__________________
best regards


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

Old   January 30, 2020, 04:42
Default ID not being used
  #3
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Hi

If you use thread_loop_c, then you do not require cell zone ID. thread_loop_c ensures that the loop is executed over all the cell zones. Check you code and you will find that variable thread is not being used at all.

However, you most likely do not want that. So, remove thread_loop_c and only use the internal loop, begin_c_loop(c, t). The second argument in this loop has to be variable thread and not t, the thread coming from Lookup_Thread command.

If you want the same code to be executed for all the cell zones, then what you are doing is right and you can simply remove the declaration of variable thread as well as command Lookup_Thread that fetches its value.
teguhtf likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 9, 2020, 22:52
Default
  #4
Senior Member
 
teguhtf's Avatar
 
teguh hady
Join Date: Aug 2009
Location: Saga, Japan
Posts: 222
Rep Power: 18
teguhtf is on a distinguished road
Dear AlexanderZ,

Thank you for your reply. Yes, I thought like your idea. However, the initialization is only one in FLUENT. I can not make more than one initialization.

After I do simulate with previous code, The code work for all domain.

Thank you for your help
__________________
Now Or Never!!!
teguhtf is offline   Reply With Quote

Old   February 9, 2020, 23:03
Default
  #5
Senior Member
 
teguhtf's Avatar
 
teguh hady
Join Date: Aug 2009
Location: Saga, Japan
Posts: 222
Rep Power: 18
teguhtf is on a distinguished road
Dear vinerm,

Thank you for your reply. Yes, My code is still working good. But, I am sorry I do not have good solid knowledge about UDF. Here i attach my simulation after 1 day. Leftside temperature contour is initial condition right side is after 24 hours. So far, it is good. Except the low temperature near the coil is too low. and temperature graph below coil is increasing when heat absorbed by coil. The figure 3 should have the similar trends with figures 1 and 2.

by the way, my geometry and meshing i have posted in here Problem in meshing slinky coil burried in the ground

I am still trying to find out the solution.

Do you have any suggestions?

Thank you
Regards
Attached Images
File Type: jpg Temperature contour.jpg (50.5 KB, 12 views)
File Type: jpg Temperature Distribution.jpg (132.9 KB, 15 views)
__________________
Now Or Never!!!
teguhtf is offline   Reply With Quote

Old   February 10, 2020, 00:51
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
so do you have problems with UDF or not? explain clearly your issues
__________________
best regards


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

Old   February 10, 2020, 05:13
Default Incomplete Information
  #7
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
There are a lot of things that we do not know about. Hence, it would be difficult to answer why the temperature trend is as it is and not what you expected. However, it most likely is correct as per your setup. To provide suggestions, we need to know the following

1. Is the energy source term being applied negative or positive? Are these sources within the circular ducts?
2. What are the boundary conditions on the bottom, side, and top surfaces?
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   February 10, 2020, 06:02
Default addition information
  #8
Senior Member
 
teguhtf's Avatar
 
teguh hady
Join Date: Aug 2009
Location: Saga, Japan
Posts: 222
Rep Power: 18
teguhtf is on a distinguished road
Dear vinerm

I am sorry I do not mention it in detail. Thank you for your reply. I do simulation only for the ground side (solid). For circular pipe wall, I set the value is constant heat flux -5kW/m2 (based on my previous data). no fluid flow inside the pipe.

All of the boundary conditions for the wall side are adiabatic. The top wall is constant temperature 302 K. and bottom wall constant heat flux 65 mW/m2.

No water flows through ground. The ground is assumed as purely solid. Actually, my UDF based on this sample I just modify parts in loop side https://www.afs.enea.it/project/nept...udf/node27.htm

Thank you for your help.
Regards
__________________
Now Or Never!!!

Last edited by teguhtf; February 10, 2020 at 06:10. Reason: addition source of UDF
teguhtf is offline   Reply With Quote

Old   February 10, 2020, 06:04
Default
  #9
Senior Member
 
teguhtf's Avatar
 
teguh hady
Join Date: Aug 2009
Location: Saga, Japan
Posts: 222
Rep Power: 18
teguhtf is on a distinguished road
dear AlexanderZ

Thank you for your reply. I am still checking if there is any mistake in the UDF or any other source errors.

Thank you for your help

Regards
__________________
Now Or Never!!!
teguhtf is offline   Reply With Quote

Old   February 10, 2020, 06:27
Default Integral calculation
  #10
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
By doing a hand calculation, you can find out if the bottom part will heat up or cool down. For -5000 W/m^2 through the pipe, multiply it by the area of the wall where the condition is applied, i.e., area of the pipe wall. Do the same for the bottom wall where 0.065 is applied. If the value at the bottom is lower, then it should eventually cool down or vice-versa.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm 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
Problem with chtMultiregionFoam radiation boundary condition baran_foam OpenFOAM Running, Solving & CFD 10 December 17, 2019 18:36
Segmentation fault when using reactingFOAM for Fluids Tommy Floessner OpenFOAM Running, Solving & CFD 4 April 22, 2018 13:30
pressure in incompressible solvers e.g. simpleFoam chrizzl OpenFOAM Running, Solving & CFD 13 March 28, 2017 06:49
Cannot run the code properly: very large time step continuity error crst15 OpenFOAM Running, Solving & CFD 9 December 14, 2014 19:17
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20


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