|
[Sponsors] |
April 16, 2018, 07:11 |
UDF for trapped particles in a wall
|
#1 |
New Member
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 12 |
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!! |
|
April 16, 2018, 11:06 |
|
#2 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
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 |
|
April 16, 2018, 13:32 |
|
#3 |
New Member
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 12 |
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!! |
|
April 16, 2018, 13:40 |
|
#4 |
New Member
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 12 |
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 |
|
April 16, 2018, 14:09 |
|
#5 |
New Member
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 12 |
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... |
|
April 18, 2018, 09:26 |
|
#6 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
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 |
|
April 19, 2018, 06:11 |
|
#7 |
New Member
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 12 |
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!! |
|
April 20, 2018, 12:12 |
|
#8 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
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) } 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 |
|
April 20, 2018, 15:19 |
|
#9 |
New Member
Rafael Agujetas
Join Date: Jul 2014
Posts: 13
Rep Power: 12 |
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!! |
|
|
|
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 10:50 |
Replicating Scalable Wall Function with a UDF | yousefaz | FLUENT | 0 | August 4, 2017 03:30 |
Wave Generation via Flapping Wall UDF | LenDawg0220 | Fluent UDF and Scheme Programming | 5 | June 26, 2017 17:05 |
Accessing wall shear stress using UDF | Robert | Fluent UDF and Scheme Programming | 2 | July 31, 2013 09:34 |
[ICEM] Export ICEM mesh to Gambit / Fluent | romekr | ANSYS Meshing & Geometry | 1 | November 26, 2011 13:11 |