CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   initialization species UDF (https://www.cfd-online.com/Forums/fluent/70460-initialization-species-udf.html)

louiza November 25, 2009 05:19

initialization species UDF
 
Hello everyone,
this UDF syntax of the initialization of different-density of species is it correct?
thank you for your answer

///////////////////////////////////////////
DEFINE_INIT(udf_init_temp, domain)
{
cell_t c,c0,c1,c2,c3,c4;
Thread *t,*t0, *t1, *t2,*t3, *t4;
real coord[ND_ND];

thread_loop_c(t,domain)
{
begin_c_loop_all(c,t)
{
C_CENTROID(coord,c,t);
if (coord[1] < 0.0005)
C_T(c,t) = 10000.0;
C_R(c0,t0)= 1E24; /* densiy of Ar */
C_R(c1,t1)= 2E22; /* density of Ar+ */
C_R(c2,t2)= 1E2; /* density of Ar2+ */
C_R(c3,t3)= 1E2; /* density of Ar3+ */
C_R(c4,t4)= 2E22; /* density of electrons */

}
end_c_loop_all(c,t)
}
}

dmoroian November 25, 2009 07:25

It needs modifications
 
Hi Louiza,
Your udf lacks correct values for c0, c1, c2, c3, c4, t0, t1, t2, t3, t4. It should give you segmentation fault.
First of all, I don't think you can set the density for species, but the mass fraction. In your case, the modification should be as following:
Code:

///////////////////////////////////////////
DEFINE_INIT(udf_init_temp, domain)
{
  cell_t c;
  Thread *t;
  real coord[ND_ND];

  thread_loop_c(t,domain)
  {
      begin_c_loop_all(c,t)
      {
        C_CENTROID(coord,c,t);
        if (coord[1] < 0.0005)
        C_T(c,t) = 10000.0;
        C_YI(c,t,0)= 1E24; /* mass fraction of Ar */
        C_YI(c,t,1)= 2E22; /* mass fraction of Ar+ */
        C_YI(c,t,2)= 1E2; /* mass fraction of Ar2+ */
        C_YI(c,t,3)= 1E2; /* mass fraction of Ar3+ */
        C_YI(c,t,4)= 2E22; /* mass fraction of electrons */

      }
      end_c_loop_all(c,t)
  }
}


louiza November 25, 2009 09:13

Hi Dragos Moroianu

Thank you for your relpy, exactely with this UDF, i receive message error "segmentation violation".

louiza November 25, 2009 09:19

I have just the density of species, how i can calculate mass fraction, have you any idea?
thank you

dmoroian November 25, 2009 09:53

Hello Louiza,
The udf I posted should not crash if you have defined 5 species!

density = mass/volume => mass = density*volume

Dragos

louiza November 25, 2009 10:55

Hi Dragos

Your UDF works fine without error, i have another question please, i need to initialize the mass fraction of species in temperature 10000 K trought UDF, and this same species in 1000 k in the pannel solve>initialize.

can i initialize all species at 1000 and 10 000k througt UDF?

my second question:

mass=density/volume, i 'm very bad in kinetic law:( how a calculate a volume, can i use pv = nRT?

Thank you dragos:)

dmoroian November 26, 2009 04:05

Hi Louiza,
I suspect you have one number for each species, representing the average density of that species in the entire computational domain. It this is the case, then the volume we are talking about is ... the entire domain.
In this approach (transport species), the temperature is defined only for the mixture, not for each species individually. Otherwise, you have to take another approach (Euler/Euler maybe).

Dragos

louiza November 26, 2009 04:56

Hi Dragos

Thank you for your answer.
Good day

louiza


All times are GMT -4. The time now is 11:40.