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

Writing a dns solver for periodic box

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 9, 2024, 03:39
Default Writing a dns solver for periodic box
  #1
New Member
 
Join Date: Dec 2024
Posts: 7
Rep Power: 2
dxg97 is on a distinguished road
Hi I am trying to complete my masters thesis for months now. It is focused on creating a turbulunce model using Neural Networks. I need dns data for perodic box simulation yet, the solvers I have found online are not entirely suitable for my use. And after some point I have decided to create my own solver for creating dns data for a periodic box with isotropic turbulence. Do you think this is a doable endeavour. I may invest this project 2 whole months with 12 hour shifts 6 days a week. My cfd and coding experience is good but this will be my first time creating a solver.
dxg97 is offline   Reply With Quote

Old   December 9, 2024, 04:31
Default
  #2
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 676
Rep Power: 21
bigfootedrockmidget is on a distinguished road
This sounds like a bad idea, it takes much longer to write a DNS solver if you do not have experience, and then you still need to do the simulations.... Better to spend a couple of days finding a DNS solver. Surely there must be DNS solvers in your group already? Even if it is not entirely suited for your needs, it is easier to modify an existing code than to build one from scratch.



Which open source DNS codes have you looked at and why are they not suited for your needs?

I have used SU2, Gerris and Nektar++, openFOAM also has DNS solvers available.

Take a look at Nektar++ for instance. Why is that not suited for your needs?

https://en.wikipedia.org/wiki/Nektar%2B%2B
bigfootedrockmidget is offline   Reply With Quote

Old   December 9, 2024, 04:52
Default
  #3
New Member
 
Join Date: Dec 2024
Posts: 7
Rep Power: 2
dxg97 is on a distinguished road
Quote:
Originally Posted by bigfootedrockmidget View Post
This sounds like a bad idea, it takes much longer to write a DNS solver if you do not have experience, and then you still need to do the simulations.... Better to spend a couple of days finding a DNS solver. Surely there must be DNS solvers in your group already? Even if it is not entirely suited for your needs, it is easier to modify an existing code than to build one from scratch.



Which open source DNS codes have you looked at and why are they not suited for your needs?

I have used SU2, Gerris and Nektar++, openFOAM also has DNS solvers available.

Take a look at Nektar++ for instance. Why is that not suited for your needs?

https://en.wikipedia.org/wiki/Nektar%2B%2B
I have used openfoam and spectralDNS as solvers, but verifying the results took too much time and effort at somepoint. And the outputs were too big to handle. But havent look at su2 gerris and nektar. Have you ever used these solvers for decaying turbulence in a box. Which parameters have you used for verifying the results?
dxg97 is offline   Reply With Quote

Old   December 9, 2024, 05:53
Default
  #4
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
Quote:
Originally Posted by dxg97 View Post
Hi I am trying to complete my masters thesis for months now. It is focused on creating a turbulunce model using Neural Networks. I need dns data for perodic box simulation yet, the solvers I have found online are not entirely suitable for my use. And after some point I have decided to create my own solver for creating dns data for a periodic box with isotropic turbulence. Do you think this is a doable endeavour. I may invest this project 2 whole months with 12 hour shifts 6 days a week. My cfd and coding experience is good but this will be my first time creating a solver.


What is your time frame?

If you are not experienced in writing CFD solvers than it could be tough task. If you have experience of writing earlier than you can try it.

Also what are you trying to solve? I could have loaned you my cartesian solver (H4O) that is designed for the purposes you mentioned but it does not support periodic conditions. One day i might do taylor green vortex but its on very low priority for me.


If nothing works by the end of december than do send me a pm.


This was done on H4O solver (around 50 million cells)



https://youtu.be/d3FWgs__yjM?si=o2aByxn7Foz86gaI
arjun is offline   Reply With Quote

Old   December 9, 2024, 06:41
Default
  #5
New Member
 
