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

pseudospectral methods in matlab

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 10, 2002, 03:39
Default pseudospectral methods in matlab
  #1
prasat
Guest
 
Posts: n/a
does anybody have experience in pseudospectral methods in matlab? help me thanks
  Reply With Quote

Old   December 11, 2002, 16:03
Default Re: pseudospectral methods in matlab
  #2
Patrick Godon
Guest
 
Posts: n/a
I have some experience in pseudospectral methods, but not in matlab...

does this helps?

Cheers,Patrick
  Reply With Quote

Old   December 11, 2002, 17:39
Default Re: pseudospectral methods in matlab
  #3
Sujit Kirpekar
Guest
 
Posts: n/a
I have experience both in F90 and MATLAB. Email me for help. -- Sujit
  Reply With Quote

Old   December 12, 2002, 02:48
Default Re: pseudospectral methods in matlab
  #4
prasat
Guest
 
Posts: n/a
The problem is I computed fft and ifft using the matlab inbuilt functions. When I am doing the differentiation of the function and inverse transforming it. I get real and imaginary values. But my input is only real I am wondering how can real input fater diff.. and doing ifft will give imaginary values. please help..
  Reply With Quote

Old   December 12, 2002, 05:27
Default Re: pseudospectral methods in matlab
  #5
Steve
Guest
 
Posts: n/a
I suggest you post this question to the comp.soft-sys.matlab newsgroup. There's loads of DSP gurus on there who'll help for free.
  Reply With Quote

Old   December 12, 2002, 11:49
Default Re: pseudospectral methods in matlab
  #6
Sujit Kirpekar
Guest
 
Posts: n/a
Its easy:

MATLAB does a Forward FFT by the typical real to complex algorithm. Similarly you can do n-dimensional complex to complex forward transforms using fft().

To do an inverse transform, use ifft(). ifft() can do a complex to complex and complex to real inverse transform. If the data on inverting is purely real, the MATLAB algorithm may return small imaginary parts which can be zeroed out.

If you want me to go into details about how modes are stored, let me know.

--Sujit
  Reply With Quote

Old   December 12, 2002, 13:31
Default Re: pseudospectral methods in matlab
  #7
Patrick Godon
Guest
 
Posts: n/a
Hi,

You got some answers concerning matlab, concerning Fourier pseudospectral methods:

Use FFT where there is a place for the real and complex part of the vector. Put the function in the real part and put 0 (zero) in the complex one. Do your FFT forward and then multiply the results by -ij, where i=sqrt(-1) and j is the discrete index number. This means that the complex value (obtained from the FFT) will now be real and that the real value (obtained from the FFT) will now be complex. Then put these back in you vector, taking care of putting the new complex and the new real in their appropriate place in the input vector. Then carried out an inverse FFT of that input vector and consider only the real part of it as your Fourier derivative. It is very important to take care of identifying correctly what is j in your program (subroutine) since you have to multiply by -j between the two FFT, and will you have also to divide by N (the number of points; k=0,1,..N/2) to normalize properly. This is if you work on a [0:2pi] segments.

I am copying here below a FORTRAN subroutine for what I just wrote for Fourier pseudospectral solver, using the Fortran FFT

I hope this helps, Patrick

subroutine pdfrnt2(f,df,if) integer i,n,if,j,it,nt,ir,nr include 'input.par' parameter (n=nt,nr=2**ir) real*8 f(n),df(n),c2(2,n),c1(2,n) real*8 fil(0:n/2),cut(0:nr),dn common /filter/cut,fil dn=dfloat(n) do i=1,n c1(1,i)=f(i)/dn ---> real value divided by N c1(2,i)=0.d0 ---> imaginary part end do call DFOURT(c1,n,1,-1,0,0.d0) ---> FFT is return in c1 do i=1,n/2+1 j=i-1 c2(1,i)=-dfloat(j)*c1(2,i) ---> multiply by -ij c2(2,i)=dfloat(j)*c1(1,i)---> multiply by -ij end do do i=n/2+2,n j=i-n-1 c2(1,i)=-dfloat(j)*c1(2,i)---> multiply by -ij c2(2,i)=dfloat(j)*c1(1,i)---> multiply by -ij end do call dfourt(c2,n,1,1,1,0.d0)---> back FFT into c1 do i=1,n df(i)=c2(1,i)---> here is the Fourier derivative end do return END
  Reply With Quote

Old   December 13, 2002, 07:19
Default Re: pseudospectral methods in matlab
  #8
prasat
Guest
 
Posts: n/a
How to do differentiation is there any command in matlab. I am getting the complex values of this diffrentiation(of real values) it is not possible. I don not know where is the error. Do you have literature pf pseudospectral methods in matlab. I want to disscuss this issue in deep. thanks prasat
  Reply With Quote

Old   December 13, 2002, 14:18
Default Re: pseudospectral methods in matlab
  #9
Sujit Kirpekar
Guest
 
Posts: n/a
Although I don't understand what your question is, this is what I think you should be doing.

=>Take a discrete real function (1D, 2D, 3D, etc)

=>Take it into Fourier Space by MATLAB function fftn()

=>To differentiate a function in Fourier Space simply multiply each coefficient by - i * (wavenumber in the direction of the derivative)

=>To get back the differentiated function on Physical space use MATLAB function ifftn() and neglect any imaginary part returned.

Hope this helps.
  Reply With Quote

Old   December 16, 2002, 04:02
Default Re: pseudospectral methods in matlab
  #10
Web surfer
Guest
 
Posts: n/a
A quick web surf gave me this link:

http://www.onid.orst.edu/~weidemaj/differ.html
  Reply With Quote

Old   December 16, 2002, 04:08
Default Re: pseudospectral methods in matlab
  #11
Web surfer
Guest
 
Posts: n/a
Or how about:

http://web.comlab.ox.ac.uk/projects/...ectra/eigtool/
  Reply With Quote

Old   December 16, 2002, 06:30
Default Re: pseudospectral methods in matlab
  #12
prasat@indiatimes.com
Guest
 
Posts: n/a
Hai sujit, Whya should I neglect the complex part after getting the diff in physical space. Lets suppose that I have neglected it but then How will I confirm that my diffentiation is correct. That is my basic questions Prasat
  Reply With Quote

Old   December 16, 2002, 10:44
Default Re: pseudospectral methods in matlab
  #13
Sujit Kirpekar
Guest
 
Posts: n/a
MATLAB's documentation (type : help ifftn) says that the FFT works such that the same function ifftn does both the inverse complex-to-complex and complex-to-real-symmetric transforms.

In case of the latter, you get back complex vectors (matrices) with very small imaginary parts, which you can throw away.
  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
How to start Fluent with Matlab?? Jay Hu FLUENT 8 November 9, 2022 06:30
comments on FDM, FEM, FVM, SM, SEM, DSEM, BEM kenn Main CFD Forum 2 July 18, 2004 18:28
pseudospectral help? jack Main CFD Forum 1 January 20, 2004 19:34
PseudoSpectral Methods M. Abedi Main CFD Forum 2 July 15, 2001 17:46
CFD - Trends and Perspectives Jonas Larsson Main CFD Forum 16 August 7, 1998 16:27


All times are GMT -4. The time now is 14:49.