
[Sponsors] 
UDF for Inlet perturbation in RANS models 

LinkBack  Thread Tools  Search this Thread  Display Modes 
September 27, 2016, 08:09 
UDF for Inlet perturbation in RANS models

#1 
New Member
Join Date: Jun 2015
Location: Australia
Posts: 15
Rep Power: 9 
Hi,
I have problem to make a UDF which spatially and temporally perturbs flow at a pipe inlet in a random manner when using a RANS model (kw  SST). It is possible to temporally make the flow perturbed at the inlet at different time steps, however, I have no idea how to apply the spatial perturbation where the flow enters at the inlet with fluctuating velocity at different cells. P.S. : If LES simulations were the case, I could use spectral synthesizer or vortex method to exert perturbation at the inlet. However there is no such options for RANS models. So if I have the code which spectral synthesizer or vortex method use to perturb flow, it would probably work for me too. Any idea would be appreciated Regards Joe Last edited by Jomid; September 28, 2016 at 23:22. 

September 28, 2016, 10:25 

#2 
Senior Member

DISCLAIMER: note that purely random perturbations are already useless in LES and will die out in few cells from the boundary. Even the internal spectral synthesizer, last time i checked, does not work great and the perturbations introduced tend to die quickly. In (U)RANS, this just becomes nonsense and you will not see anything.
When i want to introduce random perturbations in Fluent UDF, to avoid resorting to a random number generator, i typically use the logistic map with r = 4: https://en.wikipedia.org/wiki/Logistic_map and a suitable initial condition. I use this spatially, that is, every face in the face loop for the b.c. is equivalent to one of the iterates of the logistic map. If you also want to randomly perturb in time you may want to use an F_UDMI to store, for each face on the boundary, the last iterate of a different logistic map. In practice you do: 1) EXECUTE_ON_DEMAND to initialize your F_UDMI with a spatial logistic map 2) DEFINE_PROFILE that, for each face on the boundary, use the previous F_UDMI to advance locally a logistic map and than updates the F_UDMI with the new value. Nonetheless, a working spectral synthesizer is not difficult to program. It is embarassingly parallel (you can do it as if it was serial), except that you have to ensure that every processor has the same sequence of random numbers used in the formulation (otherwise you end up doing what Fluent does, which is just noise). 

September 29, 2016, 04:06 

#3 
New Member
Join Date: Jun 2015
Location: Australia
Posts: 15
Rep Power: 9 
Dear Paolo
Ciao! Grazie for your response! Indeed what you said is very similar to my recent experiment with LES; although I initialized the LES with a good URANS solution (kw SST), as you said, the perturbations introduced tend to die quickly which means that the flow turns to laminar after a few seconds. Having said that, at the moment I am comparing the turbulence effects in a pipe using different turbulence models including LES, RANS and RSM. What I realized is that in order to have the most reliable comparison (and of course more accurate), I have to keep the condition of all turbulence models consistent, e.g. apply the same perturbation at the inlet which is probably possible only by 1. using a perturbation code at the inlet because Fluent does not provide any inbuilt perturbation method when it comes to RANS and RSM. Perhaps there is a logical reason behind this that we cannot choose a default perturbation method in RANS and RSM perhaps not, but that is the only solution for my problem, or 2. Somehow use spectral synthesizer in RANS and RSM In sum, I am looking for to make one of these two options happen and apply for the set of simulations. Regarding the logistic map, I have found the following code form here: http://www.cfdonline.com/Forums/flu...alization.html #include "udf.h" DEFINE_INIT(init_func,d) { cell_t c; Thread *t; real x[ND_ND]; real x0, y0, z0; real pi, ck, cn; real ax, ay, a0, ak; pi = M_PI; ck = 0.5; cn = 3.891; ax = 20.0*pi; ay = 20.0*pi; ak = ck; thread_loop_c(t,d) { begin_c_loop_all(c,t) { C_CENTROID(x,c,t); x0 = x[0]; y0 = x[1]; z0 = x[2]; a0 = ak; ak = cn*a0*(1a0); C_U(c,t) = 20.0*y0*(y02) + 4.0*(0.5ak); a0 = ak; ak = cn*a0*(1a0); C_V(c,t) = 4.0*(0.5ak); a0 = ak; ak = cn*a0*(1a0); C_W(c,t) = 4.0*(0.5ak); } end_c_loop_all(c,t) } } I work in the field of heat transfer so I am a little familiar with programming techniques. This is actually the third time I am applying a UDF in Fluent. Perhaps that's why it is still not crystal clear for me that how the process you mentioned works. I am wondering: 1. Regarding spatial perturbation, how to write a code which applies logistic map function in a F_UDMI? Will modification of above code help me to make the code? 2. Should I use a separate code for the temporal perturbations? 3. The code should be interpreted or compiled? 4. In your own experience, if I use such a code, will it make a difference in results at pipe outlet using LES and even RANS? What I understood from the above code is that it is required to be applied when initializing, however, I am looking for a code which produces perturbation continuously during simulations, so do you think this code can work for me? Regards Joe 

