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

Density based on temperature and species mass fraction UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 3, 2021, 03:24
Default Density based on temperature and species mass fraction UDF
  #1
New Member
 
Antton
Join Date: Nov 2019
Posts: 11
Rep Power: 6
antton is on a distinguished road
Hello,

I am writting an UDF to calculate the density of my mixture taking into account the temperature and species mass fraction.

When I consider only the temperature change the simulation is OK. However when I consider both (temperature and species mass fraction) I have problems solving the simulation.

Can someone help me?

Thanks

*****

DEFINE_PROPERTY(density_mixture,c,t)
{
/* Definir variables */

int i = 0;
Material *sp;

real density;
real temp;
real conc;

real alpha;
real beta;
real homogeneous_density;
real homogeneous_concentration;

alpha = 0.001222587;
beta = 0.275;
homogeneous_density = 748.435;
homogeneous_concentration = 0.5167;

/* Temperatura & concentracion de celda */

temp = C_T(c,t);

mixture_species_loop(THREAD_MATERIAL(t),sp,i)

{
conc = C_YI(c,t,i);
}

/* Ecuación */

density = homogeneous_density*((1)-(alpha*(temp- 298.16))+(beta*(conc-0.5167)));

/* Result return */

return density;
}
antton is offline   Reply With Quote

Old   September 4, 2021, 01:54
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
"problems solving the simulation"

This can mean many things... Crash, doesn't converge, converges too slow, converges to a wrong solution... What do you mean here?
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   September 4, 2021, 03:12
Default
  #3
New Member
 
Antton
Join Date: Nov 2019
Posts: 11
Rep Power: 6
antton is on a distinguished road
I have problems with the simulation because it does not convergence, the residuals go up.

The question is that if I put in the UDF only the part of the temperature and alpha and eliminate the part of the concentration the simulation convergence correctly. Why can happen this?

I want to consider both parts (temperature and concentration) and I dont know where is the error.

Thanks
antton is offline   Reply With Quote

Old   September 4, 2021, 04:16
Default
  #4
Member
 
Guvennergiz's Avatar
 
Guven Nergiz
Join Date: Jul 2020
Location: Turkey
Posts: 52
Rep Power: 5
Guvennergiz is on a distinguished road
You want to read overall temperature of mixture or temperature of every fractions in the mixture?
Guvennergiz is offline   Reply With Quote

Old   September 4, 2021, 08:44
Default
  #5
New Member
 
Antton
Join Date: Nov 2019
Posts: 11
Rep Power: 6
antton is on a distinguished road
Hi

I want to read the temperature of each cell and also the mass fraction of each cell. Ones I know that information, I want to calculate the density using the UDF that I send.

If I consider only the temperature, the simulation runs correctly but when I use the mass fraction macro the simulation doesnt convergence.

Thanks
antton is offline   Reply With Quote

Old   September 4, 2021, 10:35
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
But the mass fraction of what? Your code is not clear about it.

You have a mixture. Your mass fractions will sum to 100%. In your code, you calculate them all, and use the last calculated mass fraction. You're lucky if that is the one you want...
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   September 4, 2021, 11:29
Default
  #7
New Member
 
Antton
Join Date: Nov 2019
Posts: 11
Rep Power: 6
antton is on a distinguished road
Hi

I want use the mass fraction of my first component in each cell to calculate the density later.

conc = C_YI(c,t,i);

With this can I calculate that eliminating the loop part?

I want to know the mass fraction of my first component (i) in each cell.

Thanks
antton is offline   Reply With Quote

Old   September 4, 2021, 14:04
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
The first component is i=0.

conc = C_YI(c,t,0);
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   September 4, 2021, 16:10
Default
  #9
New Member
 
Antton
Join Date: Nov 2019
Posts: 11
Rep Power: 6
antton is on a distinguished road
Yes I know that and in the UDF I define int i = 0. So if I eliminate the loop the other part is correct in the UDF? If I eliminate the loop am I considering the mass fraction in each cell of the first species to calculate then the density?

Thanks
antton is offline   Reply With Quote

Old   September 4, 2021, 17:36
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
If with "the loop" you mean "mixture_species_loop(THREAD_MATERIAL(t),sp,i) ", then yes.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   September 6, 2021, 02:57
Default
  #11
New Member
 
Antton
Join Date: Nov 2019
Posts: 11
Rep Power: 6
antton is on a distinguished road
Hi again,

I eliminte the "loop" part butI have the same problems, the simulation doesnt convergence.

If I only consider the temperatura and I delete the part in wich I take into account the mass fraction of my first species, the UDf that I use is the following one and the simulation convergence correctly:

#include "udf.h"

DEFINE_PROPERTY(density_mixture,c,t)
{
/* Definir variables */

int i = 0;
Material *sp;

real density;
real temp;
real conc;

real alpha;
real beta;
real homogeneous_density;
real homogeneous_concentration;

alpha = 0.001222587;
beta = 0.275;
homogeneous_density = 748.435;
homogeneous_concentration = 0.5167;

/* Temperatura & concentracion de celda */

temp = C_T(c,t);

/* Ecuación */

density = homogeneous_density*((1)-(alpha*(temp- 298.16)));

/* Result return */

return density;
}

Why can happen this? Maybe is because the density and mass fraction equations are related and is not posible to calculate the density taking into account the mass fraction?

Thanks
antton is offline   Reply With Quote

Reply


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
Species Mole and Mass Fraction Macro combustion FLUENT 18 February 5, 2024 12:23
Error message: Insufficient Catalogue Size Paresh Jain CFX 32 February 3, 2021 03:37
problem in temperature and liquid fraction value in the udf durg FLUENT 0 October 23, 2018 01:52
convective term of temperature and species mass fraction comingdaytime OpenFOAM Post-Processing 0 October 18, 2017 12:15
Accessing the species mass fraction for particles data in UDF mac_09 FLUENT 17 August 9, 2017 20:15


All times are GMT -4. The time now is 08:34.