CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   modify volume fraction (https://www.cfd-online.com/Forums/fluent/32388-modify-volume-fraction.html)

kevin chu October 26, 2003 21:11

modify volume fraction
 
Hi, Everyone,

In Eulerian-Eulerian multiphase model in Fluent, I want to modify the value of volume fraction of the primary or second phase while the solver is iterating.

Cloud someone tell me what should I do? Can I use UDF or any other ways?

The Macro C_VOF(c, pt[n])can get the value of volume fraction from the Fluent solver but I cannot modify the value and then return it to the solver. Is it?

The macro DEFINE_PROFILE can only set the value of volume fraction in boudary! It cannot set the value to the whole fluid domain! Is it?

Thank you very much for your kind reply in advance!

Best regards, kevin

ap October 27, 2003 05:34

Re: modify volume fraction
 
If you want to modify the volume fractions of your phases at every iteration, you can use DEFINE_ADJUST, calling it in the Functions Hooks panel.

To set values in the whole domain, you should use a loop.

Here's an example of the structure your function should have:


DEFINE_ADJUST(name, domain)
{
Thread **pt;
Thread *thread;

// Define here your variables

mp_thread_loop_c(thread, domain, pt)
{
cell_t cell;

begin_c_loop_int(cell, thread)
{
//Put here your commands
}
end_c_loop_int(cell, thread)
}
}


All macros in FLUENT can be used both to read and to write a value, so you can use C_VOF(cell,pt[n]) to change volume fractions as follows:

C_VOF(cell,pt[n]) = your value;

Hi :)

ap

kevin chu October 27, 2003 19:56

Re: modify volume fraction
 
Dear ap,

I really appreciate your help. But I still have some trouble:

1. It seems to me that I can only access the variales in the mixture-level domain but not the individual phase domain. In Fluent documentation, I read the following text: For multiphase flows, the domain pointer that is passed to the function by the solver is the mixture-level domain pointer. A DEFINE_ADJUST function does not return a value to the solver.

2. I have tried to use: DEFINE_EXCHANGE_PROPERTY(custom_drag, cell, mix_thread, s_col, f_col) #include "udf.h" #include "stdio.h"

#define pi 4.*atan(1.) #define diam2 3.e-4

DEFINE_EXCHANGE_PROPERTY(custom_drag, cell, mix_thread, s_col, f_col) {

...... p_vof=&C_VOF(cell, thread_g);

*p_vof=0.3;

/*C_VOF(cell, thread_g)=0.2;*/

}

fprintf(ofp,"%11.8lf\n", C_VOF(cell, thread_g)); fclose(ofp); return k_g_s; }

By using the macro above, I can write the drag coefficient, but I have not writen C_VOF(cell, thread_g). Maybe it is a wrong place to write. Do you think so?

Thank you very much,

Best Regards, kevin

ap November 11, 2003 05:48

Re: modify volume fraction
 
If your goal is to change the volume fraction of a phase during iteration, you can't use DEFINE_EXCHANGE_PROPERTY.

The easiest way is to use DEFINE_ADJUST as I showed you in my first answer:


DEFINE_ADJUST(name, domain)
{
Thread **pt;
Thread *thread;

// Define here your variables

mp_thread_loop_c(thread, domain, pt)
{
cell_t cell;

begin_c_loop_int(cell, thread)
{
//Put here your commands
C_VOF(cell, pt[0]) = your_value_for_primary_phase;
C_VOF(cell, pt[1]) = your_value_for_1st_sec_phase;
//...
}
end_c_loop_int(cell, thread)
}
}



In order to access the volume fraction of the first (primary) phase you have to use:

C_VOF(cell, pt[0])

If you have to access to the second phase, use

C_VOF(cell, pt[1])

So, in general use C_VOF(cell, pt[n]), where n = 0 for the primary phase, n=1 for the first secondary phase, n = 2 for the second secondary phase and so on.

FLUENT manual tells the macro DEFINE_ADJUST doesn't return a value to the solver. This doesn't mean you can't modify variables inside it, but just that DEFINE_ADJUST has been defined as a void function.

Hi :)

P.S. Sorry for the late answer.

ap

kevin November 11, 2003 18:23

Re: modify volume fraction
 
Hey, Dear ap,

I have tried with your valuable sugguestion. It works!

Thank you very much. I really highly appreciate your help.

:) kevin

ap November 12, 2003 10:38

Re: modify volume fraction
 
My pleasure, Kevin.

ap :)

akm April 19, 2011 05:32

Define_adjust
 
hello ap.. please help me

as i understand define_adjust can be "used to adjust or modify FLUENT
variables that are not passed as arguments".
in my 3phase eularian simulation i am required to modify the volume fractions of the two secondary phases, keeping the volume of primary phase same.

i have done the calculation as required in define_execute_at_end, to compute how much do the volume fractions change and hence correctly computed the value of global variables 'vf1' and 'vfpr'.

my adjust macro:

Code:

DEFINE_ADJUST(mt,d)
{
  Thread *t;
  cell_t c;
  real volf1, volf2, volf3;
  real xc[ND_ND];

  if (counter == 1)
  {
    thread_loop_c(t,d)
    {
      begin_c_loop(c,t)
      {
        Thread *fr = THREAD_SUB_THREAD(t,1);  //1st secondary phase
        Thread *to = THREAD_SUB_THREAD(t,2); //2nd secondary phase
          volf1 = C_VOF(c,fr);
          volf2 = C_VOF(c,to);
          volf3 = 1-(volf1+volf2);  //primary phase volume frac.

          if(volf1 > 0.01)
          {
            C_VOF(c,fr) = volf1 * vf1/vfpr;  //modifying the vol.fr. of 1st sec. phase
            volf1 = C_VOF(c,fr);
            C_VOF(c,to) = 1-(volf1+volf3);  //adjusting the vol. fr. of 2nd sec. phase, keeping the sum of volume fractions unity.
            volf1 = C_VOF(c,fr);
            volf2 = C_VOF(c,to);

            C_CENTROID(xc,c,t);
            Message("%g\t%g",xc[0],xc[1]);
            Message("\t%g  %g\n",volf1,volf2);
          }
      }
      end_c_loop(c,t)
    }       
  }

}

When the variables are printed from the udf, they do seem to get modified as required by the problem. But returning to solver at the end of iteration/timestep, the variables show no change when viewed as contours or even when accessed by define_execute_at_end macro.

What might be the problem in modifying the variables ??
Is there anything wrong in what i am trying to do? Please suggest an alternative.

Can anyone please help me..

Regards

motahar May 20, 2011 03:35

Hi friends,
I'm simulating a tube with water flow.
The tube encounters boiling near the wall.
I intend to calculate 'void fraction versus enthalpy' along the channel.
Can you help me how to calculate void fraction?

I'm in an emergency condition.
Waiting for your comments!!!

Thanks Everybody


All times are GMT -4. The time now is 14:12.