Ansys Learning Forum › Forums › Discuss Simulation › Fluids › Unexpected Downward Trend in Turb. Intensity Using Variable k and ε in Fluent › Reply To: Unexpected Downward Trend in Turb. Intensity Using Variable k and ε in Fluent
October 21, 2024 at 1:31 pm
anupamkrishnan91
Subscriber
Hi, Thank you for the reply.
#UDF Starts from the next line#
#include "udf.h"
#include "math.h"
#include "stdlib.h"
// Define constants
#define C_MU 0.09
#define LENGTH_SCALE 0.07 /* Approximate length scale as 7% of characteristic length */
#define VELOCITY 1.46 /* Mean velocity (m/s) */
#define MIN_TI 0.44 /* Minimum turbulence intensity: 44% */
#define MAX_TI 0.60 /* Maximum turbulence intensity: 60% */
// Function to set time-dependent turbulent kinetic energy (k)
DEFINE_PROFILE(variable_k, thread, position)
{
real time = CURRENT_TIME; /* Get current simulation time */
real I; /* Turbulence intensity */
real k; /* Turbulent kinetic energy */
face_t f;
/* Predefined turbulence intensity values*/
real TI_values[15] = {0.44, 0.44, 0.44, 0.48, 0.51, 0.53, 0.56, 0.58, 0.56, 0.55, 0.53, 0.50, 0.49, 0.48, 0.46}; // Values adjusted
int index = (int)(time); /* Convert time to an integer index (0 to 14) */
if (index > 14)
{
index = 14; /* Cap the index at 14 to keep TI at 46% after 15 seconds */
}
I = TI_values[index]; /* Assign the corresponding turbulence intensity */
begin_f_loop(f, thread)
{
/* Compute turbulent kinetic energy (k) based on turbulence intensity (I) */
k = 1.5 * pow(I * VELOCITY, 2); /* k = 3/2 * (I * U)^2 */
F_PROFILE(f, thread, position) = k;
}
end_f_loop(f, thread)
}
// Function to set time-dependent turbulent dissipation rate (ε) based on k
DEFINE_PROFILE(variable_epsilon, thread, position)
{
real time = CURRENT_TIME; /* Get current simulation time */
real I; /* Turbulence intensity */
real k; /* Turbulent kinetic energy */
real epsilon; /* Turbulent dissipation rate */
real l = LENGTH_SCALE; /* Turbulence length scale */
face_t f;
/* Predefined turbulence intensity values */
real TI_values[15] = {0.44, 0.44, 0.44, 0.48, 0.51, 0.53, 0.56, 0.58, 0.56, 0.55, 0.53, 0.50, 0.49, 0.48, 0.46}; // Values adjusted
int index = (int)(time); /* Convert time to an integer index (0 to 14) */
if (index > 14)
{
index = 14; /* Cap the index at 14 to keep TI at 46% after 15 seconds */
}
I = TI_values[index]; /* Assign the corresponding turbulence intensity */
begin_f_loop(f, thread)
{
/* Compute turbulent kinetic energy (k) */
k = 1.5 * pow(I * VELOCITY, 2); /* k = 3/2 * (I * U)^2 */
/* Compute dissipation rate (ε) */
epsilon = pow(C_MU, 0.75) * pow(k, 1.5) / l;
F_PROFILE(f, thread, position) = epsilon;
}
end_f_loop(f, thread)
}
###
This is the UDF that I am using.
Hope this would define the problem.
Thanks in advance.