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

Advective flux field not divergence-free in DEFINE_UDS_FLUX

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 22, 2020, 06:31
Default Advective flux field not divergence-free in DEFINE_UDS_FLUX
  #1
New Member
 
Sergio
Join Date: May 2020
Location: Toulouse
Posts: 5
Rep Power: 2
SJRC is on a distinguished road
Hello,

I am trying to define a user-defined scalar to describe the transport of a suspension in a channel with an obstacle in Fluent. Because there are distance-interactions between the obstacle and the colloids, there is an extra term to the species transport equation. The modified equation is:


\frac{\partial\rho\phi}{\partial t} + \underline{\nabla} . [\rho\phi(\underline{v}+\underline{\nabla} \Pi)] = -\underline{\nabla} . \underline{J}

where rho is the density (constant in my case), phi is the mass fraction of the species, v is the velocity of the fluid, Pi is a "potential" representing the distance-interactions with the obstacle and J is the diffusive flux. The problem I am facing is that, even though the velocity is divergence-free, the gradient of Pi is not. And according to the 2013 UDF manual I retrieved, one cannot include an advective flux that is not divergence-free.


Does anyone know if that's still true even for the most recent versions? Or is it possible now to set advective fluxes that are not divergence-free under DEFINE_UDS_FLUX?



In case it is really not possible to do so, I would think it is because the software does something like the following, where psi is the advective flux:


\underline{\nabla} . [\underline{\psi}\phi] = \phi \times \underline{\nabla} . \underline{\psi} + \underline{\psi} . \underline{\nabla}\phi \overbrace{=}^{assuming \psi divergence-free} \underline{\psi} . \underline{\nabla}\phi



Is that really what it does? If so: can I still use my non-divergence-free term and add an implicit source term (phi * divergence(psi)) in order to correct my equation?


Thanks in advance!
SJRC is offline   Reply With Quote

Old   May 24, 2020, 06:57
Default Divergence Free Field
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,549
Blog Entries: 1
Rep Power: 28
vinerm will become famous soon enough
The requirement of divergence free field is not imposed by Fluent but by physics. If a source term is being modeled, instead of the phenomenon being simulated, then field may not be divergence free. However, if that source term is neglected, then the field must be divergence free else the continuity equation will not be satisfied. So, the idea of including source term to ensure conservation should work.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared on the Forum
vinerm is online now   Reply With Quote

Old   May 25, 2020, 09:06
Default
  #3
New Member
 
Sergio
Join Date: May 2020
Location: Toulouse
Posts: 5
Rep Power: 2
SJRC is on a distinguished road
Dear Vinerm,


Thank for your reply. However, I am not sure which continuity equation will not be satisfied. The fluid's continuity equation


\underline{\nabla} . \rho \underline{v} = 0


is imposed to my model. And the continuity equation for the species is the one I wrote in my question, which is satisfied (imposed).
SJRC is offline   Reply With Quote

Old   May 25, 2020, 09:51
Default Continuity
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,549
Blog Entries: 1
Rep Power: 28
vinerm will become famous soon enough
Conservation of the scalar you are trying to solve, the UDS. Divergence free means that for each cell the inlet flux must be equal to outlet flux. If that is not the case, scalar will end up showing unrealistic values in the domain.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared on the Forum
vinerm is online now   Reply With Quote

Old   May 25, 2020, 11:16
Default
  #5
New Member
 
Sergio
Join Date: May 2020
Location: Toulouse
Posts: 5
Rep Power: 2
SJRC is on a distinguished road
But again, the conservation for the scalar I am trying to solve is given by the following equation:


\frac{\partial \rho\phi}{\partial t} + \underline{\nabla} . [\rho\phi (\underline{v}+\underline{\nabla}\Pi)] = -\underline{\nabla} . \underline{J}


Above equation is satisfied, which means my scalar is actually being conserved. I have attached a figure showing the derivation of the mass balance equation over a control volume.



Perhaps you are refering to the divergence of the overall species flux at stationary state? I.e.:


\underline{\nabla} . [\rho\phi (\underline{v}+\underline{\nabla}\Pi)+\underline{J}] = 0 at stationary state


If that is the case, I agree with you. But what is written in the UDF manual is that the advective term \underline{\psi} = \rho(\underline{v}+\underline{\nabla}\Pi) has to be divergence-free. And I am still not convinced that is a condition imposed by physics.
Attached Images
File Type: jpg balance.jpg (83.7 KB, 3 views)
SJRC is offline   Reply With Quote

