When I open the Fourier Tool with the predefined method _tools.showFourierTools(.....) I get a Window, that looks the same as a Data Tool Window and I can not see, how I can apply a Fourier transformation. This would be nice, when simulating an anharmonic oscillator (F ~- x^3) and then apply a Fourier transformation to the data.
I submitted another post on developing nonlinear optics curriculum using OSP.
For this I'd really like to have fft capabilities.
Is there a way of doing Fourier transforms from EJS?
According to your notes in Simulations in Physics, Chapter 9, it is possible to use Java with OSP libraries to do FFT. However, I couldn't implement this in EJS.
OSP has three FFTjava classes that you can readily use from EJS. The source code for the three classes are attached to this post. To use, say the FFTReal class, you need to fully qualify its name, as in org.opensourcephysics.numerics.FFTReal myFFT = new org.opensourcephysics.numerics.FFTReal(100);
(Or add an import for org.opensourcephysics.numerics.FFTReal in your simulation information window.)
That's it. Then use the myFFT object as the class allows.
Paco
PS: I'll see why the FourierTool does not do what it is supposed to do...
Re: Re: Re: Re: Is the Fourier Tool functioning? -
Carlos Trallero
4 Posts
Dear Francisco,
Thanks for your reply.
These java files, how do I incorporate them into EJS?
I tried importing fft libraries in the custom part of the code but it didn't work.
In the EJS distribution file there is a sample for Fourier analysis but it is full fft program. I couldn't find and example where other libraries are imported.
Re: Re: Re: Re: Re: Is the Fourier Tool functioning? -
Francisco Esquembre
237 Posts
Carlos,
These Java files are already into EJS. Just write code similar to what I wrote and it will compile and run. I sent you the files for you to see how they work. The Javadoc(umentation) in these files explain what you an expect from it.
Yes. A little bit of Java is needed. (But only a little bit.)
Re: Re: Re: Re: Re: Re: Re: Is the Fourier Tool functioning? -
Francisco Esquembre
237 Posts
Ivo,
What I call Javadoc is actually the comments included (with a special - Javadoc - format) in the Java files that I attached to my post. I think that you can learn how to use these classes and methods by reading these comments.
I did not create those files, so I can't be of further use myself.
The Apache Commons Mathematics library is distributed with EJS and this library contains a FFT package. You will, of course, need to access this library using ordinary Java code rather than EJS drag and drop elements but this is not hard to do. For example, I use the Apache library to do linear algebra in my falling chain model.
Re: Re: Re: Re: Re: Is the Fourier Tool functioning? -
Wolfgang
192 Posts
The information dialog available in the upper right hand corner of the EJS tool allows you to import compiled classes and jar files into your EJS models. See the attached screens shot to see how to import the Apache linear algebra classes into an EJS model.
Fourier analysis has been added to the standard Data Tool. This new functionality will be available in the next release of EJS but you can already test it using the stand-alone Data Tool program.