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   December 17, 2014, 04:43
Default
  #41
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
In your code, you are only including "udf.h". You should change the code so it also includes "threads.h".

Nevertheless: it is worth the effort to install a compiler.
pakk is offline   Reply With Quote

Old   December 17, 2014, 11:14
Default
  #42
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
- The function mixture_specie_index can only be used with compiled UDFs.
- No need to include threads.h.
- I think you're confusing the i in DEFINE_PROFILE(inlet_mf,th,i) and the i for the co2, they are not the same. See the DEFINE_PROFILE argument i description in the UDF manual.
- The if else condition you wrote is useless, I removed it.
- Your UDF should look more like this, but since the i and ico2 are two different things, all the lines involving ico2 are totally useless:

Code:
#include "udf.h"
DEFINE_PROFILE(inlet_mf,th,i)
{
face_t f;
Material *m = THREAD_MATERIAL(th);
char *name = "co2";
int ico2;
ico2 = mixture_specie_index(m,name);
begin_f_loop(f,th) 
    {
    if(i >= 7e-4)
        F_PROFILE(f,th,i) = 118;
    }
end_f_loop(f,th)
}
macfly is offline   Reply With Quote

Old   December 30, 2014, 00:29
Default
  #43
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Modified as shown below, replaced ico2 with i. Still waiting for a complier to be installed by technicians. Will try it out once compiled, and share outcome.

Thanks, regards ..
-------------------------------

#include "udf.h"
DEFINE_PROFILE(inlet_mf,th,i)
{
face_t f;
Material *m = THREAD_MATERIAL(th);
char *name = "co2";
int i;
i = mixture_specie_index(m,name);
begin_f_loop(f,th)
{
if(i >= 7e-4)
F_PROFILE(f,th,i) = 118;
}
end_f_loop(f,th)
}
visitor is offline   Reply With Quote

Old   December 30, 2014, 00:45
Default
  #44
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
#include "udf.h"
DEFINE_PROFILE(inlet_mf,th,i)
{
face_t f;
Material *m = THREAD_MATERIAL(th);
char *name = "co2";
int i;
i = mixture_specie_index(m,name);
begin_f_loop(f,th)
{
if(i >= 7e-4)
F_PROFILE(f,th,i) = 118;
}
end_f_loop(f,th)
}
That's not going to work because i is an argument of the DEFINE_PROFILE and then you declare a new i within the macro. An error will pop out. What are you trying to do exactly, read CO2 content somewhere and consequently apply some profile elsewhere?
macfly is offline   Reply With Quote

Old   January 4, 2015, 03:14
Default
  #45
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.

Aim is to read CO2 content (a mass fraction figure) in the fluid volume, and then apply a condition.

That is if CO2 is > 7e-4, then apply a profile somewhere else. In this case an extractor fan with an extract pressure of 118 Pa.

thanks
regards
visitor is offline   Reply With Quote

Old   January 5, 2015, 00:16
Default
  #46
Senior Member
 
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17
macfly is on a distinguished road
Then refer to this post: http://www.cfd-online.com/Forums/flu...tml#post522192

You need a DEFINE_EXECUTE_AT_END to read the CO2 content, then a DEFINE_PROFILE. If the DEFINE_EXECUTE_AT_END reads CO2 content in a fluid volume, it needs a begin_c_loop/end_c_loop instead of a begin_f_loop/end_f_loop.

Good luck
macfly is offline   Reply With Quote

Old   January 5, 2015, 05:31
Default
  #47
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Macfly

Thanks for your help, you are helpful.

Didn't get the compiler yet, still waiting to start work on it.

Meanwhile understood the begin/end_c_loop. But not the rest, where to insert the rest, ... DEFINE_EXECUTE_AT_END , .... DEFINE_PROFILE.

Thanks again, regards..
--

#include "udf.h"
DEFINE_PROFILE(inlet_mf,th,i)
{
face_t f;
Material *m = THREAD_MATERIAL(th);
char *name = "co2";
int i;
i = mixture_specie_index(m,name);
begin_c_loop(f,th)
{
if(i >= 7e-4)
F_PROFILE(f,th,i) = 118;
}
end_c_loop(f,th)
}
visitor is offline   Reply With Quote

Old   January 5, 2015, 10:48
Default
  #48
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
Meanwhile understood the begin/end_c_loop. But not the rest, where to insert the rest, ... DEFINE_EXECUTE_AT_END , .... DEFINE_PROFILE.

Thanks again, regards..
--

