CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

UDF in changing Turbulence Model

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 21, 2020, 23:39
Default UDF in changing Turbulence Model
  #1
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Is it possible to change the Turbulence Model from a User Defined Function?
visitor is offline   Reply With Quote

Old   August 22, 2020, 07:25
Default
  #2
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
This clearly belongs to the Fluent forum... but yes, it is, in different ways (from simply redefining the turbulent viscosity to solving your own equations), but reading the manual is the way to learn how to do it.
sbaffini is offline   Reply With Quote

Old   August 22, 2020, 07:58
Default Changing turbulence model via UDF
  #3
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
I have read the UDF manual, couldn't find anything on changing a turbulence model via UDF.

Example lets say I wanted to change from k-epsilon RNG to Realizable or SSG, ..any?

Thanks
visitor is offline   Reply With Quote

Old   August 22, 2020, 09:22
Default
  #4
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Oohhh, that kind of "change"... I have no idea, but probably not. Again, you might have better chances in the Fluent forum
sbaffini is offline   Reply With Quote

Old   August 22, 2020, 10:21
Default
  #5
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Yes, i thought so, it's not available in UDF. Don't know why fluent/cfx did not allow this?

Most of UDF are; define profile, define property,

Hope someone knows a tip.
visitor is offline   Reply With Quote

Old   August 22, 2020, 10:44
Default
  #6
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
You can do that when using a journal file. Is there a particular reason you want to do it by udf?
sbaffini is offline   Reply With Quote

Old   August 22, 2020, 11:19
Default
  #7
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Open to any suggestion. Not particularly a UDF, any method. I have not used a journal file.

Reason; some times you need to change model. I will be having some conditional statements. If cell temperature is above ... Then turbulence model X, else, than Turbulence Model XX.
visitor is offline   Reply With Quote

Old   August 22, 2020, 11:25
Default
  #8
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Then the journal file is definitely the way to go. You can learn how everything is done by using the Fluent TUI and using the same commands in the journal. Unfortunately, to use loops and other flow control features you'll need to know the Scheme language. Maybe, now Fluent comes with a guide on it. I used to write such journals using a different scripting language that I knew better
sbaffini is offline   Reply With Quote

Old   August 22, 2020, 11:50
Default
  #9
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Thanks, will look at online examples.
visitor is offline   Reply With Quote

Old   August 24, 2020, 17:19
Smile
  #10
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
It looks like this will do it

(if test true-action false-action)

It's a scheme if statement. The only concern is if I use the temperature condition, then it will trigger an action. Once temperature condition is reached, even if it's just one odd cell.

It will be good to find some statement to apply this (scheme if statement) per a cell. Then I am not generalising. More research for me.
visitor is offline   Reply With Quote

Old   August 24, 2020, 18:21
Default
  #11
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
No, we need to clarify at what level is a change of turbulence model allowed or makes any sense.

You can use scheme to switch model globally as if you were doing it by the GUI, so you can't do it on a cell by cell basis.

Actually, what you are looking for is indeed an implementation of a new turbulence model, which must be done via UDF and user defined scalars.
sbaffini is offline   Reply With Quote

Old   August 25, 2020, 06:17
Default
  #12
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Thanks.

Switching from turbulence models is quite common, just looking to automate it.

Yes I did thought of a UDF, and there are examples in changing a property per a cell shown in Fluent manuals. Something similar to this (Fluent UDF manual);

#include "udf.h"
DEFINE_PROPERTY(cell_viscosity, cell, thread)
{
real mu_lam;
real temp = C_T(cell, thread);
if (temp > 288.)
mu_lam = 5.5e-3;
else if (temp > 286.)
mu_lam = 143.2135 - 0.49725 * temp;
else
mu_lam = 1.;
return mu_lam;
}

Except instead of changing a property per a cell, change turbulence model. Yes I know how everyone does it now. Run through one model, stop and then change to another. Not a good way of automation to me.
visitor is offline   Reply With Quote

Old   August 25, 2020, 06:37
Default
  #13
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,290
Rep Power: 34
arjun will become famous soon enougharjun will become famous soon enough
Care to explain what Turbulence model this UDF is switching to.
All I can see is that it is overwriting cell viscosity and this is not switching the turbulence model. It is overwriting a turbulence model.
For example if I was using k-omega model then this udf is not capable of switching to k-epsilon, which i believe what i understand from OP.


Quote:
Originally Posted by visitor View Post
Thanks.

Switching from turbulence models is quite common, just looking to automate it.

Yes I did thought of a UDF, and there are examples in changing a property per a cell shown in Fluent manuals. Something similar to this (Fluent UDF manual);

