|
[Sponsors] |
June 3, 2014, 14:09 |
Implement external bodyforce using UDF
|
#1 |
New Member
Noris
Join Date: Jun 2014
Posts: 11
Rep Power: 12 |
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); } |
|
June 4, 2014, 05:49 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
First of all, you made a mistake in
Code:
if(i==0) 0; else if(i==1) bforce=-100; Code:
if(i==0) bforce=0; else if(i==1) bforce=-100; 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); 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. |
|
June 4, 2014, 09:29 |
|
#3 |
New Member
Noris
Join Date: Jun 2014
Posts: 11
Rep Power: 12 |
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! |
|
June 4, 2014, 10:14 |
|
#4 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
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. |
||
June 4, 2014, 10:29 |
|
#5 |
New Member
Noris
Join Date: Jun 2014
Posts: 11
Rep Power: 12 |
That was fast!
Do you have any recommendation on how to implement a force in the cell zone conditions? Or where to start? Thanks |
|
June 5, 2014, 15:48 |
|
#6 |
New Member
Noris
Join Date: Jun 2014
Posts: 11
Rep Power: 12 |
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! |
|
June 5, 2014, 16:22 |
|
#7 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I'm happy that you solved it, and thanks for sharing the outcome here!
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF programming | fullmonty | FLUENT | 5 | June 30, 2011 03:40 |
UDF compiling problem in Flient 6.3 | jeevan kumar | FLUENT | 2 | February 25, 2009 01:43 |
fluent UDF external library lapack problem | Rick | FLUENT | 0 | May 7, 2008 11:16 |
I need UDF help. | S.Whitney | FLUENT | 0 | October 15, 2007 12:29 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |