CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Mass flux as a function of pressure

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By robin_dlc

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 11, 2014, 18:58
Default Mass flux as a function of pressure
  #1
New Member
 
Join Date: Apr 2014
Posts: 3
Rep Power: 12
robin_dlc is on a distinguished road
Hi everyone! This is my first time posting on here but I'm no newbie to the CFDO forums. I've been using Fluent for around 2-3 years mainly for school , and am interested (by curiosity) in learning UDFs.

The problem I'm trying to solve is the following: I modeled a classic 2D Laval nozzle, with a straight chamber upstream of the nozzle. In this chamber lies the mass inlet, with a given mass flux rate and initial gauge pressure.

In real life, the mass flux of a solid rocket motor will depend on the burn rate of the propellant, who in turn is dependent (primarily) on this chamber pressure.

So I'm trying to find a way to have Fluent do two things:
- Compute after each converged transient timestep the average absolute pressure in that chamber
- Modify the mass flux rate so that MF = a*(PRESSURE^b)

Is this possible? If so, how should I do this, through a programmed C UDF or by defining user parameters (or something else)?

I'm not really looking for someone to dump a code that I just load into Fluent (though if it is a simple code it won't take me long to decipher it), I'm more interested in learning UDFs for future use.

Thanks in advance!
Robin
robin_dlc is offline   Reply With Quote

Old   April 12, 2014, 15:38
Default
  #2
New Member
 
Join Date: Apr 2014
Posts: 3
Rep Power: 12
robin_dlc is on a distinguished road
Okay so I wrote the following UDF to compute the average total pressure, it is compiling and giving a result, can someone please double check that it gives the correct result?

Thanks!
PS: My mass flux as a function of pressure is for a pressure in psi, Fluent outputting pascals

Code:
#include "udf.h"
#define p_op 14.7 /*psi*/
real press;
real avg_press;

DEFINE_EXECUTE_AT_END(tot_press_comp)
{
int n=1;
Domain *d;
cell_t c;
Thread *t;
face_t f;
d = Get_Domain(1);
t = Lookup_Thread(d,7);
press = 0;
avg_press = 0;

	begin_c_loop(c,t)
	{
	press = press+(C_P(c,t)*0.000145037738);
	n=n+1;
	}
	end_c_loop(c,t)

avg_press=(press/n)+p_op;
printf("average total pressure in psi = %g\n", avg_press);
}
robin_dlc is offline   Reply With Quote

Old   April 13, 2014, 13:15
Default
  #3
New Member
 
Join Date: Apr 2014
Posts: 3
Rep Power: 12
robin_dlc is on a distinguished road
I seem to have figured it out! I have some problems though, the code below works, but the only way I managed to make the pressure computation work was by inserting the code contained in DEFINE_EXECUTE_AT_END inside the DEFINE_PROFILE code.

Apparently this computes the average pressure each iteration and not at the end of each timestep, which I'm afraid might give me convergence issues.

From the code below, how can I change to have it:
- Compute the average pressure at the end of each time step
- Use that average pressure to compute the corresponding flux and modifying the inlet's flux

Thanks!
Code:
#include "udf.h"
#define p_op 14.7 /*psi*/
real press;
real avg_press;
real flux;

/*--------------------------------------------
    CODE TO COMPUTE THE AVERAGE PRESSURE
FOR SOME REASON NOT RUN AFTER EACH TIME STEP
---------------------------------------------*/

DEFINE_EXECUTE_AT_END(tot_press_comp)
{
int n=1;
Domain *d;
cell_t c;
Thread *t;
face_t f;
d = Get_Domain(1);
t = Lookup_Thread(d,7);
press = 0;
avg_press = 0;
flux = 0;

    begin_c_loop(c,t)
    {
    press = press+(C_P(c,t)*0.000145037738);
    n=n+1;
    }
    end_c_loop(c,t)

avg_press=(press/n)+p_op;
flux = 1.4929*pow(avg_press,0.3483);
printf("average total pressure in psi = %g\n", avg_press);
}

/*------------------------------------
      CODE TO CHANGE MASS FLUX
-------------------------------------*/
DEFINE_PROFILE(inlet_mf,th,i)
{
face_t f;

    /* GET THE CHAMBER PRESSURE */
    int n=1;
    Domain *d;
    cell_t c;
    Thread *t;
    d = Get_Domain(1);
    t = Lookup_Thread(d,7);
    press = 0;
    avg_press = 0;
    flux = 0;

    begin_c_loop(c,t)
    {
    press = press+(C_P(c,t)*0.000145037738);
    n=n+1;
    }
    end_c_loop(c,t)

avg_press=(press/n)+p_op;
flux = 1.4929*pow(avg_press,0.3483);

    /* APPLY THE NEW FLUX */
    begin_f_loop(f,th)
    {
    F_PROFILE(f,th,i) = flux;
    }
    end_f_loop(f,th)

printf("Internal chamber pressure = %g\n", avg_press);
printf("Adjusted mass flux = %g\n", flux);
}
mrwan and alelager like this.
robin_dlc is offline   Reply With Quote

Reply

Tags
mass flux, pressure, udf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wind turbine simulation Saturn CFX 58 July 3, 2020 01:13
An error has occurred in cfx5solve: volo87 CFX 5 June 14, 2013 17:44
Water subcooled boiling Attesz CFX 7 January 5, 2013 03:32
Problem setting with chtmultiregionFoam Antonin OpenFOAM 10 April 24, 2012 09:50
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 00:35


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