December 15, 2022 at 5:02 pmM FSubscriber
I would like to create a UDF that can measure the inlet pressure of my geometry (id = 6) and assign it to a variable (called p_a).
I am struggling with the code since the pressure result does not seem to change with time, but it should since the inlet velocity is always varying. Here's what I have right now, and I would appreciate some input on what I may be doing wrong. Thank you in advance.
real calculate_pa(Thread* tf)
Message(" START calculate_pa \n");
total_area = 0.0;
total_pressure = 0.0;
if PRINCIPAL_FACE_P(f, tf)
F_AREA(va, f, tf);
total_area += NV_MAG(va);
Message(" Loop: Total area [m^2] = %g \n", total_area);
total_pressure += F_P(f, tf) * NV_MAG(va);
Message(" Loop: Total pressure [Pa m^2] = %g \n", total_pressure);
Message(" Total_area [m^2] = %g \n", total_area);
Message(" Total_pressure [Pa m^2] = %g \n", total_pressure);
pa = total_pressure / total_area;
Message(" pa [Pa] = %g \n", pa);
December 16, 2022 at 12:44 pmDrAmineAnsys Employee
Why do you require within an UDF? What is the purpose of getting the inlet pressure in this way?
As an Ansys employee I do not debug code or write routines: but just compare the outcome to what you get through Surface integral.
Also in the UDF always to do the reduction after finishing the Node calculations (you are missing that part)
December 16, 2022 at 1:19 pmM FSubscriber
Thank you very much for your reply. I need to use the inlet pressure to obtain the value of the outlet pressure. The UDF is meant to be used as a boundary condition in the outlet, and that's why I need to calculate the inlet pressure this way.
I do not understand what reduction means, could you please explain or direct me to other material?
December 16, 2022 at 1:26 pmDrAmineAnsys Employee
Look into the Customization manual and you will see functions starting with PRF_. You need to reduce the Sum of pressure and area before doing the ratio.
Same can be achieved using Fluent Expressions wihtout writing a single UDF line. Have a look into the Fluent User's Guide and you will almost similar example like yours.
- You must be logged in to reply to this topic.
Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Suppress Fluent to open with GUI while performing in journal file
- Floating point exception in Fluent
- What are the differences between CFX and Fluent?
- Heat transfer coefficient
- Getting graph and tabular data from result in workbench mechanical
- The solver failed with a non-zero exit code of : 2
- Difference between K-epsilon and K-omega Turbulence Model
- Time Step Size and Courant Number
- Mesh Interfaces in ANSYS FLUENT
- error in cfd post
© 2023 Copyright ANSYS, Inc. All rights reserved.