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) } |
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) } |
2 Attachment(s)
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 |
Are you able to compile different udfs, or is only this udf the problem?
|
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. |
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 |
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. |
1 Attachment(s)
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.
|
Can you interpret rather than compile your udf?
|
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 |
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. |
Variable Inlet velocity
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 |
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" |
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 |
Re:Variable Inlet velocity
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!!! |
Slight change in topic
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! |
According to the help, THREAD_MATERIAL is defined in threads.h. You probably need to include threads.h for it to work.
|
Or compile it instead of interpreting. This is true in general: compiling works better than interpreting.
|
As Pakk wrote, it probably needs to be compiled.
|
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 |
All times are GMT -4. The time now is 04:51. |