π API Referenceο
MOXΡλ is a Python package for parallel calculation of energy voxels, with emphasis on reticular chemistry.
moxel.utilsο
This module provides helper functions for creating voxels.
Note
Currently, interactions are modelled with the Lennard-Jones (LJ) potential.
Attention
Consider tuning the n_jobs parameter to get the best performance
for your system:
from timeit import timeit
setup = 'from moxel.utils import voxels_from_file'
n_jobs = [1, 2, 8, 16] # Modify this according to your system.
for n in n_jobs:
stmt = f'voxels_from_file("path/to/cif", n_jobs={n})'
time = timeit(stmt=stmt, setup=setup, number=1)
print(f'Time with {n} jobs: {time:.3f} s')
- class moxel.utils.Grid(grid_size=32, *, cutoff=10.0, epsilon=50.0, sigma=2.5)[source]ο
A 3D energy grid over a crystal structure.
- Parameters:
grid_size (int, default=25) β
Number of grid points along each dimension.
Changed in version 0.5.0: Now all methods suck!
cutoff (float, default=10.0) β Cutoff radius (β«) for the LJ potential.
epsilon (float, default=50.0) β Epsilon value (Ξ΅/K) of the probe atom.
sigma (float, default=2.5) β Sigma value (Ο/β«) of the probe atom.
- structureο
Available only after
Grid.load_structure()has been called.- Type:
pymatgen.core.structure.Structure
- structure_nameο
Available only after
Grid.load_structure()has been called.- Type:
str
- cubic_boxο
Available only after
Grid.calculate()has been called.- Type:
float or None
- voxelsο
Available only after
Grid.calculate()has been called.- Type:
array of shape (grid_size,)*3
- calculate(cubic_box=30, potential='lj', n_jobs=None)[source]ο
Iterate over the grid and return voxels.
For computational efficiency and to assure (approximately) the same spatial resolution, the grid is overlayed over a supercell scaled according to MIC, see
mic_scale_factors().If lattice angles are significantly different than 90Β°, to avoid distortions set
cubic_box. In this case, the grid is overlayed over a cubic box of sizecubic_boxcentered at the origin but periodicity is no longer guaranteed.- Parameters:
potential (str, default='lj') β The potential used to calculate voxels. Currently, only the LJ potential is supported.
cubic_box (float or None, default=None) β If
None, the simulation box is a supercell scaled according to MIC. Otherwise, cubic box of sizecubic_box.n_jobs (int, optional) β Number of jobs to run in parallel. If
None, then the number returned byos.cpu_count()is used.
- Returns:
voxels
- Return type:
array of shape (grid_size,)*3
- moxel.utils.mic_scale_factors(r, lattice_vectors)[source]ο
Return scale factors to satisfy minimum image convention [MIC].
- Parameters:
r (float) β The cutoff radius used in MIC convetion.
lattice_vectors (array of shape (3, 3)) β The lattice vectors of the unit cell. Each row corresponds to a lattice vector.
- Returns:
scale_factors β
scale_factors[i]scaleslattice_vectors[i].- Return type:
array of shape (3,)
References
[MIC]Smith, βThe Minimum Image Convention in Non-Cubic MD Cellsβ, 1989.
- moxel.utils.voxels_from_dir(cif_dirname, out_pathname, grid_size=32, *, cutoff=10.0, epsilon=50.0, sigma=2.5, cubic_box=30, n_jobs=None)[source]ο
Calculate voxels from a directory of
.ciffiles and store them.Voxels are stored under
out_pathnameas.npyfiles.- Parameters:
cif_dirname (str) β Pathname to the directory containing the
.ciffiles.out_pathname (str) β Pathname of an existing directory under which voxels are stored.
grid_size (int, default=25) β Number of grid points along each dimension.
cutoff (float, default=10.0) β Cutoff radius (β«) for the LJ potential.
epsilon (float, default=50.0) β Epsilon value (Ξ΅/K) of the probe atom.
sigma (float, default=2.5) β Sigma value (Ο/β«) of the probe atom.
cubic_box (float or None, default=None) β If
None, the simulation box is a supercell scaled according to MIC. Otherwise, cubic box of sizecubic_box.n_jobs (int, optional) β Number of jobs to run in parallel. If
None, then the number returned byos.cpu_count()is used.
Notes
Structures that canβt be processsed are omitted.
- moxel.utils.voxels_from_file(cif_pathname, grid_size=32, *, cutoff=10.0, epsilon=50.0, sigma=2.5, cubic_box=30, n_jobs=None, only_voxels=True)[source]ο
Calculate and return voxels from
.ciffile.- Parameters:
cif_pathname (str) β Pathname to the
.ciffile.only_voxels (bool, default=True) β Determines
outtype.
- Returns:
out β If
only_voxels=Truearray, elseGrid.- Return type:
array or
Grid
See also
voxels_from_dir()For a description of the parameters.
- moxel.utils.voxels_from_files(cif_pathnames, out_pathname, grid_size=32, *, cutoff=10.0, epsilon=50.0, sigma=2.5, cubic_box=30, n_jobs=None)[source]ο
Calculate voxels from a list of
.ciffiles and store them.Voxels are stored under
out_pathnameas.npyfiles.- Parameters:
cif_pathnames (list) β List of pathnames to the
.ciffiles.out_pathname (str) β Pathname to the directory under which voxels are stored.
See also
voxels_from_dir()For a description of the parameters.
Notes
Structures that canβt be processsed are omitted.