Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

How to define diffusivity of species in porous zone with DEFINE_DIFFUSIVITY?

    • Weiqiang Liu
      Subscriber

      Hi all,


      I want to assign effective diffusion coefficient of species in porous zone with DEFINE_DIFFUSIVITY(mass_diff,c,t,i). In this macro, variable i represent species index which is passed by fluent solver to UDF. This means when I hook the UDF, species index i is passed to UDF by fluent solver. 


      However, I use kinetic theory to calculate mass diffusion coefficient for single species. In other words, L-J parameters are imported to calculate mass diffusion coefficient. My purpose is to use normal diffusion in non-porous zone while effective diffusion in porous zone. 


      Seems like I can only hook the UDF in mixture material panel. My question is does fluent define mass diffusion coefficient for every species even the UDF is hooked in mixture material panel?


      Best regards


      weiqiang

    • Amine Ben Hadj Ali
      Ansys Employee
      Yes. You need to write an UDF which allows different diffusivities.
    • Weiqiang Liu
      Subscriber

      Hi Amine,


      I can not understand the logic for this macro: DEFINE_DIFFUSIVITY(mass_diff,c,t,i).


      In this macro, there is a species index i, which means i is passed by fluent solver to UDF. When this UDF is hooked in species panel, my UDF knows what i value is. However, I imported L-J parameters for every species to calculate mass diffusion coefficients. Seems like I can only hook my UDF in mixture material panel. I wonder if this is doable. Whether fluent will loop all species if I just hook my UDF in mixture material panel? 


      I put my code below though it can not be loaded with some errors. 


       

    • Amine Ben Hadj Ali
      Ansys Employee
      Make a small test with small UDF just species. In the test try to identify the specie you want to Provide the diffusivity either via Mixture species name the macro is executed for every I specie out of n-1 components. The macro is hooked on the mixture level. There is no need to do a species loop. This is very expensive as the macro will go over the species indexes anyway. Something like if i ==0...

      Always learn to test blocks of UDF on test example and add complexities stepwise. Always write intermediate messages to check and store UDMI.

      Again I do want to remind here that we do not debug UDFs on the community. Even commenting is not always possible.
    • Weiqiang Liu
      Subscriber

      Thanks very much for your concern. You said to loop every species is very expensive. Can I just define a local array in which all species molar weights are stored in this array. Therefore, UDF can access species molar weight directly? 


      Because all species are imported by chemkin files. I know molar weights of every species exactly.


      Best 


      weiqiang

    • Amine Ben Hadj Ali
      Ansys Employee
      Yes you can do that if you want. Actually I wanted to say making a cell loop inside the macro does not make sense. Species loop is not a cell loop.
    • Weiqiang Liu
      Subscriber

      Hi Amine,


      I modified my code and removed the species loop. Though it still can not be loaded. I'll check further. Thanks very much for your concern!

    • Amine Ben Hadj Ali
      Ansys Employee
      What do you mean?
    • Weiqiang Liu
      Subscriber

      I defined all species molar weight as a global array mw. In the UDF, I just access molar weight of every species with mw. I don't know if this logic is right or doable in fluent?


      Best 


      Weiqiang

    • Sowmiya
      Subscriber

      Hi Sir,


          Did you find a way to determine molecular weight in array? If so please kindly give me few suggestions. I too face the same problem.


       


      Thanking you


      Regards


      Sowmiya

    • Weiqiang Liu
      Subscriber

      Hi, 


      Sorry, I have not logged in for a very long time. What do you mean by determining molecular weight in array? The unit? Or something else.


      fluent can loop all species in the system automatically. Therefore, you can just use ‘i’ as index and define a molecular weight array. Fluent can loop all species with this index ‘i’


      Best regards


      Weiqiang

    • Sowmiya
      Subscriber

      Hi Sir,


           Thank you for the reply and supporting me.


       


      Regards


      Sowmiya

    • yijecho
      Subscriber

      Hello Sir,


      I am also trying to assign effective diffusivity for the porous zone. It seems Fluent only apply the diffusion term based on the relative viscosity. I cannot find this value for the gas species from any references.


      Can you please share the UDF that you had used for the porous zone? I am very new to the UDF, so I am facing a lot of difficulties in writing code by myself...


      Best regards


      Yije


       

    • Weiqiang Liu
      Subscriber

      hi,


      I used L-J parameters from CHEMKIN database to calculate effective diffusion coefficients in porous zone. Those equations can be found in literature. I am not very sure if my results are right. What I can only tell you is fluent can loop all species automatically. You don't have to loop all species by yourself.


      Best regards

    • yijecho
      Subscriber

      Hi,


      I know what the L-J parameters are, but the parameters are known for calculating the diffusion coefficient of the mixed gas, not the effective diffusivity. Do you know how to add effective diffusivity for the porous zone that has mass diffusivity and Knudsen diffusivity of the mixed gas and the tortuosity of the porous zone? I have seen that you were looking for this kind of diffusivity. Does the CHEMKIN have a function to consider all these parameters?

    • Weiqiang Liu
      Subscriber

      I mean you have to calculate effective diffusivity all by your self. You can use UDF to access mole fraction of one particular species in the mixture. Also, the porosity and tortuosity of porous media are known. You just need to write all the equations in UDF. 


      You need to calculate binary diffusion coefficients firstly.

    • yijecho
      Subscriber

      Thank you very much for your kind reply. Where would be the UDF hooked in? Would it be mass diffusivity in the mixture material definition?


      I thought briefly about the UDF that first, I will have to write the UDF to access the species and then calculate the molecule diffusion coefficient (binary) of the mixture. The second will be to calculate the effective diffusion coefficient by using the porosity, virtuosity, and molecule and Knudsen diffusion coefficients. Is this the right sequence?


      I appreciate any additional detailed comments on the UDF!

    • Weiqiang Liu
      Subscriber

      Yes, you just need to hook it in mixture properties panel. Fluent will loop all species automatically for you. 


      Yes, it’s the right sequence. You just need to assign effective diffusion and normal diffusion in porous and non-porous zone.


      Best 

    • Yuvraj
      Subscriber

      Hi Weiqiang, I too am modeling porous media, and want to write UDF for an effective diffusion coefficient for the porous zone.  I had a few doubts regarding the same. It would be very helpful if you could clarify them.


      1) I understood that we need to hook the UDF to the mixture panel. My question is while calculating the mixture's diffusion coefficient using individual species coefficients, which methodology will fluent follow? Will it automatically use kinetic theory method? I want to use that.


      2) Also, could you describe the errors u were facing while loading the code you wrote above and how did you eliminate them?


      Thank you for taking your time in answering this query. Really appreciated. 


       

    • Weiqiang Liu
      Subscriber

      hi 


      fluent can not use kinetic theory automatically. You have to calculate it with kinetic theory in your UDF.


      regarding to the errors, maybe it's the unit of variables in those equations. 


      Best regards


      Weiqiang

Viewing 19 reply threads
  • The topic ‘How to define diffusivity of species in porous zone with DEFINE_DIFFUSIVITY?’ is closed to new replies.