-
-
June 3, 2019 at 11:27 pm
Weiqiang Liu
SubscriberHi 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
-
June 4, 2019 at 4:39 am
Amine Ben Hadj Ali
Ansys EmployeeYes. You need to write an UDF which allows different diffusivities. -
June 4, 2019 at 3:22 pm
Weiqiang Liu
SubscriberHi 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.Â

Â
-
June 4, 2019 at 3:57 pm
Amine Ben Hadj Ali
Ansys EmployeeMake 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. -
June 4, 2019 at 4:58 pm
Weiqiang Liu
SubscriberThanks 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
-
June 5, 2019 at 4:40 am
Amine Ben Hadj Ali
Ansys EmployeeYes 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. -
June 5, 2019 at 3:52 pm
Weiqiang Liu
SubscriberHi 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!
-
June 5, 2019 at 4:52 pm
Amine Ben Hadj Ali
Ansys EmployeeWhat do you mean? -
June 5, 2019 at 5:04 pm
Weiqiang Liu
SubscriberI 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
-
March 9, 2020 at 5:41 pm
Sowmiya
SubscriberHi 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
-
March 13, 2020 at 9:00 am
Weiqiang Liu
SubscriberHi,Â
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
-
April 7, 2020 at 7:06 am
Sowmiya
SubscriberHi Sir,
   Thank you for the reply and supporting me.
Â
Regards
Sowmiya
-
April 23, 2020 at 6:21 pm
yijecho
SubscriberHello 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
Â
-
April 25, 2020 at 2:45 pm
Weiqiang Liu
Subscriberhi,
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
-
April 27, 2020 at 2:58 am
yijecho
SubscriberHi,
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?
-
April 27, 2020 at 3:15 am
Weiqiang Liu
SubscriberI 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.
-
April 27, 2020 at 3:50 am
yijecho
SubscriberThank 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!
-
April 27, 2020 at 6:53 am
Weiqiang Liu
SubscriberYes, 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Â
-
May 20, 2020 at 3:14 am
Yuvraj
SubscriberHi 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.Â
Â
-
May 20, 2020 at 6:26 am
Weiqiang Liu
SubscriberhiÂ
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
-
- The topic ‘How to define diffusivity of species in porous zone with DEFINE_DIFFUSIVITY?’ is closed to new replies.
-
4904
-
1588
-
1386
-
1242
-
1021
© 2026 Copyright ANSYS, Inc. All rights reserved.