CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF to constrain one of the phase to stay in the domain (https://www.cfd-online.com/Forums/fluent-udf/106186-udf-constrain-one-phase-stay-domain.html)

Koromajor August 21, 2012 11:44

UDF to constrain one of the phase to stay in the domain
 
Has anyone ever written a UDF to constrain one of the phase (in a multiphase simulation) not to leave the domain?
I have got this two-phase simulation where my secondary phase (solid particles) are prevented from coming out the the flow cell with a wire mesh and I would like to simulate that with a UDF.

Any help and/or ideas are very welcome.

Cheers

Koromajor August 21, 2012 11:46

Just to mention that my outlet is a pressure outlet boundary condition.

Cheers

mvee August 23, 2012 02:10

UDF to constrain one of the phase to stay in the domain
 
Hi Koromajor

What do you mean by flow cell?

If you mean to say that your secondary phase does not come out of the domain then at the outlet you have to define volume fraction as zero which resist the outward flow of secondary phase.

best wishes
Mvee

Koromajor August 23, 2012 04:48

Hi Mvee,

Thanks for your reply. By flow cell I meant my computational domain, so you understood it right :)
How do you define a zero volume fraction at a pressure outlet? You can define the backflow volume fraction but this is different from the actual volume fraction of the phase.

The other option would be to change the outlet boundary to mass flow inlet, then you can specify zero mass flow rate of secondary phase through the outlet, but I don't want to do that because the next step of my project is to introduce another secondary phase that will have no constraint unlike my first secondary phase.
So if one changes the outlet boundary to mass flow inlet, you will still be stuck on what mass flow rate you will need to specify for the primary phase and the second secondary phase at the outlet.

My feel is that, the solution of the problem is through a UDF, but like I said any help /suggestions are welcome, either via UDF or other ways of doing it.

Cheers,
Koromajor

mvee August 31, 2012 05:43

I suggest to define the back flow volume fraction as 1 which will resist the secondary phase to go out. Why do you feel this as different from realistic picture?
Through UDF (DEFINE_ADJUST) you can adjust the volume fraction as zero.

Best wishes
MVee

Koromajor August 31, 2012 07:08

The backflow volume fraction is only used by the solver in case reverse flow occurs during calculation, so backflow volume fraction set to 1 cannot prevent the secondary phase to exit the domain.

I don't think DEFINE_ADJUST (setting volume fraction to 0) can solve the problem because what you will only do is telling the solver to use 0 volume fraction at the outlet at the beginning of every iteration, but at the end of the iteration the solver could calculate non-zero volume fraction of secondary at the outlet (which means flow out).

Khaled yousef June 17, 2014 15:58

Hi Koromaor,
Did you solve your problem? i face the same problem that i am trying to model steam condensation inside shell and tube condenser. I face reverse flow problem that when i set the back flow volume fraction for secondary phase equal to 1 , the domain is filled with secondary phase. So i want to prevent any phases to enter the domain when reverse flow. Also, the pressure outlet can permit any phases to go out and nothing enter the domain.
Thanks

Mechanical Engineer October 16, 2014 23:28

Go to Cell Zone conditions>select the phase>edit>mark fixed values>select constant in x and y velocity> put values to zero.

Now, after putting velocity and volume fraction to zero at inlet boundary condition, initialize the system with volume fraction of stationary phase as zero. you can then patch the domain with required volume fraction of stationary phase

Hope this helps.

sirpolar October 30, 2014 09:46

Hi dear all
I have the same proble
I want that secondary phase displce the primary phase but the volume fraction of primary phase doesn't go below the predefined value in each cell or voulme fraction of secondary phase never goes above the certain value

I would be appreciated if you could help me

Rubblevg March 15, 2017 07:23

Hi Koromajor,

Did you already solve your problem? I have currently the same issue as you, namely that I want to keep one of my phases from leaving the domain. I was thinking about using a UDF that makes all tangential velocities of the constrained phase at the outlet zero and points all normal velocities away from the outlet. Only thing is I don't have much experience writing UDF so any help would be appreciated!

annu August 30, 2017 09:55

please friends,, reply if you have found answer to this.

Rubblevg August 30, 2017 10:20

Hi Annu,

I solved this problem by programming a mass sink that removes one phase from the domain with the same rate as it flows in through the inlet. This is done by the following UDF:

#include "udf.h"
real mflow;
int ncells;

DEFINE_ADJUST(measure_mass_flow,d)
{
Domain *dom = Get_Domain(2);
Thread *t = Lookup_Thread(dom, 9);
face_t f;

mflow = 0;

begin_f_loop(f,t)
{

mflow +=F_FLUX(f,t);

}
end_f_loop(f,t)

printf("MASS Flow Rate: %g\n",mflow);
}