#include "udf.h"
DEFINE_PROPERTY(cell_viscosity, cell, thread)
{
real mu_lam;
real temp = C_T(cell, thread);
if (temp > 288.)
mu_lam = 5.5e-3;
else if (temp > 286.)
mu_lam = 143.2135 - 0.49725 * temp;
else
mu_lam = 1.;
return mu_lam;
}

Except instead of changing a property per a cell, change turbulence model. Yes I know how everyone does it now. Run through one model, stop and then change to another. Not a good way of automation to me.
arjun is offline   Reply With Quote

Old   August 25, 2020, 06:50
Default
  #14
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Quote:
Originally Posted by visitor View Post
Thanks.

Switching from turbulence models is quite common, just looking to automate it.

Yes I did thought of a UDF, and there are examples in changing a property per a cell shown in Fluent manuals. Something similar to this (Fluent UDF manual);

#include "udf.h"
DEFINE_PROPERTY(cell_viscosity, cell, thread)
{
real mu_lam;
real temp = C_T(cell, thread);
if (temp > 288.)
mu_lam = 5.5e-3;
else if (temp > 286.)
mu_lam = 143.2135 - 0.49725 * temp;
else
mu_lam = 1.;
return mu_lam;
}

Except instead of changing a property per a cell, change turbulence model. Yes I know how everyone does it now. Run through one model, stop and then change to another. Not a good way of automation to me.
You need to understand that switching turbulence model on a cell by cell basis is, indeed, a new turbulence model.

On which basis are you determining that doing such a switch based on temperature is something that makes sense at all?
sbaffini is offline   Reply With Quote

Old   August 25, 2020, 06:57
Default
  #15
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Hi arjun

It is similar to to posting #10. Basically looking to switch per a cell. from k-epsilon to RNG.

Example:

if temperature >500 K
then k-e RNG;
else
k-e
end

What posting #10 can do is a Scheme in TUI; switches turbulence model on the basis of a condition. I think posting #10 works, but it is overall, NOT per a cell.
visitor is offline   Reply With Quote

Old   August 25, 2020, 07:03
Default
  #16
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Hi sbaffini

I wouldn't call it a mew SSt. It is just a switch which most people do manually. Run on one model and then switch to another.

Why switch different models have different capabilities, based on my experience RNG has good heat handling properties.

The Scheme conditional statement does the job, but is more general. In the sense the moment the 500 K condition is reached RNG is selected. This coukd be inaccurate, if for an example. 1 cell out of 400,000 sells reach 500 K (a one off). Cannot let one cell control the rest.
visitor is offline   Reply With Quote

Old   August 25, 2020, 09:17
Default
  #17
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,195
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Let me try to give you a different perspective.

Imagine starting with RNG all over the domain. Then, for some cell, you get a Temperature condition that, according to your scheme, dictates switching locally to SST. What do you think should happen on the solver side?

Should Fluent solve for both equations (epsilon and omega) at the same time? Should it interpret the second variable differently? And more generally, how should have the developers managed such corner case which, by the way, is a completely random switch that will probably do a high harm to the solver?

Also, are you aware of the fact that the SST actually is a k-w at the wall and a k-epsilon away from it? It uses a certain function to make the switch. Yet, it is implemented as a different model and not a switch.

Besides this, using the scheme language in fluent has a very specific use case which, as I stated before, doesn't involve anything at the cell level. It is just a way/language to automate the operations at the GUI level. You maybe can save some variable trough an UDF, make it available to scheme side and use it to make a switch, but it is different from doing it at the cell level. And in any case, doing this trough scheme you are never going to converge, because any switch will throw away a lot of stuff.

What you can do is make your implementation trough user defined scalars. There are certainly some examples available. You just need to insert your temperature switch in both the source terms and turbulent viscosity routines.
sbaffini is offline   Reply With Quote

Old   August 25, 2020, 09:27
Default
  #18
Senior Member
 
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0
visitor is on a distinguished road
Yes i do know how sst works, it uses the F1 function.

What i am now looking for is looping in scheme, in TUI. This is possible, i have seen it in Scheme. Then and it's what i am searching for now is; find away to call the UDF i have mentioned above. Call a cell, check its temperature, then apply the above mentioned Scheme condition statement.

It's just automation, rather than a manual switching, automate.
visitor 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
Table bounds warnings at: END OF TIME STEP CFXer CFX 4 July 17, 2020 00:44
Turbulence model via UDF dmfo Fluent UDF and Scheme Programming 0 August 3, 2016 14:45
Changing turbulence model sunilpatil CFX 2 December 22, 2014 06:21
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 07:12
question about turbulence model selection and sensitivity karananand Main CFD Forum 1 February 26, 2010 05:41


All times are GMT -4. The time now is 22:03.