We’re putting the final touches on our new badges platform. Badge issuance remains temporarily paused, but all completions are being recorded and will be fulfilled once the platform is live. Thank you for your patience.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

UDF for convection is not working

    • iitdhn.a
      Subscriber

      hi, I want to apply convention boundary condion on a wall as a functin of varing ambient temperature. I have written a udf for free stream temperature (ambient) as funciton of time but it has unexpected effect in the convection boundary condition at the wall. when I am changing the temperature value in the udf it has no effect on solution. but for expression and as constant free stream temperature it works fine.

    • Rob
      Forum Moderator

      I assume you've got DEFINE_PROFILE returning a temperature in Kelvin and hooked into the highlighted box below?

    • iitdhn.a
      Subscriber

      Tahnks you for the reply!

      I used the following udf code to define varing ambient temperature and the unit I used in degree C

      DEFINE_PROFILE(ambient_temperature_profile, t, i)
      {
          real time = CURRENT_TIME;
          real hour = time / 3600.0;
          real temp;
          face_t f;
       
          while (hour >= 24.0)
              hour -= 24.0;
       
          if (hour >= 8.0 && hour <= 13.0)
          {
              temp = -20.0 + ((0.0 + 20.0) / 5.0) * (hour - 8.0);  // -20°C → 0°C
          }
          else if (hour > 13.0 && hour <= 18.0)
          {
              temp = 0.0 - (15.0 / 5.0) * (hour - 13.0);  // 0°C → -15°C
          }
          else if (hour > 18.0 && hour < 24.0)
          {
              temp = -15.0 - (5.0 / 6.0) * (hour - 18.0);  // -15°C → -20°C
          }
          else
          {
              temp = -20.0;  // Constant at night (midnight → 8 AM)
          }
       
          begin_f_loop(f, t)
          {
              F_PROFILE(f, t, i) = temp;
          }
          end_f_loop(f, t)
      }

       

    • Rob
      Forum Moderator

       

      Alter to Kelvin, UDFs use SI units regardless of other settings. Also avoid the arrow symbols in comments, they should be OK but there’s a risk Fluent will see it as something else because of the UNIX legacy. 

      To add, given flow timescales of under a second, and your code being hours you may want to review just how long you intend this model to run for. 

       

Viewing 3 reply threads
  • You must be logged in to reply to this topic.