mxtaltools.crystal_building.crystal_latent_transforms

class mxtaltools.crystal_building.crystal_latent_transforms.AunitTransform(asym_unit_dict, max_z_prime: int = 1)[source]

Bases: Module

forward(cell_parameters, sg_inds)[source]
inverse(cell_parameters, sg_inds)[source]
class mxtaltools.crystal_building.crystal_latent_transforms.BoundedTransform(min_val, max_val, slope=1.0, eps=1e-06, bias: float = 0.0)[source]

Bases: Module

forward(latent: Tensor) Tensor[source]

Maps latent (standard normal-like) to bounded physical space.

inverse(value: Tensor) Tensor[source]

Maps from bounded physical space to latent.

class mxtaltools.crystal_building.crystal_latent_transforms.CompositeTransform(transforms: list[Module])[source]

Bases: Module

forward(x, sg_inds, mol_radii)[source]
inverse(x, sg_inds, mol_radii)[source]
class mxtaltools.crystal_building.crystal_latent_transforms.IdentityTransform[source]

Bases: Module

forward(z)[source]
inverse(z)[source]
class mxtaltools.crystal_building.crystal_latent_transforms.LogNormalTransform(mean_log: float = 0.5, std_log: float = 0.35, eps: float = 1e-06, exp_min: float = None, exp_max: float = None)[source]

Bases: Module

forward(value: Tensor) Tensor[source]

Maps log-normal physical value to latent

inverse(latent: Tensor) Tensor[source]

Maps latent to log-normal physical variable

class mxtaltools.crystal_building.crystal_latent_transforms.NiggliTransform[source]

Bases: Module

forward(params, mol_radii)[source]

Reduce physical aunit parameters to a niggli-normed basis

inverse(niggli_params, mol_radii)[source]

Niggli params to cell params :param niggli_params: :param mol_radii: :return:

class mxtaltools.crystal_building.crystal_latent_transforms.PhiTransform(eps: float = 1e-06)[source]

Bases: Module

forward(z: Tensor) Tensor[source]
inverse(u: Tensor) Tensor[source]
class mxtaltools.crystal_building.crystal_latent_transforms.ProbitTransform(eps: float = 1e-06)[source]

Bases: Module

forward(z: Tensor) Tensor[source]
inverse(u: Tensor) Tensor[source]
class mxtaltools.crystal_building.crystal_latent_transforms.RTransform(eps: float = 1e-06)[source]

Bases: Module

forward(z: Tensor) Tensor[source]
inverse(u: Tensor) Tensor[source]
class mxtaltools.crystal_building.crystal_latent_transforms.RotationTransform(eps: float = 1e-06, mode: str = 'linear')[source]

Bases: Module

azimuth_to_std_normal(phi)[source]
azimuth_to_uniform(phi)[source]
forward(latent: Tensor) Tensor[source]

Maps latent vector (ℝ³) to rotation vector (SO(3)) using canonical z > 0 encoding and norm bounding.

inverse(rotvec: Tensor) Tensor[source]

Maps rotation vector back to latent space using inverse angle norm and canonical z decoding.

polar_to_std_normal(theta)[source]
rotation_to_std_normal(r)[source]
std_normal_to_azimuth(z)[source]
std_normal_to_polar(z)[source]
std_normal_to_rotation(z)[source]
uniform_to_azimuth(z)[source]
wrap_to_pi(x)[source]
class mxtaltools.crystal_building.crystal_latent_transforms.SquashingTransform(min_val, max_val, eps=0.01, threshold: float = 5.0, softness: float = 5.0)[source]

Bases: Module

forward(latent: Tensor) Tensor[source]

Ultra-smooth soft clipper with gradual derivative transition using PyTorch

Parameters:

xtorch.Tensor

Input tensor

thresholdfloat

Point where transition becomes noticeable (not abrupt)

sat_levelfloat

Maximum output level (saturation point)

softnessfloat

Controls how gradual the transition is (higher = more gradual)

Returns:

torch.Tensor

Soft-clipped output with very smooth derivative

inverse(squashed: Tensor) Tensor[source]

Analytical inverse of the smooth soft clip function

Parameters:

ytorch.Tensor

Output from the soft clip function (input to inverse)

thresholdfloat

Same threshold parameter used in forward function

sat_levelfloat

Same saturation level used in forward function

softnessfloat

Same softness parameter used in forward function

Returns:

torch.Tensor

Original input x that would produce output y

class mxtaltools.crystal_building.crystal_latent_transforms.ThetaTransform(eps: float = 1e-06)[source]

Bases: Module

forward(z: Tensor) Tensor[source]
inverse(u: Tensor) Tensor[source]
class mxtaltools.crystal_building.crystal_latent_transforms.UnitToPMUnit(eps: float = 1e-06)[source]

Bases: Module

forward(z: Tensor) Tensor[source]
inverse(u: Tensor) Tensor[source]
class mxtaltools.crystal_building.crystal_latent_transforms.UnitTransform(max_z_prime: int = 1)[source]

Bases: Module

forward(niggli_params)[source]

Convert niggli parameters to uniform latent basis

inverse(std_params)[source]

Convert uniform latent basis to niggli space :param std_params: :return:

mxtaltools.crystal_building.crystal_latent_transforms.compute_niggli_overlap(a, al, b, be, c, ga)[source]
mxtaltools.crystal_building.crystal_latent_transforms.enforce_niggli_plane(cell_lengths, cell_angles, mode, eps=1e-06)[source]

enforces the condition ab * ga_cos + ac * be_cos + bc * al_cos >= 0 ‘mirror’ mode is for random samples, and symmetrically puts them on the correct side of the plane ‘shift’ mode shifts offending samples to the nearest boundary of the good plane

mxtaltools.crystal_building.crystal_latent_transforms.get_max_cos(a, b, c, eps=1e-06)[source]