Phase Change Material (PCM) Simulation in Ansys Fluent: Step-by-Step Tutorial with UDF Code
Introduction
This tutorial provides a comprehensive guide to simulating phase change materials (PCM) using Ansys Fluent in a square geometry. PCM simulations are vital for analyzing thermal behavior in applications like battery cooling, electronics thermal management, and HVAC. This guide covers everything from geometry creation to setting up boundary conditions, using User-Defined Functions (UDFs) for property definition, and plotting the liquid fraction contour. This step-by-step approach will assist both beginners and experienced users in understanding PCM behavior under transient conditions in Ansys Fluent.
For a complete walkthrough, please check out the video below on PCM simulation in Ansys Fluent, where each step is demonstrated.
Geometry Setup in DesignModeler
The simulation begins with creating a square geometry in Ansys DesignModeler, a straightforward yet effective choice for studying PCM behavior. This geometry represents the confined area where the PCM will undergo phase change, allowing us to observe the melting and solidification processes under controlled boundary conditions.
Meshing the Model
Efficient meshing is crucial for accurate simulations. Here, we used Ansys Meshing to refine the mesh, ensuring that we capture the intricate behavior of PCM. The meshing process involves setting up manual sizing for enhanced precision and checking mesh quality to optimize simulation performance in Ansys Fluent.
UDF Code for PCM Properties
Defining custom PCM properties is essential, especially in cases where specific thermal characteristics are needed. We implemented a User-Defined Function (UDF) to specify PCM properties accurately. Below is the UDF code used in this simulation.
#include "udf.h"
#include "mem.h"
//n-eicosane constant properties in solid phase
#define Ros_pcm 910.0
#define Cps_pcm 1926.0
#define Ks_pcm 0.423
//n-eicosane constant properties in fluid phase
#define Rol_pcm 769.0
#define Cpl_pcm 2400.0
#define Kl_pcm 0.146
//thermal expansion coefficient
#define TEC 0.0008161
//solidus and liquidus temperatures of n-eicosane
#define Ts 309.15
#define Tl 311.15
//reference temperature for Boussinesq's approximation
#define Tr 323.15
//please set the Tref in Fluent like Tr
//density of PCM
DEFINE_PROPERTY(Ro_var_PCM,cell,thread)
{
double Gama, Ro_pcm;
Gama=C_LIQF(cell,thread);
Ro_pcm=(1-Gama)*Ros_pcm+Gama*Rol_pcm;
return Ro_pcm;
}
DEFINE_SPECIFIC_HEAT(Cp_var_PCM,T,Tref,h,yi)
{
double Gama, Cp_pcm;
if (T<Ts) { Cp_pcm=Cps_pcm; } else if (T>=Ts&&T<=Tl)
{
Gama=(T-Ts)/(Tl-Ts);
Cp_pcm=((1-Gama)*Ros_pcm*Cps_pcm+Gama*Rol_pcm*Cpl_pcm)/((1-Gama)*Ros_pcm+Gama*Rol_pcm);
}
else
{
Cp_pcm=Cpl_pcm;
}
*h=Cp_pcm*(T-Tref);
return Cp_pcm;
}
//thermal conductivity of PCM
DEFINE_PROPERTY(K_var_PCM,cell,thread)
{
double Gama, K_pcm;
Gama=C_LIQF(cell,thread);
K_pcm=(1-Gama)*Ks_pcm+Gama*Kl_pcm;
return K_pcm;
}
//dynamic viscosity of PCM
DEFINE_PROPERTY(Mu_var_PCM,cell,thread)
{
double Temp,Mu_pcm;
Temp=C_T(cell,thread);
Mu_pcm=(9*pow(10.,-4)*pow(Temp,2)-0.6529*Temp+119.94)*pow(10.,-3);
return Mu_pcm;
}
//Y-momentum source
DEFINE_SOURCE(Boussinesq_momentum_source,cell,thread,dS,eqn)
{
double Temp, source;
Temp=C_T(cell,thread);
source=Rol_pcm*9.81*TEC*(Temp-Tr);
dS[eqn]=Rol_pcm*9.81*TEC;
return source;
}
Simulation Results: Liquid Fraction Contour
This tutorial demonstrates plotting the liquid fraction contour of the PCM, showing the phase distribution at every particular time. Here’s an example image of the liquid fraction contour at 310 seconds:
This contour provides a visual representation of the PCM’s melting process, making it easy to analyze how PCM is affected under the specified boundary conditions.
No comment