Most commented posts
- Phonons: shake those atoms — 3 comments
- Start to Fortran — 1 comment
Aug 10 2015
What happens if two physicists take a holiday? They end up stargazing and hunting for the International Space Station (ISS). During the last week and a half we tried to capture the ISS flybys on camera nearly every night (with varying success). Each night we learned new things:
Aug 02 2015
Most kids love dinosaurs, or at some point in life have been intrigued by the idea of the large monsters among them. My inner child still does, so twenty-two years after having seen the original Jurassic Park movie, I watched the first three movies again with my girlfriend, as preparation for its most recent incarnation:Jurassic World.(JP4)
The movie starts from the same premise as the original one (building a theme-park with dinosaurs), but unlike the original, this theme-park is already up and running, and welcoming over 20.000 visitors a day. However, as the mathematician Dr. Ian Malcolm noted in Lost World:
Oh, yeah. Oooh, ahhh, that’s how it always starts. Then later there’s running and screaming.
and so it is in Jurassic world. Everything is peachy, until the genetically engineered Indominus Rex (or the King that can not be mastered/tamed) escapes and runs rampage on Isla Nublar. The representation of a commercialized dinosaur theme-park is scarily realistic: With a type of kids-farm like section, where little children can hug small dinosaurs and ride baby Triceratops’s, shops selling merchandising, rides through the park and animal (feeding-)shows. Also the modern trend to use abstractions (as euphemisms) to describe negative experiences and events, turns out rather painfully realistic with the automated warning messages to inform the tourists of a “containment anomaly“, when in fact the aviary is breached and the escaped pterodactyls are about to start pecking the above tourists to death.
Jul 06 2015
With the inclusion of the phonon-module and some minor fixes and extensions to existing code, the hive 3.x program now counts over 40.000 lines, spread over 60 files. 8% of all lines are blank lines, 71% of all lines contain code, and 21% contain comments, an indication of the extent of the documentation of the code.
The code now provides access to 33 command line options of varying complexity. The simplest options (extracting a geometry, or creating a cif-file) are nearly instantaneous, while more complex options (such as Hirshfeld-I calculations) can take up to several hours.
Also from this point onward, HIVE will require to be linked with a lapack-library during compilation, to allow for the efficient solution of eigenvalue-problems.
Time for a little celebration.
Jun 28 2015
June 28th or 6/28 the first three digits of 2 aka . In response to the creation of -day (March 14th), June 28th was suggested as -day to celebrate the number representing the ratio between the circumference of a circle and its radius. (And as with most opinions these days there needs to be a lot of controversy and discussion 😎 ) Having no religious preferences for either, I suggest to celebrate both, one with a single pie, and the other with two.
Jun 19 2015
In physics, a phonon is a collective excitation in a periodic, elastic arrangement of atoms or molecules in condensed matter, like solids and some liquids. Often designated a quasi-particle, it represents an excited state in the quantum mechanical quantization of the modes of vibrations of elastic structures of interacting particles.
— source: wikipedia
Or for simplicity: sound waves; the ordered shaking of atoms or molecules. When you hit a metal bell with a (small) hammer, or make a wineglass sing by rubbing the edges, you experience the vibrations of the object as sound. All objects in nature (going from atoms to stars) can be made to vibrate, and they do this at one or more specific frequencies : their eigenfrequencies or normal frequencies.
Also single molecules, if they are hit (for example by another molecule bumping into them) or receive extra energy in another way, start to vibrate. These vibrations can take many forms (elongating and shortening of bonds, rotating of parts of the molecule with respect to other parts, flip-flopping of loose ends, and so forth) and give a unique signature to the molecule since each of these vibrations (so-called eigen-modes) corresponds with a certain energy given to the molecule. As a result, if you know all the eigen-modes of a molecule, you also know which frequencies of infrared light they should absorb, which is very useful, since in experiment we do not “see” molecules (if we see them at all) as nice ball-and-stick objects.
From the computational point of view, this is not the only reason why in molecular modeling the vibrational frequencies of a system (i.e. the above eigen-modes) are calculated. In addition, they also tell if a system is in its ground state (which is what one is looking for most of the time) or not. Although this tool has wide-spread usage in molecular modeling, it is seldom used in ab initio solid state physics because of the associated computational cost. In addition, because of the finite size of the unit cell, the reciprocal space in which phonons live also has a finite size, in contrast to the single point for a molecule…making life complex. 😎
May 22 2015
additional resources | |
agent paper: | Sobkowicz |
source-code: | AgentTutorials |
Arxiv: | Full Tutorial |
In the previous tutorial, we saw how to tackle an opinion dynamics problem using agents as a class in an Object Oriented Programming (OOP) approach. In many topics of interest in (socio-)physics and chemistry, we deal with a large number of particles, be it electrons, atoms, agents, stars, … These are contained in a superstructure (electrons⇒atom, atoms⇒molecule/solid, agents⇒population, stars⇒galaxy,…) which is generally represented in the code as an array. As we noted in the previous tutorial, there were several variables which were global to the agents, but we implemented them as properties of the agents anyhow. As a result, a significant amount of additional memory needed to be allocated for storing in essence the same data. This was done to prevent the need of having to provide this information at every function call.
Returning to our problem of interest, we now consider two object classes: The TAgent-class and the TPopulation-class. This leads to several possible ways this problem can be implemented.
Although the true OOP-programmer may only consider the second option the way to go, we will consider the third option in this tutorial.
May 08 2015
These days, a scientist is no longer the lone researcher, hiding away in dark rooms and cellars, never coming out, except to ask a servant to mail a letter with his/her newest findings to a like-minded scholar hidden in some other dungeon. Nowadays, we have email to do the latter. In addition, “the scientist” has also had to become the inspiring teacher, the diligent administrator/manager, and the quick salesman/woman pitching his/her ideas for new project-funding. More recently, becoming a rock star was added to this list. (One may start to wonder when she/he should be doing research.)
Since 2005, Famelab, which is part of the Cheltenham Science Festival, has been a platform for young scientist to become such a rock star. In only three minutes, they have to explain a scientific topic of their own choice (and expertise) to the lay public. For this they are allowed only the use of a prop, which they have to be able carry by themselves onto the stage (i.e. no PowerPoint-slides or projected video). Their presentation is then judged by a panel with experience in science communication, focusing on 3 c’s: clarity (the general public should understand what you are going on about), content (it’s not because you present for a general public that you are allowed to cut corners and tell things which aren’t really true) and communication charisma (can you inspire people).
This year, my girlfriend decided to enter the Famelab competition (she’s by far the better communicator of the two of us). During the regional Famelab-heat on April 24th, in my hometown Ghent, she explained in three minutes why we see colours in soap-bubbles (video). The competition during the heat was quite impressive, and of the 25 people who started that day, she was one of the eight national finalist who will be competing, coming May 12th in Leuven, for a single spot in the international Famelab final in the UK. On her blog you can find more on the entire Famelab experience: (1),(2),(3) )
She will be presenting a different story than during the regional heat, which I am not yet allowed to disclose. All I can say is that you will look differently at yourself afterward, and we already made a video of the act/presentation in the streets of Ghent.
In her rise to science-rock-stardom, she already has her first groupie signing this post.
May 03 2015
After having set up our new project in the first session of this tutorial, we now come to an important second step: choosing and creating our Objects. In OOP, the central focus is not a (primitive) variable or a function, but “an object”. In Object Oriented Programming (OOP) most if not all variables and functions are incorporated in one or more (types of) objects. An object, is just like a real-life object; It has properties and can do things. For example: a car. It has properties (color, automatic or stick, weight, number of seats,…) and can do things (drive, break down, accelerate,…). In OOP, the variables containing the values that give the color, weight, stick or not,… of the car are called the properties of the car-object. The functions that perform the necessary calculations/modifications of the variables to perform the actions of driving, breaking down,… are called the methods.
Since we are still focusing on the opinion dynamics paper of Sobkowicz, let us use the objects of that paper to continue our tutorial. A simplified version of the research question in the paper could be as follows:
How does the (average) opinion of a population of agents evolve over time?
For our object-based approach, this already contains much of the information we need. It tells us what our “objects” could be: agents. It gives us properties for these objects: opinion. And it also tells us something of the methods that will be involved: opinion…evolve over time.
Let us now put this into Fortran code. A class definition in Fortran uses the TYPE keyword, just like complex data types.
- Type, public :: TAgentClass
- private
- real :: oi !< opinion
- contains
- private
- procedure, pass(this), public :: getOpinion
- procedure, pass(this), public :: setOpinion
- procedure, pass(this), public :: updateOpinion
- end type TAgentClass
Apr 26 2015
Because Fortran has been around since the time of the dinosaurs, or so it seems, one persistent myth is that modern constructs and techniques are not supported. One very important modern programming approach is Object Oriented Programming (OOP). Where procedural programming focuses on splitting the program in smaller functional units (functions and procedures), OOP is centered on “Objects and Classes”. These objects, just like real life objects, have properties (eg. name, color, position, …) and contain methods (i.e. procedures representing their functionality). This sounds more complex than it actually is. In a very simplistic sense, objects and classes are created by extending complex data types in procedural programming languages with internally contained functions/procedures, referred to as methods. In the table below, you see a limited comparison between the two. The first three languages are procedural oriented languages, while the last two allow for OOP.
C | Pascal | F95 | C++ OOP | F2003 OOP | |
data type keyword | struct | record | type | class | type |
containing variables | field | field | field | property | property |
containing functions | / | / | / | method | method |
inheritance | no | no | no | yes | yes |
In this tutorial series, I want to show how you can use OOP in Fortran in scientific codes. As a first example, I will show you how to create an agent based opinion dynamics code implementing the model presented by Sobkowicz in a publication I recently had to review.
I choose this as our tutorial example (over for example geometric shapes) because it is a real-life scientific example which is simple enough to allow for several aspects in scientific and OO-programming to be shown. In addition, from the physicists point of view: particle or agent, it is all the same to us when we are implementing their behavior into a program.(You could even start thinking in terms of NPC’s for a game, although game-dynamics in general require quite a bit more implementation)
So let us get started. First, you might wish to grab a copy of the paper by Sobkowicz (it’s freely accessible), just to be able to more easily track the notation I will be using in the code. After having installed code::blocks it is rather straight-forward to create a new Fortran program.
- program AgentTutorials
- use Tutorial1;
- implicit none
-
- write(*,'(A)') "Welcome to the Agents OOP-Fortran Tutorial"
- call RunTutorial1()
- write(*,'(A)') "-- Goodbye"
- end program AgentTutorials
- module Tutorial1
- implicit none
- private
-
- public :: RunTutorial1
-
- contains
- !+++++++++++++++++++++++++++++++++++++
- !>\brief Main program routine for the first agents tutorial
- !!
- !! This is the only function accessable outside this module.
- !<------------------------------------
- subroutine RunTutorial1()
- write(*,'(A)') "----Starting Turorial 1 subprogram.----"
- write(*,'(A)') "-------End Turorial 1 subprogram.------"
- end subroutine RunTutorial1
-
- end module Tutorial1
At this point or program doesn’t do that much, we have only set up the framework in which we will be working. Compiling and running the program (F9 or Build > Build and run) should show you:
In the next session of this tutorial we will use OO-Fortran 2003 to create the agent-class and create a first small simulation.