Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Storing and plotting values in UDM

    • Zwernjayden
      Subscriber

      I basically want to store the value of r, for each face, and plot it vs axial position. When I try this, its just a constant line at 0. I turned on a udm location and node memery location but is there anything else I have to do?

      #include "udf.h"
      #include
       
      #define rho 950 // kg/m^3
      #define Hg 2033631 // J/Kg
      #define Hf -310000 // J/Kg
      #define T_ref 298 // K
      #define A1 0.01104 // m/s
      #define A2 3.9648 // m/s
      #define Cp 1500 // J/(Kg*K)
      #define E1 20557.188 // J/mol
      #define E2 55893.78 // J/mol
      #define R_u 8.314 // J/(mol*K)
      #define alpha 0.3
       
      DEFINE_PROFILE(surface_temperature_profile, t, position)
      {
          face_t f;
          real Ts, heat_flux, heat, a_face, Hv, r, Ts_old, Ts_new, error, Ts_new_prime, Area[ND_ND];
          real radial_position;
          real centroid[ND_ND];
          int iter;
       
          begin_f_loop(f, t)
          {
              Ts = F_T(f, t);  // Current temperature at the face
              heat = BOUNDARY_HEAT_FLUX(f, t);  // Heat transfer at face f in watts
              F_AREA(Area, f, t);  // Get the area vector of the face
              a_face = NV_MAG(Area);  // Magnitude of the face area
       
              // Calculate the radial position of the face centroid
              F_CENTROID(centroid, f, t);
              radial_position = centroid[1]; // Assuming the radial position is the y-coordinate in 2D axisymmetric
       
              // Heat flux for the circumferential area
              heat_flux = (heat*2*M_PI*radial_position) / a_face; // Heat flux in W/m^2
              printf("Heat flux on face %d: %g W/m^2\n", f, heat_flux);
              Ts_old = Ts;
              iter = 0;
              error = 1;
              while (error > 1e-6 && iter < 100)
              {
                  Hv = Hg - Hf + Cp * (Ts - T_ref);  // Calculation heat of formation
                  r = (fabs(heat_flux)) / (Hv * rho);  // Regression rate
                  if (Ts_old > 722)
                  {
                      Ts_new = E1 / (R_u * (log(A1) - log(r)));  // New surface temperature for high temperature
                  }
                  else
                  {
                      Ts_new = E2 / (R_u * (log(A2) - log(r)));  // New surface temperature for low temperature
                  }
                  error = fabs(Ts_new - Ts_old);  // Error calculation
                  Ts_old = Ts_new;  // Update Ts_old for next iteration
                  iter++;  // Increment iteration count
              }
       
              Ts_new_prime = Ts + (alpha * (Ts_new - Ts)); 
      r = (fabs(heat_flux)) / (Hv * rho);
      // Store r in UDM
              F_UDMI(f, t, 0) = r;  // Assuming the UDM index is 0
              printf("New Temp %d: %g K\n", f, Ts_new_prime);
              printf("r_dot %d: %g mm/s\n", f, r*1000);
              F_PROFILE(f, t, position) = Ts_new_prime;  // Update the face temperature profile
          }
          end_f_loop(f, t)
      }
    • Rob
      Forum Moderator

      https://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v241/en/flu_udf/flu_udf_DataAccessMacros.html%23x1-5030004.2.9  might explain the issue?

Viewing 1 reply thread
  • The topic ‘Storing and plotting values in UDM’ is closed to new replies.
[bingo_chatbox]