Ansys Learning Forum › Forums › Discuss Simulation › Fluids › coupled simulation of vehicle and fluid tank › Reply To: coupled simulation of vehicle and fluid tank
April 5, 2024 at 10:27 am
vikram chahal
Subscriber
#include "udf.h"
DEFINE_SOURCE(moment_source, c, t, dS, eqn)
{
  real time = CURRENT_TIME; // Get the current simulation time
  real moment = 0.0; // Initialize moment to zero
  real CG[ND_ND]; // Center of gravity coordinates
  real cellCG[ND_ND]; // Cell center coordinates
  C_CENTROID(CG, c, t); // Get CG of the domain
  C_CENTROID(cellCG, c, t); // Get cell center coordinates
  real distance_from_CG = cellCG[2] - CG[2]; // Distance along z-axis
  /* Check if time is within the specified duration */
  if (time <= 2.0)
  {
    /* Apply moment only to cells at CG */
    if (distance_from_CG = 0.0)
    {
      moment = 5000.0; // Apply 5000 Nm moment
  }
  dS[eqn] = 0.0; // Reset the source term
  return moment; // Return the moment as the source term
}
and hooked as the souce term of fluid domain under cell conditions.
this UDF is giving very less value of force... could you please check it whether syntex and logic is correct or not.