[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://gitlab.com/dynadevgroup/Dyna/-/graphs/main/charts)
[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)
[![GIT](https://img.shields.io/badge/development-GIT-green.svg)](https://gitlab.com/dynadevgroup/Dyna)
[![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-31010/)

This is Dyna development files for the 4.09 version 

"Dynamic x-ray reflectivity off- or on-resonant regime for isotropic,
 magnetic and anisotropic (multi)layer simulations and refinements Program"

<!-- ABOUT THE PROJECT -->
## About The Project

Dyna is a simulation program for reflectivity and transmittance of x-rays and optics, aimed at determining structural, magnetic and electronic stackings in ultrathin multilayers.

Among so many programs in the field, Dyna has several specificities : it includes anomalous, magnetic and anisotropic components in the index of refraction; it simulates reflectivities either versus angle, or versus x-ray energy, with arbitrary incident and out-going polarizations; it simulates Kerr and Faraday spectra, and transmittance through thin layers.

All the simulations can be simultaneously fitted against one model.

The program integrates a toolbox to create charge and magnetic factors from tables.

Dyna was also designed for pedagogical aims, making easy to slide parameters for on-the-fly effects.

Dyna is an on-going free and open-source project, under Python + Qt, or Matlab environments. Dyna can also be freely downloaded, and support is offered to users upon reasonable request.

Copyright Institut Neel, CNRS, Grenoble, France

### Project Collaborators:

* Stéphane Grenier, stephane.grenier@neel.cnrs.fr
* Jean-Marc Tonnerre, jean-marc.tonnerre@neel.cnrs.fr
* Nicolas Jaouen Sextants beamline, Synchrotron Soleil, nicolas.jaouen@synchrotron-soleil.fr 
* Emmanuelle Jal (PhD, 2010-2013) now at LCPMR CNRS, Paris https://lcpmr.cnrs.fr/content/emmanuelle-jal              
* Valentin Chardonnet (PhD) - Emmanuelle Jal's group (LCPMR, Sorbonne Université, Paris)
* Marta Elzo (PhD, 2009-2012)
* Ingrid Hallsteinsen - Padraic Shaffer’s group - Berkeley Nat. Lab.
* Daniel Schick Max-Born-Institute for nonlinear optics and short pulse spectroscopy im Forschungsverbund Berlin e.V.

Questions to: 

Stéphane Grenier, stephane.grenier@neel.cnrs.fr

### Installation

pip install dyna

### Development install

git clone https://gitlab.com/dynadevgroup/Dyna
cd Dyna
pip install -e .
dyna

### Features

* magnetic-sensitive susceptibility, arbitrary magnetic moment direction described by Euler angles, with the limitation of neglictible spin-orbit coupling in the valence states
* anisotropic susceptibility, in the limitation of an uniaxial symmetry along the depth of the film, for the simulation of oriented molecules or orbitally ordered films (not in python code yet)
* structural and magnetic sensitive transmittance.
* Angular/Q scans
* Energy spectra at fix angle or fix Q
* Polarization Analysis, in and out
* Refinement in user-defined interval, with limits on parameters, and constrains between parameters
* Multifit : one system is refined by simultaneous simulations of various data (angle and energy scans, of any polarization, energy or angle configurations).
* Calculates Scattering Factors from Tables
* Calculates Kerr MO rotation and ellipticities, providing that the angles are small, validity to be checked case by case
* (Python Only) Scriptable
* (Matlab only) Genetic Algorithm (requires Optimization Toolbox)

### Testing
Integration tests are to be found in the tests folder.
Testing is done with pytest, it needs packages listed in tests/requirements_tests.txt. Mainly : pytest, pytest-qt and pytest-env. 
To launch all integration tests first activate the Dyna's python environement and then in the terminal do: 

    pytest tests/
These tests mimic common user actions on the interface in order to check a basic minimum viability. 
As not all functionality is available, some tests have been written but are set to be skipped. 

Documentations:

https://pydyna.readthedocs.io