CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

output as input

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 30, 2020, 09:31
Default output as input
  #1
New Member
 
Federico
Join Date: Jan 2017
Posts: 10
Rep Power: 5
FCTCD is on a distinguished road
Hello everybody,

I would like to setup a sort of feedback system with my simulation using udf.

I would like to get the mass flow rate in my simulation, apply an equation and give it as an input. How could I do that using UDF?

Thanks
FCTCD is offline   Reply With Quote

Old   January 30, 2020, 10:24
Default Tried?
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 539
Rep Power: 16
vinerm is on a distinguished road
Have you written a UDF to do that? May be one that is not working.
__________________
Regards,
Vinerm

PMs only for private content
vinerm is online now   Reply With Quote

Old   January 30, 2020, 10:37
Default
  #3
New Member
 
Federico
Join Date: Jan 2017
Posts: 10
Rep Power: 5
FCTCD is on a distinguished road
Hi vinerm and thanks for your answer.

At the moment I have written a udf to change rotational speed and head of my pump (they are two separate compiled udf), so my output is the flow rate. I would like to take that flow rate, apply some pipe losses and use them to change the rotational speed input accordingly.

Is is possible to do that with UDF? Is there any particular macro or procedure I should follow?
FCTCD is offline   Reply With Quote

Old   January 30, 2020, 11:00
Default Multiple Ways
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 539
Rep Power: 16
vinerm is on a distinguished road
This can be done in multiple ways. One is to create a parameter based on flow rate and then use an expression that uses this parameter to define speed. But that requires latest Fluent. If you do not have that, then you can make use of Scheme and C based UDF. You can define an rp variable that stores flow-rate, access it in UDF that changes the speed. Another alternative is to define a global variable to store the flow rate. One UDF will fill it other will use it. But it all depends on which DEFINE_ macros you are using.
__________________
Regards,
Vinerm

PMs only for private content
vinerm is online now   Reply With Quote

Old   January 30, 2020, 11:20
Default
  #5
New Member
 
Federico
Join Date: Jan 2017
Posts: 10
Rep Power: 5
FCTCD is on a distinguished road
Thanks a lot for your advice. I am using Fluent 19.2, so I need to go back to the literature to understand all the information you've given me. My boundary conditions are pressure inlet-pressure outlet.

I am using these two UDF:

For rotational speed:

Code:
#include "udf.h"
 DEFINE_ZONE_MOTION(fmotion,omega,axis,origin,velocity,time,dtime)
{
real ts = N_TIME;
real rate= 0.10472;
if (ts<5400)
{
    *omega = (1475.0+0.05467*(ts-2401))*rate;
}
else
{
*omega = 1639*rate;
}
  N3V_D (velocity,=,0.0,0.0,0.0);
  N3V_S(origin,=,0.0);        /* default values, line could be omitted */
  N3V_D(axis,=,0.0,-1.0,0.0);     /* default values, line could be omitted */

  return;
}
For Pressure inlet:

Code:
/**********************************************************************
   unsteady.c 
  UDF for specifying a transient pressure profile boundary condition
 ***********************************************************************/
 
 #include "udf.h"
 
 DEFINE_PROFILE(unsteady_pressure, thread, position)
 {
    face_t f;
    real ts = N_TIME;
    begin_f_loop(f, thread)
      {
	if (ts<5400)
        F_PROFILE(f, thread, position) = 70000.0 + 2.5926*(ts-2401);
	else
	F_PROFILE(f, thread, position) = 77777.78;
      }
    end_f_loop(f, thread)
   
 }
FCTCD is offline   Reply With Quote

Old   January 30, 2020, 11:26
Default Suggestions
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 539
Rep Power: 16
vinerm is on a distinguished road
Look for RP_Get_Real in C UDF manual. Look for rpvar in Scheme manual. I am not sure if 19.2 allows expressions. Assuming it does not, create an rpvar, which is a scheme variable, to store flow rate at the outlet. You can also do this calculation within C based UDF. Then you would not require an rpvar. All of it can be done in DEFINE_ZONE_MOTION. Just setup a face loop, i.e., begin_f_loop within DEFINE_ZONE_MOTION and calculate the flow rate. Use that to calculate your speed. Second argument of begin_f_loop can be determined using Lookup_Thread where domain can be fetched using Get_Domain(1) and zone ID is the Boundary ID given in Boundary Conditions panel for the outlet.
__________________
Regards,
Vinerm

PMs only for private content
vinerm is online now   Reply With Quote

Old   January 30, 2020, 12:05
Default
  #7
New Member
 
Federico
Join Date: Jan 2017
Posts: 10
Rep Power: 5
FCTCD is on a distinguished road
Thanks again vinerm.

I think I need to go back to the udf manual to better understand the expressions you are talking about. I will write down the functions and get back to you to see if they're set correctly. Sorry for that, but I am not very confident with udf approach
FCTCD is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scheme - output temperature as an input + increment rydol Fluent UDF and Scheme Programming 4 January 9, 2020 07:47
Parameter set output from first block as input to another Qbz ANSYS 0 October 1, 2018 04:56
Output pressure not what I input williambwright SU2 3 January 27, 2016 20:33
Questions about data output aki_yafuji OpenFOAM Running, Solving & CFD 3 September 9, 2010 02:59
lift and drag on ship superstructures vaina74 OpenFOAM Running, Solving & CFD 3 June 8, 2010 13:30


All times are GMT -4. The time now is 09:44.