Fluids

Fluids

Cell Field Variable

    • Meyzeeh
      Subscriber

      Hi

      I'm modeling a mixture of air and another gas (no reactions) using the species model and I want to add a custom source term in kg/m3s given by S=-cΦ (c=constant and Φ=concentration in kmol/m3 calculated by the species model) using DEFINE_SOURCE. My question is what macro can I use to retrieve the cell field variable Φ from the species model when defining the source? 

    • SRP
      Subscriber

      Hi,

      you can use the following macro in the source definition:C_UDMI(c,t,phi_index).

      You can use C_UDMI to access or store the value of the user-defined memory in a cell.

      It can be used to allocate up to 500 memory locations in order to store and retrieve the values of cell field variables computed by UDFs.

      For more details please refer to fluent customization manual: 3.2. Data Access Macros (ansys.com)

      If you are not able to access the link, please refer to this forum discussion: https://forum.ansys.com/forums/topic/using-help-with-links/#latest

      Thank you.

    • Meyzeeh
      Subscriber

      Thank you for your reply. I looked at C_UDMI it seems like it doesn't access the field variables directly by itself as there are calculated by the model it only stores variables in the allocated "user-defined memory" which are retrieved by cell field variable macros (e.g. C_UDMI() = C_T() would store the cell temperatures retrieved by C_T() in the allocated memory using C_UDMI() but doesn't retrieve the temperatures by itself) and once this data it stored in memory it can than be accessed using C_UDMI() for other purposes. It only links cell field variable macros with the allocated memory. I'm looking for a cell field variable macros similar to C_T(), C_U(), C_P() but for concentration. The closest thing I found was C_UDSI but this is used with UDS transport equations but in my case I don't need to define UDS transport equations since the species model is sufficiate for my problem. Can I somehow maybe pass the species model in the argument of C_UDSI(c,t,i) (e.g. using the species model index if it has one or something)?. Please help!!  

    • SRP
      Subscriber

      Hi,

      No, it is not possible to pass the species model as an argument to C_UDSI(c, t, i) in ANSYS Fluent. C_UDSI is a user-defined scalar function that allows you to access and modify user-defined scalar variables associated with a cell (c), thread (t), and index (i).

      Within the DEFINE_SOURCE macro, you can access the species concentrations using the FLUENT macros C_YI(c, t, i), which returns the mass fraction of species i in cell c and thread t.

      Thank you.

    • Meyzeeh
      Subscriber

      Thank you again for your reply. 

      I'm trying to model the effect of air ventilation on a gas that is introduced in the fluid domain with two sources. The first source is a constant in kg/m3s which results in a concentration build-up within the domain of the gas and the second negative source is the one I mentioned above which has the overall effect of removing some of this gas. In the end, I'm interested in the effect of both the ventilation and the negative source term on the concentration (kmol/m3) of the gas that is building up inside the domain. The mass fraction has no units so it wouldn't work with my source which must have the units kg/m3s. So there is no micro to access species concentration in kmol/m3 which I can then use with the source I mentioned above?

    • Meyzeeh
      Subscriber

      I also have another question. If I wanted to set up my problem as described above using UDS transport equations instead of the species model how many equations would I need and how would I define/create the air-gas mixture under the fluid tap in materials since the mixture option only appears only when you have activated the species model? The reason I'm asking is that I've gone through all the examples in the UDF manual for setting up UDS transport equations and there only consider a single fluid, not a mixture. Also, I think if I can set up UDS transport equations then I can use C_UDSI(c, t, i) to retrieve the concentration and then use it in the source.

    • Rob
      Ansys Employee

      Does the mass sink just remove one species or all gas equally?  Scalars allow you to do pretty much anything you want, the draw back is you need to know how it works: given they can also be any value it's not always simple to substitute scalar UDS for another equation. 

    • Meyzeeh
      Subscriber

      Hi Rob

       

      The diffusion-advection equation above is what I'm trying to simulate which is just the species transport equation with an extra term that is not accounted for in the species model in ansys. The C is the concentration kmol/m3, λ is the decay constant in s^-1, D is the diffusion coefficient m2/s, S is a constant source term in kg/m3s and u is the velocity m/s. I'm trying to include the term -λC which is the missing term in the species model it's called the decay term. I wanted to add it as a source term defined as E= -λC. The concentration building in the domain decays/sink by the non-constant value -λC which also depends on the value of that concentration. The gas described by this equation will be introduced in the near-wall cells to simulate the gas emanating from the wall. There is also air entering the domain providing natural ventilation which further decreases the gas emanating from the wall.

       

       

    • Rob
      Ansys Employee

      So, you also need the age of the decaying gas? That's a good use for a scalar. Nothing stopping you using species and a scalar to then calculate the source (sink) term. 

    • Meyzeeh
      Subscriber

      Hi Rob

      I only needed the gas concentration distribution in the fluid domain after ventilation and after some of it had decayed. The decay is due to the radioactivity of the gas which is taken care of by the source term I wanted to introduce using a UDF. I finally manage to solve the problem using a UDS scalar transport equation thank you Rob and subscriber SRP.

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