
[Sponsors] 
September 2, 2013, 15:00 
UDF:diffusivitystrain rate

#1 
Senior Member
Join Date: Feb 2011
Posts: 140
Rep Power: 8 
Dear all,
I have got a probelm with a UDF describing the mass diffusivity of my species which should be calculated using the strain rate (or shear rate) of my fluid. I also used the strain rate for the calculation of the viscosity of the fluid and this seems to work fine (when I take a look at the results), but for any reason the strain rate seems to be set to zero for the calculation of the diffusivity (the value of the diffusivity is constant 7.95e11 m^2/s even though the strain rate as shown at the contour plots lies in the range of 0.3 and 4000 1/s) This is the UDF I am using (I also tried several variations): #include "udf.h" #include "math.h" #define MU_INF 0.035 #define N_INF 1 #define DELTA_MU 0.25 #define DELTA_N 0.45 #define A 50 #define B 3 #define C 50 #define D 4 #define Dconst 1.5e10 real mu; real lambda; real n; real strain; real d; DEFINE_PROPERTY(cell_viscosity, c, t) { strain = C_STRAIN_RATE_MAG(c, t); lambda = MU_INF+DELTA_MU*exp((1.+fabs(strain)/A)*exp(B/fabs(strain))); n = N_INFDELTA_N*exp((1.+fabs(strain)/C)*exp(D/fabs(strain))); mu = 0.1*lambda*pow(fabs(strain),(n1.)); return mu; } DEFINE_DIFFUSIVITY(diffusivity, c, t, i) { strain = C_STRAIN_RATE_MAG(c, t); d = 0.53*Dconst+5.292e9*strain; return d; } Does anybody have an idea? Another question is: is the strain rate and the shear rate calculated/read out the same way in Fluent (C_STRAIN_RATE_MAG)? Iam really thankful for any idea! Lilly 

September 4, 2013, 04:48 
problems with diffusivity UDF  UDS?

#2 
Senior Member
Join Date: Feb 2011
Posts: 140
Rep Power: 8 
Dear all,
I didn't solve the probelm yet and I am thankful for any idea! Another thing is: I am a little confused about the UDS. Do I always have to specify a UDS if I am modelling a changing mass diffusivity as mentioned in my UDF? Or do I not need to specify a UDF since I am using the "Species Transport" model anyway? Does sombebody have a good explanation about what UDS are and what they are for (since I was a little confused about the information I received at the Fluent manual). Thank you for any hint! Lilly 

September 8, 2013, 13:01 

#3 
Senior Member
AA Azarafza
Join Date: Jan 2013
Posts: 219
Rep Power: 7 
@ Lilly
User Defined Scalars (UDS) are used to solve any arbitrary generic transport equations, something like species transport equations. You can use species transport equations to solve only mass fractions of species, but you can use UDS to solve any transport equations you want, for instance, you can use them to solve electric potential or magnetic field or injecting a tracer into media to obtain RTD. Fluent allows you to define up to 50 UDS. An arbitrary generic Scalar( UDS) has a form like this: As you see the left hand side of the generic equation has three terms. The first one is used in a transient (if you need to consider time), the second term is convective flux and the third one is diffusive flux. The right hand term is source which can be defined depending on your problem, for instance, if your scalars are consumed or produced. is diffusivity which should be defined by user. it can be considered as isotropic or anisotropic. An anisotropic diffusivity is defined as a tensor. There are several methods for diffusivity in Fluent, you can access them via Fluent material panel. F, is flux function which in case of mass flow, it is defined as multiplication of density by velocity. For other cases should be defined separately. How to run a UDS in Fluent: To run UDS in Fluent, first define the numbers of UDS in Define/ User defined/ Scalars. UDS index is used to recognize the UDSs and it starts from zero. It means that for instance, the second UDS has index 1, the fourth UDS has index 3 and so on. You need to select the solution zones for your scalars as well. If you interested in considering flux function, then define it too, otherwise leave it as none (In this case you only solve the diffusion term). By doing this, you'll be directed to material panel where you need to define the diffusivity for your scalars as I mentioned above. One more thing, you have to adjust the scalars on wall boundaries of your solution zones too either as a specified value or flux. That's a brief procedure of defining a UDS. Hope it helps Attached Thumbnails Hope it helps
__________________
Regard yours 

September 9, 2013, 03:10 

