ASE Acceleration Guide
ASE Acceleration
Section titled “ASE Acceleration”FBTK serves as a high-performance Rust backend to significantly accelerate analysis tasks in the ASE (Atomic Simulation Environment) ecosystem.
Why FBTK?
Section titled “Why FBTK?”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.
Performance Benchmark
Section titled “Performance Benchmark”Comparison of execution times for a copper crystal system with 4,000 atoms (Environment: 4-core CPU).
| Feature | ASE (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 fbtkfrom 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 generationneighbors = system.get_neighbor_list(cutoff=5.0)Benchmark Code
Section titled “Benchmark Code”You can run the following script to measure the speedup in your own environment:
import fbtkimport timeimport numpy as npfrom ase.build import bulk
# Create system (4,000 atoms)atoms = bulk('Cu', 'fcc', a=3.614, cubic=True) * (10, 10, 10)
# Convert to FBTKsystem = fbtk.from_ase(atoms)
# Measure FBTK distance calculationstart = time.time()d_fbtk = system.get_all_distances(mic=True)print(f"FBTK time: {time.time() - start:.4f} sec")
# Measure ASE distance calculationstart = time.time()d_ase = atoms.get_all_distances(mic=True)print(f"ASE time: {time.time() - start:.4f} sec")
# Verify consistencyassert np.allclose(d_ase, d_fbtk)print("Results match perfectly!")Limitations and Notes
Section titled “Limitations and Notes”Small Unit Cells and MIC
Section titled “Small Unit Cells and MIC”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.