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/)
-   -   Energy Source Term for Sub-Region (https://www.cfd-online.com/Forums/fluent-udf/165334-energy-source-term-sub-region.html)

Solmyr89 January 14, 2016 12:07

Energy Source Term for Sub-Region
 
1 Attachment(s)
Hello, I'm using ANSYS v15. for my masters thesis and I have the following problem:

My thesis is about the Multiphase-Euler-Approach to simulate granular flows under different conditions (yeah, I know DEM would be more efficient but that is what my prof wanted me to do).
I have already finished most of my workload but I simply cannot complete my last problem:

A box is filled with the 2 granular phases as shown in the little paint picture I attached (vf means volume fraction). I want to set the energy source term to be in a very specific area that is heated - so NOT for all the cells inside a certain phase, in fact the area of the energy source term should not be linked to the phases at all. I should be able to fill my box however I want to and the area of the box where I want to modify the energy source term should not be affected by it.
I have already tried everything I know. I simply cannot get the energy source term to be set ONLY for that area and to remain unchanged for everything else.

I'm NOT asking you to solve my problem, but i just want to know if what I want to do is even doable? Can the energy source term be changed only for a certain area or is it always globally? Like it was with my previous simulations where I changed the gravity for the second phase globally.

Is it possible to have a little area where the energy source term is changed? How should I construct the UDF? Because nothing I try is working.

Thanks in advance, I hope I was able to explain my problem properly :)

`e` January 14, 2016 16:37

Including an energy source term dependent on location should be straightforward using the DEFINE_SOURCE macro. Have a read of the section in the UDF manual (there's a description, example and steps on hooking the macro to your cell zone).

The DEFINE_SOURCE macro is called for each cell and therefore you could use a conditional statement to apply a local energy source. For example:

Code:

#include "udf.h" // UDFs require this header file

DEFINE_SOURCE(local_energy_source,c,t,dS,eqn)
{
    real x[ND_ND]; // array of cell coordinates
    real source = 0.; // default the source term to zero

    C_CENTROID(x,c,t); // retrieves the cell coordinates
    dS[eqn] = 0.; // derivative of source term

    if (x[0] > 0.5) // only if this cell belongs in the domain where x > 0.5 m
    {
        source = 1.; // non-zero source [generation-rate/volume e.g. W/m^3]
    }

    return source; // source is returned to solver
}


Solmyr89 January 15, 2016 04:09

Thank you e for your code :),
I already tried that but what happens is this:

Fluent goes into the if statement, looks if there are cells with x coordinates >0.5 and then applies the source term to ALL cells, not only to the cells with x coordinates above 0.5.
This is why I was asking, because I can't find the solution to my problem. It seems like the source term can only be applied globally ... :( or am I just very stupid and doing something very wrong?

`e` January 15, 2016 17:29

As I mentioned above, the source term is applied on a cell-by-cell basis. The DEFINE_SOURCE macro is called for each cell and returns a source term for that specific cell (with the cell index c).

Try the UDF I posted above and set the local source term to a very high value to make the temperature field peak in this local region (you may need to modify the conditional statement for your domain).

Solmyr89 January 16, 2016 04:31

Thank you very much for your patience. I just figured out my mistake.
When I used UDFs before this last problem, I modified the viscosity and gravity of each phase and I was used to working with absolute values. But as you pointed out the expression should be in W/m³ so I just divided the source term by the volume of each cell .... it works just fine now. Thank you =)


All times are GMT -4. The time now is 03:43.