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

Varying mass flow at an inlet boundary condition. Fuel mass flow.

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 22, 2014, 06:28
Default Varying mass flow at an inlet boundary condition. Fuel mass flow.
  #1
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Sirs:

Can anyone explain how I can set this up. I am a beginner in this field, so will need a step by step approach.

Need to for an example to set an on/off of fuel gas mass flow rate. On/off at 5 seconds intervals.

If it is through UDF, please explain how.

Note: I got a reply before on this subject, but can not find thread.

Thanks.

AH
visitor is offline   Reply With Quote

Old   April 24, 2014, 22:42
Default
  #2
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Just add as many "else if" you need to this example from Ansys Fluent UDF Manual 15.0:

2.3.19.11. Example 9 - Mass Flow Rate UDF for the Mass Flow Inlet
This UDF is used to provide a time-varying specification of the mass flow rate. This boundary condition can be applied using a DEFINE_PROFILE UDF.

#include "udf.h"
DEFINE_PROFILE(inlet_mf,th,i)
{
face_t f;
begin_f_loop(f,th)
{
if(CURRENT_TIME <= 5.0)
F_PROFILE(f,th,i) = 1.0;
else if(CURRENT_TIME <=10.0 && CURRENT_TIME >5.0)
F_PROFILE(f,th,i) = 0.0;
else if(CURRENT_TIME <=15.0 && CURRENT_TIME >10.0)
F_PROFILE(f,th,i) = 1.0;
else if(CURRENT_TIME <=20.0 && CURRENT_TIME >15.0)
F_PROFILE(f,th,i) = 0.0;
else
F_PROFILE(f,th,i) = 1.0;
}
end_f_loop(f,th);
}
macfly is offline   Reply With Quote

Old   April 28, 2014, 09:15
Default setting up
  #3
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Mac

thank you for your reply.

Being a beginner, I will be asking more questions. How to put it into practice?

1. In the define drop down menu, I can see functions>Interpret or Compiled or Manage. What do I choose? I assume interpreter.

2. If Interpreter, where do I past the suggested code? can this be done in a word file and saved in a specific format?

3. What is the boundary condition name which I will be entering in the "Mass flow Inlet" boundary condition?

4. What is the subroutine code name or file name which I need to enter in the Interpreted UDF menu, , Browse ..?

5. In the suggested code, I need to have some think like "mass = 0.001".
This will be read in the boundary condition menu of mass flow inlet of for an example 0.001 kg/s.

Thanks
visitor is offline   Reply With Quote

Old   April 28, 2014, 10:29
Default
  #4
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Quote:
Originally Posted by visitor View Post
1. In the define drop down menu, I can see functions>Interpret or Compiled or Manage. What do I choose? I assume interpreter.
interprete

2. If Interpreter, where do I past the suggested code? can this be done in a word file and saved in a specific format?
text file, change extension .txt. to .c

3. What is the boundary condition name which I will be entering in the "Mass flow Inlet" boundary condition?
DEFINE_PROFILE(whatyouwriteherewillbeavailableinth edropdownmenuoftheboundarycondition,th,i)

4. What is the subroutine code name or file name which I need to enter in the Interpreted UDF menu, , Browse ..?
the name of the .c file

5. In the suggested code, I need to have some think like "mass = 0.001".
This will be read in the boundary condition menu of mass flow inlet of for an example 0.001 kg/s.
just change the numbers in the example I gave you
There is a step-by-step example in chapter 8 of UDF Manual 15.0. Please go through this example to get acquainted with UDFs.
rahulsphogat likes this.
macfly is offline   Reply With Quote

Old   April 29, 2014, 05:49
Default Capturing the result of varying outlet boundary condition
  #5
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Mac

Thank you for your help, also went through the manuals just like you have mentioned. Now I have run the model.

Now that I have this varying inlet condition. The resulting outlet boundary condition will naturally vary. Its a pressure outlet boundary condition, let us call it X-Out. I understand that there is a way of capturing this varying boundary condition on a graph. The graph needs to plot pressure at X-Out versus time. Can you please or anyone show how this can be done.

Thanks again.
visitor is offline   Reply With Quote

Old   September 11, 2014, 07:23
Default A C routine for a non return valve
  #6
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear friends:

On similar lines to what is shown below. I have now another boundary condition. An inlet which needs to allow air to flow into the container, when there is a pressure drop below zero gauge pressure. Another words, a non-return valve.

Is there another routine in C language that I need to apply? Will this C routine be in a separate file to the one shown below (which is for another boundary condition of mass flow inlet)?

Thanks.
visitor is offline   Reply With Quote

Old   September 11, 2014, 12:20
Default
  #7
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Hi AH,

I'm not sure I have a good understanding of your problem. A pressure drop between what and what?

