I(q) and p(r) calculator for fractal Menger sponges

This Javascript calculates the scattering curve I(q) in reciprocal space and the the distance distribution function p(r) in real space of a Menger sponge, a porous cubic 3D mass fractal approximated by a 3D-grid (3x3x3 up to 81x81x81 units) occupied by spheres with constant radii (diameter 1 unit) and constant electron densities by using the Debye-formula in reciprocal and in real space, respectively. Enter the generation of the fractal (G: 1-4, if G = 4 the calculations might take a few minutes for the 160.000 coordinates), the size (edge length of the fractal cube) and the radius Rs of the spheres which build up the fractal (their radius can be either 0.5 units which means two neighboring spheres are just touching each other or can be 0.62 units which means they are overlapping slightly, but the volume of the entire fractal is equal to the sum of all sphere volumes). For n(I) points the I(q) from q = 0 to qz with a scaling factor F and for n(p) points from r = 0 to Dm (maximum dimension) with a scaling factor F will be calculated. The number of spheres (Nc) and of their different mutual distances (dij) of the fractal, the parameters of the scaled sphere radius (Rs) building up the fractal, the maximum dimension (Dm), of the Radius of Gyration (Rg), of I(0) and gamma(0) are also listed and if F = 0 is entered, the respective function will be normalized to I(0) = 1 and gamm(0) = 1. The values are listed and displayed in I vs q (left plot, optionally log(I) will be plotted) and p(r) vs r (right plot, optionally gamma(r) being p(r)/(r*r) will be plotted) in arbitrary units and can be copied and pasted from the window into any text-file for further processing and graphical displaying. An animation of the fractal model (G = 1-4) can be created and visualized here.

Input I(q)/p(r) Results

Rs=0.50u Rs=0.62u
I(q) log I
p(r) g(r)
Author: M.Kriechbaum, TU-Graz (2020), e-mail: manfred.kriechbaum@tugraz.at