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.

How is mass imbalance evaluated at each cell?

    • lslxao
      Subscriber

      Hello,


      I have a steady-state solution of a pressure-based, k-omega realizable 3D simulation.


      I would like to verify my UDF which calculates mass flow over an arbitrary surface composed by a specified group of cells in the fluid domain.


      As a starter, I'm trying to compare my values when I loop over the faces in every cell to the cell-centered mass imbalance value that I exported from the original solution.


      However, the mass flow values at the interface of each cell I get are currently about 7 or 8 magnitudes higher than what I get from mass imbalance values in Fluent.


      I am curious how exactly mass imbalance is calculated at each cell; is it taken from surface integration, or is it interpolated from the node values.


      Also, I'd like to know how I can replicate these mass imbalance values in my calculation post-solve.


      Please advice. Thanks!

    • DrAmine
      Ansys Employee
      Check the paragraphs in FLUENT related to scaled and unscaled residuals. The mass imbalance is a post processing variable ready to use.
    • lslxao
      Subscriber

      I couldn't find documentation for the latest version of ANSY. But this is what I got from the User's Guide for ANSYS 15.0.


       


       


      From the manual, I assume the mass imbalance is an unscaled residual whose value at each cell is given by Eq. 28.5 where phi is the mass flow rate, and b is zero in a region without a source/sink.


      What I still don't understand is whether or not this value is equivalent to the sum of mass flow rates across each individual cell, or why, if it is, I cannot replicate this value in Fluent.

    • Rob
      Forum Moderator

      If you click on Help in R19 and onwards you'll get the latest help.  We can't comment beyond the documentation in this case, have you also checked the list of field variables available for post processing and/or tried on a one cell model? 

    • DrAmine
      Ansys Employee
      No it is not the equivalent. You will need to sum over all faces of each cell and then sum the sum over all cells (L2 norm). But the solver is using the documented descritzed formula. Just use the post processing variable as mentioned.
    • lslxao
      Subscriber

      Hi Amine,


      Thank you for the clarification.


      I did indeed sum over all faces and cells with begin_c_loop and c_face_loop, and based my UDF script off the UDS_FLUX example.


      I'm not sure what you mean, however, by summing over all cells.


      My goal for calculating the mass imbalance at each cell is merely to validate my calculations for my ultimate goal of calculating the total flux over arbitrary volumes composed of multiple cells. This is important because while summing the cell mass imbalance over a group of cells will give me the total mass flow over that volume, I am also concerned with the mass exchange between each distinct region of cells.


      I would really like to know in detail how exactly mass imbalance is calculated in order to modify this for my application, thanks.

    • DrAmine
      Ansys Employee
      As ANSYS Staff I cannot provided any details on this.

      You make imbalance for each cell by summing the fluxes on each face belonging to the cell. That is the backbone of My imbalance. Steady state has to be zero or very small. For unsteady one expects accumulation. The way Fluent is doing that is formerly documented. You can access that variable in each cell. I do not see why you need to recalculate it.
    • lslxao
      Subscriber

      I realize it's been forever since my last post. But upon using F_FLUX to access the fluxes at each face, I was able to replicate the mass imbalance values at some of my cells. This worked drastically better any direct first-order techniques (central,upwind,etc.) which used adjacent cell density and velocity values to calculate the flux at each face. Since face fluxes in my simulation are supposed computed using the second-order upwind scheme, the matching results suggest that F_FLUX is also calculated by the same method. However, the total fluxes over the surface of more than 70% of cells in my fluid domain still differ greatly from the mass imbalance. The calculated sum of fluxes at these cells deviated from the exported mass imbalance values on the order of millions. To illustrate my point, I've included a sample output of my results:


         Cell       Sum of F_FLUX     Mass_imbalance





      0
      -2.7097E-13
      -2.7097E-13


      1
      6.6183E-06
      -1.7342E-13


      2
      5.8732E-15
      5.8732E-15


      3
      7.4255E-13
      7.4255E-13


      4
      1.3861E-05
      1.8105E-14


      5
      4.2269E-14
      4.2269E-14


      6
      6.8240E-14
      6.8240E-14


      7
      1.4225E-05
      8.4310E-14


      8
      6.8058E-14
      6.8058E-14


      9
      1.4078E-05
      8.1717E-14



      For cells 0, 2, 3, 5, 6, and 8, the sum of F_FLUX at each face is equivalent to the mass imbalance.


      For other cells in the table, the differences between these values are huge.


      There is a fair mix of external (boundary) and internal faces in each cell so that doesn't appear to be the issue...


      If these values don't match, isn't this a program bug?

    • DrAmine
      Ansys Employee
      Might be a parallelization issue of your UDF which we do not know or depth of convergence. There is no bug on flux function or imbalances. If it was bug it wont work at all. By the way central scheme is second order scheme.
    • lslxao
      Subscriber

      Correct me if I'm mistaken, but I'm using a serial UDF which is executed on-demand, so I doubt that is the case.


      I have loaded a case+data which was solved on another machine, which may have been parallel.


      I'm not sure if that will result in a parallelization issue.


      I would appreciate it if could elaborate on that or any other possible reasons why there is a mismatch.


      Correction: I meant to say first-order central difference, i.e. the unweighted average of up- and downwind cells. Which is, as you said, second-order accurate.


      I would attempt to write my own higher-order upwind schemes but sometimes I get diverging flow at a face where you can't tell the direction of the flow just by looking at the sign of the flux on one face. And I'm not sure what to do in that situation.

    • Rob
      Forum Moderator

      What's different about those cells? Ie are they on a boundary etc?

    • lslxao
      Subscriber

      Hi, they are all normal fluid cells. No multiphase flows here.


      There are both internal and boundary cells.


      But per Amine's suggestion, I looked into parallelization.


      I have been using fprintf to store raw values into .txt files and inadvertently executing my UDF in parallel the whole time, which may have caused the mismatch I mentioned.


      I will take my questions regarding parallelization elsewhere and report back once I have successfully obtained (sum of F_FLUX per cell) = mass imbalance per cell.

    • lslxao
      Subscriber

      I verified that parallelization is actually not the issue by placing all my calculations in the RP_NODE directive. The answer I get is still the same.


      What is the L2 norm that you mentioned of in relation to? Does the mass imbalance value at each cell use it?

    • lslxao
      Subscriber

      It's been forever since the original post but I would like to mention if you're struggling with the same issue to make sure when you're summing over a cell to keep in mind which face is C0 and C1. If the ID of C0 doesn't match the current cell ID, then flux over that face will be the negative of whatever F_FLUX gives. My mistake was forgetting to account for that. After fixing it my total flux matched that given by the sum of all mass imbalances in the system. Thank you for those who contributed suggestions.

    • DrAmine
      Ansys Employee

      Thanks for the update.

Viewing 14 reply threads
  • The topic ‘How is mass imbalance evaluated at each cell?’ is closed to new replies.
[bingo_chatbox]