Join Date: Dec 2024
Posts: 7
Rep Power: 2
dxg97 is on a distinguished road
Quote:
Originally Posted by arjun View Post
What is your time frame?

If you are not experienced in writing CFD solvers than it could be tough task. If you have experience of writing earlier than you can try it.

Also what are you trying to solve? I could have loaned you my cartesian solver (H4O) that is designed for the purposes you mentioned but it does not support periodic conditions. One day i might do taylor green vortex but its on very low priority for me.


If nothing works by the end of december than do send me a pm.


This was done on H4O solver (around 50 million cells)



https://youtu.be/d3FWgs__yjM?si=o2aByxn7Foz86gaI
I will probably start after january. I need to finish my thesis by the end of spring. I tried verifying existing solvers such as dnsfoam and spectralfoam but my verification attempts have failed. The problem mainly was that It was really hard to create 3 component isotropic behaviour. If you have a robust dns solver for hit3d problem, may be i can add some code for making it usable for periodic conditions. My math and fluid background is pretty solid as well as my coding experience, but as I mentioned creating a solver would be a first for me. Have you ever compared your dns experiments with existing data or looked at the anisotropy invariant maps for your own examples? What is the forcing method you use?

Last edited by dxg97; December 9, 2024 at 06:44. Reason: additional question
dxg97 is offline   Reply With Quote

Old   December 9, 2024, 09:16
Default
  #6
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 676
Rep Power: 21
bigfootedrockmidget is on a distinguished road
The outputs will be big, no matter what code you're using. What made the outputs 'too big to handle'? Are you talking memory, computing time, storage, where is the bottleneck?



Gerris development has merged with Basilisk. Haven't used it in a while, but I found it easy to install and use, and they have a couple of simple examples online, like this one on isotropic turbulence in a box:

http://basilisk.fr/src/examples/isotropic.c
bigfootedrockmidget is offline   Reply With Quote

Old   December 9, 2024, 10:22
Default
  #7
Senior Member
 
andy
Join Date: May 2009
Posts: 322
Rep Power: 18
andy_ is on a distinguished road
Quote:
Originally Posted by dxg97 View Post
Hi I am trying to complete my masters thesis for months now. It is focused on creating a turbulunce model using Neural Networks. I need dns data for perodic box simulation yet, the solvers I have found online are not entirely suitable for my use. And after some point I have decided to create my own solver for creating dns data for a periodic box with isotropic turbulence. Do you think this is a doable endeavour. I may invest this project 2 whole months with 12 hour shifts 6 days a week. My cfd and coding experience is good but this will be my first time creating a solver.
DNS codes and CFD codes tend to be different things. DNS codes need to maximise accuracy in very simple geometries with simple boundary conditions. CFD codes need to handle complex geometries, complex boundary conditions, be flexible, be robust,... which comes at a cost in terms of numerical accuracy. CFD codes are normally a poor choice for DNS.

DNS codes are typically only a few lines of code to solve a specific problem. The spectralDNS code you used is typical in being only 328 lines of C++ code with just a single main() function. If you understand the numerical method and how to code then this takes an afternoon to write. It will take longer to test and runs can take many days on large parallel computers because of the amount of data involved.

If you have tried spectalDNS and are struggling then you may well be beaten. Can you explain what was causing difficulties?
andy_ is offline   Reply With Quote

Old   December 9, 2024, 11:56
Default
  #8
New Member
 
Join Date: Dec 2024
Posts: 7
Rep Power: 2
dxg97 is on a distinguished road
Quote:
Originally Posted by andy_ View Post
DNS codes and CFD codes tend to be different things. DNS codes need to maximise accuracy in very simple geometries with simple boundary conditions. CFD codes need to handle complex geometries, complex boundary conditions, be flexible, be robust,... which comes at a cost in terms of numerical accuracy. CFD codes are normally a poor choice for DNS.