But the general answer is that all your routines can be in the same udf file. You will probably have to use a DEFINE_EXECUTE_AT_END macro with face loops in order to check the pressure drop between 2 boundaries (I guess). The result of this calculation will serve in a conditional statement within a DEFINE_PROFILE macro.

Sorry I don't have time to show you an example. Look in the UDF guide, you can find UDF examples with multiple macros that are coupled.
macfly is offline   Reply With Quote

Old   September 15, 2014, 05:21
Default problem description sketch
  #8
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Macfly

thank you for your reply.

I am not familiar with C language. Also, just started learning CFD.

Have attached a problem description, and would appreciate if a procedure is entered in the C language example dated 24th of April.

Thanks.
Attached Images
File Type: jpg example sketch.jpg (44.0 KB, 49 views)
visitor is offline   Reply With Quote

Old   September 15, 2014, 08:15
Default
  #9
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Quote:
Originally Posted by visitor View Post
I am not familiar with C language. Also, just started learning CFD.

Have attached a problem description, and would appreciate if a procedure is entered in the C language example dated 24th of April.Thanks.
I will not do it for you...
If you are starting learning, the UDF Guide is your best reference in order to learn the basics, not the forum. You will never get answers in the forum that are as clear as the UDF Guide (for the basics).

Good luck
macfly is offline   Reply With Quote

Old   September 15, 2014, 15:12
Default
  #10
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Quote:
Originally Posted by visitor View Post
Dear Macfly

thank you for your reply.

I am not familiar with C language. Also, just started learning CFD.

Have attached a problem description, and would appreciate if a procedure is entered in the C language example dated 24th of April.

Thanks.
Do you realize that you are are asking somebody else to do your work? It is good that Macfly does not do that.

If you give it your best shot, don't succeed, and post your effort here, people will be willing to help you understand what you did wrong and improve your code, so the next time you can do it yourself.
pakk is offline   Reply With Quote

Old   September 16, 2014, 07:14
Default
  #11
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Pakk

Thank you for your advise.

It is perfectly normal to ask a question. We are on this site from different levels of experience and are here to share our experience.

Yes, I have been trying and will continue to search for a solution.

Thanks.
visitor is offline   Reply With Quote

Old   September 16, 2014, 10:14
Default
  #12
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
It is no problem that you asked a question. Up to and including your message of September 11, 2014 12:23, all your questions were fine. And then macfly gave you an answer to show you which direction you should go.
Nobody expects you to understand everything immediately, and it is ok to come back with further questions, especially because you mentioned you just started learning CFD and are not familiar with C language.

But when you say "Have attached a problem description, and would appreciate if a procedure is entered in the C language example dated 24th of April.", you give the impression that you don't want to understand CFD or C, that you don't want to learn anything, but that you want macfly to write a UDf that you can use so you don't have to program anything.
That is not asking questions. That is asking somebody else to do your work.

I assume that you did not mean to be rude, but this is how your message was received, at least by me.
macfly likes this.
pakk is offline   Reply With Quote

Old   October 13, 2014, 05:13
Default
  #13
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear sirs/madams:

I have made an attempt to write a C udf to loop over a cell face. With a condition if the pressure falls bellow zero, 1 will be the value for the boundary inlet. Else if, the pressure on the cell face is greater than 100, then the boundary inlet will be zero. Trying to create a non return valve.

Question assuming the SECOND part of this code is correct, how will I specify what cell face number? There are hundreds of cells?

