Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

construct a random field with prescribed spectral slope #295

Open
liasiegelman opened this issue Jul 12, 2022 · 2 comments
Open

construct a random field with prescribed spectral slope #295

liasiegelman opened this issue Jul 12, 2022 · 2 comments

Comments

@liasiegelman
Copy link
Collaborator

liasiegelman commented Jul 12, 2022

I would like to construct a random initial field with a prescribed spectral slope x. If Energy = \int E(k) k dk then E(k) ~ k^{-x}.
As suggested by Navid, maybe we can iterate on peakedisotropicspectrum to implement this.

@liasiegelman
Copy link
Collaborator Author

liasiegelman commented Jul 13, 2022

I think this should do

function slopedisotropicspectrum(grid::TwoDGrid{T, A}, slope::Real; mask=ones(size(grid.Krsq)), allones=false) where {T, A}
 if grid.Lx !== grid.Ly
   error("the domain is not square")
 else
   modk = sqrt.(grid.Krsq)
   modψ = A(zeros(T, (grid.nk, grid.nl)))
   modψ = @. modk^((slope-1)/2)
   #modψ[1, 1] = 0.0
   CUDA.@allowscalar modψ[1, 1] = 0.0

   phases = randn(Complex{T}, size(grid.Krsq))
   phases_real, phases_imag = real.(phases), imag.(phases)
   phases = A(phases_real) + im * A(phases_imag)
   ψh = @. phases * modψ
   if allones; ψh = modψ; end
   ψh = ψh .* A(mask)
   q = A(irfft(ψh, grid.nx))
 end

 return q
end

@navidcy
Copy link
Member

navidcy commented Jul 14, 2022

So what you want is a function that returns a field q for which if energy is $E = \int q(x, y)^2 \mathrm{d}x \mathrm{d}y = \int \mathcal{E}(k) k \mathrm{d}k$ you want $\mathcal{E}(k) \propto k^{-\chi}$. Am I correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants