Skip to content

A python function to calculate the fractal dimension in 3D. Adapted to work with dana's output.

License

Notifications You must be signed in to change notification settings

pauvals/FractalDimension

 
 

Repository files navigation

Box-counting in three dimensional numpy arrays.

Description from wikipedia (2/2025):

In mathematics, a fractal dimension is a term invoked in the science of geometry to provide a rational statistical index of complexity detail in a pattern. A fractal pattern changes with the scale at which it is measured. It is also a measure of the space-filling capacity of a pattern, and it tells how a fractal scales differently, in a fractal (non-integer) dimension.

Here we offer a function that calculates the fractal dimension of an object embedded in three dimensional space using the boxcounting method, also known as the Minkowski-Bouligand dimension.

Usage

Simple example, measuring a box in 3D space.

import numpy as np
from FractalDimension import fractal_dimension
import matplotlib.pyplot as plt

#test data
box = np.zeros(shape = (100,100,100))
box[20:80,20:80,20:80] = 1

fd = fractal_dimension(box, n_offsets=10, plot = True)
print(f"Fractal Dimension of the box: {fd}")
plt.show()
Fractal Dimension of the box: 3.036397272261638

png

For a more complete overview of the function and its parameters, have a look at the notebook detailing the development of the function in binder.

A use case: measurement of the Fractal Dimension of a coordinates system from Molecular Dynamics simulations

Using dana, our molecular dynamics program, we obtained different lithium metal anode configurations. One may use this script to analyze their fractal dimension. We used directly the fractal.py script to analyze our processed outputs.

Made with 🧉 🤘 :)

About

A python function to calculate the fractal dimension in 3D. Adapted to work with dana's output.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 99.3%
  • Python 0.7%