Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scatter

License: MIT

scatter is a small Python package for converting between a radial distribution function g(r) and a static structure factor S(k).

The API is intentionally linear:

  1. provide two arrays,
  2. optionally preprocess the signal,
  3. run the transform.

No hidden state is kept between steps.

Install

git clone https://github.com/vojtechkostal/scatter
cd ./scatter
python -m pip install -e .

RDF to Structure Factor

import numpy as np
import scatter

r, g = np.loadtxt("data/Ar-gr.dat", unpack=True)

# Preprocessing returns the centered signal h(r) = g(r) - 1.
r, h = scatter.preprocess(
    r,
    g,
    smooth=1e-4,
    pad=10_000,
    taper_start=9.0,
    taper_width=1.0,
)

k, s = scatter.structure_factor(
    r,
    h,
    density=1e-3,
    k_max=10.0,
    points=1000,
    centered=True,
)

Structure Factor to RDF

import numpy as np
import scatter

k, s_minus_1 = np.loadtxt("data/KCl-Sk.dat", usecols=(0, 1), unpack=True)

k, delta_s = scatter.preprocess(
    k,
    s_minus_1,
    reference=None,
    smooth=1.5e-4,
    pad=1000,
    taper_start=9.0,
    taper_width=1.0,
)

r, g = scatter.radial_distribution(
    k,
    delta_s,
    density=1.0,
    r_max=10.0,
    points=1000,
    centered=True,
)

If your input is already clean, call the transforms directly:

k, s = scatter.structure_factor(r, g, density=1.0)
r, g = scatter.radial_distribution(k, s, density=1.0)

Use centered=True only when the values are already g(r) - 1 or S(k) - 1. Choose density in units consistent with your r and k grids.

Transform Conventions

scatter uses direct sine integrals with explicit normalization:

$$ S(k) = 1 + 4 \pi \rho \int \mathrm{d}r\ r^2 \left[ g(r) - 1 \right] \mathrm{sinc}\left(\frac{k r}{\pi}\right) $$

$$ g(r) = 1 + \frac{1}{2 \pi^2 \rho} \int \mathrm{d}k\ k^2 \left[ S(k) - 1 \right] \mathrm{sinc} \left( \frac{k r}{\pi} \right) $$

where $\rho$ is the number density and $$\mathrm{sinc}(x) = \frac{\sin(\pi x)}{\pi x}.$$

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages