mixscatter


Namemixscatter JSON
Version 0.2.3 PyPI version JSON
download
home_pageNone
SummaryA versatile tool for calculating scattering functions of particle mixtures, particularly for small-angle scattering (SAS) or static and dynamic light scattering (SLS & DLS) applications.
upload_time2024-07-22 10:44:54
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords scattering small-angle scattering sas dynamic light scattering dls light scattering particle analysis particle mixture scattering functions form factors structure factors scattering experiments scientific computing scientific analysis scientific visualization physical chemistry materials science research tools data analysis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mixscatter

[![Python](https://img.shields.io/pypi/pyversions/mixscatter.svg)](https://badge.fury.io/py/mixscatter)
[![PyPI](https://badge.fury.io/py/mixscatter.svg)](https://badge.fury.io/py/mixscatter)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Test](https://github.com/joelmaier/mixscatter/actions/workflows/test.yml/badge.svg)](https://github.com/joelmaier/mixscatter/actions/workflows/test.yml)
[![Lint](https://github.com/joelmaier/mixscatter/actions/workflows/lint.yml/badge.svg)](https://github.com/joelmaier/mixscatter/actions/workflows/lint.yml)
[![Type Check](https://github.com/joelmaier/mixscatter/actions/workflows/type_check.yml/badge.svg)](https://github.com/joelmaier/mixscatter/actions/workflows/type_check.yml)
[![Docs](https://github.com/joelmaier/mixscatter/actions/workflows/docs.yml/badge.svg)](https://github.com/joelmaier/mixscatter/actions/workflows/docs.yml)
[![Nox](https://img.shields.io/badge/%F0%9F%A6%8A-Nox-D85E00.svg)](https://github.com/wntrblm/nox)


## Table of Contents
* [Overview](#overview)
* [Installation](#installation)
* [Documentation](#documentation)
* [Example Showcase](#example-showcase)
* [Contributing](#contributing)
* [License](#license)

## Overview

**mixscatter** is a pure python package for the calculation of scattering functions of
multi-component mixtures of interacting spherical scatterers in the Born approximation
([Rayleigh-Gans-Debye scattering](https://en.wikipedia.org/wiki/Rayleigh-Gans_approximation)).

Key Features:
* Calculation of scattering amplitudes, measurable intensities, form factors, structure factors, and diffusion coefficients.
* Flexible construction of systems with arbitrary compositions and complex scattering length density profiles.
* Suitable for researchers and developers working on particulate systems characterization.

Take a look at these publications if you are interested:

  - P. Salgi and R. Rajagopalan, "Polydispersity in colloids: implications to static structure and
   scattering", [Adv. Colloid Interface Sci. 43, 169-288 (1993)](
   https://doi.org/10.1016/0001-8686(93)80017-6)
  - A. Vrij, "Mixtures of hard spheres in the Percus–Yevick approximation. Light scattering at
    finite angles",  [J. Chem. Phys. 71, 3267-3270 (1979)](https://doi.org/10.1063/1.438756)
  - R. Botet, S. Kwok and B. Cabane, "Percus-Yevick structure factors made simple",
    [J. Appl. Cryst. 53, 1570-1582 (2020)](https://doi.org/10.1107/S1600576720014041)
  - J. Diaz Maier, K. Gaus and J. Wagner, "Measurable structure factors of dense dispersions
    containing polydisperse, optically inhomogeneous particles",
    [arXiv:2404.03470 [cond-mat.soft]](https://doi.org/10.48550/arXiv.2404.03470)

## Installation

**mixscatter** is available on the [Python Package Index (PyPI)](
https://pypi.org/project/mixscatter).

### Prerequisites

Ensure you have Python 3.10 or higher installed.

### Using pip

Install the package via pip:
```shell
pip install mixscatter
```
The source code is currently hosted on GitHub at: https://github.com/joelmaier/mixscatter

## Documentation

Find the documentation on GitHub Pages: https://joelmaier.github.io/mixscatter/

## Example Showcase

This example demonstrates the fundamental capabilities of **mixscatter**. For a comprehensive 
walk-through, refer to the
[Getting Started Guide](
https://joelmaier.github.io/mixscatter/getting_started/getting-started). 

Run this code to
produce the figure below.

```python
import numpy as np
import matplotlib.pyplot as plt

from mixscatter.mixture import Mixture
from mixscatter.scatteringmodel import SimpleCoreShell
from mixscatter.liquidstructure import PercusYevick
from mixscatter import (
    measurable_intensity,
    measurable_structure_factor,
    measurable_diffusion_coefficient
)

if __name__ == "__main__":
    plt.ion()
    plt.close("all")
    fig, ax = plt.subplots(3, 2, figsize=(6, 8), layout="constrained")

    # Initialize a particle mixture
    mixture = Mixture(radius=[100, 250], number_fraction=[0.4, 0.6])

    # Visualize mixture composition
    ax[0, 0].stem(mixture.radius, mixture.number_fraction)
    ax[0, 0].set_xlim(0, 300)
    ax[0, 0].set_ylim(-0.05, 1.05)
    ax[0, 0].set_xlabel("particle radius")
    ax[0, 0].set_ylabel("number fraction")

    # Provide a model for the optical properties of the system
    wavevector = np.linspace(1e-3, 7e-2, 1000)
    scattering_model = SimpleCoreShell(
        wavevector=wavevector,
        mixture=mixture,
        core_to_total_ratio=0.5,
        core_contrast=1.0,
        shell_contrast=0.5
    )

    # Visualize SLD profile
    distance = np.linspace(0, 350, 1000)
    for i, particle in enumerate(scattering_model.particles):
        profile = particle.get_profile(distance)
        ax[0, 1].plot(distance, profile, label=f"particle {i + 1}")
    ax[0, 1].set_xlim(0, 400)
    ax[0, 1].set_xlabel("distance from particle center")
    ax[0, 1].set_ylabel("scattering contrast")
    ax[0, 1].legend()

    # Visualize individual and average form factor(s)
    for i, form_factor in enumerate(scattering_model.single_form_factor):
        ax[1, 0].plot(wavevector, form_factor, label=f"particle {i + 1}")
    ax[1, 0].plot(
        wavevector, scattering_model.average_form_factor, label="average"
    )
    ax[1, 0].set_yscale("log")
    ax[1, 0].set_ylim(1e-6, 3e0)
    ax[1, 0].legend()
    ax[1, 0].set_xlabel("wavevector")
    ax[1, 0].set_ylabel("form factor")

    # Provide a model for the liquid structure
    liquid_structure = PercusYevick(
        wavevector=wavevector, mixture=mixture, volume_fraction_total=0.45
    )

    # Calculate the scattered intensity of the system
    intensity = measurable_intensity(liquid_structure, scattering_model)
    ax[1, 1].plot(wavevector, intensity)
    ax[1, 1].set_yscale("log")
    ax[1, 1].set_xlabel("wavevector")
    ax[1, 1].set_ylabel("intensity")

    # Calculate the experimentally obtainable, measurable structure factor
    structure_factor = measurable_structure_factor(
        liquid_structure, scattering_model
    )
    ax[2, 0].plot(wavevector, structure_factor)
    ax[2, 0].set_xlabel("wavevector")
    ax[2, 0].set_ylabel("structure factor")

    # Calculate the effective Stokes-Einstein diffusion coefficient
    # which would be obtained from a cumulant analysis in
    # dynamic light scattering
    diffusion_coefficient = measurable_diffusion_coefficient(
        scattering_model, thermal_energy=1.0, viscosity=1.0 / (6.0 * np.pi)
    )
    # Visualize the apparent hydrodynamic radius, which is
    # proportional to 1/diffusion_coefficient
    ax[2, 1].plot(wavevector, 1 / diffusion_coefficient)
    ax[2, 1].set_xlabel("wavevector")
    ax[2, 1].set_ylabel("apparent hydrodynamic radius")

    fig.savefig("simple_example_figure.png", dpi=300)
```

![Example Figure](https://raw.githubusercontent.com/joelmaier/mixscatter/main/examples/simple_example_figure.png "Example figure")

## Contributing

Contributions are welcome! If you find any bugs or want to request features, 
feel free to get in touch or create an issue.

## License

This project is licensed under the MIT License - see the [LICENSE](
https://raw.githubusercontent.com/joelmaier/mixscatter/main/LICENSE) file for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mixscatter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "scattering, small-angle scattering, SAS, dynamic light scattering, DLS, light scattering, particle analysis, particle mixture, scattering functions, form factors, structure factors, scattering experiments, scientific computing, scientific analysis, scientific visualization, physical chemistry, materials science, research tools, data analysis",
    "author": null,
    "author_email": "Joel Diaz Maier <joel.diazmaier@gmail.de>",
    "download_url": "https://files.pythonhosted.org/packages/03/6d/5ac61eee8e6c132bf57ced8ae3b2da5f6f58acfb5beac7a38b8c3753ca82/mixscatter-0.2.3.tar.gz",
    "platform": null,
    "description": "# mixscatter\n\n[![Python](https://img.shields.io/pypi/pyversions/mixscatter.svg)](https://badge.fury.io/py/mixscatter)\n[![PyPI](https://badge.fury.io/py/mixscatter.svg)](https://badge.fury.io/py/mixscatter)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![Test](https://github.com/joelmaier/mixscatter/actions/workflows/test.yml/badge.svg)](https://github.com/joelmaier/mixscatter/actions/workflows/test.yml)\n[![Lint](https://github.com/joelmaier/mixscatter/actions/workflows/lint.yml/badge.svg)](https://github.com/joelmaier/mixscatter/actions/workflows/lint.yml)\n[![Type Check](https://github.com/joelmaier/mixscatter/actions/workflows/type_check.yml/badge.svg)](https://github.com/joelmaier/mixscatter/actions/workflows/type_check.yml)\n[![Docs](https://github.com/joelmaier/mixscatter/actions/workflows/docs.yml/badge.svg)](https://github.com/joelmaier/mixscatter/actions/workflows/docs.yml)\n[![Nox](https://img.shields.io/badge/%F0%9F%A6%8A-Nox-D85E00.svg)](https://github.com/wntrblm/nox)\n\n\n## Table of Contents\n* [Overview](#overview)\n* [Installation](#installation)\n* [Documentation](#documentation)\n* [Example Showcase](#example-showcase)\n* [Contributing](#contributing)\n* [License](#license)\n\n## Overview\n\n**mixscatter** is a pure python package for the calculation of scattering functions of\nmulti-component mixtures of interacting spherical scatterers in the Born approximation\n([Rayleigh-Gans-Debye scattering](https://en.wikipedia.org/wiki/Rayleigh-Gans_approximation)).\n\nKey Features:\n* Calculation of scattering amplitudes, measurable intensities, form factors, structure factors, and diffusion coefficients.\n* Flexible construction of systems with arbitrary compositions and complex scattering length density profiles.\n* Suitable for researchers and developers working on particulate systems characterization.\n\nTake a look at these publications if you are interested:\n\n  - P. Salgi and R. Rajagopalan, \"Polydispersity in colloids: implications to static structure and\n   scattering\", [Adv. Colloid Interface Sci. 43, 169-288 (1993)](\n   https://doi.org/10.1016/0001-8686(93)80017-6)\n  - A. Vrij, \"Mixtures of hard spheres in the Percus\u2013Yevick approximation. Light scattering at\n    finite angles\",  [J. Chem. Phys. 71, 3267-3270 (1979)](https://doi.org/10.1063/1.438756)\n  - R. Botet, S. Kwok and B. Cabane, \"Percus-Yevick structure factors made simple\",\n    [J. Appl. Cryst. 53, 1570-1582 (2020)](https://doi.org/10.1107/S1600576720014041)\n  - J. Diaz Maier, K. Gaus and J. Wagner, \"Measurable structure factors of dense dispersions\n    containing polydisperse, optically inhomogeneous particles\",\n    [arXiv:2404.03470 [cond-mat.soft]](https://doi.org/10.48550/arXiv.2404.03470)\n\n## Installation\n\n**mixscatter** is available on the [Python Package Index (PyPI)](\nhttps://pypi.org/project/mixscatter).\n\n### Prerequisites\n\nEnsure you have Python 3.10 or higher installed.\n\n### Using pip\n\nInstall the package via pip:\n```shell\npip install mixscatter\n```\nThe source code is currently hosted on GitHub at: https://github.com/joelmaier/mixscatter\n\n## Documentation\n\nFind the documentation on GitHub Pages: https://joelmaier.github.io/mixscatter/\n\n## Example Showcase\n\nThis example demonstrates the fundamental capabilities of **mixscatter**. For a comprehensive \nwalk-through, refer to the\n[Getting Started Guide](\nhttps://joelmaier.github.io/mixscatter/getting_started/getting-started). \n\nRun this code to\nproduce the figure below.\n\n```python\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom mixscatter.mixture import Mixture\nfrom mixscatter.scatteringmodel import SimpleCoreShell\nfrom mixscatter.liquidstructure import PercusYevick\nfrom mixscatter import (\n    measurable_intensity,\n    measurable_structure_factor,\n    measurable_diffusion_coefficient\n)\n\nif __name__ == \"__main__\":\n    plt.ion()\n    plt.close(\"all\")\n    fig, ax = plt.subplots(3, 2, figsize=(6, 8), layout=\"constrained\")\n\n    # Initialize a particle mixture\n    mixture = Mixture(radius=[100, 250], number_fraction=[0.4, 0.6])\n\n    # Visualize mixture composition\n    ax[0, 0].stem(mixture.radius, mixture.number_fraction)\n    ax[0, 0].set_xlim(0, 300)\n    ax[0, 0].set_ylim(-0.05, 1.05)\n    ax[0, 0].set_xlabel(\"particle radius\")\n    ax[0, 0].set_ylabel(\"number fraction\")\n\n    # Provide a model for the optical properties of the system\n    wavevector = np.linspace(1e-3, 7e-2, 1000)\n    scattering_model = SimpleCoreShell(\n        wavevector=wavevector,\n        mixture=mixture,\n        core_to_total_ratio=0.5,\n        core_contrast=1.0,\n        shell_contrast=0.5\n    )\n\n    # Visualize SLD profile\n    distance = np.linspace(0, 350, 1000)\n    for i, particle in enumerate(scattering_model.particles):\n        profile = particle.get_profile(distance)\n        ax[0, 1].plot(distance, profile, label=f\"particle {i + 1}\")\n    ax[0, 1].set_xlim(0, 400)\n    ax[0, 1].set_xlabel(\"distance from particle center\")\n    ax[0, 1].set_ylabel(\"scattering contrast\")\n    ax[0, 1].legend()\n\n    # Visualize individual and average form factor(s)\n    for i, form_factor in enumerate(scattering_model.single_form_factor):\n        ax[1, 0].plot(wavevector, form_factor, label=f\"particle {i + 1}\")\n    ax[1, 0].plot(\n        wavevector, scattering_model.average_form_factor, label=\"average\"\n    )\n    ax[1, 0].set_yscale(\"log\")\n    ax[1, 0].set_ylim(1e-6, 3e0)\n    ax[1, 0].legend()\n    ax[1, 0].set_xlabel(\"wavevector\")\n    ax[1, 0].set_ylabel(\"form factor\")\n\n    # Provide a model for the liquid structure\n    liquid_structure = PercusYevick(\n        wavevector=wavevector, mixture=mixture, volume_fraction_total=0.45\n    )\n\n    # Calculate the scattered intensity of the system\n    intensity = measurable_intensity(liquid_structure, scattering_model)\n    ax[1, 1].plot(wavevector, intensity)\n    ax[1, 1].set_yscale(\"log\")\n    ax[1, 1].set_xlabel(\"wavevector\")\n    ax[1, 1].set_ylabel(\"intensity\")\n\n    # Calculate the experimentally obtainable, measurable structure factor\n    structure_factor = measurable_structure_factor(\n        liquid_structure, scattering_model\n    )\n    ax[2, 0].plot(wavevector, structure_factor)\n    ax[2, 0].set_xlabel(\"wavevector\")\n    ax[2, 0].set_ylabel(\"structure factor\")\n\n    # Calculate the effective Stokes-Einstein diffusion coefficient\n    # which would be obtained from a cumulant analysis in\n    # dynamic light scattering\n    diffusion_coefficient = measurable_diffusion_coefficient(\n        scattering_model, thermal_energy=1.0, viscosity=1.0 / (6.0 * np.pi)\n    )\n    # Visualize the apparent hydrodynamic radius, which is\n    # proportional to 1/diffusion_coefficient\n    ax[2, 1].plot(wavevector, 1 / diffusion_coefficient)\n    ax[2, 1].set_xlabel(\"wavevector\")\n    ax[2, 1].set_ylabel(\"apparent hydrodynamic radius\")\n\n    fig.savefig(\"simple_example_figure.png\", dpi=300)\n```\n\n![Example Figure](https://raw.githubusercontent.com/joelmaier/mixscatter/main/examples/simple_example_figure.png \"Example figure\")\n\n## Contributing\n\nContributions are welcome! If you find any bugs or want to request features, \nfeel free to get in touch or create an issue.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](\nhttps://raw.githubusercontent.com/joelmaier/mixscatter/main/LICENSE) file for details.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A versatile tool for calculating scattering functions of particle mixtures, particularly for small-angle scattering (SAS) or static and dynamic light scattering (SLS & DLS) applications.",
    "version": "0.2.3",
    "project_urls": {
        "Documentation": "https://joelmaier.github.io/mixscatter",
        "Repository": "https://github.com/joelmaier/mixscatter"
    },
    "split_keywords": [
        "scattering",
        " small-angle scattering",
        " sas",
        " dynamic light scattering",
        " dls",
        " light scattering",
        " particle analysis",
        " particle mixture",
        " scattering functions",
        " form factors",
        " structure factors",
        " scattering experiments",
        " scientific computing",
        " scientific analysis",
        " scientific visualization",
        " physical chemistry",
        " materials science",
        " research tools",
        " data analysis"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "835322863013b8a1798fed117dead7afc13a93f9b583c241f52698e619589c00",
                "md5": "deb4a6be257b521037aad0e38edbcd9a",
                "sha256": "de6fa5766bba96c74689ba6ab9c59cc1c8e431a2112793e1fdbebfa11fb4cb4a"
            },
            "downloads": -1,
            "filename": "mixscatter-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "deb4a6be257b521037aad0e38edbcd9a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 21426,
            "upload_time": "2024-07-22T10:44:51",
            "upload_time_iso_8601": "2024-07-22T10:44:51.810618Z",
            "url": "https://files.pythonhosted.org/packages/83/53/22863013b8a1798fed117dead7afc13a93f9b583c241f52698e619589c00/mixscatter-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "036d5ac61eee8e6c132bf57ced8ae3b2da5f6f58acfb5beac7a38b8c3753ca82",
                "md5": "096cb156836e6c0aa5e6e7cde45e30b2",
                "sha256": "fd59c0b2303cd019bff693d9ab4885d549daefdd54b01663edefabe277c1656d"
            },
            "downloads": -1,
            "filename": "mixscatter-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "096cb156836e6c0aa5e6e7cde45e30b2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 25279,
            "upload_time": "2024-07-22T10:44:54",
            "upload_time_iso_8601": "2024-07-22T10:44:54.784224Z",
            "url": "https://files.pythonhosted.org/packages/03/6d/5ac61eee8e6c132bf57ced8ae3b2da5f6f58acfb5beac7a38b8c3753ca82/mixscatter-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-22 10:44:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "joelmaier",
    "github_project": "mixscatter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mixscatter"
}
        
Elapsed time: 0.31274s