DNS codes are typically only a few lines of code to solve a specific problem. The spectralDNS code you used is typical in being only 328 lines of C++ code with just a single main() function. If you understand the numerical method and how to code then this takes an afternoon to write. It will take longer to test and runs can take many days on large parallel computers because of the amount of data involved.

If you have tried spectalDNS and are struggling then you may well be beaten. Can you explain what was causing difficulties?
So my issue was basically, I was unable to capture full anisotropic behaviour, the benchmarks were generally about obtaining kolmogorov scale. I was not able to obtain a true verification for forcing, and it led me to believe that dns codes in general may not posess entirely accurate forcing schemes. This was my initial reason for pursuiting such endevaour. And in terms of large scale data, I generally dont need all domain data only a small probe would suffice for my purpose, spectraldns wouldt probe data therefore creates a significant need for memory space. I would also be glad if you know any solvers with verified forcing schemes.
dxg97 is offline   Reply With Quote

Old   December 9, 2024, 12:53
Default
  #9
Senior Member
 
andy
Join Date: May 2009
Posts: 322
Rep Power: 18
andy_ is on a distinguished road
Quote:
Originally Posted by dxg97 View Post
So my issue was basically, I was unable to capture full anisotropic behaviour, the benchmarks were generally about obtaining kolmogorov scale. I was not able to obtain a true verification for forcing, and it led me to believe that dns codes in general may not posess entirely accurate forcing schemes. This was my initial reason for pursuiting such endevaour. And in terms of large scale data, I generally dont need all domain data only a small probe would suffice for my purpose, spectraldns wouldt probe data therefore creates a significant need for memory space. I would also be glad if you know any solvers with verified forcing schemes.
What do you want to achieve precisely by forcing w.r.t. terms in the Navier-Stokes equations? What is often done affects scales differently and so becomes part of the definition of the problem being solved. If you can write down the forcing terms you want for your problem then introducing them with a few lines of C++ code in spectralDNS is likely to be doable. Cannot say for certain because the terms need to be expressable with the numerical scheme.

How would one provide the boundary conditions that accurately represent turbulent motion around a probe? Generally a DNS code needs to place the boundaries far enough part from each other so that when assumptions like periodicity are introduced there is enough space for the motion between them to become uncorrelated. If the boundaries are too close the correlation will show up in the turbulence statistics.

The 328 lines of spectralDNS C++ code include a probe that (I presume) integrates the turbulent kinetic energy after a few time steps and prints it out to monitor it's decay. A single value every few time steps is the only output. If you want a different more local probe then adding a few lines of C++ can likely provide it. Output as much or as little as you want.

What do you mean by verified forcing scheme? Decades ago when I was messing about with turbulence models I used to drive flows in several different ways. If it was done via the wall stresses then one checked how the pressure drop and mass flow varied over time, if done via body forces then one checked the wall shear stresses and mass flow, etc... How the flow was forced was part of the problem definition because it was imposed.
andy_ is offline   Reply With Quote

Old   December 9, 2024, 14:22
Default
  #10
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,896
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
DNS will always create a huge database to manage in post-processing, no matter about the code. The time required to run a code could be expensive.


There exist database available under request, for example
https://turbulence.pha.jhu.edu/Force...urbulence.aspx
FMDenaro is offline   Reply With Quote

Old   December 10, 2024, 08:17
Default
  #11
New Member
 
Join Date: Dec 2024
Posts: 7
Rep Power: 2
dxg97 is on a distinguished road
Quote:
Originally Posted by andy_ View Post
What do you want to achieve precisely by forcing w.r.t. terms in the Navier-Stokes equations? What is often done affects scales differently and so becomes part of the definition of the problem being solved. If you can write down the forcing terms you want for your problem then introducing them with a few lines of C++ code in spectralDNS is likely to be doable. Cannot say for certain because the terms need to be expressable with the numerical scheme.

