CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDRGM and Viscosity UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By vinerm

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 17, 2020, 10:37
Default UDRGM and Viscosity UDF
  #1
New Member
 
Dinis Nunes
Join Date: Jan 2020
Posts: 16
Rep Power: 6
adnunes is on a distinguished road
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
adnunes is offline   Reply With Quote

Old   March 17, 2020, 11:12
Default non-Newtonian Gas
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 17, 2020, 11:32
Default
  #3
New Member
 
Dinis Nunes
Join Date: Jan 2020
Posts: 16
Rep Power: 6
adnunes is on a distinguished road
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.
adnunes is offline   Reply With Quote

Old   March 17, 2020, 11:38
Default Real Gas Models
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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.
arashjkh likes this.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 17, 2020, 11:52
Default
  #5
New Member
 
Dinis Nunes
Join Date: Jan 2020
Posts: 16
Rep Power: 6
adnunes is on a distinguished road
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.
adnunes is offline   Reply With Quote

Old   March 17, 2020, 11:59
Default Multiphase with Real Gas
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 25, 2020, 18:59
Default
  #7
New Member
 
Dinis Nunes
Join Date: Jan 2020
Posts: 16
Rep Power: 6
adnunes is on a distinguished road
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.
adnunes is offline   Reply With Quote

Old   March 26, 2020, 03:25
Default Yes but partially
  #8
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 26, 2020, 03:42
Default
  #9
New Member
 
Dinis Nunes
Join Date: Jan 2020
Posts: 16
Rep Power: 6
adnunes is on a distinguished road
But could I have a separate UDF defining one of the properties differently than the UDRGM just for one region?
adnunes is offline   Reply With Quote

Old   March 26, 2020, 04:22
Default Property UDF
  #10
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 26, 2020, 18:46
Default
  #11
New Member
 
Dinis Nunes
Join Date: Jan 2020
Posts: 16
Rep Power: 6
adnunes is on a distinguished road
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)
}
adnunes is offline   Reply With Quote

Old   March 27, 2020, 04:13
Default Code
  #12
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 27, 2020, 06:39
Default
  #13
New Member
 
Dinis Nunes
Join Date: Jan 2020
Posts: 16
Rep Power: 6
adnunes is on a distinguished road
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.
adnunes is offline   Reply With Quote

Old   March 27, 2020, 07:25
Default Same Results
  #14
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 27, 2020, 07:45
Default
  #15
New Member
 
Dinis Nunes
Join Date: Jan 2020
Posts: 16
Rep Power: 6
adnunes is on a distinguished road
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.
adnunes is offline   Reply With Quote

Old   March 27, 2020, 08:38
Default Thread and Zone
  #16
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
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.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   March 27, 2020, 09:43
Default
  #17
New Member
 
Dinis Nunes
Join Date: Jan 2020
Posts: 16
Rep Power: 6
adnunes is on a distinguished road
Quote:
Originally Posted by vinerm View Post
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!
adnunes is offline   Reply With Quote

Old   March 27, 2020, 10:40
Default Good
  #18
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 36
vinerm will become famous soon enough
Nice to know that it worked.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile User-Defined Real Gas Model (UDRGM) Captain Convergence Fluent UDF and Scheme Programming 31 November 6, 2020 07:30


All times are GMT -4. The time now is 19:18.