Udf for wall motion (dynamic mesh)
Hi,
I have a simple channel with length = 2 mm, Height = 150 um. Inlet is a mass-flow inlet and the outlet is a pressure outlet. The liquid is water and the flow is laminar. The bottomwall (see picture) need to move up and down (along y) in order to generate pressure waves that propagate in y direction.
I wrote a udf and I compile it. I create a dynamic mesh zone ("bottomwall") and I set it to rigid body motion. The problem is that the results are not the one that I expected. It seems that the wall doesn't move correctly, only at the inlet I see something reasonable(not at all):
I think that udf is no totally correct, but I cannot find the error.
My udf:
#include "udf.h"
#include "dynamesh_tools.h"
static real vely = 0.0;
freq = 5000000;
v0 = 0.1;
DEFINE_CG_MOTION(wall, dt, vel, omega, time, dtime)
{
NV_S (vel, =, 0.0)
NV_S (omega, =, 0.0)
vely = v0*sin(2*M_PI*freq*time);
vel[1] = vely ;
printf("\n")
printf("\n y_velocity = %g \n",vel[1]);
}
Comments
Check that you selected angles in rad.
You can check mesh movement before starting the simulation.
One thing I would like to add. the frequency is very high ... to capture this fast movement, the time step should be 1e-07 or less
Thanks, @YasserSelima
The time step is 1e-08. I have difficulties to check the mesh movement, because the displacement are very small.
I have checked the angles and they are in rad, but rotation are not present in my model.
Zoom on the wall while checking the moving mesh.
Check averaged mesh y coordinate at bottom wall within a report definition
No I understand the reason.
The amplitude is equal to (v0 / 2 pi f) ... hmmm 0.1 by almost 35 millions. I know the channels width is in microns, but does this amplitude sound right?
The amplitude should be right, it is in the order of nanometres. I am confused regarding the dynamic mesh settings: I treated my wall with a rigid body motion, is it reasonable?
Regarding the report, I can create the report but I don't find the option "averaged mesh y coordinate".
first, used double precision. second define all your variables as double instead of real. This increases the number of digits saved for any number
third define a global variable
double my_bondary_location=0;
fourth add this at the end of your current function
my_boundary_location += vely*dtime ;
finally add this function to your code
DEFINE_REPORT_DEFINITION_FN(
my_location)
{
return my_boundary_location;
}
Now you can find my_boundary_location to monitor
make it
return 10e09* my_boundary_location;
Thanks for replying. I am new to Udf coding, after define_report_definition, what should I put in the parentesis?
I update my udf:
#include "udf.h"
#include "dynamesh_tools.h"
#define freq = 5000000;
#define v0 = 0.1;
double my_boundary_location = 0;
DEFINE_CG_MOTION(wall, dt, vel, omega, time, dtime)
{
NV_S (vel, =, 0.0);
NV_S (omega, =, 0.0);
vely = v0*sin(2*M_PI*f*time);
vel[1] = vely;
my_boundary_location += vely*dtime;
}
DEFINE_REPORT_DEFINITION_FN(my_location)
{
return 10e-09*my_boundary_location;
}
report plot the variable my_location .. you should be able to monitor your wall location in manometers now,
I think that I managed how to report plot of the wall location, but it seems that doesn't move. The curve is always showing zero value.
try using cosine function instead of the sine. So, you get higher velocity at the beginning
You can add this to the function as well
Message("\n velocity = %f, displacement = %f", 1000*vely , 1e9*my_boundary_location);
This should print the velocity and displacement every timestep