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. |
- 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" |
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) } |
Quote:
|
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 |
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 |
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) } |
Quote:
|
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 |
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) } |
It means you have an undeclared variable at line 5.
Your line 5 is: Code:
Material *m = THREAD_MATERIAL(th);
|
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 |
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. |
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) } |
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. |
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) } |
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. |
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) } |
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? |
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 |
All times are GMT -4. The time now is 15:14. |