CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF for pressure outlet backflow total temperature (https://www.cfd-online.com/Forums/fluent/129029-udf-pressure-outlet-backflow-total-temperature.html)

MrDaimon January 27, 2014 03:47

UDF for pressure outlet backflow total temperature
 
Hi all,
I am trying to solve a solidification and melting problem using Ansys Fluent 13. My problem is: I have a mass of PCM (Phase Change Material) which is warmed up by a flux of oil in a heat pipe. When melting occurs, I set the density of the PCM to reduce, so I need an outlet in the volume occupied by PCM to make mass flow out of domain. Obviously convective movements are important in my simulation, so I need to know if there is a way to set the backflow temperature equal to the temperature in the cell near the pressure outlet, maybe using a UDF. Can anyone help me?
I hope I've been clear.
Regards

A CFD free user January 27, 2014 13:48

Hi guy,
I think, it's possible. First, try to get the temperature in cells near the pressure outlet using a DEFINE_ADJUST general purpose macro. Then store it in a C_UDMI and recall it by a DEFINE_PROFILE macro for the face thread.

MrDaimon January 28, 2014 02:28

Thanks
 
Thanks man! Unfortunately I'm not so good using that kind of macro... Can you tell me more about it? How would you write it?

macfly January 29, 2014 08:42

I got exactly what you want, did that in the past :)

Did you look on the udf forum?

Code:

#include "udf.h"
 real T_mean;  /* defined outside because will be used in multiple DEFINE macros */

 DEFINE_ADJUST(adjust, domain, t)
 {
 real T_tot;
 real u;
 real counter = 0;

 face_t f;
 int ID = 20; /* outlet ID displayed in Fluent boundary conditions panel */
 Thread *thread;
 thread = Lookup_Thread(domain, ID);
 begin_f_loop(f, thread)
 {
 u = F_U(f, thread); /* x velocity */
 if (u >= 0) /* if fluid is going out... */
 {
 T_tot += F_T(f, thread);
 counter = counter + 1;
 }
 }
 end_f_loop(f, thread)
 T_mean = T_tot/counter; /* arithmetic mean T of outflow */
 }



 DEFINE_PROFILE(T_backflow, thread, position)
 {
 face_t f;
 begin_f_loop(f, thread)
 {
 F_PROFILE(f, thread, position) = T_mean;
 }
 end_f_loop(f, thread)
 }

- modify the velocity component and the if condition depending on your geometry...

- If I remember well, I think you have to interprete the udf before each simulation to reset the variables

- It does an arithmetic mean of the outgoing fluid temperature, not accurate if your mesh is not uniform at the outlet and temperature varies a lot

- If I were you, I'd modify the code for an area-weighted average of T of the outgoing fluid at the boundary

MrDaimon January 29, 2014 09:05

Thank you soooo much! ;)

adnanghreeb January 29, 2014 11:05

ANSYS Fluent
 
Dear friends, I have question in fluent please.
I used ICEM for simulate heat transfer in kiln, then export to fluent, actually in this time i run my program without combustion.
can get converge at residual e-2 but with not good report about mass net, as same time reasonable result.

so take more for residual until e-4 , also get converge but not reasonable result and in this case report mass excepted?

any suggest, thanks in advance
adnan


macfly January 29, 2014 11:13

Quote:

Originally Posted by adnanghreeb (Post 472361)
Dear friends, I have question in fluent please.
I used ICEM for simulate heat transfer in kiln, then export to fluent, actually in this time i run my program without combustion.
can get converge at residual e-2 but with not good report about mass net, as same time reasonable result.

so take more for residual until e-4 , also get converge but not reasonable result and in this case report mass excepted?

any suggest, thanks in advance
adnan


I think you wanted to start a new thread. Please start a thread with a specific title about your problem, not the most general title like 'Ansys Fluent'.

MrDaimon January 29, 2014 13:27

Quote:

Originally Posted by macfly (Post 472337)
I got exactly what you want, did that in the past :)

Did you look on the udf forum?

Code:

#include "udf.h"
 real T_mean;  /* defined outside because will be used in multiple DEFINE macros */

 DEFINE_ADJUST(adjust, domain, t)
 {
 real T_tot;
 real u;
 real counter = 0;

 face_t f;
 int ID = 20; /* outlet ID displayed in Fluent boundary conditions panel */
 Thread *thread;
 thread = Lookup_Thread(domain, ID);
 begin_f_loop(f, thread)
 {
 u = F_U(f, thread); /* x velocity */
 if (u >= 0) /* if fluid is going out... */
 {
 T_tot += F_T(f, thread);
 counter = counter + 1;
 }
 }
 end_f_loop(f, thread)
 T_mean = T_tot/counter; /* arithmetic mean T of outflow */
 }



 DEFINE_PROFILE(T_backflow, thread, position)
 {
 face_t f;
 begin_f_loop(f, thread)
 {
 F_PROFILE(f, thread, position) = T_mean;
 }
 end_f_loop(f, thread)
 }

- modify the velocity component and the if condition depending on your geometry...

- If I remember well, I think you have to interprete the udf before each simulation to reset the variables

- It does an arithmetic mean of the outgoing fluid temperature, not accurate if your mesh is not uniform at the outlet and temperature varies a lot

- If I were you, I'd modify the code for an area-weighted average of T of the outgoing fluid at the boundary




Did you have the pressure outlet on the right side of domain? I have it on the left, so maybe I should consider the velocity in the opposite direction... Am I right? :)

macfly January 29, 2014 13:29

yes that's it, plot the velocity you'll see what's negative or not

MrDaimon February 3, 2014 08:16

Quote:

Originally Posted by macfly (Post 472382)
yes that's it, plot the velocity you'll see what's negative or not


Man, I'm sorry but it doesn't seem to work :( I used the ID of my outlet, change the velocity direction but it doesn't work... It sets the backflow total temperature to 0, even if I initialize my case with 423.15 K (which is my initial condition). My geometry is planar (2D), not solid, but I am using an assialsimmetry condition... does it affect the UDF? Was your UDF written for a 3D geometry?

macfly February 3, 2014 12:16

- I assume you interpreted the udf and set the backflow T at the outlet.

- But did you hook the DEFINE_ADJUST? (Define\User-Defined\Function Hooks...\edit Adjust and select 'adjust'

The udf works in 2D or 3D. I don't think that the axial symmetry boundary affects the udf.

MrDaimon February 4, 2014 02:10

I didn't know how to use the "adjust", I'm sorry :) I never used this kind of UDF before, so thank you so much! I'm now tryin to do what you told me.
Anyway, does this UDF work in steady and transition conditions too?

macfly February 4, 2014 10:11

hooking is like telling Fluent to use the udf it interpreted (or compiled), see the Ansys Fluent UDF Manual

yes it will work for steady or transient cases

jjfm20 June 23, 2017 00:45

Hello,

I'm trying with this UDF but it stops when reaching about the 30 iteration (Diverges), and I'm still not sure why, can some help me, what do I need to check for that to work well? I have to tell, this only happens when I use the Coupled Pseudotransient Method, the thing is, I do need to use this solution method.

Hope you can help me.

Regards.


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