pymatgen.optimization package
Optimization utilities.
Submodules
pymatgen.optimization.fast_parser module
- parse_n_doubles(file, out, nelem=-1)[source]
Parse doubles from a binary file object into
out.The file is read in 1 MiB chunks. On return, the file position follows the stop pointer returned by the parser without rewinding trailing whitespace.
The
filemust be a seekable binary stream (the function usestell()/seek()to leave the cursor right after the last parsed number). Backward seeks on compressed streams (e.g.gzip.GzipFile,bz2.BZ2File) are implemented as decompress-from-start and can be dramatically slower than on uncompressed files; prefer decompressing upstream when parsing large compressed inputs.- Returns:
Parsed element count.
- Return type:
int
- Raises:
TypeError – If
fileis not a binary stream.ValueError – If
nelemexceedsout.shape[0].
pymatgen.optimization.neighbors module
- find_points_in_spheres(all_coords, center_coords, r, pbc, lattice, tol=1e-08, min_r=1.0)[source]
For each point in center_coords, get all the neighboring points in all_coords that are within the cutoff radius r. All the coordinates should be Cartesian.
- Parameters:
all_coords – (np.ndarray[double, dim=2]) all available points. When periodic boundary is considered, this is all the points in the lattice.
center_coords – (np.ndarray[double, dim=2]) all centering points
r – (float) cutoff radius
pbc – (np.ndarray[np.int64_t, dim=1]) whether to set periodic boundaries
lattice – (np.ndarray[double, dim=2]) 3x3 lattice matrix
tol – (float) numerical tolerance
min_r – (float) minimal cutoff to calculate the neighbor list directly. If the cutoff is less than this value, the algorithm will calculate neighbor list using min_r as cutoff and discard those that have larger distances.
- Returns:
Indexes of center_coords. index2 (n, ): Indexes of all_coords that form the neighbor pair. offset_vectors (n, 3): The periodic image offsets for all_coords. distances (n, ).
- Return type:
index1 (n, )