Skip to content

Small-Angle X-ray Scattering (SAXS)

This module contains functions to compute the SAXS spectrum starting from the atomic positions (and chemical species).

snow.descriptors.saxs

thomson(element, q)

Computes the Thomson part of the atomic form factor at given exchanged momentum using the Cromer-Mann approximation

Parameters:

Name Type Description Default
element str

Symbol of the chemical species

required
q float

Magnitude of exchanged momentum

required

Returns:

Name Type Description
f float

Atomic form factor for the element at given exchanged momentum

Source code in snow/descriptors/saxs.py
def thomson(element: str ,q : float):
    """
    Computes the Thomson part of the atomic form factor at given exchanged
    momentum using the Cromer-Mann approximation

    Parameters
    ----------
    element : str
        Symbol of the chemical species
    q : float
        Magnitude of exchanged momentum

    Returns
    -------
    f : float 
        Atomic form factor for the element at given exchanged momentum
    """
    coeffs=cm_coeffs[element]
    f = coeffs['c']
    for a,b in zip(coeffs["a"],coeffs["b"]):
        f += a*np.exp(-b*(q/4/np.pi)**2)
    return f

iq_from_dist_mat(species, q, dist_mat)

Computes the SAXS spectrum for a set of points from its distance matrix.

Parameters:

Name Type Description Default
species list[strings]

The list with species of the atoms

required
q float

Magnitude of exchanged momentum

required
dist_mat float

Matrix of distances of the atoms, can be computed with snow.utils.distance_matrix

required

Returns:

Name Type Description
iq float

Intensity of SAXS for the considered system, at given exchanged momentum

Source code in snow/descriptors/saxs.py
def iq_from_dist_mat(species: list ,q : float ,dist_mat : np.ndarray):
    """
    Computes the SAXS spectrum for a set of points from its distance matrix.

    Parameters
    ----------
    species : list[strings]
        The list with species of the atoms
    q : float
        Magnitude of exchanged momentum
    dist_mat : float
        Matrix of distances of the atoms, can be computed with `snow.utils.distance_matrix`

    Returns
    -------
    iq : float 
        Intensity of SAXS for the considered system, at given exchanged momentum
    """
    iq = 0.0
    factors = np.zeros((len(species),len(species)))
    for i in range(len(species)):
        for j in range(len(species)):
            factors[i,j] = thomson(species[i],q)*thomson(species[j],q)
    ds = dist_mat.flatten()
    factors = factors.flatten()
    ds = [np.sinc(d*q/np.pi) for d in ds]
    iq = np.dot(factors,ds)
    return iq

iq_from_pddf(element_i, element_j, q, dists, counts, nat=0)

Computes thes SAXS spectrum from a PDDF.

Carfeul: if the bin at distance 0 is not included, nat must be manually set, otherwise set at 0

Parameters:

Name Type Description Default
element_i str

Name of the chemical species of atoms i

required
element_j str

Name of the chemical species of atoms j

required
nat int

Number of atoms (only set if element_i == element_j)

0
q float

Magnitude of exchanged momentum

required
dists list[float]

Central values of the bins of the PDDF

required
counts list

Values of PDDF at the bins

required

Returns:

Name Type Description
intensity float

Intensity of SAXS for the considered system, at given exchanged momentum

Source code in snow/descriptors/saxs.py
def iq_from_pddf(element_i: str,element_j : str,q :float,
            dists:list ,counts:list ,nat:int =0):
    """
    Computes thes SAXS spectrum from a PDDF.

    Carfeul: if the bin at distance 0 is not included, nat must be
    manually set, otherwise set at 0

    Parameters
    ----------
    element_i : str
        Name of the chemical species of atoms i
    element_j : str
        Name of the chemical species of atoms j
    nat : int
        Number of atoms (only set if element_i == element_j)
    q : float
        Magnitude of exchanged momentum
    dists : list[float]
        Central values of the bins of the PDDF
    counts: list[float]
        Values of PDDF at the bins

    Returns
    -------
    intensity : float 
        Intensity of SAXS for the considered system, at given exchanged momentum

    """
    fi = thomson(element_i,q)
    fj = fi if element_j == element_i else thomson(element_j,q)
    intensity = 0.0
    for dist,count in zip(dists,counts):
        intensity += 2* count * np.sinc(q*dist/np.pi)
    intensity *=  fi*fj
    if element_i == element_j:
        intensity += nat * fi**2
    return intensity