Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

How to get area weighted avg outlet temp at a specific time using udf?

    • Prakash Singh
      Subscriber

      How to get area weighted avg outlet temp at a specific time using udf?

    • Nilay Pedram
      Forum Moderator

      Hello,
      Please refer to this discussion - how to calculate avg temp at outlet?

    • Prakash Singh
      Subscriber

      Thank you.

    • Prakash Singh
      Subscriber

      How can I patch the fluid domain using UDF?  I want to patch the fluid domain with T= 300 K at t= 0 sec, and T= stored outlet temperature at t=2.1 sec. I have already written a UDF to store the outlet temp.

      where t varies as follows:

      real t = CURRENT_TIME;
      for(;;){
              if(t<=4.2)
                  break;
              t=t-4.2;
          }
      Thank you.
    • SRP
      Ansys Employee

      Hi,

      Since you've already written a UDF to store the outlet temperature, you'll need to include a conditional statement within your UDF to check the current simulation time and apply the desired temperature accordingly.

      DEFINE_ADJUST macro can be used to make adjustments at every time step based on the current simulation time.

    • Prakash Singh
      Subscriber

      DEFINE_EXECUTE_AT_END(patch_temperature)
      {
          Domain *d = Get_Domain(1);
          Thread *t;
          cell_t c;
          double t = CURRENT_TIME;

          // Adjusting current_time to within 4.2s periodic cycle
         for(;;)
              {
                  if(t<=4.2)
                          break;
                  t=t-4.2;

      }

      // Patching at t = 2.1 sec using stored outlet temperature
          if (fabs(current_time - 2.1) < 1e-3)  
          {
              Message("Using stored outlet temperature: %f K\n", stored_temp);

              thread_loop_c(t, d)
              {
                  if (FLUID_THREAD_P(t))
                  {
                      begin_c_loop(c, t)
                      {
                          C_T(c, t) = stored_temp;  // Use dynamically stored outlet temperature
                      }
                      end_c_loop(c, t)
                  }
              }
              Message("Temperature patched to %f K at t = 2.1 sec\n", stored_temp);
          }

      I am attempting this method. However, the issue is that I am not achieving the same outcome as I achieved by manual patching. Kindly see the attached image.

      What am I doing wrong?

      Thank you for taking your time to read my issue.

    • Prakash Singh
      Subscriber

      *Note: 

      // Adjusting current_time to within 4.2s periodic cycle
         for(;;)
              {
                  if(t<=4.2)
                          break;
                  t=t-4.2;

      }//

      please read 't' as 'current_time' in the above code.

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