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 ball motion inside a valve. (https://www.cfd-online.com/Forums/fluent-udf/157447-udf-ball-motion-inside-valve.html)

A.Jalal July 29, 2015 14:17

UDF for ball motion inside a valve.
 
1 Attachment(s)
Hello All,

I am trying to simulate motion of a ball in a valve. The model I created is a simple 2D half model of the cross-section of a hypothetical valve. There is an attachment of the model.

I have created a UDF file to define motion of the ball due to velocity using the 6DOF solver. The symmetry line should also be deforming. I have a few questions.

1) Do I need to run a case without any Dynamic Mesh before compiling the code?

2) I keep getting an error that says: Unable to read motion history file

3) Can you please let me know if there are any suggestions to make to the UDF.

Here is the UDF for the motion:

#include "udf.h"

DEFINE_SDOF_PROPERTIES(Lightweight_ball, prop, dt, time,dtime)

{

prop[SDOF_ZERO_TRANS_X]= TRUE;
prop[SDOF_ZERO_TRANS_Z]= TRUE;

prop[SDOF_ZERO_ROT_X]= TRUE;
prop[SDOF_ZERO_ROT_Y]= TRUE;
prop[SDOF_ZERO_ROT_Z]= TRUE;


prop[SDOF_MASS] = 1e-3;


prop[SDOF_IXX] = 1.92e-8;
prop[SDOF_IYY] = 1.92e-8;
prop[SDOF_IZZ] = 1.92e-8;

}


And someone suggested I do a changing time step UDF as well:

#include "udf.h"
#include "dx.h"
#include "grid.h"
#include "var.h"
#include "mem.h"
#include "dynamesh_tools.h"


DEFINE_DELTAT(mydeltat,d)
{
int z_ID =5;
real urf = 0.5;
real mydx=1e-5;
real maxT= 1e-3;
real minT= 1e-10;

real time_step;
real my_vel;
real TS1;

Dynamic_Thread *ndt = NULL;

Thread *ball_ft = Lookup_Thread(d,z_ID);
ndt = THREAD_DT(ball_ft);

my_vel = DT_VEL_CG(ndt)[1];

TS1 = ABS(urf*mydx/(my_vel+0.00000001));
//Message("\n My TS1 %f",TS1);

time_step = MIN(TS1,maxT);
//Message("\n My Time Step1 %f",time_step);

time_step = MAX( time_step, minT);
Message("\n My Time Step %f",time_step);

return time_step;
}


All times are GMT -4. The time now is 08:58.