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

Mass flow rate defined by velocity function and inlet area

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 16, 2015, 11:26
Default Mass flow rate defined by velocity function and inlet area
  #1
New Member
 
Join Date: Jun 2015
Posts: 6
Rep Power: 7
saml is on a distinguished road
Hi,

Apologies if this questions has been asked, I can't find the solution I'm looking for. I'm new to using Fluent. I am trying to figure out how to get a UDF working where a defined velocity and density is given and then mass flow rate is calculated dependent on the inlet surface area. As an example, the velocity profile is given here https://confluence.cornell.edu/pages...geId=268895958

If I change the variable, totalarea to a value that I have calculated manually, the resultant measured velocity is as expected.
It appears that the problem is in the totalarea += NV_MAG(area), it does not output the correct inlet surface area. Not sure what I'm missing. Any help would be greatly appreciated.

#include "udf.h"
#define PI 3.141592654

#define bloodrho 1060

real area[ND_ND];
real totalarea=0.0;

DEFINE_PROFILE(inlet_massflowrate,th,i)
{
{
face_t f;
double t = (CURRENT_TIME*2-floor(CURRENT_TIME*2))/2;
begin_f_loop(f,th)
{
F_AREA(area,f,th);
totalarea += NV_MAG(area);
printf("Area= %d\n",totalarea);
if(t <= 0.218)
F_PROFILE(f,th,i) = bloodrho*(0.5*sin(4*PI*(t+0.0160236)))*totalarea;
else
F_PROFILE(f,th,i) = bloodrho*0.1*totalarea;
}
end_f_loop(f,th);
}
}

Thanks!
saml is offline   Reply With Quote

Old   July 16, 2015, 13:17
Default
  #2
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 10
Kokemoor is on a distinguished road
You'll need to have two loops to do this: one to calculate the total area, then a second to set the profile. Doing it in one loop means that the profile is being set the with the area computed so far, not the actual total area.

I think you'll also want to reinitialize totalarea=0 inside the DEFINE_PROFILE macro, before the loop. Otherwise, your totalarea will continue to grow every iteration.
Kokemoor is offline   Reply With Quote

Old   July 16, 2015, 22:58
Default
  #3
New Member
 
Join Date: Jun 2015
Posts: 6
Rep Power: 7
saml is on a distinguished road
Quote:
Originally Posted by Kokemoor View Post
You'll need to have two loops to do this: one to calculate the total area, then a second to set the profile. Doing it in one loop means that the profile is being set the with the area computed so far, not the actual total area.

I think you'll also want to reinitialize totalarea=0 inside the DEFINE_PROFILE macro, before the loop. Otherwise, your totalarea will continue to grow every iteration.
Great, thanks for the help. I've done the changes and with using printf, I can see the output of "total area". I'm using a cylinder to test the code out. I know the surface area is around 0.049 m^2.
The output of the printf is a list? Not sure if it's meant to be a list but if I summed the listed values,
6.642245e-03
4.322405e-03
2.799194e-03
0.000000e+00
1.558870e-02
5.616377e-03
9.217984e-03
4.651606e-03

It's about 0.049 or is this a coincidence? How do I sum these values in the UDF?

Code:
#include "udf.h"
#define PI 3.141592654
#define bloodrho 1060

DEFINE_PROFILE(inlet_massflowrate,th,i)
{
	real totalarea=0.0;
	real area[ND_ND];
	face_t f;
	begin_f_loop(f,th)
	{
	F_AREA(area,f,th);
	totalarea+=NV_MAG(area);
	}
	end_f_loop(f,th)
	printf("%e\n",totalarea);

		begin_f_loop(f,th)
		{
		double t = (CURRENT_TIME*2-floor(CURRENT_TIME*2))/2;
		if(t <= 0.218)
			F_PROFILE(f,th,i) = bloodrho*0.5*sin(4*PI*t+0.0160236)))*0.049;0160236)))*totalarea;
		else
			F_PROFILE(f,th,i) = bloodrho*0.1*totalarea;
		}
		end_f_loop(f,th);

}
Thanks!
saml is offline   Reply With Quote

Old   July 17, 2015, 06:43
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,478
Rep Power: 20
pakk will become famous soon enough
You get eight numbers... Are you doing a parallel calculation with 8 processes? If so, you will have to add some code to let the processes talk to each other, since they should communicate what the total area is. I don't know from my head how, but the manual helps here.

But in any case, I would start to get it working in serial mode, and only when that works go towards parallel.
pakk is offline   Reply With Quote

Old   July 17, 2015, 12:08
Default
  #5
Senior Member
 
Andrew Kokemoor
Join Date: Aug 2013
Posts: 122
Rep Power: 10
Kokemoor is on a distinguished road
pakk is exactly right. Make sure it works in serial first, then look up global reduction macros, Section 7.5.4 in the UDF Manual.
Kokemoor is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Pressure Outlet Targeted Mass Flow Rate LuckyTran FLUENT 1 November 23, 2016 11:40
Issues on the simulation of high-speed compressible flow within turbomachinery dowlee OpenFOAM Running, Solving & CFD 8 October 25, 2016 20:48
[blockMesh] non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Meshing & Mesh Conversion 7 April 17, 2013 06:42
Water subcooled boiling Attesz CFX 7 January 5, 2013 04:32
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 12 December 12, 2011 05:16


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