How would one provide the boundary conditions that accurately represent turbulent motion around a probe? Generally a DNS code needs to place the boundaries far enough part from each other so that when assumptions like periodicity are introduced there is enough space for the motion between them to become uncorrelated. If the boundaries are too close the correlation will show up in the turbulence statistics.

The 328 lines of spectralDNS C++ code include a probe that (I presume) integrates the turbulent kinetic energy after a few time steps and prints it out to monitor it's decay. A single value every few time steps is the only output. If you want a different more local probe then adding a few lines of C++ can likely provide it. Output as much or as little as you want.

What do you mean by verified forcing scheme? Decades ago when I was messing about with turbulence models I used to drive flows in several different ways. If it was done via the wall stresses then one checked how the pressure drop and mass flow varied over time, if done via body forces then one checked the wall shear stresses and mass flow, etc... How the flow was forced was part of the problem definition because it was imposed.
I am trying to obtain a certain ratio in a decaying fully isotropic turbulent box using neural networks. For the physics to be suitable, certain conditions for the flow must be sufficient. I look at the reynolds stress correlations and anisotropy invariant maps to see if the flow has reached this fully isotropic behaviour. Yet my efforts did not reach to a positive conclusion yet. Maybe I can try a different forcing I have written on my own in spectraldns.
dxg97 is offline   Reply With Quote

Old   December 10, 2024, 11:10
Default
  #12
Senior Member
 
andy
Join Date: May 2009
Posts: 322
Rep Power: 18
andy_ is on a distinguished road
What do you mean by forcing? To me forcing would mean how a turbulent motion is maintained so it doesn't decay away but this doesn't appear to be what you mean? Are you seeking to specify an intial field that decays and moves rapidly towards to isotropic motion before it has decayed away fully? All length scales or just the smaller ones?
andy_ is offline   Reply With Quote

Old   December 11, 2024, 03:21
Default
  #13
New Member
 
Join Date: Dec 2024
Posts: 7
Rep Power: 2
dxg97 is on a distinguished road
Quote:
Originally Posted by andy_ View Post
What do you mean by forcing? To me forcing would mean how a turbulent motion is maintained so it doesn't decay away but this doesn't appear to be what you mean? Are you seeking to specify an intial field that decays and moves rapidly towards to isotropic motion before it has decayed away fully? All length scales or just the smaller ones?
That is precisely what I am trying to do. First, to create fully isotropic behaviour then turning the forcing off and observing the rest of the motion until the decay is complete. Therefore the validity of isotropy before the decay is of crucial importance for me.
dxg97 is offline   Reply With Quote

Old   December 11, 2024, 06:13
Default
  #14
Senior Member
 
andy
Join Date: May 2009
Posts: 322
Rep Power: 18
andy_ is on a distinguished road
How would you go about creating isotropic turbulence in a periodic box by forcing? Turbulence is generated by the flow doing work against the largest scales which typically involves shearing leading to the largest scales being anisotropic.

One approach might be to access one of the many turbulence databases that has generated a region of isotropic turbulence perhaps, for example, downstream of a grid. This is likely to be doable as part of a masters program.

Another approach might be to implement one or a few of the synthetic isotropic turbulence schemes and monitor how they behave in comparison with the form/s of isotropic turbulence you wish to study. This is doable as part of a masters program although the results may not be wholly satisfactory. If honestly reported this is fine as part of a masters because most research ends up like this.

If I understand correctly what you mean by forcing scheme within a periodic box, to come up with a successful one, implement and test it as sub-part of masters project does not look doable to me. If you can find one in the literature and implement that then perhaps but is there one? I cannot see how one would go about it but then I have not been actively developing turbulence for 30 years and there are some smart people around.
andy_ is offline   Reply With Quote

Old   December 11, 2024, 08:51
Default
  #15
New Member
 
