programming

How do I save power spectra at different y locations ?

emmanuel germaine, 2009-01-29 12:10

I want to plot the 1D energy spectra (Euu=f(kappa)) at different y-location (e.g, one close to the wall and the other close to the centerline).

Can I do that starting with the following ?

  u.makeSpectral();
  u.saveSpectrum("data/uspectra");

Thank you Emmanuel

Discussion

John F. Gibson, 2009-02-08 07:59

Ooops! I haven't been checking this forum often enough.

No, the FlowField::saveSpectrum function saves a 2D function E(kx,kz) where

Latex

I.e the (square root of) the total energy in the kx,kz Fourier mode.

Can you write n expression for me the quantity you want to compute in terms of the velocity field? Then I can tel you how to compute it.

John

John F. Gibson, 2009-02-10 07:34

I mean, write down an expression that shows mathematically how the quantity you are interested is derived from the velocity field. E.g. for vorticity, it would be

Graph

There are too many conventional quantities in fluid mechanics for me to keep track of!

John F. Gibson, 2009-02-12 19:37

Gotcha. There is not a built-in function for doing this but you could write one along these lines


array<Real> Ekx(FlowField& u, int ny) {
  u.makeState(Spectral, Physical);
  array<Real> rtn(u.kxMax());
  for (int kx=0; kx<u.kxMax(); ++kx) {
    Real sum=0;
    int mx = u.mx(kx);
    for (int i=0; i<u.Nd(); ++i) 
      for (int mz=0; mz<u.Mz; ++mz) 
        sum += abs2(u.cmplx(mx,ny,mz,i));
    rtn[kx] = sum;
  }
  return rtn;
}

and similarly for kz. A couple caveats: The textbook E(kappa_x) is for continuous kappa_x and the above is for discrete values kx, where kappa_x = 2*pi*kx/Lx. You would have to double-check that relation and test out the results on some known functions to be sure. Also, the above code only produces E(kx) for kx>0. I suppose it'll be symmetric in +/- kx for real-valued fields, right?

John

 
programming/how_do_i_save_power_spectrum_at_a_specified_y_location.txt · Last modified: 2010-02-02 07:55 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki