CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF "running frequency" (https://www.cfd-online.com/Forums/fluent-udf/86418-udf-running-frequency.html)

dmalcher March 22, 2011 09:54

UDF "running frequency"
 
Hello everyone,

I'm using the UDF DEFINE_CG_MOTION for simulating a check valve. i want the UDF to run one time per time step. Currently, the UDF runs four times per time step what is not appropriate for this case.
As I've noticed this UDF "running frequency" does not depend on the max iterations per time step but I have no clue where to change it.

Thanks for any answers

Daniel

dmalcher March 24, 2011 03:44

I solved my problem using the UDF DEFINE_EXECUTE_AT_END.

Regards
Daniel

Josyula October 13, 2011 03:50

Regarding DEFINE_EXECUTE_AT_THE_END
 
Hi,

I have a DEFINE_CG_MOTION UDF which has a sin function to move the walls of the geometry in my problem.

But like you said, the UDF is running 4 times per time step. I want it to run one time each timestep.

How do you input the DEFINE_EXECUTE_AT_END in this case?

Thank you.

dmalcher October 14, 2011 05:05

At the meantime, I found out, that DEFINE_CG_MOTION is repeated for every wall you want to move (in your case you have also 4 walls, I guess).

Define the velocity of your walls as a global variable and calculate it within a void function. Call the void function with DEFINE_EXECUTE_AT_END.

Example:

#include <udf.h>

/* Define Constants */
#define amplitude 0.02;
#define pi 3.14;

/* Define Global Variables */
real vel /* velocity */


void fun_velocity(real flowtime)
{
vel = amplitude * 2 * pi * cos(2*pi*flowtime); /* calculating current velocity */
}

DEFINE_EXECUTE_AT_END(yourUDFname)
{
real flowtime = CURRENT_TIME; /* Passing current flow time from solver to udf */
fun_velocity(flowtime); /* Calling void function 'fun_velocity' and passing current flowtime */
}

DEFINE_CG_MOTION(yourUDFname2,dthread,velocity,ang ular_velocity,ftime,dtime)
{
velocity[0] = vel; /* passing value of vel to x-component of 'velocity'*/
}

I didn't test this small UDF but I hope it will make it clear to you.

Regards

d

dmalcher October 14, 2011 06:57

I should add to my previous comment, that I solve a equation of motion numerically to gain the angular velocity of the flap. Thus, the velocity depends on the current pressure field.
If I put this calculation within the DEFINE_CG_MOTION UDF, every wall would receive a slightly different angular velocity, as the pressure field changes during the iterations. At some point of time my model would break apart.
This is the reason, why I use DEFINE_EXECUTE_AT_END to get one velocity for all walls.
If you calculate the velocity, say with a sin function, the velocity depends only from the flow time. As the flow time remains equal during the iterations of one time step, the velocity will be the same for all walls.

To cut a long story short, the use of DEFINE_EXECUTE_AT_END is not necessary for case, Josyula.
DEF_CG_MOTION runs 4 times, because you probably have 4 walls to move.

Regards
d

Josyula October 21, 2011 00:39

D,

Thanks for the reply.

My geometry is a straight rectangular microchannel. There are only 2 walls which need to be moved i.e. the top and bottom. Left and Right are specified as Pressure inlet and Pressure outlet B.C. respectively.

I have a question though: Is there a way we can decide the amplitude based on the time step size? Because, the wall movement is visible only when I give A = 0.1 or A = 0.5. The time step size I am specifying is 1e-07 s.

But being a microchannel channel, the phase lag i.e. +ve to -ve will happen after a very long time.

Instead, what I am looking for is this: for one time step I need a +ve phase lag (i.e. the walls expand) and the next time step, I need a -ve phase lag (i.e. the walls contract). Sinusoidal profile is really not working well for this.

Any suggestions?

dmalcher October 21, 2011 10:20

I'm not quite sure whether I fully understand your intention.
Basically speaking, you can obtain information about the current time step, flow time etc. with the "time dependent macros" . You can use this information in your UDF within an if-condition or whatever to control the amplitude or the velocity of the walls.
I don't know if that really answers your question but keep in mind, that the path that the moving walls will pass during one time step, might be pretty tiny due to your very small time step.


All times are GMT -4. The time now is 12:05.