Ansys Learning Forum › Forums › Discuss Simulation › Fluids › source term modification of energy equation in non-equilibrium thermal model › Reply To: source term modification of energy equation in non-equilibrium thermal model
Here is my UDF:
#include "udf.h"
#define HFS_CONSTANT 1000Â Â
#define AFS_CONSTANT 0.1Â Â Â
// Fluid Source Term
DEFINE_SOURCE(Fluid_source, c, t, dS, eqn)
{
  real Tf, Ts;
  real hfs, Afs;
  real source;
  // Obtain the fluid temperature (Tf) and solid temperature (Ts)
  Tf = C_STORAGE_R(c, t, SV_T_F);  // Access fluid temperature
  Ts = C_STORAGE_R(c, t, SV_T_S);  // Access solid temperature
  Â
  // Calculate or use constants for hfs (heat transfer coefficient) and Afs (interfacial area density)
  hfs = HFS_CONSTANT;  // Define or calculate hfs
  Afs = AFS_CONSTANT;  // Define or calculate Afs
  // Calculate the source term using modified expression hA(Tf^4 - Ts^4)
  source = hfs * Afs * (pow(Ts, 4) - pow(Tf, 4));
  // Define the derivative of the source term with respect to Tf
  dS[eqn] = -4 * hfs * Afs * pow(Tf, 3);
  return source;  // Return the calculated source term
}
// Solid Source Term
DEFINE_SOURCE(Solid_source, c, t, dS, eqn)
{
  real Tf, Ts;
  real hfs, Afs;
  real source;
  // Obtain the fluid temperature (Tf) and solid temperature (Ts)
  Ts = C_STORAGE_R(c, t, SV_T_S);  // Access solid temperature
  Tf = C_STORAGE_R(c, t, SV_T_F);  // Access fluid temperature
  // Calculate or use constants for hfs (heat transfer coefficient) and Afs (interfacial area density)
  hfs = HFS_CONSTANT;  // Define or calculate hfs
  Afs = AFS_CONSTANT;  // Define or calculate Afs
  // Calculate the source term using modified expression hA(Ts^4 - Tf^4)
  source = hfs * Afs * (pow(Ts, 4) - pow(Tf, 4));
  // Define the derivative of the source term with respect to Ts
  dS[eqn] = 4 * hfs * Afs * pow(Ts, 3);
  return source;  // Return the calculated source term
}
I am not sure if it is right to access the solid temperature in the fluid zone and fluid temperature in the solid zone.