#include "udf.h"
DEFINE_PROFILE(inlet_mf,th,i)
{
face_t f;
Material *m = THREAD_MATERIAL(th);
char *name = "co2";
int i;
i = mixture_specie_index(m,name);
begin_c_loop(f,th)
{
if(i >= 7e-4)
F_PROFILE(f,th,i) = 118;
}
end_c_loop(f,th)
}
I gave you a full, commented example of how to use DEFINE_EXECUTE_AT_END and DEFINE_PROFILE, now it's your turn to personalize my example for your problem. I'm trying to help and you keep reposting the same udf with the i problem... showing no work on your part... that's the end of the discussion.
macfly is offline   Reply With Quote

Old   January 6, 2015, 04:42
Default
  #49
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Mcfly

It sounds like there is a misunderstanding. I did say I am waiting for a compiler before I start work on it.

Thanks anyway for your help. Will work on it once I get a compiler and share results with everyone.

Regards
visitor is offline   Reply With Quote

Old   February 21, 2015, 01:41
Default
  #50
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Still waiting for a compiler, was informed by ITs that a compiler will be installed on netwrok by next academic year!

Have tried another go using Interpreter, got this message "undecleared variable at line 5. Can anyone explain this please, I am not a C programmer.

Prefer to keep code as is with minimal necessary changes for now, please.


--------
#include "udf.h"
DEFINE_EXECUTE_AT_END(exec_at_end)
{
face_t f;
Material *m = THREAD_MATERIAL(th);
char *name = "co2";
int i;
i = mixture_specie_index(m,name);
}
DEFINE_PROFILE(inlet_mf,th,i)
{
begin_f_loop(f,th)
{
if(i => 7e-4)
F_PROFILE(f,th,i) = 118;
else if(i < 7e-4)
F_PROFILE(f,th,i) = 0;
}
end_f_loop(f,th)
}
visitor is offline   Reply With Quote

Old   February 23, 2015, 10:10
Default
  #51
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
It means you have an undeclared variable at line 5.

Your line 5 is:
Code:
Material *m = THREAD_MATERIAL(th);
Even if you don't know anything about programming, you could guess that there are four things that could be a "variable":
  • Material
  • m
  • THREAD_MATERIAL
  • th
Now, go ahead and try to reason which one of these are variables (hint: two of the four are variables) and which variable is undeclared. If you don't know what "undeclared" means, try to guess.
pakk is offline   Reply With Quote

Old   February 25, 2015, 02:19
Default
  #52
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Pakk

Thank you for your suggestion.

Tried by declaring as follows;
float Material; and then the same for the rest, didn't work.

Thanks
visitor is offline   Reply With Quote

Old   February 25, 2015, 03:51
Default
  #53
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Your guess was wrong: "th" is the undeclared variable.

The line says, translated into English: m is a pointer to a material, and gets the value of the material of "th".

But Fluent has no idea which thread "th" should be. Neither do I. You need to find a way tell Fluent which thread "th" is, because now it is undefined.
pakk is offline   Reply With Quote

Old   February 25, 2015, 07:22
Default
  #54
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Thanks Pakk

Just to get rid of the error message I had regarding the undeclared variable, changed th to t, and declared t is a char.

The error message now is line 13 undeclared variable. But f is already declared as face_t f; ...?

Thanks , regards.
__

#include "udf.h"
DEFINE_EXECUTE_AT_END(exec_at_end)
{
face_t f;
char t;
Material *m = THREAD_MATERIAL(t);
char *name = "co2";
int i;
i = mixture_specie_index(m,name);
}
DEFINE_PROFILE(inlet_mf,th,i)
{
begin_f_loop(f,th)
{
if(i => 7e-4)
F_PROFILE(f,th,i) = 118;
else if(i < 7e-4)
F_PROFILE(f,th,i) = 0;
}
end_f_loop(f,th)
}
visitor is offline   Reply With Quote

Old   February 25, 2015, 09:10
Default
  #55
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
From your actions, it appears that you didn't fully understand the problem. (Which is not bad, programming can be hard if you are not used to it.)

In your change, you changed the name "th" to "t" (why?), and you had already informed Fluent that "t" is a char.
Why would you say "t" is a char? Is there any thought behind that, or are you just guessing? If it were a guess, the guess is wrong, it should be "Thread *t". See the definition of THREAD_MATERIAL in UDF manual 2.3.20.
A big problem still exists in line 5, by the way. Fluent does not know which value "t" should have. I also don't know what you want, so I can not say you what to put there. What is, according to you, the function of line 5? If you can give me, in plain English, a description of what that line should do, maybe I can give you the corresponding code for that.

