|
[Sponsors] |
Match Pressure Inlet/Outlet Boundary Condition Mass Flow Rate |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 14, 2019, 10:43 |
Match Pressure Inlet/Outlet Boundary Condition Mass Flow Rate
|
#1 |
New Member
Michael
Join Date: Dec 2018
Posts: 3
Rep Power: 7 |
Hi all,
I am currently aiming to run a CFD simulation on a diffusing duct with pressure inlet (total) and pressure outlet (static) specification. I have two additional pressure boundary conditions within the duct in order to simulate an external duct connecting these two slot locations. As such, I have set the bleed slot as a pressure outlet and the injection slot as a pressure inlet. Currently, I do not explicitly know the mass flow rate through the external duct yet, but for continuity purposes the mass flow should match for the two internal boundary conditions. Thus, I am aiming to implement a UDF to set the target mass flow rate of the bleed slot (pressure outlet). The idea that I am currently working with, is that this mass flow rate should be based on the mass flow rate through the injection slot. At the injection slot a total pressure specification sets the mass flow, where the total pressure is obtained from an estimated total pressure drop through the "external duct". (From my understanding, fluent extrapolates the static pressure from the internal volume, which would, given the fixed total pressure, set the mass flow rate). The UDF I am currently working with is as shown below; I don't have a lot of experience with UDFs, so apologies for any major mistakes! I have adapted code from https://www.cfd-online.com/Forums/fluent-udf/74052-udf-measure-mass-flow-rate.html & https://www.sharcnet.ca/Software/Fluent6/html/udf//node42.htm#sec-define-profile for this purpose. The aim of this UDF is to obtain the mass flow rate from domain 5 (the injection slot) and set the target mass flow rate of domain 4 (the bleed slot) after each iteration, so that the mass flow rates will ultimately match. Currently, the "Mass Flow Set" command is often producing a 0 output and so I am certain that the UDF is not functioning as intended and I am a little bit unsure how come a 0 output is possible? Additionally, I believe that at the moment I am assigning each face thread the total mass flow rate rather than the mass flux in the DEFINE_PROFILE function. Would I be able to assign the mass flux directly to F_PROFILE instead? Any advice on this would be greatly appreciated. Thank you very much in advance! #include "udf.h" real massflow_total; DEFINE_EXECUTE_AT_END(getmassflow){ Domain *d; cell_t c; Thread *t; face_t f; real massflow; d = Get_Domain(1); t = Lookup_Thread(d, 5); begin_f_loop(f,t) /*Loop through all face threads on domain with id 5*/ { massflow+=F_FLUX(f,t); /* Assign mass flux at given face to variable massflow for each face thread in domain 5 */ } end_f_loop(f,t) massflow_total = massflow; massflow = 0.; } DEFINE_PROFILE(adjustbc, t, i) { Domain *d; face_t f; d = Get_Domain(1); t= Lookup_Thread(d, 4); begin_f_loop(f,t) /* Loop through all face threads on domain with id 4 */ { F_PROFILE(f,t,i) = massflow_total; /* Assign mass flow to profile for target mass flow specification */ } end_f_loop(f,t) printf("MassFlow Set: %g\n",massflow_total); /* Checking */ massflow_total=0.; /* Reset total mass flow for next iteration */ } |
|
February 16, 2019, 19:22 |
|
#2 |
Senior Member
Join Date: Sep 2017
Posts: 246
Rep Power: 12 |
Hi MSchneid,
The zero output could be easy to explain: the DEFINE_PROFILE might be called more often than you expect -- so, more often than the DEFINE_EXECUTE_AT_END refills the global massflow_total. It would be much better to initialize massflow_total just before you refill it -- that is, in the DEFINE_EXECUTE_AT_END. I am slightly surprised that a mass-flow inlet accepts a DEFINE_PROFILE. Since it does, you need to find by experimentation (or maybe reading the manual, then experimentation) what it does with the values you feed it. So, feed it some constant values and postprocess what mass flowrate it produces. (Please tell us your findings for future use.) To convert a mass flowrate to a mass flux, obviously you need to assemble a total face area and then divide the flowrate by the area to get a flux. I would never use printf, only Message inside UDFs. But it seems you are doing OK despite this. It would take a small amount of work to make your UDF suitable for parallel simulations. Good luck! Ed |
|
February 17, 2019, 17:01 |
|
#3 | |
New Member
Michael
Join Date: Dec 2018
Posts: 3
Rep Power: 7 |
Quote:
Thank you very much for your advice, this is very helpful and I really appreciate it. I am hoping to implement these changes this week and will make necessary adjustments to the UDF for use in parallel simulations, which would speed up the process. Many thanks again! |
||
February 23, 2019, 06:00 |
|
#4 |
New Member
Michael
Join Date: Dec 2018
Posts: 3
Rep Power: 7 |
Just to provide an update on this. The error, as mentioned by Ed, was to do with the parallelization. The UDF had been written for serial purposes on the aforementioned links, but I was running the simulation in parallel on 8 cores. Thus, the UDF ran on each node and I was only collecting the mass flow on a specific domain, the other partititions were measuring 0 mass flow rate. The output was seven times a 0 and once the actual desired output (8 cores). I adjusted the code for parallel simulations and actually collected the mass flow rate data within the DEFINE PROFILE rather than the two seperate functions and it worked perfectly.
Additionally, I have fed the target mass flow specification a constant value for testing. This worked absolutely fine, with the pressure adjusting itself automatically to meet the mass flow. Due to the posed problem, the mass flow was oscillating around the specified rate but the average did meet the specified value. I hope this is helpful. Best wishes. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
sliding mesh problem in CFX | Saima | CFX | 46 | September 11, 2021 07:38 |
Issues on the simulation of high-speed compressible flow within turbomachinery | dowlee | OpenFOAM Running, Solving & CFD | 11 | August 6, 2021 06:40 |
Centrifugal fan-reverse flow in outlet lesds to a mass in flow field | xiexing | CFX | 3 | March 29, 2017 10:00 |
Error - Solar absorber - Solar Thermal Radiation | MichaelK | CFX | 12 | September 1, 2016 05:15 |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 06:28 |