CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Defining Boundary Conditions Dictated by a Pump Curve (https://www.cfd-online.com/Forums/fluent/134578-defining-boundary-conditions-dictated-pump-curve.html)

robtheslob May 1, 2014 17:31

Defining Boundary Conditions Dictated by a Pump Curve
 
Hello all,

I'll give a short version and a long version of this thread topic. The answer could prove to be quite simple, as I'm new to CFD. Thanks in advance for the help!

The short version:

When the inlet condition for a flow domain is dictated by a specific type of pump that will be used (i.e. all that is known is the characteristic pump curve) to force flow, how should one define the inlet boundary condition in Fluent?

The long version:

I am trying to simulate the flow of water in an engine cooling jacket. I intend to perform CHT analysis, but that isn't important for now.

In reality, the pumping system is closed. This may be an important consideration; for now, I intend to simulate the water jacket as open loop system with "fresh" water entering the system.

The flow in the actual prototype is forced by virtue of a pump. My current understanding is that the operation point of the system is found at the intersection of the characteristic pump curve and the system (demand) curve. The characteristic pump curve is given. The system curve is not known.

NOTE: I intended to write how I might go about finding a system curve by hand, but I've run out of time. Will edit what I get a chance.

EDIT: I'll just respond to ghost.

ghost82 May 3, 2014 05:47

Hi Rob,
as you know the characteristic curve of a pump is a chart of head vs. flow rate (usually volumetric flow rate of water).
You are right the operative point will be the intersection between the characteristic curve of the pump and the system curve.

I will write basic instructions on how I would address your problem (this is just an idea).

I would write and udf for inlet mass flow rate to be execute at the end of each iteration.
I would fit the pump curve with a function flowrate=f(head).
I would loop over the outlet face to compute the pressure and make the difference with inlet pressure to calculate fluent pressure drop.
This pressure drop should be an input for the function flowrate=f(head) to assign the new mass flow rate to inlet.

If you don't want to write the udf you can proceed by trial and error:
- fix a mass flow rate and compute total pressure drop by fluent
- compare pressure drop with characteristic curve of the pump
- if calculated pressure drop are > than characteristic curve of the pump you should decrease mass flow rate in your second trial, if they are < then you have to increase mass flowrate
- proceed until pressure drop are on or very near the pump curve

Also, if you don't want to write the udf you can calculate the system curve
- make some simulations of your system with different mass flow rates and calculate system pressure drops
- build a chart system pressure drop vs. flowrate: this will be the system curve
- overlap the two charts; the intersection point will be your flowrate (operative point)

Daniele

robtheslob May 6, 2014 10:47

Daniele,

Thank you so much for your insightful post! This is great information. I'm glad my question wasn't totally inane and unfounded!

The last idea in your list (developing a system curve) was essentially the "by hand" process that I was thinking about discussing in my first post.

As I implied in my first post, I am new to Fluent. You listed two ways to avoid creating a UDF. Is creating a UDF typically a laborious process that should be avoided? I will definitely do some reading to learn more about writing them.

Thanks again for the help!

ghost82 May 6, 2014 11:40

Hi rob,
writing a udf for your case will not be so difficult.
You have to know c language, but if you look at some examples in fluent udf manual and you are smart enough to understand what the code does I think you can write it on your own.

Daniele

robtheslob May 13, 2014 15:07

Daniele,

Thank you for the response. The C doesn't look particularly hard for this scenario.

I am, however, having some issues with compiling my code. I know you rock, so, if you have some time, please take a look!

I will be sure to post a functioning pump BC UDF in this thread once I get it working so that the community may benefit!

Thank you,

Rob

robtheslob December 2, 2014 14:30

Unfortunately, I've practically abandoned this project, as adequate results have been obtained for my model at a few known flow rates. However, for posterity, I thought I would post the code that I have so far. It has been so long since I've looked at this code that I can't recall exactly what's wrong with it, but I know a bit more debugging is required. I don't think it was accurately determining the pressure drop for some reason. I'm certain any further contributions would be beneficial to the CFD community!

If enough interest is shown, I'd be happy to continue contributing in my free time. Frankly, this code is not very complicated, so I'm sure I've just overlooked something simple.

Code:

/******************************************************************************
 DESCRIPTION:        UDF for determining real inlet conditions based on pump curve
                        data (hard-coded) and the system demand curve (geometry in
                        ANSYS)
 AUTHOR:        Robert (robtheslob)
 CREATED:        5/9/2014
 LAST CHANGED:        6/27/2014
******************************************************************************/

#include "udf.h"                /*Required for all Fluent UDFs

#define INLET_AREA 0.0001                /*Inlet cross-sectional area in m^2*/
#define HEIGHT 0.0001        /*Height of inlet to be added to*/
                                                        /*position vector in m*/
#define ZONE_ID 7                /*Zone ID for outlet*/

/*-----------------------------------------------------------------------------
        *Adjusts BC using ANSYS compiler macro
        *Uses value of pressure difference to adjust flow velocity
        *Flow velocity is considered in 1 dimension
        *t is pointer to thread on which BC is applied
        *i is index that identifies variable that is set when UDF is hooked
-----------------------------------------------------------------------------*/
DEFINE_PROFILE(pump_curve,t,i)       
{
        /*-------------------------------------------------------------------------
                *Global variable initialization
        -------------------------------------------------------------------------*/
        Domain *domain;                /*Domain is declared as a variable*/
        face_t f;                /*Declare a special variable structure to store face data*/
        real outlet_pressure = 0;
        real pressure_drop = 0;                /*Pressure variables*/
        real area_pressure = 0;
        real area = 0;
        real area_sum = 0;                /*Area weighting variable*/
        real a[ND_ND];                /*Area vector required to obtain scalar face area*/
        Thread *outlet_thread;

        /*-------------------------------------------------------------------------
                *First, the domain must be retrieved
                *Required because it was not passed in define macro
        -------------------------------------------------------------------------*/
        domain = Get_Domain(1);                /*Returns fluid domain pointer*/

        /*-------------------------------------------------------------------------
                *Next, we must obtain the outlet thread
                *The inlet thread is passed via the define macro, not outlet
                *We need outlet thread to determine outlet pressure
                *Outlet pressure is used to determine pressure drop later
        -------------------------------------------------------------------------*/
        outlet_thread = Lookup_Thread(domain,ZONE_ID);

        /*-------------------------------------------------------------------------
                *Outlet pressure must now be obtained
                *Outlet pressure area-weighted average of all faces
                *Outlet pressure is used to determine pressure drop later
        -------------------------------------------------------------------------*/
        begin_f_loop(f,outlet_thread)
        {
                //Message("LOOP: Area = %-11g  Area Sum = %-11g  Area Pressure = %-11g\n", area,area_sum,area_pressure);

                F_AREA(a,f,outlet_thread);                /*Get the area of this face*/
                area = NV_MAG(a);                /*Get magnitude of vector (scalar value)*/
                area_sum += area;                /*Sum values of area to obtain total area*/
                area_pressure += F_P(f,outlet_thread)*area;                /*Get pressure at face
                                                                                                                then sum pressure*/
        }
        end_f_loop(f,outlet_thread)

        area_sum = PRF_GRSUM1(area_sum);
        area_pressure = PRF_GRSUM1(area_pressure);

        Message("%2d area_sum = %11f  area_pressure = %11f\n",myid,area_sum,area_pressure);
       


        if(area_sum != 0)
        {
                outlet_pressure = area_pressure/area_sum;                /*Average outlet pressure*/
        }
        else
        {
                outlet_pressure = 0;
                Message("Outlet pressure set to zero - division by zero was attempted.!\n");
        }


       

        /*-------------------------------------------------------------------------
                *Set the inlet pressure
                *Hard-coded pump curve lives here
        -------------------------------------------------------------------------*/
        begin_f_loop(f,t)
        {
                        F_PROFILE(f,t,i) = 2000; /*Test value*/
        }
        end_f_loop(f,t)


        Message0("Outlet Pressure = %-11g.  Area Sum = %-11g  Area Pressure = %-11g  Area = %-11g\n",outlet_pressure,area_sum,area_pressure,area);

       
}

PS this is my first UDF... use at your own risk!


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