UDF doubt
Hello everyone,
I am simulating the behaviour of the non-Newtonian fluid, Colgate on top of a vibrating membrane of a speaker. I have been working on a UDF to apply on a vibrating membrane, giving it a sinusoidal input velocity, i.e., v =v0* cos(pi*x/L)*sin(2*pi*f*t) Where v0 is the maximum velocity achieved by the vibrating membrane and pi is already defined. f is the input frequency which I have obtained from previous experiments. #include "udf.h" #include "dynamesh_tools.h" #define pi 3.1416 DEFINE_GEOM(plane,domain,dt,position) { position[1]=0.001; } DEFINE_GRID_MOTION(inlet_y_velocity,d,dt,time,dtim e) { Thread *t; real y[ND_ND]; real x_c; face_t f; real v; Node *w; int n; SET_DEFORMING_THREAD_FLAG(THREAD_TO(t)); begin_f_loop(f,t) { f_node_loop(f,t) { w = F_NODE(f,t,n); if (NODE_X(v)>0 && NODE_X(v)<0.08 && NODE_Y(v)==0 && NODE_POS_NEED_UPDATE(v)) { NODE_POS_UPDATED(v); v=.2*cos((pi*x_c)/.08)*sin(2*pi*120*time); } end_f_loop(f,t) } } I would like to know the correction for the errors in the code, as well as suggestions to improve the code. |
All times are GMT -4. The time now is 21:42. |