Skip to content
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Modeling Physical Systems with Modern Object Oriented Perl


Many scientists use Fortran for their numeric modeling. Some of my fellow Ph.D. candidates have done all of their work in Mathematica. Closer to home, PDL provides Perl with some really nice numerical array handling power. Still, all of these tools left me looking for something higher level.

In this talk I will present some of the modeling paradigms I have been using in my research. These simulations model physical systems as Perl objects (rapid designing of classes via MooseX::Declare). Dynamics are closures which genereated by some objects and influence others. Using this paradigm, simulations are written quickly and are tremendously flexible and extensible.

For the majority of the talk, I will use a Perl-level fixed time-step differential equations solver. At the end, I will introduce (ever so briefly) my PerlGSL::DiffEq module, which I use to solve systems of differential equations which are made of closures over these object/closure systems.

I hope this talk will show that high-level languages can be used to model physical systems and make it feel very natural to the Perl programmer.


This talk would be in the "Perl in the Wild" sequence and likely would be about 20 minutes (it could be longer but it would get too technical for anyone to care). In my research at UIC I model the dynamics of electron pulses in a (proposed) time-resolved electron microscope. These dynamics are very important for designing the microscope. The model consists of 7 highly coupled first-order differential equations. Were it just this I might just feed the equations into Mathematica or the Gnu Scientific Library (GSL, a C library), however each element in the system (e.g. lenses, rf compression cavities) contribute position dependent terms to two of the equations. I really wanted to make a simulation that people could use without know about the underlying simulation. I cast the whole system a class of Perl objects using MooseX::Declare. An electron and laser pulse objects, as well as a column object are created by the user. Then lens and compressor objects are created and added to the column object. This is a easy as it sounds from the user standpoint. Underneath, each object generates a closure representing the term of the differential equation. Then a super-closure is created which wraps all the effects and the general equations. This closure is passed to my specially made differential equation solver PerlGSL::DiffEq which (as the name suggests) calls the GSL.

This has been a long description of what I hope could actually be conveyed rather easily. Closures can represent parts of your logic, those can be wrapped into a larger logic and used. It also demonstrates that numerical modeling can be done in high-level languages if speed isn't an issue. Object oriented design lends itself quite well to numerical modeling if you think of different influences as objects.

The model can be seen at

and an example user's script is available at

N.B. PDL is used at the end for visualization, but is not used internally

Something went wrong with that request. Please try again.