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 time dependent angular velocity calculation (https://www.cfd-online.com/Forums/fluent-udf/138225-udf-time-dependent-angular-velocity-calculation.html)

shashankmechguy July 1, 2014 01:03

UDF for time dependent angular velocity calculation
 
Hi,
I am trying to use dynamic meshing for 2D wind turbine simulation and generate rpm on the basis of inlet velocity using udf.

This is the code I wrote

#include"udf.h"
real w_prev= 0.0;
DEFINE_CG_MOTION(turbine, dt,vel,omega,time,dtime)
{

Thread *t;
face_t f;
real NV_VEC(A);
real force,torque,x[ND_ND], dw;
NV_S(vel,=,0);
NV_S(omega,=,0);

/* Get the thread pointer for which this motion is defined */
t= DT_THREAD(dt);
/* Compute pressure force of body by looping through all faces */
force = 0;
torque= 0;
begin_f_loop(f,t)
{
F_AREA(A,f,t);
F_CENTROID(x,f,t);
torque+= x[1] * (F_P(f,t)* NV_MAG(A);
}
end_f_loop(f,t)

/* Compute change in angular velocity */
dw= dtime* torque/ 50.00;
w_prev= w_prev + dw;

Message ("time = %f , z_omega= %f,torque = %f\n", time, w_prev, torque);
/* Set Z Component of Angular velocity */
omega[2]= w_prev;

I know the code is wrong since I need to take the vector cross product of force with radius vector but I dont have any idea how to do that so I made is simple and tried to run this with this wrong code.

Anyone have any comment on how to get what I wish to simulate

https://drive.google.com/file/d/0B2z...it?usp=sharing

jealor October 24, 2016 03:34

There seems to be an marcon "Compute-force-and-momentum" which can be used to compute the momentum
but i am not quite sure . u can do some research about it

mmunige October 24, 2016 04:43

UDF for inlet temperature
 
Dear all

I have following UDF for inlet temperature, untill 1300s it takes correct values according to equation, but after 1300s values are higher and not accorrding to equation, like at 1301s it should have value of 405C but in simulation inlet temperature is 621C. I could not find the error in my UDF after lot of try. please check this and guide me. Thank you.
#include"udf.h"

DEFINE_PROFILE(inlet_temperature,thread,position )

{

face_t f;

begin_f_loop(f,thread)

{

real t = RP_Get_Real("flow-time");

if (t <=1300.0 )

{

F_PROFILE(f,thread,position) = 379.13 + 0.0005*t;

}

else if (1300.0 < t && t <= 1500.0 )

{

F_PROFILE(f,thread,position)= -1.04289036878969*pow(10,-10)*pow(t,6.0)+ 8.86126436853789*pow(10,-7)*pow(t,5.0)-3.13621260398811*pow(10,-3)*pow(t,4.0)+5.91804640375908*pow(t,3.0)-6.27969461279651*pow(10,3)*pow(t,2.0)+ 3.55273415252714*pow(10,6)*t - 8.37223405676245*pow(10,8);
}
else
{

F_PROFILE(f,thread,position) = -9.51538261322402*pow(10,-23)*pow(t,6) + 8.26192751387975*pow(10,-18)*pow(t,5)-2.85237398505875*pow(10,-13)*pow(t,4)+4.97518353700886*pow(10,-9)*pow(t,3)-4.58733775886876*pow(10,-5)*pow(t,2)+ 2.10251137071757*pow(10,-1)*t +3.57252192344954*pow(10,2);

}

}

end_f_loop(f,thread)

}


All times are GMT -4. The time now is 06:56.