Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Compiling UDF

    • Jeroen
      Subscriber

      Hello


      I am new to ANSYS and UDF's and am trying to simulate a reacting particle. Now I've written my UDF but I get the following error when compiling in ANSYS:


         The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).


       


         The system cannot find the path specified.


       


         C:Userss151272DocumentsMasterAfstudeer_opdrachtANSYSrz_model_filesdp0FFFFluentlibudfwin643d_hostlibudf.dll


       


       


      My UDF is located in the following directory:


         C:Userss151272DocumentsMasterAfstudeer_opdrachtANSYSMass_balance_UDF.c


       


       


      How do I solve this issue?


       

    • Karthik Remella
      Administrator

      Hello,


      Have you checked the UDF for a serial run? Instead of opening a parallel Fluent session, could you please try to run your UDF in a serial session?


      Thank you.


      Best,


      Karthik

    • Jeroen
      Subscriber

      Starting fluent with serial processing enabled does not solve the issue unfortunately. I have also tried using the interpreted option though this gives a parse error in line 1. 

    • Karthik Remella
      Administrator

      Could you please post the entire error message?

    • Jeroen
      Subscriber

      For the compiled option I get the following error:


      s151272: Opening library "C:Userss151272DocumentsMasterAfstudeer_opdrachtANSYSrz_model_filesdp0FFFFluentlibudf"...


      RPC RCX_SC_SET_ERR_MSG failed: RPC: Can't encode arguments


       


       


      Error at host: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).


       


      The system cannot find the path specified.


       


      C:Userss151272DocumentsMasterAfstudeer_opdrachtANSYSrz_model_filesdp0FFFFluentlibudfwin643d_hostlibudf.dll


      Error at Node 0: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).


       


      The system cannot find the path specified.


       


      C:Userss151272DocumentsMasterAfstudeer_opdrachtANSYSrz_model_filesdp0FFFFluentlibudfwin643d_nodelibudf.dll


       


      ===============Message from the Cortex Process================================


       


      Compute processes interrupted. Processing can be resumed.


       


      ==============================================================================


       


      Error: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).nnThe system cannot find the path specified.


      nnC:Userss151272DocumentsMasterAfstudeer_opdrachtANSYSrz_model_filesdp0FFFFluentlibudfwin643d_hostlibudf.dll


       


      Error Object: #f


       

    • Karthik Remella
      Administrator

      Hello,


      Are you able to compile any UDF on your system at all? Or it the issue very specific to the code you are trying to compile?


      Could you please take a simple test code from the Fluent UDF manual and try to compile it to see if that compiles? This might help us narrow down the issue. Right now, it could either be your code or that your compiler has not been installed properly on your machine.


      Best,


      Karthik

    • Jeroen
      Subscriber

      I get the same issue with several UDF's in the Manual, both for interpreted and compiled codes.


      So the issue is not in the UDF code.


       


      What other steps can I take to fix this error?

    • Jeroen
      Subscriber

      nnC:Userss151272Documents...............rz_model_filesdp0FFFFluentlibudfwin643d_hostlibudf.dll


       


      I think the problem is in loading the libudf.dll file, which is not being generated by Fluent. Any ideas why it is not there or how it must be generated?

    • Rob
      Forum Moderator

      If you interpret the code what's the full error?  Parse errors tend to mean there's a rogue/missing character on the line. Copy+Paste straight from the manual usually means you've got some white space characters that you don't want too.

    • Jeroen
      Subscriber

      ****************************************************************************


      ****************************************************************************


      ** WARNING: Automatically switched to run in parallel -t1 mode. **


      ** Detected non-parallelized UDF usage, enabling parallel usage. **


      ** If you encounter any issues, please re-run with -t0 flag. **


      ****************************************************************************


      ****************************************************************************


      cpp -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/main" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/addon-wrapper" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/io" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/species" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/pbns" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/numerics" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/sphysics" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/storage" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/mphase" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/bc" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/models" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/material" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/amg" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/util" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/mesh" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/udf" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/ht" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/dx" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/turbulence" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/acoustics" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/parallel" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/etc" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/ue" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/dpm" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/dbns" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/tgrid/src" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/PRIME/tgrid/src" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/cortex/src" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/client/src" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/multiport/src" -I. -DUSE_UDF_HOST_DUMMY -DUDFCONFIG_H="" "CUsers/s151272/Documents/Master/Afstudeer_opdracht/ANSYS/Mass_balance_UDF.c"


      Error: CUsers/s151272/Documents/Master/Afstudeer_opdracht/ANSYS/Mass_balance_UDF.c: line 1: parse error.


       


      cpp -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/main" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/addon-wrapper" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/io" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/species" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/pbns" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/numerics" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/sphysics" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/storage" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/mphase" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/bc" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/models" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/material" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/amg" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/util" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/mesh" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/udf" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/ht" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/dx" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/turbulence" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/acoustics" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/parallel" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/etc" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/ue" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/dpm" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/src/dbns" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/tgrid/src" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/PRIME/tgrid/src" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/cortex/src" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/client/src" -I"C:PROGRA~1ANSYSI~1v195fluentfluent19.5.0/multiport/src" -I. -DUDFCONFIG_H="Users/s151272/AppData/Local/Temp/udfconfig-14880-node0.h>" "CUsers/s151272/AppData/Local/Temp/Mass_balance_UDF.c.14880.0.c"


       


      Error: CUsers/s151272/AppData/Local/Temp/Mass_balance_UDF.c.14880.0.c: line 1: parse error.

    • Karthik Remella
      Administrator

      Hello,


      Could you please run the UDF with a -t0 flag? When you open the Fluent session, please set the number of processers to 0 and try running a UDF from the UDF manual first? This should force Fluent to open in legacy serial.


      Also, could you also share the UDF you are using in one of your posts so we can take a look at it?


      Thank you.


      Best Regards,


      Karthik

    • Jeroen
      Subscriber

      Starting with a -t0 flag also has no effect. My UDF code is below:


       


      /***********************************************************************


         UDF for defining the heat and mass transport of single step reduction


       ***********************************************************************/


       #include "udf.h"


       #include "dpm.h"


       #include "pdf_props.h"


       


       DEFINE_DPM_HEAT_MASS(Mass_bal_Hematite,p,Cp,hgas,hvap,cvap_surf,Z,dydt,dzdt)


       {


        Thread *t0 = P_CELL_THREAD(p);    /* thread where the particle is in*/


        cphase_state_t *c = &(p->cphase); /* cell information of particle location*/


       


        int nFe = 2;  /* indices for chemical formula oxide */


        int nO = 3;


       


        float K = 1;          /* equilibrium constant */


        float E_act = 214000; /* activation energy [J/mol] */


        float k0 = 4.41e7;    /* pre-exponential factor */


        real H_Ox = 9.8509E5; /* oxide enthalpy */


       


        real T_p = P_T(p);    /* particle temperature [K] */


        real mp = P_MASS(p);  /* particle mass [kg] */


       


        int atm = 101325;         /* atmospheric pressure [Pa] */


        real p_c = C_P(c,t0)/atm;   /* cell pressure [atm] */


        /*real Tc = P_T(c,t0);    /* cell temperature [K] */


       


        real mf[0] = Pdf_Yi(c,t0,0);  /* mass fraction hydrogen */


        real mf[1] = Pdf_Yi(c,t0,1);  /* mass fraction steam */


       


        float molMassFe = 55.845/1000;          /* mol mass iron [kg/mol] */


        float molMassO = 15.9994/1000;          /* mol mass oxide [kg/mol] */


        float molMassH2 = 2.01488/1000;         /* mol mass hydrogen [kg/mol] */


        real molMassH2O = molMassH2 + molMassO; /* mol mass water [kg/mol] */


       


        real molf[0] = (mf[0]/molMassH2)/((mf[0]/molMassH2)+(mf[1]/molMassH2O));  /* mole fraction hydrogen */


        real molf[1] = (mf[1]/molMassH2O)/((mf[0]/molMassH2)+(mf[1]/molMassH2O)); /* mole fraction steam */


       


        real p_H2 = p_c*molf[0]/(molf[0] + molf[1]);    /* partial pressure hydrogen [atm]*/


        real p_H2O = p_c*molf[1]/(molf[0] + molf[1]);   /* partial pressure steam [atm]*/


        


        real p_time = P_TIME(p);       /* particle time in reactor */


        real time = CURRENT_TIME;      /* current time */


        real dt   = CURRENT_TIMESTEP;  /* time step */


       


        float R = 8.3144598;  /* Gas constant [J/mol*K] */


       


        real X_t = 1-exp(-k0*exp(-E_act/(R*T_p))*(p_H2 - p_H2O/K)*p_time) ;     /* reduction rate at current time step */


        real X = 1-exp(-k0*exp(-E_act/(R*T_p))*(p_H2 - p_H2O/K)*(p_time+dt));   /* calculate reduction rate at end of time step [%] */


       


        real molMass_FeOx = nFe*molMassFe + nO*molMassO; /* initial molar mass iron oxide */


        real nMol = mp/molMass_FeOx;                     /* amount of moles iron oxide in the particle */


        real O_initial = (nO*molMassO)/molMass_FeOx;


       


        real Fe_t = (1 - O_initial)/(1 - X_t*O_initial);              /* mass-% iron at time t */


        real x_t = (nFe*molMassFe/Fe_t - nO*molMassFe)/molMassO;      /* amount of oxygen left at time t */


        real Fe_end = (1 - O_initial)/(1 - X*O_initial);              /* mass-% iron at end of timestep */


        real x_end = (nFe*molMassFe/Fe_end - nO*molMassFe)/molMassO;  /* amount of oxygen left at end of timestep */


       


        real molMass_FeOx_t = nFe*molMassFe + x_t*molMassO;      /* molar mass at time t*/


        real molMass_FeOX_end = nFe*molMassFe + x_end*molMassO;  /* molar mass at end of timestep */


       


        real dmdt = -(molMass_FeOx_t - molMass_FeOx_end)*nMol/dt;  /* dmdt iron oxide particle [kg/s] */


        dzdt->species[0] = -nMol*(x_t-x_end)*molMassH2/dt;         /* dmdt hydrogen flow [kg/s] */


        dzdt->species[1] = nMol*(x_t-x_end)*molMassH2O/dt;         /* dmdt steam formation [kg/s] */


        


        real H_Fe = 3.3864E5;         /* Enthalpies (temperature dependent) */


        real H_Ox = 9.8509E5;


        real H_h2 = 4.6595E4; 


        real H_h2o = 9.7514e+04;


        real dH = H_Ox + nO*H_h2 - nO*H_h2o - nFe*H_Fe;   /* Enthalpy difference of reaction */


       


        dzdt ->energy[1] += (dmdt * dH)/(mp * Cp);  /* source term  of the steam temperature [K/s] */


       


        dydt[1] += dmdt;                            /* source term of the particle mass [kg/s] */


       


        dzdt->species[0] = 0;  /*neglect formation of steam and dissipation of hydrogen */


        dzdt->species[1] = 0;


        dzdt ->energy[1] += 0; /*neglect temperature change due to reaction */


        dydt[1] += 0;          /*neglect change in particle mass due to reaction */


       


        /* write output file to verify data */


        str = fopen ("UDF_output.txt","a");


        fprintf (str,"particle time: %f , time: %f, reduction degree: %f n", p_time, time, X);


        fclose (str);


       }

    • Karthik Remella
      Administrator

      Hello,


      Since you said you were not able to compile any UDFs from the manual, I'm not sure if it is wise to debug the UDF you've posted here. It is perhaps that your compiler is not working the way it should and therefore, we are seeing the following issue. I'm posting a very simple piece of code here. If compiled properly, you should be able to prescribe a parabolic velocity profile at your inlet. Here is the code. Please copy this code you a text file, name the file - inlet.c and try to compile this. Please let us know your findings here. Depending on this, we should be able to help you better.


      Thanks,


      Best,


      Karthik


      Code:


      /***********************************************************************
      UDF for specifying steady-state parabolic pressure profile boundary
      profile for a turbine vane
      ************************************************************************/

      #include "udf.h"

      DEFINE_PROFILE(pressure_profile,t,i)
      {
      real x[ND_ND]; /* this will hold the position vector */
      real y;
      face_t f;
      begin_f_loop(f,t)
      {
      F_CENTROID(x,f,t);
      y = x[1];
      F_PROFILE(f,t,i) = 1.1e5 - y*y/(.0745*.0745)*0.1e5;
      }
      end_f_loop(f,t)
      }
    • Amine Ben Hadj Ali
      Ansys Employee
      You need a compiler. Interpreting UDFs is not always possible aNd the docu states that for several define macros a compiler is required. Moreover Ansys staff do not debug UDFs if ths is your intention later
    • Jeroen
      Subscriber

      The code supplied also does not work and gives the following error:


      Error: The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform (win64).nnThe system cannot find the file specified.


      nnC:Userss151272DocumentsMasterAfstudeer_opdrachtANSYSlibudfwin643d_hostlibudf.dll


       


      Error Object: #f


       


      I currently have Windows Visual 2019 and Pelles C installed as compilers. However, I have never established a coupling between Fluent and one of these compilers. How should this be done?


       

    • Amine Ben Hadj Ali
      Ansys Employee
      Can you try compiling from x64 cross vs compiler prompt just start Fluent there.
    • Jeroen
      Subscriber

      I have tried starting it from the compiler prompt you mentioned, though that still doesn't work.

    • Amine Ben Hadj Ali
      Ansys Employee
      Can you screenshot cl in this prompt? Type cl and insert the screenshot.
    • Jeroen
      Subscriber

    • Amine Ben Hadj Ali
      Ansys Employee
      The VS 2019 is supported with 2020R1. Fir 2019Rx a patch is required. Either you have access to customer portal or use another version like VS 2017. Always clean uninstall any Visusl Studio version and install as admin.
    • Jeroen
      Subscriber

      Alright with VS 2017 it indeed works. However I now get a syntax error whilst udf_names.c is being generated.


         # Generating udf_names.c because of React_Hematite.obj


         udf_names.c


         udf_names.c(7): error C2059: syntax error: '}'


       


         udf_names.c(8): warning C4034: sizeof returns 0


       


      Any idea why this happens and how I can solve this issue?

    • Karthik Remella
      Administrator

      While compiling your code, the compiler found issues with the code. Please go to those lines and check the syntax you used in your code. The error messages will help you debug your code.


      For example, please go to line no. 7 in your code to understand why there is a missing parenthesis.


      Thanks.

    • Amine Ben Hadj Ali
      Ansys Employee
      Nice that now it seems working. Now stick to the documentation and what my colleague shared.
Viewing 22 reply threads
  • The topic ‘Compiling UDF’ is closed to new replies.