#4 
Senior Member
Join Date: Feb 2011
Posts: 140
Rep Power: 8 
Thank you so much for your information about UDS, AA Azarafza!
This was really helpful! If I got it right, I do not have to use a UDS for the simulation a simple species transport, at which I am interested in the mass fraction and transport of the species inside a fluid? But is it also fine just to define the diffusivity of the mass via UDF as shown in the UDF above (and do not consider any UDS)? Furthermore, I realized for any reason the UDF shown above for diffusivity seems to be working: The areaaveraged diffusivity in several planes is changing depending on the shear rate. However, the contour plot is still not working and just shows a constant value for the diffusivity for the whole geometry! Might this be a bug?! Thank you for any idea! Lilly 

September 9, 2013, 09:33 

#5 
Senior Member
AA Azarafza
Join Date: Jan 2013
Posts: 219
Rep Power: 7 
@ Lilly
Regarding to UDF for diffusivity, yes you right, there's no necessity to use UDS if you want to model only a mass fraction transport equation. But, you can do it by UDS as well. If you use species transport model, the only thing you have to do is that define an appropriate diffusivity model (mass diffusivity in material panel). In addition to default options defined in Fluent, you can define your own model using UDF. As far as I know, UDF models in Fluent are good. For instance, you can use Maxwellstefan model, Multicomponent model. Even you can define the diffusivity as isotropic or anisotropic. It's possible to define diffusivity for any species separately. Have a look at the user guide. You can get even more there. Respecting to the last question, you claim that there's a difference in diffusivity on planes but the contour is constant. I wonder how you prove that the values are changed? Are the results the same when you uncheck the global option in contour window?
__________________
Regard yours Last edited by A CFD free user; September 9, 2013 at 11:57. 

September 10, 2013, 08:00 

#6 
Senior Member
Join Date: Feb 2011
Posts: 140
Rep Power: 8 
Thank you again, AA Azarafza!
I attached a pic of the lam. diffusion coeff. inside my geometry (it didn' t make a difference whether the global range was switched on or off). At the bottom there are the values of the lam diffusion coeff. in a plane perpendicular to the flow direction for the same time step area. I also recorded the strain rate and it perfectly fits the UDF equation for the diffusion coeff. as recorded in the plane. But as you can see at the contour plot there is just a single (wrong with respect to the diffusion equation) value shown for the whole area. Do you have any idea why this happens? Thank you for any help! Lilly 

September 10, 2013, 23:04 

#7 
Senior Member
AA Azarafza
Join Date: Jan 2013
Posts: 219
Rep Power: 7 
@ Lilly
It's sort of weird. Check out several new surfaces in different distances. Uncheck "Auto range" and try the values individually and see if it changes.
__________________
Regard yours 

December 17, 2013, 14:06 

#8 
Member
Peter Aestas
Join Date: Dec 2013
Posts: 64
Rep Power: 5 
@AA Azarafza
i am a freshman in using fluent UDF.I already have a general idea about what UDF can do. My project is to simulate plasma motion in magnetic field, and i think i have to use UDS to define magnetic B, Electric E. The equations in my model is rather complicated,Lorentz in momentum equations.B and E will be modified by Maxwell equations. i know the fluent itself will solve mass,momentum and energy equations, my problem is, how should i define my model(contain mass,momentum ,energy and Maxwell electromagnetic equations)? Should i just give diffusivity and source terms of mass,momentum and energy Maxwell by Using UDF(DEFINE_SOURCE and DEFINE_DIFFUSIVITY,right?),and use UDS for E and B? if so,what about E and B in momentum source?How do they abtain values? 

January 30, 2014, 06:57 

#9 
Senior Member
AA Azarafza
Join Date: Jan 2013
Posts: 219
Rep Power: 7 
@Aestas,
You got it exactly. You need to define diffusivity and source terms of mass,momentum and energy using UDF. You must also use UDS to define both B and E equations. Regarding the effects of B and E on momentum, I'm not quite sure how it could affect the momentum but one thing is sure, if you have a porous media, then you must add a source term for momentum equation or you can use porous option already available in Fluent.
__________________
Regard yours Last edited by A CFD free user; February 2, 2014 at 16:43. 

January 31, 2014, 01:27 

#10 
Member
Peter Aestas
Join Date: Dec 2013
Posts: 64
Rep Power: 5 
@AA Azarafza Thk u soooo much!I am working on the source term~.BTW,my geometric model is pretty simple and it's not a porous media, my field is MHD physics.PS:Today is Chinese Spring Festival~I wish you a happy day.


Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
strain rate in UDF  Paulina  FLUENT  11  November 20, 2014 04:06 
Shear Strain Rate  Dave442  Main CFD Forum  5  October 25, 2013 04:08 
strain rate magnitude  ahmadbakri  STARCCM+  1  June 3, 2010 13:03 
Strain rate.  MM?  Main CFD Forum  1  February 15, 2006 09:55 
strain rate at arbitrary position in a cell  K. Kevala  FLUENT  0  February 4, 2004 18:14 