In line 13, the problem is indeed f. In that region, f is not defined, f is only defined in the function DEFINE_EXECUTE_AT_END(exec_at_end), not in the function DEFINE_PROFILE(inlet_mf,th,i). If you want to use it there, you have to define it again.
pakk is offline   Reply With Quote

Old   February 26, 2015, 03:00
Default
  #56
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Pakk

Thanks, yes I have no background in c, mainly CFD. With the changes made the pending errors are "parse error" at lines 16 and 18.

Thanks.
-------

#include "udf.h"
DEFINE_EXECUTE_AT_END(exec_at_end)
{
face_t f;
Thread *th;
Material *m = THREAD_MATERIAL(th);
char *name = "co2";
real i;
i = mixture_specie_index(m,name);
}
DEFINE_PROFILE(inlet_mf,th,i)
{
face_t f;
begin_f_loop(f,th)
{
if(i => 7e-4)
F_PROFILE(f,th,i) = 118;
else if(i < 7e-4)
F_PROFILE(f,th,i) = 0;
}
end_f_loop(f,th)
}
visitor is offline   Reply With Quote

Old   February 26, 2015, 04:12
Default
  #57
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
What is the goal of this question? Getting rid of all the warnings in Fluent? Or getting a UDF that does what you want?

Right now, you only seem to care about getting rid of all the warnings. Forget those warnings for a while. The warnings are not the problem, the warnings only indicate that there is a problem.

You still have a big problem in line 5, as I explained last post. As you can see here, you still have problems in lines 14 and 16. These lines should be different.
But there are millions of possible lines that would remove the warnings. And almost all of them will not give you the result that you want.

Please say, in English (or French, or German, or whatever), what your lines 5, 14 and 16 should do. That is the first step. The second step will be how to tell Fluent to do that, but I can not help you with the second step until you do the first step.

Stop with making changes to the code, take a step back, and think about what the code should do. Otherwise you will be running around in circles forever.
pakk is offline   Reply With Quote

Old   February 26, 2015, 04:46
Default
  #58
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Pakk

Two back steps taken.

First part of code should enter the fluid body and picks up the mass fraction of co2.

Second part is a loop which loops around the value of i. If i is => 7e-4, then a boundary condition is set which is,
F_PROFILE(f,th,i) = 118;

Please see red text below.

Thanks.
--

#include "udf.h"
DEFINE_EXECUTE_AT_END(exec_at_end)
{
face_t f;
char t;
Material *m = THREAD_MATERIAL(t); /*This line should declare the material value *mm which is used in i = mixture_specie_index(m,name); below */
char *name = "co2";
int i;
*/code below, the m should represent the co2 figure, whicle name should represent the co2 text. Another words we are reading mass fraction value or the m value of co2 or name*/
i = mixture_specie_index(m,name);
}
DEFINE_PROFILE(inlet_mf,th,i)
{
begin_f_loop(f,th)
{
if(i => 7e-4)
F_PROFILE(f,th,i) = 118;
else if(i < 7e-4)
F_PROFILE(f,th,i) = 0;
}
end_f_loop(f,th)
}
visitor is offline   Reply With Quote

Old   February 26, 2015, 05:44
Default
  #59
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 Pakk

Two back steps taken.

First part of code should enter the fluid body and picks up the mass fraction of co2.

Second part is a loop which loops around the value of i. If i is => 7e-4, then a boundary condition is set which is,
F_PROFILE(f,th,i) = 118;
Ok, now your intentions become more clear.
Allow me to paraphrase in my own words the steps that you want Fluent to take.

- Fluent should, at every iteration, set the mass-flow at your inlet at a value that depends on the volume-averaged mass fraction of co2 in your total volume.

And your implemention strategy was:
- At every iteration, calculate the volume-averaged mass fraction of co2, and store that in a variable. (The exec_at_end-part)
- At every iteration, set the mass flow at the inlet depending on that stored variable. (the inlet_mf part)

Before I continue: is my interpretation correct?
pakk is offline   Reply With Quote

Old   February 26, 2015, 06:05
Default
  #60
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Dear Pakk

Thanks for your prompt response.

Yes your interpretation is correct.

Accept that from what I understand that DEFINE_EXECUTE_AT_END(exec_at_end)
actually reads information at the end of each time step rather than iteration.


Thanks
visitor 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 14:19.