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/)
-   -   Having difficulties in writing udf define_CG_motion for a piston (https://www.cfd-online.com/Forums/fluent-udf/64712-having-difficulties-writing-udf-define_cg_motion-piston.html)

tonisantos May 20, 2009 17:35

Having difficulties in writing udf define_CG_motion for a piston
 
Please can someone help me write a udf to define CG_motion for a piston inside a cilinder.
the equation for the position is Y=27*cos(A)+sqrt(100^2 - (27^2)*sin^2(A))

Thank you so much everybody

Jessica.S May 5, 2012 21:32

hope it's not too late....

DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime)
{
real Y = ;
real A = ;

/* reset velocities */
NV_S(vel, =, 0.0);
NV_S(omega, =, 0.0);

if (!Data_Valid_P()) /* Do nothing if gradient isn’t allocated yet. */
return;

Y = 27*cos(A)+sqrt(100^2 - (27^2)*sin^2(A));

/* sets the components of velocity */
vel[0] = 0;
vel[1] = Y;
vel[2] = 0;
}

this udf is for the speed not the position.....

tsram90 February 20, 2015 06:02

Quote:

Originally Posted by Jessica.S (Post 359511)
hope it's not too late....

DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime)
{
real Y = ;
real A = ;

/* reset velocities */
NV_S(vel, =, 0.0);
NV_S(omega, =, 0.0);

if (!Data_Valid_P()) /* Do nothing if gradient isn’t allocated yet. */
return;

Y = 27*cos(A)+sqrt(100^2 - (27^2)*sin^2(A));

/* sets the components of velocity */
vel[0] = 0;
vel[1] = Y;
vel[2] = 0;
}

this udf is for the speed not the position.....


There are many UDFs available for velocity. But I don't know the equation for velocity. I have equation of displacement. How do I implement that?

pakk February 20, 2015 07:30

Quote:

Originally Posted by tsram90 (Post 532634)
There are many UDFs available for velocity. But I don't know the equation for velocity. I have equation of displacement. How do I implement that?

If you have the equation of displacement, it should be easy to derive the equation for velocity, don't you think?

So if I were you, I would go for the easy solution, and use the equation of velocity.

feel April 7, 2015 06:14

hi friends,
I have a piston sinusoidal motion code ...


#include "udf.h"
#include <stdio.h>

DEFINE_CG_MOTION(piston_mov, dt, vel, omega, time, dtime)
{
real a, w, pi;

pi = 3.1415;

/* define motion variables */
a = 0.007; /* 0.012m movement amplitude */
w = 2 * pi * 30; /* 30Hz (1800rpm) frequency */

/* define object movement law */
vel[0] = 0;
vel[1] = a * w * sin(w*time);
vel[2] = 0;
}


its working very well.

But i want to set the velocity and displacement as according below mentioned equations

Let suppose

equation of displacement

A=0.0036;
theta=0:360;

Xp=A*sin(theta)+(cos(theta))^0.5

And velocity

Vp=A*w(cos(theta)-sin(theta))^-0.5



Please tell me, how i can modify the above udf according these equations

Thanks

pakk April 13, 2015 05:03

You should write your equations as functions of time. Currently it is a function of theta (which is probably an angle), but you should specify how the angle depends on time.


All times are GMT -4. The time now is 22:04.