Skip to content

nanoMLMS/saxyz.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

saxyz.jl

A Small Angle X-Ray Scattering (SAXS) calculator from coordinate files such as XYZ in Julia.

Introduction

This Julia package is built to compute the X-ray scattering response of atomic clusters at small angles (SAXS). To do so, the Debye formula is utilized:

$$ I(q) = \sum_i^N \sum_j^N f_i(q,E) f_j^*(q,E) \frac{\text{sin}(q r_{ij})}{q r_{ij}} $$

where f are atomic form factors, q is the magnitude of transferred momentum and $r_{ij}$ is the distance of atom $i$ to atom $j$.

Functions to parse xyz/extxyz files are provided, yet at its core the code only requires atomic coordinates and the corresponding chemical species - you can use any other code to obtain them and feed those to the desired functions.

For large systems, and statistical ensembles , it is more useful to evaluate Debye's formula starting from the Pair Distance Distribution Function (PDDF) which indicates , on average, how many atoms are at a certain distance. Debye's formula becomes:

$$ I(q) = \sum_{(i,j)\in C}\int_0^R f_i(q,E) f_j^*(q,E) p^{(2)}_{ij}(r) \frac{\text{sin}(q r)}{q r} dr $$

where $p^{(2)}_{ij}(r)$ is the PDDF for chemical species $i,j$, and the sum runs over all combinations of atomic species.

Model

The atomic form factors can be written as:

$$ f(q,E) = f(q) + f_1(E) + if_2(E) $$

They contain :

  1. A part dependent on transferred momentum q , deriving from Thomson scattering
  2. A part dependent on the energy of the incoming X-ray , or resonant part

The momentum dependent contribution is written using the Cromer-Mann parametrization:

$$ f(q) = \sum_{i=1}^{4} a_i \exp\left(-b_i \left( \frac{q}{4\pi} \right)^2 \right) + c $$

Where the a,b and c are empirical parameters.

Installation

saxyz.jl is now packaged as a Julia package. You can now run it by:

using Pkg
Pkg.activate("PATH/TO/SAXYZ-JL/saxyz.jl/saxyz")

To import the calcolator as a regular package, you have to include the saxyz.jl folder to the JULIA_LOAD_PATH environment variable.

export JULIA_LOAD_PATH="/PATH/TO/saxyz.jl:$JULIA_LOAD_PATH"

Then, in Julia scripts run

using saxyz

Parallelization

saxyz.jl can be multithreaded by splitting the calculations for the required exchanged momenta in chunks. Given an arrays $qs$ of momenta magnitude, run:

saxyz.parallel_I_q_1D(qs,atoms,types,f_res)

It will use all threads available to the Julia session.

Fitting utilities

A python library to fit spectra is provided including Porod's and Guinier's laws.

License

This code is released under an MIT license. Please acknowledge nanoMLMS @ University of Milan if you use this code in your work.

Notes

Units used are : KeV for energies , Angstrom for distances , Angstrom -1 for momenta.

References

About

A Small Angle X-Ray Scattering (SAXS) calculator from coordinate files such as XYZ.

Resources

License

Stars

Watchers

Forks

Packages

No packages published