CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Varying mass flow at an inlet boundary condition. Fuel mass flow. (https://www.cfd-online.com/Forums/fluent-udf/133883-varying-mass-flow-inlet-boundary-condition-fuel-mass-flow.html)

 visitor April 22, 2014 06:28

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

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

 macfly April 24, 2014 22:42

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);
}

 visitor April 28, 2014 09:15

setting up

Dear Mac

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

 macfly April 28, 2014 10:29

Quote:
 Originally Posted by visitor (Post 488663) 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.

 visitor April 29, 2014 05:49

Capturing the result of varying outlet boundary condition

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 September 11, 2014 07:23

A C routine for a non return valve

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.

 macfly September 11, 2014 12:20

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.

 visitor September 15, 2014 05:21

problem description sketch

1 Attachment(s)
Dear Macfly

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.

 macfly September 15, 2014 08:15

Quote:
 Originally Posted by visitor (Post 510344) 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

 pakk September 15, 2014 15:12

Quote:
 Originally Posted by visitor (Post 510344) 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.

 visitor September 16, 2014 07:14

Dear Pakk

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.

 pakk September 16, 2014 10:14

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.

I assume that you did not mean to be rude, but this is how your message was received, at least by me.

 visitor October 13, 2014 05:13

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)
}

 pakk October 13, 2014 06:23

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.

 visitor October 13, 2014 07:09

Dear Pakk

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.

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)
}

 pakk October 13, 2014 07:14

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?

 visitor October 13, 2014 07:57

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.

 macfly October 13, 2014 11:39

Quote:
 Originally Posted by visitor (Post 514053) 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

 visitor October 14, 2014 09:21

Dear Mac

Thanks.

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)
}

 ghost82 October 14, 2014 09:33

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.

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