Old   May 25, 2020, 12:05
Default Advective Flux of UDS
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,549
Blog Entries: 1
Rep Power: 28
vinerm will become famous soon enough
The statement does not talk about advection term but the flux returned by the UDF. The flux returned by the UDF if summed over each cell must be zero. However, as mentioned earlier, the premise for this statement is that there is no source. Since your case has a source term, the condition would not be applicable, but might require correction such that if there is no source the flux is 0.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared on the Forum
vinerm is online now   Reply With Quote

Old   May 25, 2020, 13:39
Default
  #7
New Member
 
Sergio
Join Date: May 2020
Location: Toulouse
Posts: 5
Rep Power: 2
SJRC is on a distinguished road
There is no actual source term in my case study. The "source term" appearing after developing \underline{\nabla}.[\underline{\psi}\phi] (c.f. last equation in my first message) is just a "fantasy" source term. According to the mass balance illustration I have shown in the figure attached to my previous reply, we can see that there is no real source term. Only fluxes contribute to the mass balance equation.


Further, according to UDF manual, DEFINE_UDS_FLUX needs to return \underline{\psi}.\underline{A} (c.f. screenshot attached), where A refers to the face normal vector and \underline{\psi}=\underline{v}+\underline{\nabla}\Pi in my case. And having the sum of \underline{\psi}.\underline{A} over the faces of a cell being 0 is equivalent to saying that \underline{\nabla} . \underline{\psi} = 0. Therefore, I believe I am correct when I say that Fluent requires \underline{\psi} (which I'm calling the advective term) to be divergence-free.






To avoid any confusion from my part, would you mind writting down which term exactly do you expect to be divergence-free?
Attached Images
File Type: jpg screenshot.jpg (69.1 KB, 5 views)
SJRC is offline   Reply With Quote

Old   May 26, 2020, 07:10
Default Advection Term
  #8
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,549
Blog Entries: 1
Rep Power: 28
vinerm will become famous soon enough
Yes, it is \psi or \rho\psi, if compressible flow, that needs to be divergence free, but since you have two terms that are responsible for conveying the species or whatever the scalar represents, whole of the term needs to be divergence free. Since, from continuity equation, \rho\vec{v} is divergence free, so, the second component should be divergence free on its own accord, i.e., gradient of your distance interaction should be divergence free as well. You mentioned in the first post that it is not divergence free. In that case, there will always be some scalar either left-over or taken-from each cell. It is quite possible that is the desired outcome of the distance interaction. As long as these over or undershoots are bounded, there should not be much issue, but in any case, you should be able to explain the physical significance of the distance interaction in increasing or reducing scalar in each cell.

In my view, you should run one simulation and observe the convergence as well as imbalance of UDS.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared on the Forum
vinerm is online now   Reply With Quote

Old   May 27, 2020, 14:07
Default
  #9
New Member
 
Sergio
Join Date: May 2020
Location: Toulouse
Posts: 5
Rep Power: 2
SJRC is on a distinguished road
Thank you for your answer, Vinerm. I have followed your advise and simulated a case study as follows:


1) 2D closed-box domain
2) Stagnant fluid
3) Advection field not divergence-free: \underline{\psi}=\rho\underline{\nabla}\Pi
4) Initial concentration of particles \phi=0.1


Profile at steady state is attached. It turns out that the scalar is conserved (average of phi is equal to 0.1 at steady state). And comparing Fluent with an open-source solver, both give the same results at steady state. So I think I'll just ignore the warning in UDF manual for now.
Attached Images
File Type: jpg distribution_colloide.jpg (58.5 KB, 1 views)
SJRC 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
How to calculate divergence of a field in CFD-post shafa_hn CFX 1 December 22, 2017 17:15
fluent divergence for no reason sufjanst FLUENT 2 March 23, 2016 16:08
foamCalc: Fatal io error calculating divergence of velocity field rendagar OpenFOAM Running, Solving & CFD 0 February 4, 2014 10:20
Divergence Free on the Magnetic Field Valdemir Main CFD Forum 1 March 19, 2003 18:33
help:spectral methods & divergence free functionsn D. Puigjaner Main CFD Forum 1 August 28, 2000 10:06


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