Pages

Showing posts with label physics. Show all posts
Showing posts with label physics. Show all posts

Saturday, September 8, 2012

Bessel functions of complex argument

   Our research group, Dynamica, has openly published a shared object C++ library to compute Bessel functions of complex argument. It is available ready to compile as a tar archive or, for the initiated, as C++ and Fortran source code on Google Code.

   The Fortran code comes from D.E. Amos and his 1986 article. The article clearly details the limits, accuracy and speed of the subroutines. Being tested and proven against the test of time, we use them without modification. A C++ wrapper is defined in a header.

   More documentation is available on the Google Code repository. To thank you for reading this, here's a pretty picture!

"Proof" that the algorithms work.


Friday, August 24, 2012

Fortran, C++ and qmake

Qt Creator Logo
   Call me a noob, but I love using Qt Creator even when I'm not programming a GUI. The UI greatly facilitates code writing: the syntax highlighting is very customizable, it shows you the methods of a class when you use the . or -> operators, it makes the build process faster and easier to configure (sometimes), etc.

   Now, I didn't want to make this a post about Qt Creator, so here comes the meat. I've been trying to add Fortran code to my numerical library, something I think is pretty common in scientific circles. Of course, that's been done before, but my research has yielded one link for Fortran and Qt. 

   I'm using D.E. Amos' Fortran code to compute Bessel and Hankel functions of complex arguments and all (real) orders (we use identities to convert the negative order computations to positive order ones). Complex orders are not supported. Work by Temme could be used for this, but maybe a later time. 

   I have two Fortran source files that must be incorporated into a C++ numerical library. Using qmake, this is child's play. 

  • First, add the Fortran source files as sources in your .pro file. 
  • SOURCES += machine.for zbesh.for

    Those are the names of the Fortran sources files used by Amos.  
  • Second, create a C++ header file that links to the Fortran subroutines inside the source files. 

    A couple things about this linkage. Notice that I appended a _ to the Fortran subroutine names. The extern keyword tells the compiler that a separately compiled object will be used. By default, g++ will append _ to Fortran subroutines when creating an object file. This means that if you change this compiler setting, be sure to remember to change your function declarations in your C++ header file.
    Also, the functions take pointers to variables. In Fortran, all functions take their arguments by reference. It is thus necessary to use pointers when using Fortran subroutines in C++. 
  • You're done! You can now use your Fortran subroutines in your C++ program! Just don't forget to add the
    -lgfortran
    when compiling either the program you are writing or a program that uses a library that uses Fortran subroutines.

Wow, that last sentence was terrible.

   Anyway, have fun programming!

Thursday, May 17, 2012

Lattice Gauge Theory

   During the Winter 2012 semester at U. Laval, I took a Particle Physics course. I'm not sure of the exact appelation in English, but it was given as directed reading (lectures dirigées). I didn't have classes: only the reference book.

   None of that really matters anyway. The course culminated into an exploration of Lattice Gauge Theory by us two undergrad students. The resulting text is more a collection of interesting results or, in other words, an elementary review of the basics of the theory. 

   The PDF document is available on the website we made for the project. Again, French only. 

Thursday, March 1, 2012

Equations in Blogger (part 2)

  A while ago, I fumbled into a method to typeset equations on any web page. However, the JavaScript needed to do the work suddently disappeared (I didn't research that) and anyhow, the equations stopped displaying properly. 

Now I just found out that MathJax is available as CDN service. This makes my life way easier. You have to add a HTML/JavaScript gadget to Blogger and paste some code. The simple procedure is explained in their good documentation. 

So... want a taste of it? Let $\rho(\mathbb{x})$ be the probability density function of $n$ statistically independant variables distributed according to some distribution function. The normalization condition is:

\[ \int\cdots\int_{-\infty}^{\infty} \rho(\mathbb{x})d^n\mathbb{x} = 1. \]

Oh hell, I like this too much! Another one!

\[ \mathcal{H} = \frac{1}{2}\frac{p_{\theta}^2}{mL^2}-mgL\cos\theta.\]

Friday, June 17, 2011

Integrability and Chaos in Hamiltonian Systems

   This last semester, I took a course intitled Nonlinear Dynamics and Chaos (in  French). It was quite a novelty, as undergraduates in physics mostly deal with linear problems (they are much easier to solve analytically. Most nonlinear systems do not possess such solutions and they do, the analytic expression is so complex that it offers no qualitative understanding of the subject.

    A dynamicist must make use of a completely different set of tools, mostly numeric, to try to grasp the inner workings of a particular system. Phase space, which shows the relationship between a variable and its nth order derivatives (where n is the dynamical order of the system, if I can use this vocabulary), is an important example of these tools.

   In the special context of Hamiltonian mechanics, where momenta and position are related through what is called a symplectic symmetry, the topology of the phase space trajectories are significantly restricted; they are N-tori. That is, as long as the system is integrable (has a closed form solution).

   As soon as a perturbation is added that renders the system non-integrable, then the phase space qualitatively evolves as described by what is called the KAM Theorem.

This last theorem was the main topic of a mini research project that was conducted by Raphaël Dubé-Demers and myself throughout the second half of the semester. Following these last few words are the text produced during this research and the Beamer presentation used to introduce the subject to our peers.

Happy reading!

[Presentation]  (in French)
[Text]  (in French)

To anyone that will ask nicely, I could translate it in English. Asked very nicely!

UPDATE: I made a flipbook out of it. It looks pretty cool, but that's pretty much it!
UPDATE 2: Here's the link to the complete thing.