CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Accelarating of a cylinder UDF (https://www.cfd-online.com/Forums/fluent/46834-accelarating-cylinder-udf.html)

Ashutosh December 14, 2007 12:40

Accelarating of a cylinder UDF
 
I am writing a udf program to accelerate a cylinder in a wind tunnel from 0m/s to 5 m/s in the -ve x direction and then keeping its velocity constant to 5 m/s.this udf will be complined in fluent.can anyone please help me write the udf problem. i have written the problem as under

#include "udf.h"

#include "dynamesh_tools.h"

static real v_prev = 0.0;

DEFINE_CG_MOTION(cylinder, dt, vel, time, dtime)

{

Thread *t;

face_t f;

real dv;

/* reset velocities */

NV_S (vel, =, 0.0);

if (!Data_Valid_P ())

return;

/* get the thread pointer for which this motion is defined */

t = DT_THREAD ((Dynamic_Thread *)dt);

/* compute change in velocity */

dv = dtime * -5 ;

v_prev += dv;

Message ("time = %f, x_vel = %f, , time, v_prev,);

/* set x-component of velocity */

vel[0] = v_prev;

}

Natasha December 19, 2007 20:03

Accelarating of a cylinder UDF
 
I am writing a udf program to accelerate a cylinder in a wind tunnel from 0m/s to 5 m/s in the -ve x direction and then keeping its velocity constant to 5 m/s.this udf will be complined in fluent.can anyone please help me write the udf problem. i have written the problem as under

#include "udf.h"

#include "dynamesh_tools.h"

static real v_prev = 0.0;

DEFINE_CG_MOTION(cylinder, dt, vel, time, dtime)

{

Thread *t;

face_t f;

real dv;

/* reset velocities */

NV_S (vel, =, 0.0);

if (!Data_Valid_P ())

return;

/* get the thread pointer for which this motion is defined */

t = DT_THREAD ((Dynamic_Thread *)dt);

/* compute change in velocity */

dv = dtime * -5 ;

v_prev += dv;

Message ("time = %f, x_vel = %f, , time, v_prev,);

/* set x-component of velocity */

vel[0] = v_prev;

}

szz December 20, 2007 04:49

Re: Accelerating of a cylinder UDF
 
Hi,

your code had two minor errors. Below they are corrected and commented. The program itself works now.

Now you still need to define the acceleration. I suggest you use an if-condition until 5 m/s has been reached:

real a = ...; // define acceleration

if (v_prev < 5)

{

dv = 0.5 * a * dtime * dtime;

v_prev += dv;

}

vel[0] = v_prev;

Hope this helps with your problem.

Regards szz

#include "udf.h"

#include "dynamesh_tools.h"

static real v_prev = 0.0;

// omega is a mandatory argument

DEFINE_CG_MOTION(cylinder, dt, vel, omega, time, dtime) {

Thread *t;

face_t f;

real dv;

/* reset velocities */

NV_S (vel, =, 0.0);

if (!Data_Valid_P ()) return;

/* get the thread pointer for which this motion is defined */

t = DT_THREAD ((Dynamic_Thread *)dt);

/* compute change in velocity */

dv = dtime * -5 ;

v_prev += dv;

Message ("time = %f, x_vel = %f\n", time, v_prev); // Syntax error corrected

/* set x-component of velocity */

vel[0] = v_prev;

}


szz December 20, 2007 05:43

Re: Accelarating of a cylinder UDF
 
Sorry, I had a mistake in my post: It should be

dv = a * dtime;

Greetings szz

almostafa67 August 3, 2010 06:52

rotation about z axis
 
2 Attachment(s)
hi everybody...
first please let me brief you my problem,these two image that i sent you are simulated in gambit, both of them are kind of peristaltic pump,i want to rotate two/one small cylinder about z axis,i should write an udf,for this simple movement i used following udf
# include "udf.h"
# include "dynamesh_tools.h"
DEFINE_CG_MOTION(pump,dt,vel,omega,time,dtime)
{
Thread *t;

real freq_t;
NV_S(vel,=,0.0);
NV_S(omega,=,0.0);
if(!Data_Valid_P())
return;
freq_t = 4.0;
t= DT_THREAD((Dynamic_Thread*)dt);
vel[0] = 0.0;
vel[1] = 0.0;
vel [2] = 0.0;
omega [0] = 0.0;
omega [1] = 0.0;
omega [2] = freq_t;
}
but it does not work (the small cylinder does not rotate so i can not make an animation to show continuous variation of pressure on it)
i will be thankful if you could help me out
looking forward to ur help..:)


All times are GMT -4. The time now is 13:57.