DEFINE_SOURCE(mass_well, cell, thread, dS, eqn)
{
real source;
source = mflow / C_VOLUME(cell, thread) / ncells;

dS[eqn] = 0.0;
return source;
}

DEFINE_INIT(calculate_cells,d)
{
cell_t c;
Thread *ct = Lookup_Thread(d, 6);
ncells = 0;

begin_c_loop(c,ct)
{

ncells++;
printf("Amount of cells is %d\n",ncells);
}

end_c_loop(c,ct)


}

The define_source UDF needs to be set for the phase that is to be removed and it needs to be applied to a small volume close to the wall that represents the mass sink/outlet.

Feel free to ask any questions if this does not work for you or if something is unclear!

CeesH August 30, 2017 10:24

Couldn't you just use the degassing boundary condition in current versions of FLUENT?

H.Almrayatee November 2, 2017 21:27

Hi Rubblevg,

I have two phases, liquid as primary phase and gas as secondary. Only gas is injected and the liquid is already patch. The liquid is leaving the domain from the outlet pressure. I can't use degassing BC because I have gas surface on the top of liquid. Can you help me with the UDF you write and how I can prevent the primary phase leaving the domain.
Thanks

Safiya November 5, 2017 13:14

UDF for linearly varies density
 
Can anyone, please write a udf for linearly variable water density, from 1025kg/m^3 at sea surface to 1032 Kg/m^3 at 500m depth below sea surface, on a open channel flow , in a two phase air -water sea condition.

annu November 6, 2017 09:15

still stuck
 
hi rubblevg,
i am working on fixed bed reactor 2D, i am using boundary condition for inlet as velocity inlet and for outlet pressure outlet. i am not using multiphase. in the cell zone condition, i am using porous media condition where i am using porosity of 0.4. so case is simple only air is flowing. but when i see in voulme integrals mass, mass is continuously decreasing, what is the reason behind it? i dont understand. please help me..please..

Rubblevg November 6, 2017 10:17

Hi all,

@ H.Almrayatee : I gave some explanation with the UDF in my last post. What remains unclear to you and what do you need help with? If you want the mass sink in your model to resemble a pressure outlet you should try modifying the DEFINE_SOURCE part of my UDF to satisfy the boundary conditions of a pressure outlet. Now it removes mass homogeneously over the outflow zone.

@ Safiya : Could you be more specific? What is your UDF supposed to do? Does it need to remove water or air? Maybe it is worth checking the section about open channel flows in the Fluent User's guide: https://www.sharcnet.ca/Software/Ans...n_channel.html

@Annu : I already answered your private message so I won't address your problem here. I do think however that it would be better if you'd create a new thread for this problem since it isn't about constraining phases to a domain anymore :-)

@Ceesh : I think degassing is indeed useful for gases, but I don't think it can be used for liquids and particles. Personally I used my UDF to filter an Eulerian particle phase

Cheers!
Ruben

H.Almrayatee November 7, 2017 23:49

Thanks Rubblevg for your reply.
I already modify the DEFINE_ADJUST to calculate the mass leaving from pressure outlet for the liquid phase only without the gas phase, because need to let gas leave, and used the same DEFINE_SOURCE to feed the mass leaving back to domain. But still I don't get mass balance and mass keep decreasing from the domain.
You said it mass sink do we need to have a negative signal source = mflow / C_VOLUME(cell, thread) / ncells;?
thanks

Rubblevg November 8, 2017 05:01

Hi H.Almrayatee,

In my case the value of F_FLUX(f,t) was negative at the cell face of the inlet, resulting in a negative m_flow. Therefore, the source is defined as it is, since it was meant to remove mass from the domain (mass sink). I guess it works the same in your case since you observe decreasing mass in your domain. You can verify this by checking the sign of m_flow (it is printed during the calculation). If it is indeed negative, you should add a minus in the DEFINE_SOURCE part. Alternatively, you can just take the absolute value of m_flow to ensure that your source is indeed a mass well.

I think you should also check whether a pressure outlet is compatible with a mass well that depends on the outlet. Incompatible boundary conditions can also cause the decreasing mass you observe. You could try replacing your pressure outlet with other outlet types to see if the mass in your domain still decreases.

I hope this helps, good luck!

H.Almrayatee November 11, 2017 22:23

Thanks Rubblevg, for your reply.
The BC are velocity inlet and pressure outlet, I can't change to another outlet because outflow BC is incompatible with Eulerian, also can't use the degassing due to the gas surface above the liquid primary phase. so pressure outlet is the best to use. Unfortunately I'm still get mass decreasing, I notice drag law used is also effect the case, now I change to another law "Symmetric" now mass is stable for 2 second but after that is start to decrease.
Any other thoughts?


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