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/)
-   -   Dpm udf (https://www.cfd-online.com/Forums/fluent-udf/183908-dpm-udf.html)

sina_mech February 16, 2017 10:57

Dpm udf
 
Hi,

I would like to set flow rate for an injection of particles. The injection is a surface injection. Over the loop, I set P_FLOW_RATE(p), but I noticed that the flow rate applies to every stream in that injection. So for example, for a surface injection (of say 100 streams at inlet), instead of having 1 kg/s , I have 100kg/s eventually! any fix? I would like to have 1kg/s for the entire injection, also "Scale flow rate by face area".

This is a sample code that I use:

Code:

#include "udf.h"
DEFINE_DPM_INJECTION_INIT(init_prt,  I)
{
        Particle *p;
        real t = CURRENT_TIME;
       
        if (t>=0)
        {
                loop(p,I->p_init)
                {
                        P_FLOW_RATE(p) = 1.0;

                }
        }
}


pakk February 16, 2017 11:32

P_FLOW_RATE(p) defines the flow rate for trajectory p. If you want to distribute 1 kg/s over 100 different trajectories, you will have to do that yourself!

If you know that there are exactly 100, and you want to distribute them equally over the trajectories, the simplest way is to do the calculation yourself and conclude you need 0.01 kg/s for each trajectory:

Code:

P_FLOW_RATE(p) = 0.01;
If you want to make it proportional to the face area, you have to:
1. Find out which on which face the particle is.
2. Calculate the area of that face.
3. Put that area in the equation.

I will put some thoughts on these 3 steps below.

1. Find out which on which face the particle is:

I don't know how to find the face, but to find the cell, you do:
Code:

cell=P_CELL(p);
cell_thread=P_CELL_THREAD

Maybe P_FACE(p) also works...

2. Calculate the area of that face:
If you know it is on face "face" on face thread "face_thread":
Code:

F_AREA(A,face,face_thread);
facearea=NV_MAG(A);

3. Put that area in the equation.
You need to know the total flow rate that you want to have (1kg/s in your case), and the total area of the surface. Either you read that one from Fluent, or you use a UDF to calculate that. Then, the relevant part becomes:

Code:

P_FLOW_RATE(p) = facearea/totalarea*totalflowrate;

sina_mech February 19, 2017 16:26

Quote:

Originally Posted by pakk (Post 637427)
P_FLOW_RATE(p) defines the flow rate for trajectory p. If you want to distribute 1 kg/s over 100 different trajectories, you will have to do that yourself!

If you know that there are exactly 100, and you want to distribute them equally over the trajectories, the simplest way is to do the calculation yourself and conclude you need 0.01 kg/s for each trajectory:

Code:

P_FLOW_RATE(p) = 0.01;
If you want to make it proportional to the face area, you have to:
1. Find out which on which face the particle is.
2. Calculate the area of that face.
3. Put that area in the equation.

I will put some thoughts on these 3 steps below.

1. Find out which on which face the particle is:

I don't know how to find the face, but to find the cell, you do:
Code:

cell=P_CELL(p);
cell_thread=P_CELL_THREAD

Maybe P_FACE(p) also works...

2. Calculate the area of that face:
If you know it is on face "face" on face thread "face_thread":
Code:

F_AREA(A,face,face_thread);
facearea=NV_MAG(A);

3. Put that area in the equation.
You need to know the total flow rate that you want to have (1kg/s in your case), and the total area of the surface. Either you read that one from Fluent, or you use a UDF to calculate that. Then, the relevant part becomes:

Code:

P_FLOW_RATE(p) = facearea/totalarea*totalflowrate;

pakk, thank you very much. I will try this.


All times are GMT -4. The time now is 16:37.