.. raw:: html

  <p>
  <a href="https://badge.fury.io/py/dynasor"><img src="https://badge.fury.io/py/dynasor.svg" alt="PyPI" height="18"></a>
  <a href="https://anaconda.org/conda-forge/dynasor/"><img src="https://anaconda.org/conda-forge/dynasor/badges/version.svg" alt="Conda" height="18"></a>
  <a href="https://doi.org/10.5281/zenodo.10012241"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.10012241.svg" alt="zenodo" height="18"></a>
  </p>
  

dynasor -- Correlations for everyone
************************************

:program:`dynasor` is a tool for calculating total and partial dynamic structure factors as well as related :ref:`correlation functions <theory>` from molecular dynamics (MD) simulations.
Analysis of these functions enables one to access the dynamics of a system without resorting to perturbative approaches.
By combining in particular the structure factor with the cross sections (or form factors) of, e.g., neutrons, X-rays or electrons, it is also possible to directly predict experimental spectra.

Specifically **dynasor** can be used to calculate the following :ref:`quantities <correlation_functions>`:

* Partial and total dynamic structure factors, including the incoherent (or self) part
* Partial and total static structure factors
* Partial and total intermediate scattering functions
* Longitudinal and transverse, partial and total, current correlations
* Spectral energy densities

.. grid:: 3
   :gutter: 2

   .. grid-item-card:: Static correlation functions
      :link: tutorials/NiAl-neutron-and-Xray-weighting.html

      .. image:: _static/Ni3Al-disordered.png
         :alt: Static correlation function
         :width: 100%

   .. grid-item-card:: Dynamic correlation functions
      :link: tutorials/aluminum_solid_dynamic.html

      .. image:: _static/Ni3Al-current-correlation.png
         :alt: Dynamic correlation functions
         :width: 100%

   .. grid-item-card:: Mode projection
      :link: tutorials/mode_projection.html

      .. image:: _static/mode-projection.png
         :alt: Mode projection
         :width: 100%

The main input consists of a trajectory from a MD simulation, i.e., a file containing snapshots of the particle coordinates, and optionally velocities that correspond to consecutively and equally spaced points in (simulation) time.
The following snippet illustrates how one can calculate dynamic structure factors from such a trajectory ::

   traj = Trajectory('dump.xyz', trajectory_format='extxyz')
   q_points = get_spherical_qpoints(traj.cell, q_max=20)
   sample = compute_dynamic_structure_factors(traj, q_points=q_points, dt=5, window_size=100)
   sample.write_to_npz('test.npz')

.. note::

   For questions and help please use the `dynasor discussion forum on matsci.org <https://matsci.org/dynasor>`_.

   Please consult the :ref:`credits page <credits>` for information on how to cite :program:`dynasor`.

:program:`dynasor` has been developed at Chalmers University of Technology in Gothenburg, Sweden, in the `Condensed Matter and Materials Theory division <http://www.materialsmodeling.org>`_ at the Department of Physics.
:program:`dynasor` and its development are hosted on `gitlab <https://gitlab.com/materials-modeling/dynasor>`_.


.. toctree::
   :maxdepth: 1
   :hidden:

   get_started/index
   tutorials/index
   reference/index
   credits
   backmatter/index

