Fluids

Fluids

Topics relate to Fluent, CFX, Turbogrid and more

Error while trying to hook UDFs

    • ISAR CHARMCHI
      Subscriber

      Hi, I am trying to model solidifiaction of water-sucrose solution and need to define property by UDFs. While I comiple them succesfully I cannot hook them. Just the density seems to hook succesfully. You can find my UDFs and the error that I get below. I thought it may be the issue of parallelization but I cannot find any guide in the UDF user manual. I think these UDFs series are also fine in parallel. I appreciate if you can guide me. I am also compiling them in HPC in 4 nodes. 

      #include "udf.h"

      DEFINE_PROPERTY(cell_viscosity,c,t)
      {
        real mu_lam;
        real temp = C_T(c,t);
        if (temp > 259.25)
          mu_lam = ((1.0 / (1.0 + 5.0 * pow(0.1, 3.4) * pow((temp / 273.15), 12.0))) * pow(10.0, (3.8 - 0.013 * temp) + 0.1 * (1.184 + 1.53 * pow(0.1, 4.5) * pow((temp / 273.15), -9.0) * pow(10.0, (0.87 * 0.1)))))/1000;
        else
          mu_lam = 1.;
        return mu_lam;
      }

       

      #include "udf.h"

      DEFINE_PROPERTY(cell_density,c,t)
      {
        real rho;
        real temp = C_T(c,t);
        real liqfrac = (temp - 259.25)/(272.52 - 259.25); 
        if (temp > 272.52)
          rho = 1020;
        else if (temp > 259.25)
          rho = liqfrac * 1020 + (1 - liqfrac) * 931;
        else
          rho = 931;
        return rho;
      }

      #include "udf.h"

      DEFINE_PROPERTY(cell_heat_capacity,c,t)
      {
        real Cp;
        real temp = C_T(c,t);
        real liqfrac = (temp - 259.25)/(272.52 - 259.25); 
        if (temp > 272.52)
          Cp = 3936;
        else if (temp > 259.25)
          Cp = liqfrac * 3936 + (1 - liqfrac) * (1116 + 3.34 * temp);
        else
          Cp = 1116 + 3.34 * temp;
        return Cp;
      }

       

      #include "udf.h"

      DEFINE_PROPERTY(cell_ktc,c,t)
      {
        real ktc;
        real temp = C_T(c,t);
        real liqfrac = (temp - 259.25)/(272.52 - 259.25); 
        if (temp > 272.52)
          ktc = 0.583 * (1 - 0.585 * 0.1) * (1 + 0.00224 * (temp - 273.15));
        else if (temp > 259.25)
          ktc = liqfrac * (0.583 * (1 - 0.585 * 0.1) * (1 + 0.00224 * (temp - 273.15))) + (1 - liqfrac) * (7.47 - 0.02925 * temp + 3.646e-5 * temp * temp );
        else
          ktc = 7.47 - 0.02925 * temp + 3.646e-5 * temp * temp ;
        return ktc;
      }

    • ISAR CHARMCHI
      Subscriber

      I also added C_UDMI(c,t,0) = mu_lam, C_UDMI(c,t,1) = rho, ... until 4 udmi but still doesn't work, 

    • ISAR CHARMCHI
      Subscriber

      I tried everything that I could think of: Write all of them in a file and compile and load with one file in one library didn't work. I write them separately compile them in different library didn't work. I write them separately compile them in one library didn't work. I compile them in my PC didn't work. In just one node didn't work. When I set the first property the other ones give the error above and for Cp is always the same error. I really have no idea. I thought because of the error is about the name but you have to set the name of function DEFINE_PROPERTY with just three variables. Please guide me through this:)

    • ISAR CHARMCHI
      Subscriber

       

      I think the problem is specific heat but I checked materials.h and there is prop_Cp so I should be able to define it by UDF. I really don’t know what I am missing.

       

       

    • ISAR CHARMCHI
      Subscriber

      I think I finally figured it out but have some question regarding cp: I wrote the code below for cp but as I undersdtand cp is not a field but depends on the temperature field that solver solved. I can define it as a parameter related to temperature like below: and how can I save in user define memory? 

       

      DEFINE_SPECIFIC_HEAT(my_user_cp, T, Tref, h, yi)
      {
        real cp;
        real liqfrac = (T – 259.25)/(272.52 – 259.25); 
        if (T > 272.52)
          cp = 3936;
        else if (T > 259.25)
          cp = liqfrac * 3936 + (1 – liqfrac) * (1116 + 3.34 * T);
        else
          cp = 1116 + 3.34 * T;
        *h = cp*(T-Tref);
        return cp;
      }

    • Rob
      Ansys Employee

      Why do you need it as a UDM? 

    • ISAR CHARMCHI
      Subscriber

      Used defined memory so that I can check the value later on the post-processing each time step. Also, specific heat is a cell-based value? T here is the same as C_T(c,t)?

       

    • Rob
      Ansys Employee

      You can report/plot the cp directly when you open the data file. 

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