September 29, 2016, 05:55 

#4 
Senior Member

Dear Joe,
unfortunately, at the moment, i cannot guide you trough all the details concerning UDFs. However, while in a certain sense you might be right in desiring the same input for all your turbulence models, that does not necessarily translates in having a fluctuating input also for (U)RANS computations. Indeed, the fluctuations you introduce at inlet for LES are, at least in theory, within the same functional space where your LES solution resides. In more practical terms this means that your LES solution inside your domain will have fluctuations on the same scales (spatial and temporal) of those introduced at inlet by the methods used by Fluent. In reality, this is not even true for LES, as the numerical method will damp some of the smallest scales introduced at inlet (the method to produce the fluctuations, obviously, is purely theoretical and introduces fluctuations up to your smallest resolvable scale for the given grid... so it doesn't know that your numerical method is not going to sustain them). Actually, what happens for the spectral synthesizer (again, last time i checked) is that you can actually fail to introduce the correct fluctuations (in the sense of having the proper spatial and temporal correlations over all the relevant scales) and the method works (actually doesn't) as if you are not introducing them at all. Now, if we turn our attention to URANS (i first used the parenthesis around U because i didn't know what you were trying to achieve; now it is clear that, in any case, you need to be unsteady for a fair comparison, even if the simulation eventually turns out to be steady), the matter is different. The fluctuations that the LES inlet methods are going to introduce at inlet are OUT of the functional space where the URANS solution resides. To be more precise, when URANS solution are clearly and uniquely interpretable, than they do not contain those scales (in practice URANS solution are supposed to have the same spectral content of RANS ones). Sometimes (e.g., flow around bluff bodies) it might happen that some outofrange scales are present but if you look at the resulting spectra they are clearly far from being anywhere close to turbulence. Consider, for example, the attached picture. From top to bottom (in terms of intensity) you have the Power Spectral Densities of the velocity signals of LES, SAS and URANS simulations of the flow in the wake of a surface mounted cube. LES somehow captures what we know to be a turbulentlike signal, SAS tries to stay there, URANS is clearly not there as there is no energy between those peaks. So, going back to your original question: what is, in my opinion, the most suitable approach to have a fair comparison? First, consider that all the LES inlet methods still rely on RANS inlet profiles. That is, besides the mean velocity profile, they also require and profiles at inlet to properly work. So, the idea is to simply use for LES the same profiles you are using for your (U)RANS computations. In case of , just transform to . Does this make sense? 

September 29, 2016, 07:53 

#5 
New Member
Join Date: Jun 2015
Location: Australia
Posts: 15
Rep Power: 9 
Thank you Paolo for the informative reply. It is clearer now.
What I perceived from your reply is that the inbuilt LES inlet methods cannot be used as perturbation methods in URANS (so they are not useful in this case) because these two (LES and URANS) capture different turbulence scales. On the other hand, URANS method damps the perturbation applied at the inlet which is why Fluent does not have such a perturbation method for URANS. This means that when using URANS, applying a udf which perturbs the inlet flow will not make a different result at the outlet. Now, referring to your last paragraph, the question is how to use for LES the same profiles I am using for URANS computations? Should I use a udf or alternatively through Fluent’s inbuilt turbulence specification method (the picture is attached)? Thanks in advance Joe 

September 29, 2016, 10:28 

#6 
Senior Member

That's exactly what i meant. I want to stress that this is not only true from a practical point of view but also, and mainly, theoretically (as you have noticed from the picture, in practical URANS you can still end up having some frequencies in the turbulent range).
Now, at this point, there are two aspects. First, to have a meaningful comparison, you should just have the same inlet profile you used for your URANS. From your answer i guess you just used constant values, which is also a possibility in the LES methods (even if with possibly more catastrophic effects). If you used any UDF to specify them, you should instead just use it. Finally, what i typically use is a different strategy. I first compute a streamwise periodic RANS solution with the full ReynoldsStress model in a domain whose section is just equal to my inlet section. In practice you create a new grid from your inlet section (or the part of it where you are going to apply the LES inlet method) by extruding it along the normal to the section (4 cells is just enough). This will take not more than few minutes to converge to machine accuracy. From this solution you can exctract all the profile files you need to apply your LES method (velocity and all the Reynolds Stresses, k and epsilon). Then you start your LES case and read in the profiles, which are ready to be used for your inlet. You can apply the same also for a kw based method, but then you endup without the epsilon profile (profile files are just txt files with coordinates and values, so you should convert omega to epsilon by yourself...maybe you can use a custom field function, but i don't know for sure). 

September 30, 2016, 02:40 

#7 
New Member
Join Date: Jun 2015
Location: Australia
Posts: 15
Rep Power: 9 
Hi Paolo
Thanks for sharing your strategy. Sorry for continuously asking questions, but regarding this strategy, a few questions arise here. First of all, my geometry is a helical pipe, so essentially choosing periodic boundary conditions cannot be true because of existence of centrifugal forces. Secondly, what do you mean by “RANS solution with the full ReynoldsStress model”? (Do you mean a RANS and a Reynolds Stress Model (RSM) separately?) What do you mean by full then? Thirdly, I already have all these solutions converged (RASNS, URANS, RSM, LES). Do you think I should initialise all of them again using the new profile files or just enter the new values in the existing case and data files and continue simulating from where it is? And finally is it true to activate vortex method in LES and set the number of vortices to zero (in order to have a fair comparison) and instead I set k, epsilon and Reynolds stresses (UU, VV, WW) obtained from the 4cell simulations (as shown in the attached image)? Cheers Last edited by Jomid; September 30, 2016 at 06:41. 

October 3, 2016, 04:43 

#8 
Senior Member

Dear Jomid,
for what concerns the helical geometry, while the periodicity can be applied considering a full cycle, it is indeed more problematic to apply the necessary source term to drive the flow (as the standard pressure gradient or mass flow methods would not work here). However, it is not so much complicated neither: you work with a full cycle of the helical geometry, and instead of using the fluent methods to drive the flow (pressure gradient/assigned mass flow), you use a DEFINE_SOURCE UDF which, for each cell, applies the source term in the direction tangential to the local helical geometry. So, in practice, you need something to obtain the tangent vector to the local helical axis for given axial coordinate, which turns out to be very simple: https://en.wikipedia.org/wiki/Helix https://en.wikipedia.org/wiki/Frenet...erret_formulas With “RANS solution with the full ReynoldsStress model” i actually intend a RANS solution whose turbulence model is a 7 equation Reynolds stress model, which has as output the 6 components of the Reynolds stress, the k and the epsilon (moreover, it seems to be particularly adequate for an helical geometry, because of secondary motions etc.) Initializing or restarting from the last solution when using a different b.c. will tipically make no much difference. Still, restarting is never a bad idea if it works. I do not know what happens for the vortex method when the number of vortices is 0, i guess it simply uses the base velocity profile as inlet. Still, i don't think i got your question here. 

May 20, 2022, 15:35 
Is vortex method than inducing specific frequencies?

#9 
New Member
Jo
Join Date: Mar 2016
Location: Belgium
Posts: 2
Rep Power: 0 
Dear Paolo,
Dear Joe, I reply to this post because I believe it is the most related to my question on the vortex method. I made an image for clarification: https://ibb.co/B2BZg5k I’m performing LES simulations of indoor ventilation flow, with the supply inlet as visualised in the image (the room is only partially shown). The inlet geometry gradually reduces in height. I used the vortex method for inlet velocity fluctuations, with the number of vortices equal to 1000 (maximum value you can set in Fluent; although I am aware now that one can set it higher) and the number of grid cells in the inlet plane around 12,000. On the righthand side in the image, the 1D energy spectrum of the streamwise velocity obtained at the monitoring point indicated with the cross symbol (located close to the room inlet) is depicted. As you can see, the spectrum contains highenergy frequencies at a fixed frequency interval (2.17 Hz, 4.34 Hz, 6.52 Hz: separation = 2.18 Hz). My question is, why do we see these discrete frequency peaks? Some observations I made:
Since you mentioned in one of the comments above that “DISCLAIMER: note that purely random perturbations are already useless in LES and will die out in few cells from the boundary.” Is the vortex method intentionally inducing periodic fluctuations in the streamwise velocity? Or could the frequencies be related to the number of vortices (1000) being less than N/4, with N the number of grid cells (12,000)? Thank you for considering my question Best regards Last edited by JH.T; June 11, 2022 at 05:38. 

Tags 
les, perturbation, rans, special synthesizer, udf 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
UDF Compilation Error  Loading Library  COMMON Problem! Help!  robtheslob  Fluent UDF and Scheme Programming  8  July 24, 2015 01:53 
Reynolds transport, turbulence model, etc  Beginner  Main CFD Forum  1  January 7, 2009 06:36 
Rankings of RANS based Turbulence Models  Abhijit Tilak  Main CFD Forum  0  September 10, 2004 13:10 
DEFINE_DPM_OUTPUT macro UDF HELP  Puneet  FLUENT  3  November 28, 2003 11:55 
flow calculations with RANS 2eq models  Andreas Abdon  Main CFD Forum  3  March 8, 2000 07:09 