Skip to content

ASE Acceleration Guide

FBTK serves as a high-performance Rust backend to significantly accelerate analysis tasks in the ASE (Atomic Simulation Environment) ecosystem.

While ASE is versatile, performing calculations like all-atom distance matrices or neighbor list generation for large systems (tens of thousands of atoms) can be slow in pure Python. FBTK executes these computations in parallel using Rust, drastically reducing execution time.

Comparison of execution times for a copper crystal system with 4,000 atoms (Environment: 4-core CPU).

FeatureASE (Python)FBTK (Rust)Speedup
get_all_distances~1.8 sec~0.01 sec~180x
get_neighbor_list~0.2 sec~0.01 sec~15x

Simply wrap an ASE Atoms object using fbtk.from_ase() to unlock high-speed analysis methods.

import fbtk
from ase.build import bulk
# 1. Create a system in ASE (Cubic cell)
atoms = bulk('Cu', 'fcc', a=3.614, cubic=True) * (10, 10, 10)
# 2. Convert to FBTK System (High speed, minimal memory copy)
system = fbtk.from_ase(atoms)
# 3. High-speed distance matrix calculation (MIC supported)
dists = system.get_all_distances(mic=True)
# 4. High-speed neighbor list generation
neighbors = system.get_neighbor_list(cutoff=5.0)

You can run the following script to measure the speedup in your own environment:

import fbtk
import time
import numpy as np
from ase.build import bulk
# Create system (4,000 atoms)
atoms = bulk('Cu', 'fcc', a=3.614, cubic=True) * (10, 10, 10)
# Convert to FBTK
system = fbtk.from_ase(atoms)
# Measure FBTK distance calculation
start = time.time()
d_fbtk = system.get_all_distances(mic=True)
print(f"FBTK time: {time.time() - start:.4f} sec")
# Measure ASE distance calculation
start = time.time()
d_ase = atoms.get_all_distances(mic=True)
print(f"ASE time: {time.time() - start:.4f} sec")
# Verify consistency
assert np.allclose(d_ase, d_fbtk)
print("Results match perfectly!")

For performance reasons, FBTK’s distance calculation (with mic=True) uses a standard Minimum Image Convention algorithm. If the unit cell dimensions are smaller than twice the distance being measured (e.g., measuring 3 Å in a 5 Å box), results may differ from ASE’s exhaustive search algorithm.

For typical bulk systems (dimensions > 10 Å recommended), this limitation has no impact, and FBTK provides identical results to ASE with significantly better performance.