Python script to calculate the Madelung constant of an infinite lattice

During my Diploma thesis in Physics I had to calculate the Madelung constant for a lattice of ZnO supercells. For this purpose, I implemented a small Python programm. The only prerequisite is SciPy. The script calculates the Madelung constant for an infinite lattice of point charges, neuralized by a counter-charged jellium background. All documentation is inside the file There’s another script (supercell madelung constant) in there which demonstrates reading a POSCAR file describing an atomic lattice and calculating the Madelung constant for it.

Maybe someone can so something useful with the stuff. I would be happy about feedback whether the implementation actually works for your specific case 🙂

Weekly Update


I have found out this week, that Ecstatica FANT files are actually stacks of FANT files. For example in „estatic.“, there are actually present around 2000 FANT files. The file „offsets.“ includes offsets into the file which are used to access the large file at the correct offset. In „ecstatic.“ the single FANT files often contain only a single sound or a single list of scene events.

So I had to expand my code in order to handle the lists of FANT files and it does now. The XML export- and import seems to work now also for the case of multiple FANT „objects“ within one file.

I never had tested my XML export/import code with sounds yet. A problem arised: Originally I inteded to include the binary wave data for each sound in a CDATA section within the XML file. But it turned out that this is not possible, because XML forbids certain characters even within CDATA sections. So what I do now is I export the wave data into separate binary data files and include a reference into the XML data. That way I was now able to completely read in „ecstatic.“, export it to XML, reimport it from XML and export it to FANT file format again. The resulting FANT file (correctly: stack of FANT files) is binary equivalent to the original „ecstatic.“ file.

Procedural Graphics

Today I was travelling across a number of sites about procedural terrain generation and procedural graphics in general.

Here are my links:

Other Stuff

I stumbled across this amazing flash animation visualizing on what different scales things in our universe exist. Take a look at the main site also, because there’s a lot of other original flash stuff avaible.

Not understanding theories

Have you ever witnessed or experienced the moment when someone finally understands a scientific theory? In German, one uses phrases like „the coin has fallen“ or „she has got risen a light“ to describe it. What does happen in that moment? I think it is basically the second, where the picture used in the theory gets apparent. The backbone of theories are always pictures. Mathematical pictures in most scientific theories. A mathematical entity to represent something in the real world.

Understanding scientific theories is therefore based on understanding the properties of the entities used. Like for example a harmonic oscillator, which is a ridiculously simple picture used to represent thingies „swinging“. As a result, people don’t understand scientific theories if they lack understanding of the used mathematical pictures.

But even if one owns knowledge about the properties of a specific picture already, there still can be problems in understanding a theory using them. The very same mathematical object can appear in quite a lot of different forms. You can talk about matrices as operators transforming vectors or you can see matrices as bilinearforms mapping 2 vectors onto a number. Those are completely equivalent descriptions, but they impose completely different pictures in our mind. Even if you own a certain intuition for vectors, you might lack intuition for bilinearforms.

Graphical Raytracing using CarMetal

In optics, the law of refraction by Snellius is widely known.

n_1 \cdot sin(\alpha_1) = n_2 \cdot sin(\alpha_2)

The calculation of  sin(\alpha_2) can actually be done using geometry exclusively.

mere geometric calculation of the refraction of a ray

mere geometric calculation of the refraction of a ray

I have created this nice image using CarMetal, a geometry program. You can download the CarMetal-file brechung_regulaerundtotal.zir and play around with the angles yourself. While you change \alpha_1, f0r example, CarMetal maintains the introduced relationships like „… being parallel to …“ or „… goes through the intersection of … and … „. The green ray shows near total reflection which appears as soon as there’s no intersection of the vertical line with the inner circle.