Video link: https://www.youtube.com/watch?v=zAA4ceR2KCc
/*********************************************************************
UDF for specifying a temperature-dependent viscosity and density property
flapdoor.c
udf for specifying a simple harmonic motion
specifying this marco below
/*F_PROFILE(f,t,nv) = 0.3*exp(0.2*t);
*********************************************************************/
#include "udf.h"
#include "math.h"
#define BMODULUS 2.2e9
#define rho_ref 1000.0
#define p_ref 101325
#define Freq 2.0
#define angular_freq 2.0*M_PI*Freq
#define tetmax 2.0*M_PI/180
/*DEFINE_SDOF_PROPERTIES(Valve_6dof,prop,dt,time,dtime)
{
prop[SDOF_MASS] = 0.1;
prop[SDOF_IZZ] = 1.332e-3;
prop[SDOF_ZERO_TRANS_X] = TRUE;
prop[SDOF_ZERO_TRANS_Y] = TRUE;
prop[SDOF_ZERO_TRANS_Z] = TRUE;
prop[SDOF_ZERO_ROT_X] = TRUE;
prop[SDOF_ZERO_ROT_Y] = TRUE;
prop[SDOF_ZERO_ROT_Z] = FALSE;
prop[SDOF_LOAD_M_Z] = -9.81*0.1*sin(DT_THETA (dt)[2])*0.1;
Message("\n 2d : Updated 6DOF properties DT_THETA_z:%e,Mz:%e, Mass:%e\n",DT_THETA (dt)[2],prop[SDOF_LOAD_M_Z],prop[SDOF_MASS]);
}*/
DEFINE_PROFILE(inlet_profile,thread,position)
{
face_t f;
real t = CURRENT_TIME;
begin_f_loop(f,thread)
{
/*F_PROFILE(f,t,nv) = 0.3*exp(0.2*t);*/
F_PROFILE(f,thread,position) = 15.0*sin(10.*t);
}
end_f_loop(f,thread)
}
DEFINE_CG_MOTION(shm,dt,cg_vel,cg_omega,time, dtime)
{
real omega;
omega = tetmax*angular_freq*cos(angular_freq*time); /*rotational speed about axis*/
cg_vel[0] = 0.0;
cg_vel[1] = 0.0;
cg_vel[2] = 0.0;
cg_omega[0] = 0.0;
cg_omega[1] = 0.0;
cg_omega[2] = omega;
}
DEFINE_PROPERTY(cell_viscosity, cell, thread)
{
real mu_lam;
real temp = C_T(cell, thread);
mu_lam = 0.6402+18.9612*exp(-.074*temp) ;
return mu_lam;
}
DEFINE_PROPERTY(cell_density,cell,thread)
{
real rho;
real temp= C_T(cell,thread);
rho=-0.72222*temp+1087.28;
return rho;
}
/********************************************************************
Density and speed of sound UDFs for compressible liquid flows.
For use with pressure-based solver, for single phase, multiphase mixture
or cavitation models only.
Note that for density function, dp is the difference between a cell
absolute pressure and reference pressure.
*********************************************************************/
DEFINE_PROPERTY(superfluid_density, c, t)
{
real rho;
real p, dp;
real p_operating;
p_operating = RP_Get_Real ("operating-pressure");
p = C_P(c,t) + p_operating;
dp = p-p_ref;
rho = rho_ref/(1.0-dp/BMODULUS);
return rho;
}
DEFINE_PROPERTY(sound_speed, c,t)
{
real a;
real p, dp,p_operating;
p_operating = RP_Get_Real ("operating-pressure");
p = C_P(c,t) + p_operating;
dp = p-p_ref;
a = (1.-dp/BMODULUS)*sqrt(BMODULUS/rho_ref);
return a;
}