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

DNS with random initial condition with initial energy spectrum

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 26, 2016, 16:40
Default DNS with random initial condition with initial energy spectrum
  #1
Senior Member
 
Selig
Join Date: Jul 2016
Posts: 213
Rep Power: 10
selig5576 is on a distinguished road
Hi All,

I am writing a CFD code to simulate 2D turbulence via a Fourier spectral method, however am running into issues in terms of the initial condition. I am currently trying to implement McWilliams 2000 initial condition, however have 2 questions regarding setting up the initial condition.

According to McWilliams, the initial condition is a "zero mean, Gaussian vorticity field with random Fourier Phases." The initial energy spectrum is defined as
E(k,0) = \frac{C_{0} k^{6}}{(1+\frac{k}{60})^{18}}

My interpretation of his initial condition is
w_{0} = E(k,0) e^{2 i \theta} + i E(k,0) e^{2 i \theta}

The "theta" represents a random Gaussian distribution. In terms of the code, I have implemented it as follows

Code:
Lap_hat = sqrt(kx**2 + ky**2)
Energy0 = C0*Lap_hat**6/(1+Lap_hat/60)**18
Vort0 = Energy0*exp(2*1j*np.random.normal(0,1)) + 1j*Energy0*exp(2*1j*np.random.normal(0,1))

Vort_hat = rfft2(Vort0)
Vort_Temp = irfft(Vort0)

Vort = Vort_Temp
Vort represents is an array np.array(nk,nl). In this case I'm running a simulation of 256 x 256. With that said, with my implementation I do not get accurate results. In stead of np.random.normal I have also used np.random.uniform(0,1). I was curious if someone knew of an example code or could point out my mistake. I can also provide my main body of code.


Paper of interesting:
"Revisting Freely Decaiying two-dimensiona turbulence at millennial resolution," J. C. McWilliams, 2000, Physics of Fluids
Attached Images
File Type: png Initial_Condition.png (50.7 KB, 11 views)
selig5576 is offline   Reply With Quote

Old   November 27, 2016, 04:31
Default
  #2
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,768
Rep Power: 71
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by selig5576 View Post
Hi All,

I am writing a CFD code to simulate 2D turbulence via a Fourier spectral method, however am running into issues in terms of the initial condition. I am currently trying to implement McWilliams 2000 initial condition, however have 2 questions regarding setting up the initial condition.

According to McWilliams, the initial condition is a "zero mean, Gaussian vorticity field with random Fourier Phases." The initial energy spectrum is defined as
E(k,0) = \frac{C_{0} k^{6}}{(1+\frac{k}{60})^{18}}

My interpretation of his initial condition is
w_{0} = E(k,0) e^{2 i \theta} + i E(k,0) e^{2 i \theta}

The "theta" represents a random Gaussian distribution. In terms of the code, I have implemented it as follows

Code:
Lap_hat = sqrt(kx**2 + ky**2)
Energy0 = C0*Lap_hat**6/(1+Lap_hat/60)**18
Vort0 = Energy0*exp(2*1j*np.random.normal(0,1)) + 1j*Energy0*exp(2*1j*np.random.normal(0,1))

Vort_hat = rfft2(Vort0)
Vort_Temp = irfft(Vort0)

Vort = Vort_Temp
Vort represents is an array np.array(nk,nl). In this case I'm running a simulation of 256 x 256. With that said, with my implementation I do not get accurate results. In stead of np.random.normal I have also used np.random.uniform(0,1). I was curious if someone knew of an example code or could point out my mistake. I can also provide my main body of code.


Paper of interesting:
"Revisting Freely Decaiying two-dimensiona turbulence at millennial resolution," J. C. McWilliams, 2000, Physics of Fluids

Have you considered that E(k) is a kinetic energy and you are setting the intial vorticity field? Be careful of the dimensions.
I suggest to reconstruct first a velocity field by means of the energy spectrum, if it works fine you should get the same energy spectra. Then you can compute the vorticity field.
FMDenaro 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
Floating point exception error lpz_michele OpenFOAM Running, Solving & CFD 53 October 19, 2015 02:50
Cannot run the code properly: very large time step continuity error crst15 OpenFOAM Running, Solving & CFD 9 December 14, 2014 18:17
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 06:20
Unstabil Simulation with chtMultiRegionFoam mbay101 OpenFOAM Running, Solving & CFD 13 December 28, 2013 13:12
calculation stops after few time steps sivakumar OpenFOAM Running, Solving & CFD 7 March 17, 2013 06:37


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