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

Help with setting up UDF/UDS for diffusivity

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 6 Post By obscureed

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 25, 2018, 01:29
Default Help with setting up UDF/UDS for diffusivity
  #1
New Member
 
MCKoz
Join Date: Apr 2018
Posts: 9
Rep Power: 8
dinknflicka is on a distinguished road
Hi all, I am new to fluent, and this is my first post to this forum.

I am attempting to do a multiphase flow simulation for my geometry. This involves a porous zone, as well as another non-porous zone. I am attempting to use UDS to define the diffusivity in each of these regions.

Currently I have selected for there to be two UDS, one for each region. Additionally I have written a UDF, and have a macro for each region. Now, I'm not sure where to go from here. I'm confused on how to associate the UDF code to the UDS that I want to track, which is the diffusion of the secondary phase throughout the volume. The only thing I can see to do is to attach my compiled UDF to 'UDS diffusivity' for the secondary material. However, this does nothing for the simulation, and the UDS has no calculations.

Could someone help me to understand how I can apply my Diffusivity code for each zone and then monitor the diffusion in CFD-Post. Any help is much appreciated!
dinknflicka is offline   Reply With Quote

Old   April 25, 2018, 05:09
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Quote:
Originally Posted by dinknflicka View Post
Hi all, I am new to fluent, and this is my first post to this forum.

I am attempting to do a multiphase flow simulation for my geometry. This involves a porous zone, as well as another non-porous zone. I am attempting to use UDS to define the diffusivity in each of these regions.

Currently I have selected for there to be two UDS, one for each region. Additionally I have written a UDF, and have a macro for each region. Now, I'm not sure where to go from here. I'm confused on how to associate the UDF code to the UDS that I want to track, which is the diffusion of the secondary phase throughout the volume. The only thing I can see to do is to attach my compiled UDF to 'UDS diffusivity' for the secondary material. However, this does nothing for the simulation, and the UDS has no calculations.

Could someone help me to understand how I can apply my Diffusivity code for each zone and then monitor the diffusion in CFD-Post. Any help is much appreciated!
what do you mean under UDS and UDF?
UDF is a user-defined functions, actually it is a code
UDS is user-defined scalar, which is defined through UDF
frankly speaking, I do not understand what is a problem. Once you have both codes for UDS and some other code (you called UDF), you may put everything into one file., or different files with links.

You may monitor any variable defined in UDF using UDMIs

best regards
AlexanderZ is offline   Reply With Quote

Old   April 25, 2018, 14:02
Default
  #3
New Member
 
MCKoz
Join Date: Apr 2018
Posts: 9
Rep Power: 8
dinknflicka is on a distinguished road
Hi,

Thanks for your reply. So I suppose I already have both codes for my UDS with the code I have written. One Diffusivity macro for each zone.

I've compiled my code and imported into fluent, and then selected for two UDS in my setup. Now I'm wondering how I associate the code with the UDS or 'define it through UDF' as you mentioned.

Additionally, how would I apply one macro to one zone, and then one macro to the other zone?
dinknflicka is offline   Reply With Quote

Old   April 25, 2018, 21:01
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Unfortunately, I don't understand your points.
May be anybody else will help you.

If you need my help, put here sketch of your domain and codes, I will try to help you

best regards
AlexanderZ is offline   Reply With Quote

Old   April 26, 2018, 09:11
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Quote:
I am attempting to use UDS to define the diffusivity in each of these regions.
This is wrong.
The UDS is a scalar that is diffusing. The UDS should have a diffusivity, not be used to define a diffusivity.

You can however define the diffusivity for your UDS using a UDF.

So the UDF that you used, could be used for the diffusivity of your UDS.

But you also have to give boundary conditions for your UDS. If you did not change any boundary conditions for your UDS, you will use the default boundary conditions, which are very boring, and result in a solution which is zero everywhere.

I don't know exactly what you want, but I can make two guesses:
A. You are attempting to use a UDF to define the diffusivity of regular fluids in each of these regions.
In this case: get rid of the UDS's.
B. You are attempting to use a UDF to define the diffusivity of a UDS in each of these regions.
In this case: you only need one UDS, and you need to add boundary conditions for your UDS.
pakk is offline   Reply With Quote

Old   April 26, 2018, 14:01
Default
  #6
New Member
 
MCKoz
Join Date: Apr 2018
Posts: 9
Rep Power: 8
dinknflicka is on a distinguished road
Thanks for your reply! Pakk, I think I am understanding better now. Based on your comments, I am attempting to use a UDF to define the diffusivity of a UDS.

So in that case, I suppose I just need the one UDS, and my boundary condition could essentially be the inlet value of the mass fraction?

Then I just simply need to attach my DEFINE_DIFFUSIVITY UDF to the material properties for whatever the primary fluid is (i.e. water). Does this sound correct?

Again, I thank you for your comments!
dinknflicka is offline   Reply With Quote

Old   April 27, 2018, 12:08
Default
  #7
Senior Member
 
Join Date: Sep 2017
Posts: 246
Rep Power: 11
obscureed is on a distinguished road
Hi dinknflicka,

A few quick pointers:

1) You seem to be asking about how to hook the UDFs into the model. It is very true that you can write a UDF and compile it, but it still has zero effect on the model until you use put that UDF into some settings. The settings that you are looking for here are presumably the material properties of the UDS in the fluid. So, go look there (and in the help files) -- it should become more obvious.

2) However, you will find that there is no mechanism for applying one UDF to one zone and another to another. You need to supply one UDF for the property, and decide inside there which value is relevant -- possibly a three-way decision, if you want a third value for zones other than the two you mentioned. So, a sketch of what you want might be this:
Code:
#include "udf.h"
#define ZONE1_ID 4
#define ZONE2_ID 7
DEFINE_DIFFUSIVITY(uds_diff, c, t, i)
{
  real diff;
  if(THREAD_ID(t) == ZONE1_ID)
    diff = 1e-6;
  else if (THREAD_ID(t) == ZONE2_ID)
    diff = 2e-6;
  else
    diff = 1e-5;
  return diff;
}
These zone ID numbers are found in the Cell Zone Conditions window in the Fluent session: select the relevant cell zone and you should see a value in a window called ID.

3) The example in the Customisation Manual has two important but subtle details:
Code:
DEFINE_DIFFUSIVITY(mean_age_diff,c,t,i)
 {
    return C_R(c,t) * 2.88e-05 + C_MU_EFF(c,t) / 0.7;
 }
First: to get a UDS diffusivity in units of m2/s like a normal species, you need to add a factor of C_R(c,t), which is density. This is because the transport equations in Fluent for UDS and species differ by a factor of density. So, the first term achieves a diffusivity of 2.88e-5 m^2/s.
Second: if you want your UDS to be dispersed by turbulence, you need to add it yourself to the UDF diffusivity. This is unlike the situation for species. The second term above does this, assuming a turbulent Schmidt number of 0.7.

Good luck!
Ed
pakk, Papes, THA SEANGHAI and 3 others like this.
obscureed is offline   Reply With Quote

Reply

Tags
multi phase flow, user defined function, user defined scalar


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
Fluent Parallelization Problem After AC Power Dropped pawl Hardware 5 November 13, 2016 06:08
using chemkin JMDag2004 OpenFOAM Pre-Processing 2 March 8, 2016 22:38
[snappyHexMesh] determining displacement for added points CFDnewbie147 OpenFOAM Meshing & Mesh Conversion 1 October 22, 2013 09:53
Cells with t below lower limit Purushothama Siemens 2 May 31, 2010 21:58
Warning 097- AB Siemens 6 November 15, 2004 04:41


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