CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF to change angular velocity after every timestep based on the previous value (https://www.cfd-online.com/Forums/fluent/246031-udf-change-angular-velocity-after-every-timestep-based-previous-value.html)

usr0830 November 8, 2022 11:13

UDF to change angular velocity after every timestep based on the previous value
 
Hello,
I am trying to run a simulation where the angular velocity of a dynamic mesh zone changes every time step based on this equation of motion where moment_z is the moment on the two aerofoils defined as one wall.

omega_prev + = ((1/I) * (moment_z - (alpha * omega_prev)))
When I set up the dynamic mesh with the udf, the initialisation returns an "All compute processes received SIGFPE." error. I am not sure what the cause of this error is. Could someone more knowledgeable please help me solve this?

This is the UDF I am using:

Code:

#include "udf.h"
real current_dt;
real omega_old;
real omega_new;
real moment_z;
static I = 0.0275; /* Moment of inertia */
static alpha = 0.00626;
static real omega_prev = 0.0;
DEFINE_CG_MOTION (rotational_motion1, dt, vel, omega, time, dtime)
{
#if !RP_HOST
current_dt = RP_Get_Integer("time-step");
if (current_dt ==1)
omega_prev = -128;
else
omega_prev = omega[2];
Message("Omega_old1 is %g",omega_prev);
Domain *d =Get_Domain(1);
Thread *t_object = Lookup_Thread(d, 2);
real moment [ND_ND], cg[ND_ND], force [ND_ND];
Compute_Force_And_Moment(d, t_object, cg, force, moment, TRUE);
moment_z= moment [2];
/* Equation of motion */
omega_prev += ((1/I) * (moment_z - (alpha * omega_prev)));
Message("Omega_new1 is %g",omega_prev);
omega[2] = omega_prev;
#endif
}


Thank you!


All times are GMT -4. The time now is 02:16.