divergence when mass diffusion UDF is included

  • 50 Views
  • Last Post 12 June 2019
  • Topic Is Solved
Weiqiang Liu posted this 09 June 2019

Hi all,

I wrote an UDF with which to define effective diffusion coefficients in porous zone. In my UDF, molecular mass diffusion coefficients for all species are calculated according to their L-J parameters. Because I have 16 species in the system. The code has nearly 1000 lines. The UDF can be compiled and loaded without any errors. 

However, it causes divergence after some iterations. Since the code is so long, I don't know where to start to check error. I think firstly there should be no syntax error because it can be compiled and loaded without error. 

I think the logic of the code is wrong. Maybe it gives unreasonable mass diffusion coefficients or the loop inside the UDF becomes infinity at some points. In order to find out why, I want ask a question about this macro: DEFINE_DIFFUSIVITY 

what is the sequence for this macro to assign mass diffusion coefficients to every species? does it assign diffusion coefficient for every species in a cell and then go to another cell? Or it just gives diffusion coefficients for a species in the whole domain and then goes to next species?

best regards.

weiqiang

Order By: Standard | Newest | Votes
rwoolhou posted this 10 June 2019

That may well depend on how you structured the code. Do you apply a different DEFINE_DIFFUSIVITY loop for each species then loop over the domain, or? 

Try putting a cap on the returned value at a physically reasonable but "high" value eg 1e-3.  See if that limit is hit after a few iterations. 

Weiqiang Liu posted this 10 June 2019

The truth is I just used one DEFINE_DIFFUSIVITY to loop every species. So this is illogical, right? This macro only loops all cells, not all species?

Best.

Weiqiang

Weiqiang Liu posted this 10 June 2019

I tried to return a constant mass diffusion 1e-3 to all species. Then divergence does not happen anymore. Then this means that return value of my UDF is  physically wrong, right?

Best

Weiqiang

abenhadj posted this 11 June 2019

For 16 species you can provide the input without UDF via GUI if the values are constant for each specie.

Best regards,

Amine

rwoolhou posted this 11 June 2019

Possibly: you need to check each section of the UDF and figure out what's causing the problem. 

Weiqiang Liu posted this 11 June 2019

The diffusion coefficients are temperature and species mass fraction dependent。

Best

Weiqiang Liu posted this 11 June 2019

yes, it must be the UDF returns physically wrong value

abenhadj posted this 11 June 2019

Or it returns correct values but the problem is now getting more stiff with different scales. Check both: the returned values (via C_UDMI) and be a bit conservative with solver settings.

Best regards,

Amine

Weiqiang Liu posted this 11 June 2019

I set the under-relaxation factor of both species and energy to 0.01. Then divergence doesn't happen. is it allowable for such a small under relaxation factor in fluent?

Best

Weiqiang Liu posted this 11 June 2019

I was wrong. No matter how small the under relaxation factor is, divergence will happen.

Does this mean my returned value is not physically right?

Best.

 

abenhadj posted this 11 June 2019

Might be reason for divergence. Smaller URF can helpfull to avoid large changes but does not provide a warranty that it works. Please use coupled solver as well as enable stiff chemistry if not already used. On the other hand quantify the diffusion coefficient.

I wont reduce implicit URF too much. 0.01 is definitely too low. Do not do that.

Best regards,

Amine

Weiqiang Liu posted this 11 June 2019

I enabled the stiff chemistry and coupled solver. It just postponed the divergence to 400 iterations. However, convergence was very good and results seems were approaching reasonable results before divergence.

Best regards.

Weiqiang

rwoolhou posted this 12 June 2019

If you look at the results about 10 iterations before it diverges how are the diffusivity rates etc looking? 

Weiqiang Liu posted this 12 June 2019

I am trying to do this. Can I ask a question related to this? Since I have 16 species and so many cells. Which kind of species and in which cell the mass diffusion coefficient I should check?

Best

Weiqiang

Close