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

UDF for trapped particles in a wall

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 16, 2018, 06:11
Default UDF for trapped particles in a wall
  #1
New Member
 
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 9
rafash2 is on a distinguished road
Hi everyone,

I am trying to calculate the effect of a passive scalar into a fluid using the UDS in Fluent.
I have to impose a determined flux of trapped particles on a wall with a UDF for the specified flux in the walls boundary conditions. The formula that I have to implement is Flux=sigma x particle concentration,where sigma is the adherence coefficient.
I have been reading the Help of Fluent related with DEFINE_UDS_FLUX but I am not be able to apply it to my problem.
Could anyone help me with this problem please??
Thank you very much in advance
Cheers!!
rafash2 is offline   Reply With Quote

Old   April 16, 2018, 10:06
Default
  #2
Senior Member
 
Join Date: Sep 2017
Posts: 230
Rep Power: 9
obscureed is on a distinguished road
Hi there Rafash2,

It looks to me like DEFINE_UDS_FLUX is not what you want. That defines how the UDS is transported from cell to cell, basically.

I think you want to define a wall boundary condition for a User-Defined Scalar -- is that right? That is more of a job for DEFINE_PROFILE, I think. (I might have misinterpreted your question. You could be planning to move the particles themselves (along the walls, maybe), or to inject new particles into the domain based on the other particles. These possibilities are a lot harder.)

One tip would be to store your calculations in a User-Defined Memory, which you might update at the end of every timestep using DEFINE_EXECUTE_AT_END, for example. Then your DEFINE_PROFILE just looks up the UDM. This is a good plan because it allows you to view the current profile outside of iterations. You can also ensure that the profile stays stable over a timestep, rather than changing constantly.

Good luck!
Ed
obscureed is offline   Reply With Quote

Old   April 16, 2018, 12:32
Default
  #3
New Member
 
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 9
rafash2 is on a distinguished road
obscureed, thank you very much for your answer.
Yes, I want to define a wall boundary condition for a UDS, more specifically a "Specified Flux" in wall boundary condition.
Following your tip I have written a UDF with DEFINE_PROFILE, but I am not very expert in this code and I am not very sure.
This is my UDF:

#include "udf.h"

#define sigma 0.05


real Flux;
real Concentration;

DEFINE_PROFILE(wall_Flux,thread,nv)
{
Thread *t;
face_t f;

Concentration=0.0; //initial value

begin_f_loop(f,thread)
{
Concentration+=F_UDSI(f,thread,0); //sum of Scalars of all faces of the outlet at the same time step

}
end_f_loop(f,thread)

Flux=sigma*Concentration; //calculate Flux

begin_f_loop(f,thread)
{
F_PROFILE(f,thread,nv)=Flux;
}
end_f_loop(f,thread)
}

Here I am trying to find the scalar flux through the wall from a fixed adherence coefficient (sigma) and the own scalar concentration calculated by Fluent in each face (Flux=sigma*concentration os scalar).

I have a problem because the uds residual are very high (10^2).
Do you think the UDF is right??
Thank you in advance

Regards!!
rafash2 is offline   Reply With Quote

Old   April 16, 2018, 12:40
Default
  #4
New Member
 
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 9
rafash2 is on a distinguished road
After 100 iterations I find "Divergence detected in AMG solver: uds-0". Thre is something in the UDF that doesn´t work.
I appreciate the help of all of you!!!

Regards
rafash2 is offline   Reply With Quote

Old   April 16, 2018, 13:09
Default
  #5
New Member
 
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 9
rafash2 is on a distinguished road
I´m sorry for my insistence. I just relized that I was running the simulation in steady state. I have just changed to transient simulation.
I hope your comments please...
rafash2 is offline   Reply With Quote

Old   April 18, 2018, 08:26
Default
  #6
Senior Member
 
Join Date: Sep 2017
Posts: 230
Rep Power: 9
obscureed is on a distinguished road
Hi Rafash2,

First, please note that positive values of a flux Boundary Condition count as inward flux, into the model. So, if your UDF is applied to the same UDS that it calculates from, you have a positive feedback loop into your model. This will lead to exponential growth in your values of the UDS.

