Generate disordered-to-nanocrystalline atomic supercells guided by three-body (g3) distributions.
Project description
tricor
Generate disordered atomic supercells guided by three-body (g3) distributions, spanning the full spectrum from liquid to nanocrystalline. Designed for machine-learning training data generation.
Installation
# Default install (pure-numpy g3 measurement)
pip install tricor
# Recommended: with numba acceleration (~20× faster measure_g3 +
# enables thermal_relax / orientation refinement features)
pip install 'tricor[fast]'
# Optional data-IO extras
pip install 'tricor[data]' # h5py, zarr
Or to install the development checkout:
git clone https://github.com/ophusgroup/tricor
cd tricor
uv sync # or: pip install -e '.[fast,test]'
tricor requires Python ≥ 3.10 and works on Linux, macOS, and Windows.
Quick start - Si
from ase.build import bulk
import tricor as tc
atoms = bulk('Si', 'diamond', a=5.431)
shell_target = tc.CoordinationShellTarget.from_atoms(
atoms,
phi_num_bins=90,
)
cell = tc.Supercell.from_atoms(
atoms,
cell_dim_angstroms=(40, 40, 40),
r_max=10,
r_step=0.1,
phi_num_bins=90,
relative_density=0.96,
rng_seed=42,
)
cell.generate(
shell_target,
num_steps=150,
grain_size=13.0,
bond_weight=1.9,
angle_weight=0.9,
repulsion_weight=2.5,
hard_core_scale=0.95,
nonbond_push_scale=0.7,
displacement_sigma=0.04,
)
cell.measure_g3()
cell.plot_g3()
cell.plot_structure(output='structure.mp4')
Quick start - SiC (binary)
atoms = bulk('SiC', 'zincblende', a=4.36)
shell_target = tc.CoordinationShellTarget.from_atoms(
atoms,
phi_num_bins=90,
)
cell = tc.Supercell.from_atoms(
atoms,
cell_dim_angstroms=(40, 40, 40),
r_max=10,
r_step=0.1,
phi_num_bins=90,
relative_density=0.96,
rng_seed=42,
)
cell.generate(
shell_target,
num_steps=150,
grain_size=13.0,
bond_weight=1.9,
angle_weight=0.9,
repulsion_weight=2.5,
hard_core_scale=0.95,
nonbond_push_scale=0.7,
displacement_sigma=0.04,
)
cell.measure_g3()
cell.plot_g3() # browse Si | Si Si, C | C C, etc.
Structure generation
generate() builds disordered structures by combining Voronoi grain
construction with spring-network relaxation.
| Parameter | Controls |
|---|---|
grain_size |
Crystallite diameter (A). None = no grains (liquid). |
bond_weight |
Spring strength for bond distances. Larger = tighter. |
angle_weight |
Spring strength for bond angles. Larger = tighter. |
hard_core_scale |
Scales the minimum bond distance wall. < 1 = softer (liquid). |
nonbond_push_scale |
Scales the non-bonded clearance distance. < 1 = broader 2nd shell. |
displacement_sigma |
Gaussian jitter on grain atoms (A). Broadens crystalline peaks. |
relative_density |
Density relative to crystal (set on from_atoms). |
Recommended presets for Si
Available as Supercell.PRESETS:
cell = tc.Supercell.from_atoms(
atoms,
(40, 40, 40),
rng_seed=42,
)
cell.generate(shell_target, **tc.Supercell.PRESETS["MRO"])
| Regime | grain_size | bond_wt | angle_wt | rep_wt | hc_scale | nbp_scale | disp_sigma |
|---|---|---|---|---|---|---|---|
| liquid | None | 0.4 | 0.5 | 0.5 | 0.75 | 0.7 | - |
| amorphous | 6 | 1.2 | 0.6 | 1.5 | 0.9 | 0.5 | 0.08 |
| SRO | 10 | 2.2 | 1.0 | 2.0 | 0.95 | 0.6 | 0.04 |
| MRO | 13 | 1.9 | 0.9 | 2.5 | 0.95 | 0.7 | 0.04 |
| MRO_more | 18 | 2.0 | 1.0 | default | 0.95 | 0.9 | 0.04 |
| nanocrystalline_10 | 15 | 2.8 | 1.3 | default | default | default | 0.02 |
| nanocrystalline_20 | 20 | 3.0 | 1.5 | default | default | default | 0.02 |
All presets use relative_density=0.96. Abbreviations: rep_wt = repulsion_weight, hc_scale = hard_core_scale, nbp_scale = nonbond_push_scale.
Optional: target g3 for comparison
To compare the supercell against a target distribution, create one explicitly and pass it as the initial distribution:
dist = tc.G3Distribution(atoms)
dist.measure_g3(
r_max=10,
r_step=0.1,
phi_num_bins=90,
)
target = dist.target_g3(
target_r_min=5.0,
target_r_max=8.0,
r_sigma=0.05,
phi_sigma_deg=3.0,
)
cell = tc.Supercell(
target,
cell_dim_angstroms=(40, 40, 40),
relative_density=0.96,
)
cell.generate(
shell_target,
grain_size=13.0,
bond_weight=1.9,
angle_weight=0.9,
repulsion_weight=2.5,
hard_core_scale=0.95,
nonbond_push_scale=0.7,
displacement_sigma=0.04,
)
cell.measure_g3()
cell.plot_g3_compare()
Core classes
G3Distribution- measures rooted three-body angle/distance histograms from atomic structuresCoordinationShellTarget- extracts first-shell coordination targets (bond lengths, angles, coordination numbers) from a reference crystalSupercell- generates and optimises disordered supercells
Dependencies
numpy,matplotlib,ase,anywidget- Optional:
h5py,zarr(for data I/O)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tricor-0.1.0.tar.gz.
File metadata
- Download URL: tricor-0.1.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab24d006639a99e65e5604203cdebe1e9945858c741c38797d23d63c199ac8f7
|
|
| MD5 |
0424a5d0c34a0021a39110141741d837
|
|
| BLAKE2b-256 |
34dc66e257b910798039cee70d9db510b0239805e0445398cb8a84ade3a19143
|
File details
Details for the file tricor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tricor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72dc93e16f898a46a42a8f5f7b9732d054cbef62c73b082269bacaeadb80796a
|
|
| MD5 |
5bc0c1fa26cb0f767fcbf695e051355d
|
|
| BLAKE2b-256 |
52ca7a6080929fff083564ef0dac68bb409d491f5bba3d4d1e97400517702d83
|