aidsorb.utils#
Helper functions for generating input representations.
Currently supported representations:
- Molecular point clouds
Fast and flexible representation suitable for any molecular system.
- 3D energy images
Physics-informed representation tailored for adsorption in porous materials.
References
- aidsorb.utils.pcd_from_dir(dirname, outname, features=None)[source]#
Create molecular point clouds from a directory of structure files and store them.
Point clouds are stored under
outnameas.npyfiles.Tip
To get a list of the supported chemical file formats see
ase.io.read(). Alternatively, you can list them from the command line with:ase info --formats.- Parameters:
dirname (str) β Absolute or relative path to the directory.
outname (str) β Directory where the point clouds will be stored. It is created if does not exist.
features (list of str, optional) β Elemental properties from periodic table.
- Return type:
None
Notes
Structures that canβt be processed are omitted.
Examples
>>> dirname = 'path/to/structures' >>> outname = 'path/to/pcd_data' >>> # xyz coordinates + atomic number + electronegativity >>> pcd_from_dir(dirname, outname, features=['en_pauling'])
- aidsorb.utils.pcd_from_file(filename, features=None)[source]#
Create molecular point cloud from a structure file.
The molecular
pcdhas shape(N, 4+C)whereNis the number of atoms,pcd[:, :3]are the atomic coordinates,pcd[:, 3]are the atomic numbers andpcd[:, 4:]any additionalfeatures. Iffeatures=None, then the only features are the atomic numbers.- Parameters:
filename (str) β Absolute or relative path to the file.
features (list of str, optional) β See
pcd_from_dir().
- Returns:
data β Molecular point cloud and its name as
(name, pcd).- Return type:
Notes
The
nameof the molecule is the basename offilenamewith its suffix removed.Examples
>>> # xyz coordinates + atomic number + electronegativity + radius >>> name, pcd = pcd_from_file('path/to/file', features=['en_pauling', 'atomic_radius']) ...
- aidsorb.utils.pcd_from_files(filenames, outname, features=None)[source]#
Create molecular point clouds from a list of structure files and store them.
Point clouds are stored under
outnameas.npyfiles.- Parameters:
filenames (iterable) β An iterable providing the filenames. Absolute or relative paths can be used.
outname (str) β Directory where the point clouds will be stored. It is created if does not exist.
features (list of str, optional) β See
pcd_from_dir().
- Return type:
None
Notes
Structures that canβt be processed are omitted.
Examples
>>> # Create and store the point clouds. >>> outname = 'path/to/pcd_data' >>> pcd_from_files(['path/to/foo.xyz', 'path/to/bar.cif'], outname) >>> # Load back a point cloud. >>> pcd = np.load(f'{outname}/foo.npy')
- aidsorb.utils.voxels_from_dir(cif_dirname, out_pathname, grid_size=32, *, cutoff=10.0, epsilon=50.0, sigma=2.5, cubic_box=30.0, 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=32) β 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=30) β 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.
- aidsorb.utils.voxels_from_file(cif_pathname, grid_size=32, *, cutoff=10.0, epsilon=50.0, sigma=2.5, cubic_box=30.0, n_jobs=None, only_voxels=True)[source]#
Calculate and return voxels from
.ciffile.- Parameters:
- Returns:
out β If
only_voxels=Truearray, elseGrid.- Return type:
array or
Grid
See also
voxels_from_dir()For a description of the parameters.
- aidsorb.utils.voxels_from_files(cif_pathnames, out_pathname, grid_size=32, *, cutoff=10.0, epsilon=50.0, sigma=2.5, cubic_box=30.0, n_jobs=None)[source]#
Calculate voxels from a list of
.ciffiles and store them.Voxels are stored under
out_pathnameas.npyfiles.- Parameters:
See also
voxels_from_dir()For a description of the parameters.
Notes
Structures that canβt be processsed are omitted.