|
[Sponsors] |
August 21, 2020, 23:39 |
UDF in changing Turbulence Model
|
#1 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Is it possible to change the Turbulence Model from a User Defined Function?
|
|
August 22, 2020, 07:25 |
|
#2 |
Senior Member
|
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.
|
|
August 22, 2020, 07:58 |
Changing turbulence model via UDF
|
#3 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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 |
|
August 22, 2020, 10:21 |
|
#5 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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. |
|
August 22, 2020, 11:19 |
|
#7 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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. |
|
August 22, 2020, 11:25 |
|
#8 |
Senior Member
|
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
|
|
August 22, 2020, 11:50 |
|
#9 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
Thanks, will look at online examples.
|
|
August 24, 2020, 17:19 |
|
#10 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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. |
|
August 24, 2020, 18:21 |
|
#11 |
Senior Member
|
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. |
|
August 25, 2020, 06:17 |
|
#12 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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. |
|
August 25, 2020, 06:37 |
|
#13 | |
Senior Member
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34 |
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:
|
||
August 25, 2020, 06:50 |
|
#14 | |
Senior Member
|
Quote:
On which basis are you determining that doing such a switch based on temperature is something that makes sense at all? |
||
August 25, 2020, 06:57 |
|
#15 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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. |
|
August 25, 2020, 07:03 |
|
#16 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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. |
|
August 25, 2020, 09:17 |
|
#17 |
Senior Member
|
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. |
|
August 25, 2020, 09:27 |
|
#18 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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. |
|
|
|
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 |