Join Date: Dec 2024
Posts: 7
Rep Power: 2
dxg97 is on a distinguished road
Quote:
Originally Posted by andy_ View Post
How would you go about creating isotropic turbulence in a periodic box by forcing? Turbulence is generated by the flow doing work against the largest scales which typically involves shearing leading to the largest scales being anisotropic.

One approach might be to access one of the many turbulence databases that has generated a region of isotropic turbulence perhaps, for example, downstream of a grid. This is likely to be doable as part of a masters program.

Another approach might be to implement one or a few of the synthetic isotropic turbulence schemes and monitor how they behave in comparison with the form/s of isotropic turbulence you wish to study. This is doable as part of a masters program although the results may not be wholly satisfactory. If honestly reported this is fine as part of a masters because most research ends up like this.

If I understand correctly what you mean by forcing scheme within a periodic box, to come up with a successful one, implement and test it as sub-part of masters project does not look doable to me. If you can find one in the literature and implement that then perhaps but is there one? I cannot see how one would go about it but then I have not been actively developing turbulence for 30 years and there are some smart people around.
I believe openfoam does it by constantly adding random energy to scales within a certain wave number. Spectral does it by adding energy to the flow until a certain reynolds lambda is achieved. For my research, I need the dissipation gradients after the forcing is stopped. I did not see any database that involves the data for the timeframe that the periodic flow is no longer fed by the energy. Since I am trying to use neural network for my study, I need a lot of data for confirmation and training. Actually I handled every aspect of this research besides this part. And It drove me insane at some point, verifying the validity of HIT is pretty hard if not impossible. Do you know any databases for this research?
dxg97 is offline   Reply With Quote

Old   December 12, 2024, 06:15
Default
  #16
Senior Member
 
andy
Join Date: May 2009
Posts: 322
Rep Power: 18
andy_ is on a distinguished road
I don't know the abbreviation HIT. 30 years ago there were tens of turbuence databases around that universities could access. Today there are many more including online ones but you may need to get permission to access via your university. Homogeneous turbulence is common and might be what you are after although how it is generated will influence the higher order statistics.

I still don't understand what you mean by verify and it may be relevant. Turbulent motion, both synthetic and natural, varies depending on how it is generated. If you remove the work being done to sustain the motion it will decay away but from different initial conditions. The decay will be different although it is likely (I haven't studied the subject) the unsteady motion may move towards something similar in some cases before it goes out. I get the impression, perhaps wrongly, that you are seeking a universal motion on which to train your network rather than a specific motion that is a function of how it was generated?
andy_ is offline   Reply With Quote

Old   Yesterday, 10:06
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
Look in the code section of cfdonline. There are several codes that could do HIT DNS and likely have some forcing. Nek5000 and Incompact are just two names that I see you haven't considered yet. But there are more.

Introducing a forcing term to sustain HIT is also, pretty much, a solved problem. I can't say which of these code will have the proper one, but I have recently read some recent paper/thesis that also focused on that. Search for it and you will find what you need (can't remember the name, but probably showed up in my researchgate feed, so it must be recent). From the implementation perspective, tough, don't expect easy rides just because it is a forcing term. Getting it right is not always obvious for a given code.

In any case, data will be produced, and it will take space and time to be processed, there is no escape from this
sbaffini is offline   Reply With Quote

Reply

Tags
dns, isotropic turbulence, solver development


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
Turbulence flow and heat flux budgets for LES / DNS in an OpenFOAM solver kakkapriyesh OpenFOAM 0 December 21, 2022 17:07
Error: WorkBench Error: Could not handle event: SolutionStatusUpdate Kieyo Fluent Multiphase 0 November 10, 2022 00:58
Writing all continuity errors to a file using custom solver in parallel mode saurabh1011 OpenFOAM Running, Solving & CFD 1 September 14, 2022 21:44
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 12:04
Star cd es-ice solver error ernarasimman STAR-CD 2 September 12, 2014 01:01


All times are GMT -4. The time now is 16:28.