Next, it seems clear to me that the current calculations cannot be physically correct, because they are mesh-dependent. The variable you call Concentration is a sum of N values, where N is the number of faces in the thread. To make it mesh-independent, you need something like an area-weighted average. I don't the details of what you want, because I don't understand how the flux at each location of the zone is defined by the concentration across the entire zone. Or, to phrase it as a question, why isn't the flux at each location defined by the local concentration only:
F_PROFILE(f,thread,nv)= MAGIC_CONSTANT * F_UDSI(f,thread,0);

When I start thinking about mesh effects, I worry about whether the values returned by the DEFINE_PROFILE are meant to be flux, in units of [quantity of UDS]-per-m2-per-second, or a net flowrate per face, in units of [quantity of UDS]-per-second. There are several places in Fluent UDFs where something called a flux is actually a flowrate-per-face.

You might want to check that the UDF does what you expect by building and running test cases, if necessary on a simple test geometry. If you do this, you will less reliant on advice from me (or others on this forum), which could be wrong.

Good luck!
Ed
obscureed is offline   Reply With Quote

Old   April 19, 2018, 05:11
Default
  #7
New Member
 
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 9
rafash2 is on a distinguished road
obscureed, thank you again for your answer. I think I am complicating myself. Really the only thing I desire to impose in my wall boundary condition is that the flux of scalar through this wall verifies: F=sigma*C, where F is the flux of scalar, sigma is the adherence coefficient of the scalar on the wall and C is the quantity of scalar given by fluent (uds-0).
I think it must not be difficult, but as I said, I am not very skilled with UDS and UDF.
I thank you very much your help.

Regards!!
rafash2 is offline   Reply With Quote

Old   April 20, 2018, 11:12
Default
  #8
Senior Member
 
Join Date: Sep 2017
Posts: 230
Rep Power: 9
obscureed is on a distinguished road
Hi,

It sounds like you want something simple:
Code:
#include "udf.h"
#define MAGIC_CONSTANT (-0.15)

DEFINE_PROFILE(uds0_flux,thread,nv)
{
  Thread *t;
  face_t f;

  begin_f_loop(f,thread)
  {
    /* Note that MAGIC_CONSTANT is negative!!! */
    F_PROFILE(f,thread,nv)=MAGIC_CONSTANT * F_UDSI(f,thread,0);
  }
  end_f_loop(f,thread)
}
There is still the question of how to get the right value for MAGIC_CONSTANT. What are its units, even? Fluent dodges this question, partly because it does not know what you are storing in the UDS. However, if you look at the transport equation for UDS, you see that the transient term is (d/dt)(rho*UDS) -- which makes sense if the UDS is some kind of concentration PER MASS OF FLUID. (Not, for example, per volume of space.) It could very well be that you actually want a factor of fluid density in the rate law, either sneaked in as a constant (if appropriate) or looked up from the face or (more likely) from the neighbouring cell.

It takes quite a lot of care to find the correct value of MAGIC_CONSTANT from whatever rate data you have available. I really do stress the requirement for test cases here: find a simulation set-up where you can calculate what should be happening, and then verify that it is actually happening in the model.

Good luck!
Ed
obscureed is offline   Reply With Quote

Old   April 20, 2018, 14:19
Default
  #9
New Member
 
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 9
rafash2 is on a distinguished road
Really thank you very very much!!
It is true that code doesn't seem very complex.
I will tell you if it works ok
Regards!!
rafash2 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 for suction velocity on a wall ahmed425 Fluent UDF and Scheme Programming 0 November 2, 2017 09:50
Replicating Scalable Wall Function with a UDF yousefaz FLUENT 0 August 4, 2017 02:30
Wave Generation via Flapping Wall UDF LenDawg0220 Fluent UDF and Scheme Programming 5 June 26, 2017 16:05
Accessing wall shear stress using UDF Robert Fluent UDF and Scheme Programming 2 July 31, 2013 08:34
[ICEM] Export ICEM mesh to Gambit / Fluent romekr ANSYS Meshing & Geometry 1 November 26, 2011 12:11


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