|
[Sponsors] |
|
September 10, 2010, 07:16 |
|
#1 |
New Member
adrian lynch
Join Date: Feb 2010
Posts: 9
Rep Power: 16 |
Hi Kartn
The problem with the previous code that I posted was in getting the value for the variable “flow” from the DEFINE_EXECUTE_AT_END section and using it in the DEFINE_PROFILE. The way it was set as a global variable was okay but what was happening was it was been set to zero after the DEFINE_EXECTUE_AT_END loop so the DEFINE_PROFILE function was seeing a value of flow=0. Sorry if what I am saying is hard to follow, but I have attached the working code below and maybe from comparing the two you will be able to understand. The only real different is in introducing the flow_tot variable as the global variable instead of using the flow variable. #include"udf.h" real flow_tot; real p ; DEFINE_EXECUTE_AT_END(funny) { Domain *d; real flow; cell_t c; Thread *t; face_t f; d = Get_Domain(1); t= Lookup_Thread(d, 12); begin_f_loop(f,t) { flow+=F_FLUX(f,t); } end_f_loop(f,t) p = C_P(c,t); printf("static pressure = %g\n", p); printf("MASS Flow Rate: %g\n",flow); flow_tot =flow; flow=0.; } DEFINE_PROFILE(pressure_out,t,i) { real set_point = 1; real pressure; face_t f; printf("MASS Flow Rate: %g\n",flow_tot); if (flow_tot < set_point) pressure = p - 1; elseif (flow_tot > set_point) pressure = p + 1; else pressure = p; begin_f_loop(f,t) { F_PROFILE(f,t,i) = pressure; } end_f_loop(f,t) printf("Adjusted pressure = %g\n", pressure); } Hope this helps! |
|
February 22, 2011, 02:48 |
Udf for applying transient mass flow rate
|
#2 |
New Member
zubair
Join Date: Feb 2011
Posts: 2
Rep Power: 0 |
I am trying to figure out how to write a udf for applying a transient mass flow rate at the inlet. In my case study the mass flow rate varies with time from 0 to 40L/min and then comes down to zero in one cycle that ranges from 0 to 4 sec.
If anybody have a ready made udf, i wud be grateful if u could plz post it in this link or pass on through my email id. I admit i am have a bad programming knowledge but since it is bit urgent, i have to seek ur opinion and help without having to take the pain to learn it myself. Plz do help |
|
June 21, 2011, 21:43 |
|
#3 | |
Member
Join Date: Mar 2011
Posts: 38
Rep Power: 15 |
Quote:
begin_f_loop(f,t) { flow+=F_FLUX(f,t); } end_f_loop(f,t) Here the F_FLUX(f,t) is a vector, I believe, so what if you want to get the mass flow rate, instead of the flux, can I write: begin_f_loop(f,t) { flow+=F_YI(f,t,i)*F_FLUX(f,t)*F_AREA(A,f,t); } end_f_loop(f,t) or real A[ND_ND], flux(ND_ND) begin_f_loop(f,t) { flux=F_FLUX(f,t); F_AREA(A,f,t); mf=F_YI(f,t,i); flow+=mf*NV_DOT(flux, A); } end_f_loop(f,t) As I understand, F_YI(f,t,i), F_FLUX(f,t) and F_AREA(A,f,t) just get one patch of the surface 'f' corresponding to the thread 't', so the area 'A' is the area of that patch, that's why we need the begin_f_loop and end_f_loop, am I getting this right? thanks! |
||
June 24, 2011, 16:30 |
|
#4 | |
New Member
Join Date: Sep 2010
Posts: 3
Rep Power: 15 |
Quote:
F_FLUX(f,t) by itself outputs the mass flow rate entering or leaving a face in a cell. It is a scalar quantity and it outputs the result of the dot product of the mass flux vector and area normal vector. So all u have to do in order to calculate the mass flow rate of a particular species is find the product of total flux of the mass flux vector and the mass fraction. begin_f_loop(f,t) { flow+=F_FLUX(f,t)*F_YI(f,t); } end_f_loop(f,t) |
||
June 25, 2011, 01:04 |
|
#5 | |
Member
Join Date: Mar 2011
Posts: 38
Rep Power: 15 |
Thanks a million Kartn!
So, if I have some fluid entering into a surface, F_FLUX should be a negative scalar, right? I remembered I've seen it somewhere, the result we see from the GUI values are actually the opposite of the F_FLUX , because they have different definitions of the 'normal' direction. What I mean, from GUI, the value should be positive, because the fluid is entering into the surface, so it should be positive, but according to the definition of F_FLUX, it should be negative. Am I getting this right? Thanks! Quote:
|
||
May 4, 2012, 06:58 |
|
#6 |
New Member
|
Good morning everybody,
I was reading your post and I think I've the same problem as all of you. I'm analyzing journal bearings. The problems seams easy but i can't have the convergence if the "pressure-inlet" vs "pressure-outlet" are imposed. If I try to impose "mass flow inlet" vs "pressure-outlet" i can reach a good convergence. The problem is: I don't know the mass flow!!!! My idea is: impose a mass flow, calculate the total pressure (known data) and then recompute the mass flow at any iteration. I've to write an UDF like yours: 1. Calculate the total average total pressure on the inlet and with an algorithm calculate the next mass flow (this is easy like a bisection algorithm will work sure, remember i had an aimed total pressure). 2. Input the new mass flow. So the first UDF must be an DEFINE_EXECUTE_AT_END, to calculate for example "mass_flow", and the next will be an DEFINE_PROFILE. My question is: how to calculate the average total pressure on a face (of course Ptot=Pstat+0.5*rho*v^2) but i don't know how to implement it as an average on the boundary. when u do this: begin_f_loop(f,t) { flow+=F_FLUX(f,t); } end_f_loop(f,t) means that fluent is going to give u "flow" as the summatory of all the face fluxes of the boundary with the same ID? thanks for your help! |
|
June 20, 2012, 12:53 |
|
#7 | |
Senior Member
mahdi abdollahzadeh
Join Date: Mar 2011
Location: Covilha,Portugal
Posts: 153
Rep Power: 15 |
Quote:
Thanks For sharing your work. Could you please help me. I want to calaculate the mass flow rate on a surface diffrent that the outlet boundary and then i want to modify the pressure at outlet according to that mass flow. I dont have that surface as a boundary seprately. I just creat that surface as an isosurface in Fluent and I was calculataing the mass flow in GUI. I appriciate your help. Best Mehdi |
||
September 26, 2017, 12:50 |
|
#8 | |
Senior Member
Astio Lamar
Join Date: May 2012
Location: Pipe
Posts: 186
Rep Power: 14 |
Quote:
Code:
============================================================================== Node 0: Process 13808: Received signal SIGSEGV. ============================================================================== ============================================================================== Node 1: Process 17288: Received signal SIGSEGV. ============================================================================== ============================================================================== Node 3: Process 17844: Received signal SIGSEGV. ============================================================================== ============================================================================== Node 999999: Process 16332: Received signal SIGSEGV. ============================================================================== ============================================================================== Node 5: Process 12176: Received signal SIGSEGV. ============================================================================== ============================================================================== Node 6: Process 17444: Received signal SIGSEGV. ============================================================================== MPI Application rank 0 exited before MPI_Finalize() with status 2 The fl process could not be started. Thanks. PS: I interpret the UDF. |
||
Tags |
lookup_thread, mass flow rate, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mass flow rate not conserved in turbomachine, interface defined wrong? | wildli | FLUENT | 3 | September 15, 2022 12:19 |
mass flow rate (CFX post) | sanchezz | CFX | 2 | January 14, 2010 06:54 |
Mass Flow Rate | student87 | CFX | 4 | January 2, 2010 04:45 |
mass flow rate entering and exiting a cell | samir bensaid | FLUENT | 0 | July 4, 2007 05:37 |
User defined function of mass flow rate | Eric | FLUENT | 1 | April 22, 2005 18:15 |