Ansys UDF help


    • James

      Good afternoon,

      How does the command F_C0 and F_C1 work? I am trying to model adsorption of heavy metals on porous media and I developed a UDF that loops over the faces at the boundary between the porous media and the inlet zone and then I added the command F_C0 to choose cells in the porous media and carry out the adsorption operation. It didn't work as expected so I wrote a seperate UDF that explains exactly how the functions work. So for example a face at the boundary has the centroid coordinates (0.10, 0.021)m, then shouldn't the centroid coordinates of cell c1 be (0.10 + x, 0.021)? The results I am getting are very weird with the cell coordinates having absurdly large values or simply (0,0). 

      I have the same question for the functions THREAD_T0 and THREAD_T1. Do these functions select the threads , respectively, on the left and right of the thread provided in the input argument?

      My model is quite simple. It's a straight horizontal pipe (25cm) with 5 cm of porous media in the middle. The inlet is on the right, the porous media in the center followed by an outlet.

    • Federico Alzamora Previtali

      Unless you are using the output of F_C0 to obtain the cell centroid with C_CENTROID(xc, c, t), F_C0/F_C1 return cell_t for cell c, on their respective side of the face. F_C0/F_C1 does not return coordinates. cell_t is an integer data type that identifies a particular cell within a cell thread.

      Similarily for THREAD_T0, which returns a cell thread pointer for the cell adjacent to the cell. If the cell on the other side of that face does not belong to the same cell thread, THREAD_T1 will return the corresponding cell thread pointer for that cell.

      • James

        Thank you Federico for your reply.

        Yes, I am using the output of F_C0 to obtain the cell centroid and it does work. My apologies as my question wasn't exactly clear, perhaps I should get straight to the point. How exactly do I choose the cell immediately right of a face? and then choose the cell next to that and so on? 

        In my UDF I tried to use an "internal" that sits in between the porous media and the inlet area and apply either F_C0 or F_C1 to find the cell immediately to the right (meaning that the cell belongs to the porous media) to apply a formula for change in concentration but everytime I do that, it selects the porous media cell zone. In the image below you can see the concentration at the walls of the porous media is 0.1 for visualization purposes. That's the cell zone selected when I apply 

                threadC1 = THREAD_T1(thread);
                ThreadIDC1 = THREAD_ID(threadC1);
        where thread is the pointer that points to the "internal" boundary condition discussed above.
        Below are the messages I printed on the console. The thread with ID 5 belongs to the porous media cell zone and thread with ID 2 belongs to an internal boundary condition. 
        I am basically teaching myself to code and I am not experienced at this at all. Any help is appreciated. Also If you have any suggestions on modelling adsorption using bohart adams model and how I should proceed with doing that, that would be awesome. Thank you
    • Rob
      Ansys Employee

      Interior threads don't always have a normal so unless you're reporting the cells for c0 and c1 from the same facet you could see the above. I think there's a comment in UDF manual somewhere, it is/was mentioned in the surface reports in Fluent because it can mess with the post processing reports. 

      The UDF manual is a good source of information. We do provide training too, but you'd need to request that (or much cheaper, Ansys Learning Hub access) via your University. 

      • James

        Very well. Thank you for the quick response Rob :)

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