Skip to main content

PyTorch-based implementation of pygidSIM package for calculating GIWAXS patterns

Project description

pygidSIM_torch

pygidSIM_torch calculates GIWAXS patterns from crystal structure descriptions. It is a PyTorch-based implementation of the pygidSIM package.

pygidSIM_torch

Installation

Install from PyPI

pip install pygidsim_torch

Install from source

First, clone the repository:

git clone https://github.com/MishaRomodin/pygidSIM_torch.git

Then, to install all required modules, navigate to the cloned directory and execute:

cd pygidSIM_torch
pip install -e .

Development Installation

For development and testing, install with development dependencies:

pip install -e .[dev]

Testing

The project uses pytest for testing. To run the test suite:

# Run all tests
pytest

# Run tests with coverage report
pytest --cov=pygidsim_torch --cov-report=html

# Run tests in parallel
pytest -n auto

Usage

From CIF

Not implemented yet.

Crystal description

To calculate a GIWAXS pattern from your own description, use the following example:

import torch
from pygidsim_torch.experiment import ExpParameters
from pygidsim_torch.giwaxs_sim import GIWAXS, Crystal
from pygidsim_torch.directions import get_mi

params = ExpParameters(
    q_xy_range=torch.tensor([0, 2.7]),
    q_z_range=torch.tensor([0, 3.5]),
    en=18000
)  # experimental parameters

# lattice parameters [a, b, c, α, β, γ]
lat_par = torch.tensor([6.3026, 6.3026, 6.3026, 90., 90., 90.], dtype=torch.float32)
mi = get_mi(min_index=-6, max_index=6)  # Miller indices

cr = Crystal(lat_par)
el = GIWAXS(cr, params, mi)
q_2d, q_mask = el.giwaxs_sim()

To add crystal rotation, use the argument orientation with the value "random" or a Tensor containing the corresponding Miller indices [hkl]:

q_2d, q_mask = el.giwaxs_sim(orientation='random')

q_2d, q_mask = el.giwaxs_sim(orientation=torch.tensor([2., 0., 1.]))

For multiple structures, the lattice parameters tensor should have shape (n_structures, 6).

The orientation tensor should have shape (n_structures, 3) or (3,) in case of same orientations for all samples.

Citation

If you use this package in your research, please cite it as follows:

Romodin, M., Starostin, V., Lapkin, D., Hinderhofer, A., & Schreiber, F. (2025).
mlgid-project/pygidSIM: v0.1.1. Zenodo. https://doi.org/10.5281/zenodo.17609569

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygidsim_torch-0.1.2.tar.gz (51.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygidsim_torch-0.1.2-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

Details for the file pygidsim_torch-0.1.2.tar.gz.

File metadata

  • Download URL: pygidsim_torch-0.1.2.tar.gz
  • Upload date:
  • Size: 51.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for pygidsim_torch-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6765c3a4e0908b59ef9d4e76018bba11c11defad4fcb28354ae9a28fbd0f8494
MD5 6bfb0a7fce2210e7eac3f4c8f9662f95
BLAKE2b-256 44323dedeab78071ddefbfa9e9de231f74180f3fe28ce4f44d9c1d78c78e24a7

See more details on using hashes here.

File details

Details for the file pygidsim_torch-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pygidsim_torch-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for pygidsim_torch-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d69cbfa412be8a58d781208a897585ddfbefb0a40f57cba293bda031601f2c48
MD5 7138dc5c13221471daa7d3b15971e925
BLAKE2b-256 b7e5657edd76449d0a7e29a6906dcf05d16dc3091329fdf87cfd9c4c83c1351d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page