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

Implement external bodyforce using UDF

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 3, 2014, 13:09
Default Implement external bodyforce using UDF
  #1
New Member
 
Noris
Join Date: Jun 2014
Posts: 11
Rep Power: 9
ngallandat3 is on a distinguished road
Hello

I am a beginner with Ansys and I am struggling to solve the following issue. In my problem, I need to include an external body force on my fluid. In the actual case, it will be an electrostatic force that will depend on the location of the particle as well, but as a first try, I just want to include a constant body force in the y-direction everywhere. I am running a simple, steady state simulation with an air flow through a vertical channel with heated walls.

I slightly modified the UDF given in the UDF manual (2.5.2). I can compile and load the library, everything seems to work fine. I can select the defined body force in "Model -> Discrete Phase, on -> Interaction with Continuous Phase, yes -> UDF -> particle_body_force." I set the number of scalars to 1 in the user variables.

Now my issue is, the results do not change with or without the external body force: it appears that it is always equal to 0.

Does anyone have an idea on how to fix that issue?

Thanks


This is my UDF:

/* UDF adding an external body force to the fluid */
#include "udf.h"
#define TSTART 0.0 /* field applied at t = tstart */
DEFINE_DPM_BODY_FORCE(particle_body_force,p,i)
{
real bforce;
if(P_TIME(p)>=TSTART)
{
if(i==0) 0;
else if(i==1) bforce=-100;
}
else
bforce=0.0;
/* an acceleration should be returned */
return (bforce);
}
ngallandat3 is offline   Reply With Quote

Old   June 4, 2014, 04:49
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,916
Rep Power: 23
pakk will become famous soon enough
First of all, you made a mistake in
Code:
if(i==0) 0;
else if(i==1) bforce=-100;
I think what you meant was:
Code:
if(i==0) bforce=0;
else if(i==1) bforce=-100;
I don't that this is the reason for your problem, but you could try it and see if it fixes things.

Otherwise, I would add a debugging line in the code:
Code:
Message("At time %f, for i=%d, acceleration %f is given.\n",P_TIME(p),i,bforce);
Add this line just above "return (bforce);".

Then, Fluent will print a line every time that this udf is called, and you can see what is happening. Do this only for a few time steps, with a few particles, otherwise you will have to wait extremely long.
After that, analyze the results.
pakk is offline   Reply With Quote

Old   June 4, 2014, 08:29
Default
  #3
New Member
 
Noris
Join Date: Jun 2014
Posts: 11
Rep Power: 9
ngallandat3 is on a distinguished road
Thanks pakk for your reply. I followed your suggestion (corrected the code and added the debugging line).

Now this is what happens: the debugging line is never printed. So I assume that the UDF is never called?!?

You were suggesting to do this for a few time steps only. Sounds like a dumm question, but since I am trying to run a steady state simulation, do I even have a timestep?

Also, in this first problem, I would like to apply a constant body force to every single fluid particle.

Any further hint would be greatly appreciated!
ngallandat3 is offline   Reply With Quote

Old   June 4, 2014, 09:14
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,916
Rep Power: 23
pakk will become famous soon enough
Quote:
Originally Posted by ngallandat3 View Post
Thanks pakk for your reply. I followed your suggestion (corrected the code and added the debugging line).

Now this is what happens: the debugging line is never printed. So I assume that the UDF is never called?!?
I suddenly realize what your problem is...
You want to put a body force on your fluid, but you are telling Fluent to set a body force on discrete particles. You (probably) did not put any discrete particles in your model, so it has no effect.

To put it simply: this UDF is not the right way to go. It has to be something in the "cell zone conditions", that's the best I can tell you.
pakk is offline   Reply With Quote

Old   June 4, 2014, 09:29
Default
  #5
New Member
 
Noris
Join Date: Jun 2014
Posts: 11
Rep Power: 9
ngallandat3 is on a distinguished road
That was fast!

Do you have any recommendation on how to implement a force in the cell zone conditions? Or where to start?

Thanks
ngallandat3 is offline   Reply With Quote

Old   June 5, 2014, 14:48
Default
  #6
New Member
 
Noris
Join Date: Jun 2014
Posts: 11
Rep Power: 9
ngallandat3 is on a distinguished road
Hey Pakk

I think that I found a way to do what I wanted. You were right: it has to do with the cell zone conditions. I wrote a UDF to define a momentum source, and it seems to work. The name "momentum" was a tad confusing to me because what I want is a body force on the fluid, but I reviewed the theory manual and it corresponds to what I want.

Thanks again for directing me to the right path!
ngallandat3 is offline   Reply With Quote

Old   June 5, 2014, 15:22
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,916
Rep Power: 23
pakk will become famous soon enough
I'm happy that you solved it, and thanks for sharing the outcome here!
pakk is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
UDF programming fullmonty FLUENT 5 June 30, 2011 02:40
UDF compiling problem in Flient 6.3 jeevan kumar FLUENT 2 February 25, 2009 00:43
fluent UDF external library lapack problem Rick FLUENT 0 May 7, 2008 10:16
I need UDF help. S.Whitney FLUENT 0 October 15, 2007 11:29
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


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