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 for one dimensional linear motion based on force (https://www.cfd-online.com/Forums/fluent-udf/200953-udf-one-dimensional-linear-motion-based-force.html)

maccheese April 17, 2018 12:23

udf for one dimensional linear motion based on force
 
1 Attachment(s)
Hi guys,

I am currently working on a Fluent simulation which contains a rigid body which should move in a certain way.

At the moment, my goal is to get a udf file working which contains the following information:

1. Translational movement over a certain range from point a to b in negative y-direction caused by body forces of the rigids

2. A certain amount of time where the rigids rest at point b

3. Translational movement back from point b to a

The magnitude of the force and the duration of time for step 2 should be modifiable in the udf.

I looked at the define_cg_motion example in the udf manual, which seems to be a quite good point for me to start on. In this example, "the linear velocity is computed from a simple force balance on the body in the x-direction".

Here it is:

/************************************************** **********
* 1-degree of freedom equation of motion (x-direction)
* compiled UDF
************************************************** **********/

#include "udf.h"
static real v_prev = 0.0;
DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime)
{
Thread *t;
face_t f;
real NV_VEC(A);
real force, dv;

/* reset velocities */

NV_S(vel, =, 0.0);
NV_S(omega, =, 0.0);

if (!Data_Valid_P())
return;

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

t = DT_THREAD(dt);

/* compute pressure force on body by looping through all faces */

force = 0.0;

begin_f_loop(f,t)
{
F_AREA(A,f,t);

force += F_P(f,t) * NV_MAG(A);

}
end_f_loop(f,t)

/* compute change in velocity, i.e., dv = F * dt / mass
velocity update using explicit Euler formula */

dv = dtime * force / 50.0;
v_prev += dv;
Message ("time = %f, x_vel = %f, force = %f\n", time, v_prev,
force);

/* set x-component of velocity */
vel[0] = v_prev;
}


However, I do not really understand how this udf is supposed to work, as the force is defined as zero (see the marked red line).

I tested the udf out with a simple geometry (please see the image attached), which would allow a rigid sphere to move freely in x-direction with the use of dynamic meshing, but the sphere doesnīt bother to move at all. I modified the udf and put the force to a value of 100 instead of 0, but still no motion of the sphere.

I would really appreciate some insights on this udf. Maybe I do get the udfs purpose all wrong and it isnīt supposed to work the way which I think of?

Also, if you have some tips for writing an udf which performs the way i need it to, any help is really appreciated as well! In general, I am eager to learn more about C programming, but I just do not have the necessary time to learn it from the start to solve all the issues I have with udfs by myself. I do not expect someone to write the udf for me, but some tips from more experienced users are of essential meaning for the progression of my model at the moment.

Thank you in advance!

poya0070 May 11, 2019 03:05

Hi dear

This parameters is the first value for forces and at the end of loop, force summation can be calculated.

hossein73 September 1, 2019 02:18

Quote:

Originally Posted by maccheese (Post 689239)
Hi guys,

I am currently working on a Fluent simulation which contains a rigid body which should move in a certain way.

At the moment, my goal is to get a udf file working which contains the following information:

1. Translational movement over a certain range from point a to b in negative y-direction caused by body forces of the rigids

2. A certain amount of time where the rigids rest at point b

3. Translational movement back from point b to a

The magnitude of the force and the duration of time for step 2 should be modifiable in the udf.

I looked at the define_cg_motion example in the udf manual, which seems to be a quite good point for me to start on. In this example, "the linear velocity is computed from a simple force balance on the body in the x-direction".

Here it is:

/************************************************** **********
* 1-degree of freedom equation of motion (x-direction)
* compiled UDF
************************************************** **********/

#include "udf.h"
static real v_prev = 0.0;
DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime)
{
Thread *t;
face_t f;
real NV_VEC(A);
real force, dv;

/* reset velocities */

NV_S(vel, =, 0.0);
NV_S(omega, =, 0.0);

if (!Data_Valid_P())
return;

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

t = DT_THREAD(dt);

/* compute pressure force on body by looping through all faces */

force = 0.0;

begin_f_loop(f,t)
{
F_AREA(A,f,t);

force += F_P(f,t) * NV_MAG(A);

}
end_f_loop(f,t)

/* compute change in velocity, i.e., dv = F * dt / mass
velocity update using explicit Euler formula */

dv = dtime * force / 50.0;
v_prev += dv;
Message ("time = %f, x_vel = %f, force = %f\n", time, v_prev,
force);

/* set x-component of velocity */
vel[0] = v_prev;
}


However, I do not really understand how this udf is supposed to work, as the force is defined as zero (see the marked red line).

I tested the udf out with a simple geometry (please see the image attached), which would allow a rigid sphere to move freely in x-direction with the use of dynamic meshing, but the sphere doesnīt bother to move at all. I modified the udf and put the force to a value of 100 instead of 0, but still no motion of the sphere.

I would really appreciate some insights on this udf. Maybe I do get the udfs purpose all wrong and it isnīt supposed to work the way which I think of?

Also, if you have some tips for writing an udf which performs the way i need it to, any help is really appreciated as well! In general, I am eager to learn more about C programming, but I just do not have the necessary time to learn it from the start to solve all the issues I have with udfs by myself. I do not expect someone to write the udf for me, but some tips from more experienced users are of essential meaning for the progression of my model at the moment.

Thank you in advance!

I also had a problem with you.I need your help .


All times are GMT -4. The time now is 03:28.