I wanted to write about a Java molecular simulation that I made a while ago, before I became entranced by Python. The program is a simple 2D physics simulation, with circles representing billiard ball-style atoms. The idea before the simulation was initially an attempt to create a virtual lava lamp.
In its first incarnation, there were two types of atom. Each atom was attracted to nearby atoms of the same type (with a force proportional one over distance squared). If the distance between any two atoms was below a threshold then the two atoms repel each other. If the simulation is started with a mixture of two types of atoms and left to run with a bit of thermal energy, then eventually the two types of atoms separate like water and oil.
I extended this simulation by altering the interactions between some atoms, thereby allowing the creation of molecules (though with enough force, atoms can be ripped from their molecules). At some point, I'll put up the applet or at least a video or the simulation.
The simulation is of lipids in water. The lipids are made of two types of atom: the red charged (or hydrophilic) head atom, and two green uncharged (hydrophobic) tail atoms. The red atom is essentially the same type as the water atoms, which I’ve hidden. This simple program simulates the spontaneous formation of lipid bilayers and micelles. I think better, more spherical micelles would form if the head atoms were made wider than the tail atoms, so the shape of the molecules was more triangular, as real lipids are.
Applet on Wordpress
[This paragraph is slightly irrelevant on this version of my site, but it might be useful for other people.]
To embed my Java applet into Wordpress was relatively straightforward. The key point was to disable to the Visual Editor in the ‘Your Profile’ settings. Then it was simply a case of remembering to add the CODEBASE parameter to point to where Wordpress stores the .CLASS file. Having spent some time converting my old Java programs to Python, I might now convert some of my new shiny Python programs to Java.
I'll also now need to work out how to add applets to a Drupal site.