|
[Sponsors] |
Varying mass flow at an inlet boundary condition. Fuel mass flow. |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 17, 2014, 04:43 |
|
#41 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
|
December 17, 2014, 11:14 |
|
#42 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
- 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) } |
|
December 30, 2014, 00:29 |
|
#43 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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) } |
|
December 30, 2014, 00:45 |
|
#44 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
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?
|
|
January 4, 2015, 03:14 |
|
#45 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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 |
|
January 5, 2015, 00:16 |
|
#46 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
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 |
|
January 5, 2015, 05:31 |
|
#47 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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) } |
|
January 5, 2015, 10:48 |
|
#48 | |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Quote:
|
||
January 6, 2015, 04:42 |
|
#49 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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 |
|
February 21, 2015, 01:41 |
|
#50 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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) } |
|
February 23, 2015, 10:10 |
|
#51 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
It means you have an undeclared variable at line 5.
Your line 5 is: Code:
Material *m = THREAD_MATERIAL(th);
|
|
February 25, 2015, 02:19 |
|
#52 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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 |
|
February 25, 2015, 03:51 |
|
#53 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
|
February 25, 2015, 07:22 |
|
#54 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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) } |
|
February 25, 2015, 09:10 |
|
#55 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
|
February 26, 2015, 03:00 |
|
#56 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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) } |
|
February 26, 2015, 04:12 |
|
#57 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
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. |
|
February 26, 2015, 04:46 |
|
#58 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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) } |
|
February 26, 2015, 05:44 |
|
#59 | |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Quote:
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? |
||
February 26, 2015, 06:05 |
|
#60 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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 |
|
|
|
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 |