mxtaltools.crystal_building.utils

mxtaltools.crystal_building.utils.align_mol_batch_to_standard_axes(mol_batch, handedness=None, return_rot=False)[source]

align principal inertial axes of molecules in a crystaldata object to the xyz or xy(-z) axes only works for geometric principal axes (all atoms mass = 1)

mxtaltools.crystal_building.utils.aunit2ucell(mol_batch)[source]
Parameters:

mol_batch

Returns:

mxtaltools.crystal_building.utils.canonicalize_aunit_order(batch)[source]
mxtaltools.crystal_building.utils.canonicalize_rotvec(rotvecs: Tensor)[source]

since the direction of the axis is arbitrary, (x,y,z) is the same rotation as (-x,-y,-z), we can obtain uniqueness constraining the axis to a half-sphere. Here we will take the +z direction as ‘canonical’

Swap the direction and take 2pi-norm to recapture the identical rotation.

mxtaltools.crystal_building.utils.cleanup_invalid_rotvecs(rotation_matrix_list, rotvec_list)[source]
mxtaltools.crystal_building.utils.descale_asymmetric_unit(asym_unit_dict, mol_position, sg_inds)[source]

input fractional coordinates are scaled on 0-1 rescale these for the specific ranges according to each space group only space groups in asym_unit_dict will work - not all have been manually encoded this approach will not work for asymmetric units which are not neat parallelpipeds :param asym_unit_dict: :param mol_position: :param sg_inds:

mxtaltools.crystal_building.utils.extract_aunit_orientation(mol_batch, enforce_right_handedness, canonicalize_orientation: bool = True)[source]
mxtaltools.crystal_building.utils.find_coord_in_box_torch(coords, box, epsilon=0)[source]
mxtaltools.crystal_building.utils.generate_sorted_fractional_translations(supercell_size)[source]
mxtaltools.crystal_building.utils.get_aunit_positions(mol_batch, std_orientation: bool = True, mol_handedness: OptTensor = None) Tensor[source]

pose asymmetric unit via fractional translations and rotations always take the zp=1 component

mxtaltools.crystal_building.utils.get_cart_translations(cc_centroids, T_fc, mol_radii, cutoff, supercell_size: int = 9)[source]
mxtaltools.crystal_building.utils.identify_canonical_asymmetric_unit(T_cf, asym_unit_dict, sg_ind, unit_cell_coords)[source]
mxtaltools.crystal_building.utils.instantiate_cluster(atoms_per_ucell, atoms_per_cluster, atomwise_translation, ucells_per_cluster, crystal_batch)[source]
mxtaltools.crystal_building.utils.parameterize_crystal_batch(crystal_batch, asym_unit_dict, enforce_right_handedness: bool = False, return_aunit: bool = False)[source]

Asymmetric Unit Centroid Analysis identify “canonical” asymmetric unit out of the Z asymmetric units in the unit cell # TODO would be nice if this could be parallelized. Would be nice indeed

mxtaltools.crystal_building.utils.protonate_mol(atom_types, coords)[source]

atom_types : list/array of atomic numbers coords : (N,3) float array in Å returns: (new_atom_types, new_coords) with added hydrogens

mxtaltools.crystal_building.utils.rescale_asymmetric_unit(asym_unit_dict, mol_position, sg_inds)[source]

input fractional coordinates are scaled on 0-max rescale these for the specific ranges according to each space group only space groups in asym_unit_dict will work - not all have been manually encoded this approach will not work for asymmetric units which are not neat parallelpipeds :param asym_unit_dict: :param mol_position: :param sg_inds:

mxtaltools.crystal_building.utils.ucell2cluster(crystal_batch, cutoff: float = 6, supercell_size: int = 10, zp_buffer: float | Tensor = 0)[source]
  1. generate supercell cluster including only unit cells which could plausibly interact with the asymmetric unit

  2. instantiate the cluster

  3. pare cluster to asymmetric units which actually interact with the asymmetric unit