|
[Sponsors] |
Varying mass flow at an inlet boundary condition. Fuel mass flow. |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 15, 2014, 08:50 |
|
#21 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Thank you for your reply Ghost82
There is a sketch attached in entry #8 above dated 15 Sept. Basically one of the inlets shown in the sketch need to act as a one way airflow. If pressure in vessel drops below zero, than the z Cartesian inlet in the boundary Pressure Inlet condition will have 1 in the z Cartesian field, to allow air to enter. Other wise, if pressure is above 1000, then z will have a 0, to stop air flow entering or going out. Not sure why have 0<pressure>1000? If it makes it simpler, can rewrite to as follows (closing the gap between the 0 and 1000): - 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 > 0) F_PROFILE(f,t,i) = 0; } end_f_loop(f,t) } |
|
October 15, 2014, 08:55 |
|
#22 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Thank you for your reply Ghost82
There is a sketch attached in entry #8 above dated 15 Sept. Basically one of the inlets shown in the sketch need to act as a one way airflow. If pressure in vessel drops below zero, than the z Cartesian inlet in the boundary Pressure Inlet condition will have 1 in the z Cartesian field, to allow air to enter. Other wise, if pressure is above 1000, then z will have a 0, to stop air flow entering or going out. Not sure why have 0<pressure>1000? If it makes it simpler, can rewrite to as follows (closing the gap between the 0 and 1000): - 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 > 0) F_PROFILE(f,t,i) = 0; } end_f_loop(f,t) } |
|
November 17, 2014, 00:46 |
|
#23 |
Senior Member
Tanjina Afrin
Join Date: May 2013
Location: South Carolina
Posts: 169
Rep Power: 13 |
Hello Everyone,
I am trying to use UDF for time varying mass flow rate at inlet and edited the UDF from UDF manual. When I try to load the UDF, it gives me the error shown in the attached figure. Here is my UDF- For serial : #include "udf.h" DEFINE_PROFILE(inlet_mf,th,i) { face_t f; begin_f_loop(f,th) { if(CURRENT_TIME <= 3.0) F_PROFILE(f,th,i) = 10.0; else if(CURRENT_TIME <=5.0 && CURRENT_TIME >3.0) F_PROFILE(f,th,i) = 9.0; else if(CURRENT_TIME <=7.0 && CURRENT_TIME >5.0) F_PROFILE(f,th,i) = 8.0; else if(CURRENT_TIME <=9.0 && CURRENT_TIME >7.0) F_PROFILE(f,th,i) = 7.0; else if(CURRENT_TIME <=10.0 && CURRENT_TIME >9.0) F_PROFILE(f,th,i) = 6.0; else if(CURRENT_TIME <=11.0 && CURRENT_TIME >10.0) F_PROFILE(f,th,i) = 5.0; else if(CURRENT_TIME <=12.0 && CURRENT_TIME >11.0) F_PROFILE(f,th,i) = 4.0; else if(CURRENT_TIME <=13.0 && CURRENT_TIME >12.0) F_PROFILE(f,th,i) = 3.0; else if(CURRENT_TIME <=15.0 && CURRENT_TIME >13.0) F_PROFILE(f,th,i) = 3.0; else F_PROFILE(f,th,i) = 1.0; } end_f_loop(f,th); } and for parallel- #include "udf.h" DEFINE_PROFILE(inlet_mf,th,i) { #if !RP_HOST face_t f; begin_f_loop(f,th) { if(CURRENT_TIME <= 3.0) F_PROFILE(f,th,i) = 10.0; else if(CURRENT_TIME <=5.0 && CURRENT_TIME >3.0) F_PROFILE(f,th,i) = 9.0; else if(CURRENT_TIME <=7.0 && CURRENT_TIME >5.0) F_PROFILE(f,th,i) = 8.0; else if(CURRENT_TIME <=9.0 && CURRENT_TIME >7.0) F_PROFILE(f,th,i) = 7.0; else if(CURRENT_TIME <=10.0 && CURRENT_TIME >9.0) F_PROFILE(f,th,i) = 6.0; else if(CURRENT_TIME <=11.0 && CURRENT_TIME >10.0) F_PROFILE(f,th,i) = 5.0; else if(CURRENT_TIME <=12.0 && CURRENT_TIME >11.0) F_PROFILE(f,th,i) = 4.0; else if(CURRENT_TIME <=13.0 && CURRENT_TIME >12.0) F_PROFILE(f,th,i) = 3.0; else if(CURRENT_TIME <=15.0 && CURRENT_TIME >13.0) F_PROFILE(f,th,i) = 3.0; else F_PROFILE(f,th,i) = 1.0; } end_f_loop(f,th); #endif } Any suggestion to make it work will be highly appreciated. Regards, Tanjina |
|
November 17, 2014, 04:27 |
|
#24 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Are you able to compile different udfs, or is only this udf the problem?
|
|
November 17, 2014, 04:31 |
|
#25 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
I would add to pakk's question that for your udf it is not a must to modify the udf for parallel computation; this is because it is a profile udf, and if more than one node will assign a profile to the same cell it will simply overwrite the same value.
Did you install the development tool (gcc, etc) on linux? After installing the development tools, delete in the working folder the libudf folder, so to have only cas, dat and .c files; then recompile the .c udf and load the library.
__________________
Google is your friend and the same for the search button! Last edited by ghost82; November 17, 2014 at 08:04. |
|
November 17, 2014, 12:27 |
|
#26 |
Senior Member
Tanjina Afrin
Join Date: May 2013
Location: South Carolina
Posts: 169
Rep Power: 13 |
Thanks Pakk and Ghost 82.
@ Pakk, Yup I can compile other UDF.. actually before this, I only worked with one hydrostatic pressure inlet using UDF and here it is - #include "udf.h" DEFINE_PROFILE(pressure_profile,t,i) { #if !RP_HOST real x[ND_ND]; real y; face_t f; begin_f_loop(f,t) { F_CENTROID(x,f,t); y=x[1]; F_PROFILE(f,t,i)=(0.4728-y)*998.2*9.81; } end_f_loop(f,t) #endif } It worked perfectly. @ Ghost82, gcc is installed on my university cluster ( I am working on Cluster). there are 3 available version in cluster 3.4,4.4 and 4.8.1 Is there something like that I have to select/call one of them ? One more question: If I can't make this UDF work unfortunately, then if I change the flow rate manually time to time, will it work properly? ( Just asking) Regards, Tanjina |
|
November 17, 2014, 12:36 |
|
#27 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
Did you delete the libudf folder and recompile the udf directly on the cluster?
In your first screenshot I can see something related to 3d_node/3d_host, but you're on a 2d simulation. Yes, of course you can manually change the values with the same effect.
__________________
Google is your friend and the same for the search button! |
|
November 17, 2014, 12:43 |
|
#28 |
Senior Member
Tanjina Afrin
Join Date: May 2013
Location: South Carolina
Posts: 169
Rep Power: 13 |
I was thinking something like that....so I tried from my friend's account and I found the error which is something different from previous one but still I couldn't compiled the UDF. I am attaching the error image.
|
|
November 17, 2014, 12:48 |
|
#29 |
Senior Member
Rick
Join Date: Oct 2010
Posts: 1,016
Rep Power: 27 |
Can you interpret rather than compile your udf?
__________________
Google is your friend and the same for the search button! |
|
November 17, 2014, 12:58 |
|
#30 |
Senior Member
Tanjina Afrin
Join Date: May 2013
Location: South Carolina
Posts: 169
Rep Power: 13 |
I interpreted...there was no problem.... I followed the procedure described in UDF guide. Define->User defined->interpret.
Then from Define->User defined->compile->source file ->add. Up to this point this is okay. then I find this error when I try to build the library and load the udf. I am not that much comfortable with programming.... maybe I am missing something very easy. So I am seeking help from you guys. Regards, Tanjina |
|
November 24, 2014, 03:20 |
|
#31 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
The UDF worked fine for me.
As you have mentioned; Interpret then from your boundary condition eg inlet or what ever, select in the field (where it usually says constant) pressure_profile. Careful with semicolons .. Hope I have answered your question. |
|
December 2, 2014, 13:41 |
Variable Inlet velocity
|
#32 |
New Member
sam
Join Date: Apr 2013
Posts: 2
Rep Power: 0 |
Hello, I am studying a variable speed flow for cooling operation in a box with inlet and outlet. I want to define the inlet boundary as a function of outlet temperature, when the temperature increase or decrease below or above the set point range the inlet flow rate has to increase or decrease respectively. Is it possible to do that using UDF as you have discussed the time dependent flow? If so pls give me some hint.
Kind regards |
|
December 2, 2014, 23:23 |
|
#33 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
Hi Sam, it's totally doable.
Here's a UDF that 1. initialize some stuff 2. compute area-averaged T on a boundary at the end of each time step 3. define inlet profile as a function of what has been computed in step 2. Code:
#include "udf.h" /* global variables, will be used in multiple DEFINE macros */ real T_area_avg = 0.; real sum_T_area_avg = 0.; real area_outlet = 0.; DEFINE_INIT(init, domain) { /* Compute outlet area once and for all */ Thread *thread; face_t face; real area[ND_ND]; area_outlet = 0.; domain = Get_Domain(1); /* Get the domain using ANSYS FLUENT utility */ thread = Lookup_Thread(domain, 12); /* ID displayed in Boundary Conditions panel */ begin_f_loop(face, thread) F_AREA(area, face, thread); area_outlet += NV_MAG(area); end_f_loop(face, thread) printf("total outlet area = %g m^2 \n", area_outlet); /* Initialize T_area_avg */ T_area_avg = 300.; } DEFINE_EXECUTE_AT_END(exec_at_end) { /* Compute area-averaged T on boundary */ Domain *domain; /* declare domain pointer since it is not passed as an argument to the DEFINE macro */ Thread *thread; face_t face; real area[ND_ND]; sum_T_area_avg = 0.; /* needs to be reset at each timestep */ domain = Get_Domain(1); /* Get the domain using ANSYS FLUENT utility */ thread = Lookup_Thread(domain, 12); begin_f_loop(face, thread) F_AREA(area, face, thread); sum_T_area_avg += F_T(face, thread)*NV_MAG(area); end_f_loop(face, thread) T_area_avg = sum_T_area_avg/area_outlet; /* area-averaged temperature */ } DEFINE_PROFILE(inlet, thread, position) { face_t face; begin_f_loop(face, thread) { if (T_area_avg <= 305) F_PROFILE(face, thread, position) = 1; else F_PROFILE(face, thread, position) = 2; } end_f_loop(face, thread) } |
|
December 10, 2014, 08:32 |
|
#34 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
This looks good and useful.
One question, if I was to monitor CO2 content rather than temperature (for an example), what changes are required? Thanks in advance for; posting this helpful example, and answering this question. Regards |
|
December 11, 2014, 03:30 |
Re:Variable Inlet velocity
|
#35 | |
New Member
sam
Join Date: Apr 2013
Posts: 2
Rep Power: 0 |
Quote:
Thanks a lot macfly it was really very helpful. I have made some modification to make it compatible with my system and it works. Cheers!!! |
||
December 16, 2014, 09:09 |
Slight change in topic
|
#36 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Dear sirs/madams:
Similar work, in UDFs. Trying to ready CO2 content in model and then activate a boundary layer. This is in simple words. A Co2 sensor, once level exceeds a fixed figure, a boundary outlet is activated. Used this as first attempt: #include "udf.h" DEFINE_PROFILE(inlet_mf,th,i) { face_t f; Material *m = THREAD_MATERIAL(t); 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; else if(i < 7e-4); } end_f_loop(f,th) } - - - Error message line 5 undeclared variable. Help anyone, please, and thanks in advance. There may be other mistakes! |
|
December 16, 2014, 09:12 |
|
#37 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
According to the help, THREAD_MATERIAL is defined in threads.h. You probably need to include threads.h for it to work.
|
|
December 16, 2014, 09:13 |
|
#38 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Or compile it instead of interpreting. This is true in general: compiling works better than interpreting.
|
|
December 16, 2014, 09:29 |
|
#39 |
Senior Member
François Grégoire
Join Date: Jan 2010
Location: Canada
Posts: 392
Rep Power: 17 |
As Pakk wrote, it probably needs to be compiled.
|
|
December 17, 2014, 01:40 |
|
#40 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Thanks for your responses.
Did not understand "You probably need to include threads.h for it to work". Do I need to replace the t with h? In ; Material *m = THREAD_MATERIAL(t); Haven't got a compiler, need to stick with interpreter. 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 |