|
[Sponsors] |
March 10, 2020, 10:04 |
Pitot pressure UDF
|
#1 |
New Member
Join Date: Mar 2020
Posts: 5
Rep Power: 6 |
I am currently trying to create a UDF to calculate the pitot pressure along a series of planes that I already set in a supersonic simulation around an axisymmetric body.
The idea here is to filter the information based on Mach number in such a way that the total pressure (found as the sum of static and dynamic pressures) is used in the subsonic regions of the planes and the total pressure obtained by using Rayleigh's pitot tube equation is used in the supersonic regions. I am new at doing UDF's and at coding in C (I made and tested the code in python and changed it to C by following notes). I am facing several difficulties at making my UDF in ANSYS Fluent and thus I would like to ask for some support on it. I currently have two main questions: 1) Regarding the UDF I'm not completely sure on the way to use the macros. Given that I'm trying to find a scalar value (pitot pressure) out of field variables I was thinking on using DEFINE_SOURCE. However I don't know if the macro DEFINE_PROPERTY could be used in my case. Could someone give me advice on the different types of macros and when it is recommended to use each of them? 2) I saw several examples of UDF's online but it never came clear to me from which point in the UDF one has to start and end the loop to find the desired property. I've attached the ".c" function in case someone wants to give it a try in Fluent. Any extra advise regarding the way I'm coding the UDF would be more than welcomed. Thank you very much for the attention! |
|
March 10, 2020, 10:12 |
Define_
|
#2 |
Senior Member
|
Though this can be done inside any DEFINE_ function, including DEFINE_PROPERTY that you used, however, as the name clarifies, DEFINE_PROPERTY is used to modify property of fluid or flow and not meant for post-processing.
However, for your scenario, you don't need a UDF. All you need is a Custom Field Function or expression if you are using R19.x. A CFF is just an equation defined in terms of available field variables.
__________________
Regards, Vinerm PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority. |
|
March 12, 2020, 19:32 |
|
#3 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
if you still wanna try UDF, you may use user-defined memory, the code will look like this,compile it, in fluent you must allocate memory for UDMI in User-Defined -> memory
Code:
/*----------------------------------------------------------- Test on ways to process pitot pressure during a simulation -------------------------------------------------------------*/ #include "udf.h" DEFINE_EXECUTE_AT_END(pitot_pressure) { Domain *d; Thread *t; cell_t c; real uc; /*velocity x component*/ real vc; /*velocity y component*/ real wc; /*velocity w component*/ real temp; /*Static temperature*/ real press; /*Static pressuret*/ real dens; /*Density*/ /*------------------------- Variables to calculate ---------------------------*/ real M; /*Mach number*/ real vmag; /*Velocity magnituder*/ real dyna; /*Dynamic pressure*/ real totp; /*Total pressure*/ real pitot; /*Pitot pressure*/ d = Get_Domain(1); thread_loop_c(t,d) { begin_c_loop(c,t) { /*------------------------- Fluent fleld variables ---------------------------*/ uc = C_U(c,t); /*velocity x component*/ vc = C_V(c,t); /*velocity y component*/ wc = C_W(c,t); /*velocity w component*/ temp = C_T(c,t); /*Static temperature*/ press = C_P(c,t); /*Static pressuret*/ dens = C_R(c,t); /*Density*/ vmag = sqrt(pow(uc,2) + pow(vc,2) + pow(wc,2)); M=vmag/sqrt(1.4*287*temp); dyna = (dens*pow(vmag,2))/2; totp = press + dyna; /*-------------------------- Mach filter ----------------------------*/ if (M <= 1) { pitot = totp; } else { pitot = (pow(((2.4*2.4*pow(M,2))/(5.6*pow(M,2)-0.8)),3.5)*((-0.4+2.8*pow(M,2))/2.4))*press; } C_UDMI(c,t,0) = pitot; } end_c_loop(c,thread) } }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF for vapor pressure | anuarun | Fluent UDF and Scheme Programming | 12 | December 24, 2021 10:12 |
static vs. total pressure | auf dem feld | FLUENT | 17 | February 26, 2016 13:04 |
sonicFoam - pressure driven pipe: flow continuity violation and waveTransmissive BC | Endel | OpenFOAM Running, Solving & CFD | 3 | September 11, 2014 16:29 |
vaporization pressure UDF | Komon | Fluent UDF and Scheme Programming | 0 | September 20, 2011 19:33 |
Neumann pressure BC and velocity field | Antech | Main CFD Forum | 0 | April 25, 2006 02:15 |