#include "udf.h"
DEFINE_PROFILE(inlet_mf,th,i)
{
face_t f;
begin_f_loop(f,th)
{
if(CURRENT_TIME <= 5.0)
F_PROFILE(f,th,i) = 1.0;
else if(CURRENT_TIME <=10.0 && CURRENT_TIME >5.0)
F_PROFILE(f,th,i) = 0.0;
else if(CURRENT_TIME <=15.0 && CURRENT_TIME >10.0)
F_PROFILE(f,th,i) = 1.0;
else if(CURRENT_TIME <=20.0 && CURRENT_TIME >15.0)
F_PROFILE(f,th,i) = 0.0;
else
F_PROFILE(f,th,i) = 1.0;
}
end_f_loop(f,th);
}
/*second part. The following lines are to monitor pressure on a specific face pressure and loop over it with conditions.
DEFINE_PROFILE(vary,th,i)
{
C_P(c,t)
begin_f_loop(f,t)
{
pressure = F_P(f,t)
if(pressure <= 0)
F_PROFILE(f,th,i) = 1;
else if(pressure > 1000)
F_PROFILE(f,th,i) = 0;
}
end_f_loop(f,t)
}
visitor is offline   Reply With Quote

Old   October 13, 2014, 06:23
Default
  #14
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Hi visitor,

I don't understand your question: where do you want to specify a cell face number?

For your code, the line 'C_P(c,t)' should be removed, and you need to choose to call the thread "th" or "t", but not use both to refer to the same thing, that won't work.
pakk is offline   Reply With Quote

Old   October 13, 2014, 07:09
Default
  #15
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Pakk

Thank you for your reply.

1- Deleted C_P(c,t).
2- Replaced th with t.
3- Regarding where to specify the cell number? Anywhere as long as the specific cell number is read in the body fluid. Let us say I want the code to read pressure in cell number 100. How can I specify this.
4- Also, one more concern, I am concerned about running in parallel processors.

Thanks in advance for your explanation.

Regards.
---------


#include "udf.h"
DEFINE_PROFILE(inlet_mf,th,i)
{
face_t f;
begin_f_loop(f,th)
{
if(CURRENT_TIME <= 5.0)
F_PROFILE(f,th,i) = 1.0;
else if(CURRENT_TIME <=10.0 && CURRENT_TIME >5.0)
F_PROFILE(f,th,i) = 0.0;
else if(CURRENT_TIME <=15.0 && CURRENT_TIME >10.0)
F_PROFILE(f,th,i) = 1.0;
else if(CURRENT_TIME <=20.0 && CURRENT_TIME >15.0)
F_PROFILE(f,th,i) = 0.0;
else
F_PROFILE(f,th,i) = 1.0;
}
end_f_loop(f,th);
}
/*second part. The following lines are to monitor pressure on a specific face pressure and loop over it with conditions.
DEFINE_PROFILE(vary,t,i)
{

begin_f_loop(f,t)
{
pressure = F_P(f,t)
if(pressure <= 0)
F_PROFILE(f,t,i) = 1;
else if(pressure > 1000)
F_PROFILE(f,t,i) = 0;
}
end_f_loop(f,t)
}
visitor is offline   Reply With Quote

Old   October 13, 2014, 07:14
Default
  #16
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I am sorry, but I still don't understand.
I see no need to specify a cell number anywhere, I don't know why you would want to specify a cell number anywhere, I don't know which function the cell number should have in your code, I don't know where (in the code) you would want the cell number to be...
What is wrong with the code that you supplied? What is the thing you want to add by including a cell number?
pakk is offline   Reply With Quote

Old   October 13, 2014, 07:57
Default
  #17
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Sirs/Madams:

Thanks again.

In a large body of fluid, as an example in the sketch I have uploaded in previous postings. Pressure can slightly vary in the enclosed body of fluid, depending on location.

I will carry on searching through manuals, if anyone can help thanks in advance. Dear Pakk, thanks again.
visitor is offline   Reply With Quote

Old   October 13, 2014, 11:39
Default
  #18
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Quote:
Originally Posted by visitor View Post
DEFINE_PROFILE(vary,t,i)
{

begin_f_loop(f,t)
{
pressure = F_P(f,t)
if(pressure <= 0)
F_PROFILE(f,t,i) = 1;
else if(pressure > 1000)
F_PROFILE(f,t,i) = 0;
}
end_f_loop(f,t)
}
face_t f; is missing
the pressure variable has to be declared first
macfly is offline   Reply With Quote

Old   October 14, 2014, 09:21
Default
  #19
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Mac

Thanks.
Added: -

real pressure;
face_t f;

Hope it will work when I get to the uni computer lab.
Regards.
--------------------------

DEFINE_PROFILE(vary,t,i)
{
real pressure;
face_t f;
begin_f_loop(f,t)
{
pressure = F_P(f,t)
if(pressure <= 0)
F_PROFILE(f,t,i) = 1;
else if(pressure > 1000)
F_PROFILE(f,t,i) = 0;
}
end_f_loop(f,t)
}
visitor is offline   Reply With Quote

Old   October 14, 2014, 09:33
Default
  #20
Senior Member
 
ghost82's Avatar
 
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27
ghost82 will become famous soon enough
I think you should add a condition if 0<pressure>1000.
Also I don't understand where you want to apply these 2 profiles: you'd better to attach some pictures of your domain/boundary conditions.
ghost82 is offline   Reply With Quote

Reply


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
Boudaries for bouynat driven flow with additional mass flux at inlet Charon CFX 2 April 27, 2013 09:02
Water subcooled boiling Attesz CFX 7 January 5, 2013 04:32
velocity calculations in mass flow inlet boundary condition montazer1012 FLUENT 1 October 18, 2010 04:11
Mass flow boundary condition Renato. Main CFD Forum 0 July 21, 2006 23:07
New topic on same subject - Flow around race car Tudor Miron CFX 15 April 2, 2004 07:18


All times are GMT -4. The time now is 13:50.