CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDRGM and Viscosity UDF (https://www.cfd-online.com/Forums/fluent-udf/225184-udrgm-viscosity-udf.html)

adnunes March 17, 2020 09:37

UDRGM and Viscosity UDF
 
Dear all,

I'm currently using a user-defined real gas model and I want to include a non-Newtonian model for viscosity. As I understand, the real gas model only allows to define the viscosity as a function of state variables such as temperature, pressure, etc.
How can I define viscosity as a function of shear strain only (using DEFINE_PROPERTY) and not having it being overridden by what's in the UDRGM code?

Thanks in advance,
Dinis

vinerm March 17, 2020 10:12

non-Newtonian Gas
 
Does a non-Newtonian gas exist? Even if it does, I doubt it would have fluidic characteristics, so, it won't be governed by N-S (in reality, no non-Newtonian fluid is governed by N-S but we can still use it for liquids and suspensions).

UDF for Real gas has a material scope and not a mesh scope, i.e., there are not cell index or zone threads available. Hence, you cannot fetch any values for a cell within these UDFs. This is quite similar to DEFINE_SPECIFIC_HEAT

adnunes March 17, 2020 10:32

I understand that the question in itself might not seem very reasonable, I just wanted to know if it's technically possible. I want to simulate the mixing of two streams and was instructed to avoid multiphase modelling. However, the viscosities between the 2 streams are different, hence the need to override the viscosity definition of the UDRGM.

Would a multiphase model be best suited then? I could define the properties of one stream with the UDRGM and the other with DEFINE_PROPERTY macros, although I fear it might affect the mixing behaviour (this is the reason why I am avoiding multiphase).

Thank you.

vinerm March 17, 2020 10:38

Real Gas Models
 
Multiphase modeling is incompatible with real gas models. If both are gases, then you can use species transport but multiphase option is unavailable with real gas models.

adnunes March 17, 2020 10:52

That is the issue, they are actually both liquids, but the pressure and temperature conditions are close to critical point of water, that's the justification for using the real gas model in this case. The NIST real gas model actually has an option for liquid phase, so I guess this makes sense?
I can enable the multiphase option and the mixing zone doesn't change in comparison to the single phase counterpart, however, if this is producing feasible value I have no idea.

vinerm March 17, 2020 10:59

Multiphase with Real Gas
 
As far as Fluent is concerned, I don't think multiphase and any real gas model are compatible, even in the latest version. So, either it has to be real gas or multiphase. Mixing phenomenon close to critical points is subtle; there is no known physical model for that.

adnunes March 25, 2020 17:59

Hey, I have a somehow related question and so I will ask it here instead of opening a new thread. Is it possible, keeping the model as single phase, to define for the same property 2 different expressions in different regions of my domain?

Thank you in advance.

vinerm March 26, 2020 02:25

Yes but partially
 
Within a UDF, property values are returned on a cell by cell by basis, i.e., you are already returning different value for each region. However, this is not doable for each material property, such as, not possible for specific heat in general and none of the property being defined using UDRGM.

adnunes March 26, 2020 02:42

But could I have a separate UDF defining one of the properties differently than the UDRGM just for one region?

vinerm March 26, 2020 03:22

Property UDF
 
Whenever UDRGM is used, it does not give option to apply another property UDF. You can certainly try to modify a property using DEFINE_ADJUST, however, this might lead to conservation issues.

adnunes March 26, 2020 17:46

Dear vinerm,

I tried to change viscosity through the DEFINE_ADJUST function, but I couldn't get it to work. Maybe you can help me?

Thank you in advance.

Code:
Code:

/* Defines viscosity just for the specified zone ID */
DEFINE_ADJUST(rkeos_visc, domain)
{
    cell_t c;
    real temp, mu, tr, tc, pcatm;
    int ID = 7;
    /* Set desired Zone ID from Boundary Conditions task page */
    Thread* t = Lookup_Thread(domain, ID);
    /* loop over all cells in thread */
    begin_c_loop(c, t)
    {
        temp = C_T(c, t); /* get cell temperature */
        /* RKEOS viscosity EoS */
        tr = temp / TCRIT;
        tc = TCRIT;
        pcatm = PCRIT / 101325.;
        mu = 6.3e-7 * sqrt(MWT) * pow(pcatm, 0.6666) / pow(tc, 0.16666) *
            (pow(tr, 1.5) / (tr + 0.8));

        C_MU_L(c,t) = mu;
    }
    end_c_loop(c, t)
}


vinerm March 27, 2020 03:13

Code
 
The code is correct, provided

1. ID 7 belongs to a cell zone and not a boundary zone.
2. TCRIT, PCRIT are defined somewhere. Fluent does not have these inbuilt. If you want to use these values from what Fluent has for real gas, then you have to use generic_property function as given in the Example 2 at the following link

https://www.afs.enea.it/project/nept...udf/node46.htm

Use PROP_critical_temperature, PROP_critical_pressure to fetch these values.

Though the UDF will compile and work, however, there is no guarantee that Fluent will use this viscosity for the calculations. DEFINE_ADJUST is executed before every iteration. This will modify the viscosity. However, during the calculation, it is quite possible that Fluent will pick-up values from PROPERTY UDF for Real Gas. You have to test it on a simple case by running a few iterations and then comparing results against another case where you do not use DEFINE_ADJUST function. If results are same, then this function is not useful.

adnunes March 27, 2020 05:39

Dear vinerm,

The the code is just an excerpt, ID 7 corresponds to the zone I want to adjust the viscosity and the critical properties are also defined in the beginning of the file. I've runned both with and without the DEFINE_ADJUST on and the results are the same.

vinerm March 27, 2020 06:25

Same Results
 
If the results are same, then, you cannot use this UDF to adjust. However, I doubt you need it. As I stated in my earlier post, even DEFINE_PROPERTY UDF as well as Real Gas UDF define the properties on a cell by cell basis. So, you can identify the domain within the real gas UDF and apply this equation. That would work. To identify thread, you need to do following within _viscosity UDF of real gas

if(THREAD_ID(t) == 7)
the equation for mu that you want to use within zone 7
else
whatever equation you are currently using

t is the second argument of _viscosity UDF in real gas. This was not doable in earlier versions but current versions have cell ID and thread avalaible.

adnunes March 27, 2020 06:45

7 is the zone ID, not the thread ID, hence why I use:
Code:

Thread* t = Lookup_Thread(domain, ID)
As I understand, these are not the same

I could print the thread ID to the console, though and then use your solution.

EDIT:

The Fluent documentation states that the THREAD_ID macro does the inverse of Lookup_Thread.

vinerm March 27, 2020 07:38

Thread and Zone
 
Yes, 7 cannot be thread id; thread ID is always long. THREAD_ID command returns the zone ID. Therefore, I asked you to compare it against 7.

adnunes March 27, 2020 08:43

Quote:

Originally Posted by vinerm (Post 763176)
Yes, 7 cannot be thread id; thread ID is always long. THREAD_ID command returns the zone ID. Therefore, I asked you to compare it against 7.

The if condition worked! Thank you very much for your assistance!

vinerm March 27, 2020 09:40

Good
 
Nice to know that it worked.


All times are GMT -4. The time now is 12:25.