spyndynamica 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spyndynamica-0.1.0/LICENSE +98 -0
- spyndynamica-0.1.0/PKG-INFO +92 -0
- spyndynamica-0.1.0/README.md +64 -0
- spyndynamica-0.1.0/pyproject.toml +40 -0
- spyndynamica-0.1.0/setup.cfg +4 -0
- spyndynamica-0.1.0/spyndynamica/__init__.py +319 -0
- spyndynamica-0.1.0/spyndynamica/_local.py +257 -0
- spyndynamica-0.1.0/spyndynamica/algebras.py +275 -0
- spyndynamica-0.1.0/spyndynamica/analysis.py +128 -0
- spyndynamica-0.1.0/spyndynamica/backend.py +126 -0
- spyndynamica-0.1.0/spyndynamica/data/isotopes.json +928 -0
- spyndynamica-0.1.0/spyndynamica/data/orientations.npz +0 -0
- spyndynamica-0.1.0/spyndynamica/dynamics.py +735 -0
- spyndynamica-0.1.0/spyndynamica/ensembles.py +120 -0
- spyndynamica-0.1.0/spyndynamica/exchange.py +322 -0
- spyndynamica-0.1.0/spyndynamica/graphics.py +312 -0
- spyndynamica-0.1.0/spyndynamica/groups.py +269 -0
- spyndynamica-0.1.0/spyndynamica/interactions.py +84 -0
- spyndynamica-0.1.0/spyndynamica/liouville.py +558 -0
- spyndynamica-0.1.0/spyndynamica/operators.py +401 -0
- spyndynamica-0.1.0/spyndynamica/rotations.py +395 -0
- spyndynamica-0.1.0/spyndynamica/signals.py +554 -0
- spyndynamica-0.1.0/spyndynamica/states.py +226 -0
- spyndynamica-0.1.0/spyndynamica/system.py +680 -0
- spyndynamica-0.1.0/spyndynamica/tensors.py +79 -0
- spyndynamica-0.1.0/spyndynamica.egg-info/PKG-INFO +92 -0
- spyndynamica-0.1.0/spyndynamica.egg-info/SOURCES.txt +28 -0
- spyndynamica-0.1.0/spyndynamica.egg-info/dependency_links.txt +1 -0
- spyndynamica-0.1.0/spyndynamica.egg-info/requires.txt +9 -0
- spyndynamica-0.1.0/spyndynamica.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alexej Jerschow
|
|
4
|
+
|
|
5
|
+
Spynach is a Python reimplementation of the Spinach spin dynamics kernel
|
|
6
|
+
(https://spindynamics.org); its `easyspyn` package is a reimplementation of
|
|
7
|
+
EasySpin (https://easyspin.org); its `ctps` package is a port of the
|
|
8
|
+
author's earlier MATLAB (CCCP.m) and C++ (CCCP++) programs for coherence
|
|
9
|
+
pathway selection; its `spyndynamica` package is a port of SpinDynamica
|
|
10
|
+
(https://www.spindynamica.soton.ac.uk). This licence derives from the MIT
|
|
11
|
+
licences of Spinach (Ilya Kuprov) and EasySpin (Stefan Stoll and other
|
|
12
|
+
contributors); both notices are reproduced below, followed by the terms of
|
|
13
|
+
use of SpinDynamica.
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
Spinach
|
|
35
|
+
=======
|
|
36
|
+
|
|
37
|
+
The sources, tests, molecule data, isotope table, spherical grids and
|
|
38
|
+
example scripts of Spynach were written by reading and translating Spinach. Spinach is distributed under the MIT License with the following
|
|
39
|
+
notice, which is reproduced here as that licence requires and must be kept
|
|
40
|
+
with any copy or substantial portion of this software.
|
|
41
|
+
|
|
42
|
+
Copyright (c) 2005-2025 ILYA KUPROV
|
|
43
|
+
|
|
44
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
45
|
+
|
|
46
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
47
|
+
|
|
48
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
EasySpin
|
|
52
|
+
========
|
|
53
|
+
|
|
54
|
+
The `easyspyn` package (src/easyspyn), its tests and its isotope table were
|
|
55
|
+
written by reading and translating EasySpin (https://easyspin.org), which
|
|
56
|
+
is distributed under the MIT License with the following notice, reproduced
|
|
57
|
+
here as that licence requires and to be kept with any copy or substantial
|
|
58
|
+
portion of this software.
|
|
59
|
+
|
|
60
|
+
Copyright (c) 2006-2024 Stefan Stoll and other contributors
|
|
61
|
+
|
|
62
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
63
|
+
|
|
64
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
65
|
+
|
|
66
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
SpinDynamica
|
|
70
|
+
============
|
|
71
|
+
|
|
72
|
+
The `spyndynamica` package (src/spyndynamica), its tests and its reference
|
|
73
|
+
data were written by reading SpinDynamica (Malcolm H. Levitt and
|
|
74
|
+
co-authors, https://www.spindynamica.soton.ac.uk), following its
|
|
75
|
+
conventions and comparing with results computed by it. No SpinDynamica
|
|
76
|
+
source code is included. SpinDynamica names no formal licence; its terms of
|
|
77
|
+
use (https://www.spindynamica.soton.ac.uk/about/termsofuse/) state that
|
|
78
|
+
SpinDynamica is open-source and freely available for use, and ask that
|
|
79
|
+
published work cite
|
|
80
|
+
|
|
81
|
+
C. Bengs, M. H. Levitt, "SpinDynamica: Symbolic and numerical magnetic
|
|
82
|
+
resonance in a Mathematica environment", Magn. Reson. Chem. (2017),
|
|
83
|
+
doi:10.1002/mrc.4642,
|
|
84
|
+
|
|
85
|
+
and that the authors of any add-on used be credited as well. Work that uses
|
|
86
|
+
`spyndynamica` should cite that publication. Keep this notice with any copy
|
|
87
|
+
or substantial portion of the `spyndynamica` package.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
Use of AI in the translation
|
|
91
|
+
============================
|
|
92
|
+
|
|
93
|
+
The translation of Spinach from MATLAB to Python was carried out largely by
|
|
94
|
+
an AI coding agent (Claude, Anthropic) working under the direction of
|
|
95
|
+
Alexej Jerschow, who set the goals, reviewed the results and holds the
|
|
96
|
+
copyright above. Commits made by the agent are marked as such in the git
|
|
97
|
+
history. Correctness rests on the test suite, which compares Spynach with
|
|
98
|
+
reference data computed by Spinach, not on the method of authorship.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spyndynamica
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: SpinDynamica in Python (SpynDynamica): symbolic and numerical spin dynamics for NMR
|
|
5
|
+
Author: Alexej Jerschow
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://ajerschow.github.io/spynach/
|
|
8
|
+
Project-URL: Documentation, https://github.com/ajerschow/spynach/blob/main/docs/spyndynamica.md
|
|
9
|
+
Project-URL: Source, https://github.com/ajerschow/spynach
|
|
10
|
+
Project-URL: Changelog, https://github.com/ajerschow/spynach/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: NMR,spin dynamics,SpinDynamica,product operators,symbolic,simulation
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: numpy>=1.26
|
|
21
|
+
Requires-Dist: scipy>=1.11
|
|
22
|
+
Requires-Dist: sympy>=1.12
|
|
23
|
+
Provides-Extra: plot
|
|
24
|
+
Requires-Dist: plotly>=6; extra == "plot"
|
|
25
|
+
Provides-Extra: test
|
|
26
|
+
Requires-Dist: pytest>=8; extra == "test"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# SpynDynamica: SpinDynamica in Python
|
|
30
|
+
|
|
31
|
+
A Python port of [SpinDynamica](https://www.spindynamica.soton.ac.uk) 3.10.2, the Mathematica package for
|
|
32
|
+
spin dynamics and NMR by Malcolm H. Levitt and co-authors. Spin operators are sums of product and spherical
|
|
33
|
+
tensor operators with symbolic coefficients (SymPy), and a numeric engine (NumPy, SciPy) propagates sequences
|
|
34
|
+
of pulses and delays.
|
|
35
|
+
|
|
36
|
+
pip install spyndynamica
|
|
37
|
+
|
|
38
|
+
Nothing to install? The examples run in the browser, cell by cell:
|
|
39
|
+
https://ajerschow.github.io/spynach/try.html#ex-sd-cosy
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import sympy as sp
|
|
43
|
+
from spyndynamica import SpinSystem
|
|
44
|
+
|
|
45
|
+
s = SpinSystem(2)
|
|
46
|
+
I = s.I
|
|
47
|
+
Omega, J, t = sp.symbols("Omega J t", real=True)
|
|
48
|
+
H = Omega * I(1, "z") + 2 * sp.pi * J * (I(1, "z") @ I(2, "z"))
|
|
49
|
+
|
|
50
|
+
rho = I(1, "z").rotate(sp.pi / 2, "x", spins=[1]).evolve(H, t)
|
|
51
|
+
print(rho)
|
|
52
|
+
print(rho.amplitude(2 * I(1, "x") @ I(2, "z")))
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
What is ported:
|
|
56
|
+
|
|
57
|
+
- spin systems of any spin quantum numbers, product and spherical tensor operators, commutators, rotations,
|
|
58
|
+
closed-form evolution, the Zeeman, singlet-triplet, coupled and user-defined bases, kets and bras;
|
|
59
|
+
- Liouville space: operator bases, superoperators, phenomenological relaxation, coherence-order and spherical
|
|
60
|
+
rank filters;
|
|
61
|
+
- the numeric engine: pulses, delays, shaped pulses and pulse sequences, time-dependent and periodic
|
|
62
|
+
Hamiltonians, adiabatic events, trajectories, signals with their Fourier transform in one and two dimensions,
|
|
63
|
+
the COMPUTE method with the carousel average, ensemble and powder averages;
|
|
64
|
+
- density operators and polarization levels, chemical exchange in extended Liouville space, bounds on
|
|
65
|
+
transformation amplitudes, eigenvalues followed along a parameter;
|
|
66
|
+
- commutants, Lie algebras, spin permutation groups and symmetry-adapted bases, and three-dimensional pictures
|
|
67
|
+
of tensors and frames.
|
|
68
|
+
|
|
69
|
+
The conventions are those of SpinDynamica, and the results are compared with SpinDynamica's own output on
|
|
70
|
+
about 980 reference cases. Names follow Python usage (`signal_1d` for `Signal1D`); the table of names and the
|
|
71
|
+
list of differences are in
|
|
72
|
+
https://github.com/ajerschow/spynach/blob/main/docs/coming-from-spindynamica.md. Where SpinDynamica 3.10.2
|
|
73
|
+
does something else than it documents, the port follows the documentation and records the case in
|
|
74
|
+
https://github.com/ajerschow/spynach/blob/main/porting/spyndynamica/DIVERGENCES.md.
|
|
75
|
+
|
|
76
|
+
SpynDynamica is part of the [Spynach](https://github.com/ajerschow/spynach) project, which also ports the
|
|
77
|
+
Spinach spin dynamics kernel and EasySpin; it uses none of their code and is installed on its own. It is an
|
|
78
|
+
early release; corrections and bug reports are welcome on GitHub.
|
|
79
|
+
|
|
80
|
+
- Guides: https://github.com/ajerschow/spynach/blob/main/docs/spyndynamica.md (operators, bases, superoperators),
|
|
81
|
+
https://github.com/ajerschow/spynach/blob/main/docs/spyndynamica-simulations.md (the numeric engine),
|
|
82
|
+
https://github.com/ajerschow/spynach/blob/main/docs/spyndynamica-symmetry.md (algebras, symmetry, pictures),
|
|
83
|
+
https://github.com/ajerschow/spynach/blob/main/docs/spyndynamica-adiabatic.md (trajectories, level diagrams,
|
|
84
|
+
adiabatic events)
|
|
85
|
+
- Figures of the three-dimensional pictures need Plotly: `pip install "spyndynamica[plot]"`
|
|
86
|
+
|
|
87
|
+
Credit and citation: SpinDynamica is the work of Malcolm H. Levitt and co-authors. Its
|
|
88
|
+
[terms of use](https://www.spindynamica.soton.ac.uk/about/termsofuse/) state that it is open-source and freely
|
|
89
|
+
available for use, and ask that published work cite C. Bengs, M. H. Levitt, *SpinDynamica: Symbolic and
|
|
90
|
+
numerical magnetic resonance in a Mathematica environment*, Magn. Reson. Chem. (2017), doi:10.1002/mrc.4642.
|
|
91
|
+
Work that uses SpynDynamica should cite that publication. The port is under the MIT licence (`LICENSE`, which
|
|
92
|
+
carries the SpinDynamica notice); no SpinDynamica source is part of it.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# SpynDynamica: SpinDynamica in Python
|
|
2
|
+
|
|
3
|
+
A Python port of [SpinDynamica](https://www.spindynamica.soton.ac.uk) 3.10.2, the Mathematica package for
|
|
4
|
+
spin dynamics and NMR by Malcolm H. Levitt and co-authors. Spin operators are sums of product and spherical
|
|
5
|
+
tensor operators with symbolic coefficients (SymPy), and a numeric engine (NumPy, SciPy) propagates sequences
|
|
6
|
+
of pulses and delays.
|
|
7
|
+
|
|
8
|
+
pip install spyndynamica
|
|
9
|
+
|
|
10
|
+
Nothing to install? The examples run in the browser, cell by cell:
|
|
11
|
+
https://ajerschow.github.io/spynach/try.html#ex-sd-cosy
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
import sympy as sp
|
|
15
|
+
from spyndynamica import SpinSystem
|
|
16
|
+
|
|
17
|
+
s = SpinSystem(2)
|
|
18
|
+
I = s.I
|
|
19
|
+
Omega, J, t = sp.symbols("Omega J t", real=True)
|
|
20
|
+
H = Omega * I(1, "z") + 2 * sp.pi * J * (I(1, "z") @ I(2, "z"))
|
|
21
|
+
|
|
22
|
+
rho = I(1, "z").rotate(sp.pi / 2, "x", spins=[1]).evolve(H, t)
|
|
23
|
+
print(rho)
|
|
24
|
+
print(rho.amplitude(2 * I(1, "x") @ I(2, "z")))
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
What is ported:
|
|
28
|
+
|
|
29
|
+
- spin systems of any spin quantum numbers, product and spherical tensor operators, commutators, rotations,
|
|
30
|
+
closed-form evolution, the Zeeman, singlet-triplet, coupled and user-defined bases, kets and bras;
|
|
31
|
+
- Liouville space: operator bases, superoperators, phenomenological relaxation, coherence-order and spherical
|
|
32
|
+
rank filters;
|
|
33
|
+
- the numeric engine: pulses, delays, shaped pulses and pulse sequences, time-dependent and periodic
|
|
34
|
+
Hamiltonians, adiabatic events, trajectories, signals with their Fourier transform in one and two dimensions,
|
|
35
|
+
the COMPUTE method with the carousel average, ensemble and powder averages;
|
|
36
|
+
- density operators and polarization levels, chemical exchange in extended Liouville space, bounds on
|
|
37
|
+
transformation amplitudes, eigenvalues followed along a parameter;
|
|
38
|
+
- commutants, Lie algebras, spin permutation groups and symmetry-adapted bases, and three-dimensional pictures
|
|
39
|
+
of tensors and frames.
|
|
40
|
+
|
|
41
|
+
The conventions are those of SpinDynamica, and the results are compared with SpinDynamica's own output on
|
|
42
|
+
about 980 reference cases. Names follow Python usage (`signal_1d` for `Signal1D`); the table of names and the
|
|
43
|
+
list of differences are in
|
|
44
|
+
https://github.com/ajerschow/spynach/blob/main/docs/coming-from-spindynamica.md. Where SpinDynamica 3.10.2
|
|
45
|
+
does something else than it documents, the port follows the documentation and records the case in
|
|
46
|
+
https://github.com/ajerschow/spynach/blob/main/porting/spyndynamica/DIVERGENCES.md.
|
|
47
|
+
|
|
48
|
+
SpynDynamica is part of the [Spynach](https://github.com/ajerschow/spynach) project, which also ports the
|
|
49
|
+
Spinach spin dynamics kernel and EasySpin; it uses none of their code and is installed on its own. It is an
|
|
50
|
+
early release; corrections and bug reports are welcome on GitHub.
|
|
51
|
+
|
|
52
|
+
- Guides: https://github.com/ajerschow/spynach/blob/main/docs/spyndynamica.md (operators, bases, superoperators),
|
|
53
|
+
https://github.com/ajerschow/spynach/blob/main/docs/spyndynamica-simulations.md (the numeric engine),
|
|
54
|
+
https://github.com/ajerschow/spynach/blob/main/docs/spyndynamica-symmetry.md (algebras, symmetry, pictures),
|
|
55
|
+
https://github.com/ajerschow/spynach/blob/main/docs/spyndynamica-adiabatic.md (trajectories, level diagrams,
|
|
56
|
+
adiabatic events)
|
|
57
|
+
- Figures of the three-dimensional pictures need Plotly: `pip install "spyndynamica[plot]"`
|
|
58
|
+
|
|
59
|
+
Credit and citation: SpinDynamica is the work of Malcolm H. Levitt and co-authors. Its
|
|
60
|
+
[terms of use](https://www.spindynamica.soton.ac.uk/about/termsofuse/) state that it is open-source and freely
|
|
61
|
+
available for use, and ask that published work cite C. Bengs, M. H. Levitt, *SpinDynamica: Symbolic and
|
|
62
|
+
numerical magnetic resonance in a Mathematica environment*, Magn. Reson. Chem. (2017), doi:10.1002/mrc.4642.
|
|
63
|
+
Work that uses SpynDynamica should cite that publication. The port is under the MIT licence (`LICENSE`, which
|
|
64
|
+
carries the SpinDynamica notice); no SpinDynamica source is part of it.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# The PyPI distribution "spyndynamica": SpynDynamica, the Python port of SpinDynamica in this repository. Built
|
|
2
|
+
# from a staged copy of src/spyndynamica by scripts/build_spyndynamica.py.
|
|
3
|
+
[build-system]
|
|
4
|
+
requires = ["setuptools>=77"]
|
|
5
|
+
build-backend = "setuptools.build_meta"
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
name = "spyndynamica"
|
|
9
|
+
version = "0.1.0" # keep equal to spyndynamica.__version__ (tests/spyndynamica/test_packaging.py); own numbering
|
|
10
|
+
description = "SpinDynamica in Python (SpynDynamica): symbolic and numerical spin dynamics for NMR"
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
license = "MIT"
|
|
13
|
+
license-files = ["LICENSE"]
|
|
14
|
+
authors = [{name = "Alexej Jerschow"}]
|
|
15
|
+
requires-python = ">=3.11"
|
|
16
|
+
dependencies = ["numpy>=1.26", "scipy>=1.11", "sympy>=1.12"]
|
|
17
|
+
keywords = ["NMR", "spin dynamics", "SpinDynamica", "product operators", "symbolic", "simulation"]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 3 - Alpha",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Topic :: Scientific/Engineering :: Chemistry",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Physics",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
plot = ["plotly>=6"] # figures of the three-dimensional pictures (Scene.figure)
|
|
28
|
+
test = ["pytest>=8"]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://ajerschow.github.io/spynach/"
|
|
32
|
+
Documentation = "https://github.com/ajerschow/spynach/blob/main/docs/spyndynamica.md"
|
|
33
|
+
Source = "https://github.com/ajerschow/spynach"
|
|
34
|
+
Changelog = "https://github.com/ajerschow/spynach/blob/main/CHANGELOG.md"
|
|
35
|
+
|
|
36
|
+
[tool.setuptools]
|
|
37
|
+
packages = ["spyndynamica"]
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.package-data]
|
|
40
|
+
spyndynamica = ["data/*.json", "data/*.npz"]
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"""SpynDynamica: a Python port of SpinDynamica (Malcolm Levitt's Mathematica package for spin dynamics).
|
|
2
|
+
|
|
3
|
+
The symbolic core (spin systems, operators as sums of product and spherical tensor operators with symbolic
|
|
4
|
+
coefficients, rotations, bases, kets, exact matrices), Liouville space (operator bases, superoperators) and
|
|
5
|
+
the numeric engine for sequences of time-independent events, signals with their Fourier transform, and the
|
|
6
|
+
isotope data; chemical exchange, operator algebras, permutation symmetry and three-dimensional pictures. See
|
|
7
|
+
``docs/spyndynamica.md``, ``docs/spyndynamica-simulations.md``, ``docs/spyndynamica-symmetry.md``,
|
|
8
|
+
``docs/coming-from-spindynamica.md`` and ``porting/spyndynamica/PLAN.md``. The package imports NumPy, SciPy and
|
|
9
|
+
SymPy only, and nothing of spynach.
|
|
10
|
+
|
|
11
|
+
SpinDynamica is the work of Malcolm H. Levitt and co-authors. Its terms of use
|
|
12
|
+
(https://www.spindynamica.soton.ac.uk/about/termsofuse/) state that it is open-source and freely available
|
|
13
|
+
for use and ask that published work cite C. Bengs, M. H. Levitt, "SpinDynamica: Symbolic and numerical
|
|
14
|
+
magnetic resonance in a Mathematica environment", Magn. Reson. Chem. (2017), doi:10.1002/mrc.4642. Work
|
|
15
|
+
that uses this port should cite that publication.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from spyndynamica.algebras import (
|
|
19
|
+
abelian_subalgebra,
|
|
20
|
+
bicommutant,
|
|
21
|
+
commutant,
|
|
22
|
+
inaccessible,
|
|
23
|
+
is_maximal_abelian,
|
|
24
|
+
lie_algebra,
|
|
25
|
+
)
|
|
26
|
+
from spyndynamica.analysis import CorrelatedEigensystems, amplitude_bounds, correlated_eigensystems
|
|
27
|
+
from spyndynamica.dynamics import (
|
|
28
|
+
Adiabatic,
|
|
29
|
+
Delay,
|
|
30
|
+
OperatorTrajectoryFunction,
|
|
31
|
+
Periodic,
|
|
32
|
+
Precalculated,
|
|
33
|
+
Pulse,
|
|
34
|
+
PulseSequence,
|
|
35
|
+
Repeat,
|
|
36
|
+
ShapedPulse,
|
|
37
|
+
TimeDependent,
|
|
38
|
+
TrajectoryFunction,
|
|
39
|
+
amplitudes,
|
|
40
|
+
operator_trajectory_function,
|
|
41
|
+
precalculate,
|
|
42
|
+
propagate,
|
|
43
|
+
propagator,
|
|
44
|
+
superpropagator,
|
|
45
|
+
trajectory,
|
|
46
|
+
trajectory_function,
|
|
47
|
+
)
|
|
48
|
+
from spyndynamica.ensembles import (
|
|
49
|
+
ensemble_average,
|
|
50
|
+
orientation_schemes,
|
|
51
|
+
orientations,
|
|
52
|
+
random_orientations,
|
|
53
|
+
step_alpha_beta,
|
|
54
|
+
step_beta,
|
|
55
|
+
)
|
|
56
|
+
from spyndynamica.exchange import ExtendedOperatorBasis, KineticExchange, SiteDependent, kinetic_exchange_matrix
|
|
57
|
+
from spyndynamica.graphics import (
|
|
58
|
+
Scene,
|
|
59
|
+
arrow_3d,
|
|
60
|
+
axes_3d,
|
|
61
|
+
l_shape,
|
|
62
|
+
ovaloid,
|
|
63
|
+
ovaloid_radius,
|
|
64
|
+
rotor,
|
|
65
|
+
sphere_and_axes,
|
|
66
|
+
visualize_euler,
|
|
67
|
+
)
|
|
68
|
+
from spyndynamica.groups import dual_pairing, permutation_group, spin_permutation_group, symmetry_adapted_basis
|
|
69
|
+
from spyndynamica.interactions import (
|
|
70
|
+
constants,
|
|
71
|
+
dipolar_coupling,
|
|
72
|
+
isotope,
|
|
73
|
+
isotopes,
|
|
74
|
+
larmor_frequency,
|
|
75
|
+
magnetogyric_ratio,
|
|
76
|
+
natural_abundance,
|
|
77
|
+
spin_quantum_number,
|
|
78
|
+
)
|
|
79
|
+
from spyndynamica.liouville import (
|
|
80
|
+
OperatorBasis,
|
|
81
|
+
Superoperator,
|
|
82
|
+
cartesian_product_basis,
|
|
83
|
+
check_operator_basis,
|
|
84
|
+
coherence_filter,
|
|
85
|
+
commutation,
|
|
86
|
+
default_operator_basis,
|
|
87
|
+
define_operator_basis,
|
|
88
|
+
double_commutation,
|
|
89
|
+
left_multiplication,
|
|
90
|
+
lindbladian,
|
|
91
|
+
liouvillian,
|
|
92
|
+
permutation_superoperator,
|
|
93
|
+
phenomenological_relaxation,
|
|
94
|
+
projection,
|
|
95
|
+
right_multiplication,
|
|
96
|
+
rotation_euler_superoperator,
|
|
97
|
+
rotation_superoperator,
|
|
98
|
+
shift_and_polarization_basis,
|
|
99
|
+
shift_and_z_basis,
|
|
100
|
+
shift_superoperator,
|
|
101
|
+
singlet_triplet_operator_basis,
|
|
102
|
+
spherical_component_filter,
|
|
103
|
+
spherical_tensor_basis,
|
|
104
|
+
unity_superoperator,
|
|
105
|
+
zeeman_ket_bra_basis,
|
|
106
|
+
)
|
|
107
|
+
from spyndynamica.operators import Operator, commutator
|
|
108
|
+
from spyndynamica.rotations import (
|
|
109
|
+
axes_to_euler,
|
|
110
|
+
axis_system,
|
|
111
|
+
bond_angle,
|
|
112
|
+
clebsch_gordan,
|
|
113
|
+
distance,
|
|
114
|
+
euler_matrix,
|
|
115
|
+
polar_rotation_matrix,
|
|
116
|
+
polar_to_quaternion,
|
|
117
|
+
polar_to_vector,
|
|
118
|
+
quaternion_product,
|
|
119
|
+
quaternion_to_euler,
|
|
120
|
+
quaternion_to_polar,
|
|
121
|
+
rotate_euler,
|
|
122
|
+
rotate_polar,
|
|
123
|
+
solid_angle,
|
|
124
|
+
subtended_angle,
|
|
125
|
+
torsion_angle,
|
|
126
|
+
vector_to_polar,
|
|
127
|
+
wigner_D,
|
|
128
|
+
wigner_d,
|
|
129
|
+
)
|
|
130
|
+
from spyndynamica.signals import (
|
|
131
|
+
Signal,
|
|
132
|
+
absorption,
|
|
133
|
+
apply_line_broadening,
|
|
134
|
+
combine_complementary_spectra,
|
|
135
|
+
combine_data,
|
|
136
|
+
dispersion,
|
|
137
|
+
embed_coordinates,
|
|
138
|
+
frequency_axis,
|
|
139
|
+
ft,
|
|
140
|
+
ft2,
|
|
141
|
+
ft_coordinates,
|
|
142
|
+
gaussian,
|
|
143
|
+
lorentzian,
|
|
144
|
+
reflect_spectrum,
|
|
145
|
+
signal_1d,
|
|
146
|
+
split_coordinates,
|
|
147
|
+
)
|
|
148
|
+
from spyndynamica.states import (
|
|
149
|
+
amplitude_table,
|
|
150
|
+
maximize_amplitude,
|
|
151
|
+
polarization_level,
|
|
152
|
+
polarized,
|
|
153
|
+
secularize,
|
|
154
|
+
singlet_polarization_level,
|
|
155
|
+
singlet_polarized,
|
|
156
|
+
thermal_equilibrium,
|
|
157
|
+
thermalize,
|
|
158
|
+
)
|
|
159
|
+
from spyndynamica.system import (
|
|
160
|
+
Basis,
|
|
161
|
+
Bra,
|
|
162
|
+
Ket,
|
|
163
|
+
SpinSystem,
|
|
164
|
+
check_basis,
|
|
165
|
+
define_basis,
|
|
166
|
+
product_basis,
|
|
167
|
+
rank_histories,
|
|
168
|
+
spins_of,
|
|
169
|
+
)
|
|
170
|
+
from spyndynamica.tensors import cartesian_to_spherical, spherical_to_cartesian, transform_spherical_tensor
|
|
171
|
+
|
|
172
|
+
__version__ = "0.1.0"
|
|
173
|
+
|
|
174
|
+
__all__ = [
|
|
175
|
+
"bond_angle",
|
|
176
|
+
"distance",
|
|
177
|
+
"solid_angle",
|
|
178
|
+
"subtended_angle",
|
|
179
|
+
"torsion_angle",
|
|
180
|
+
"Scene",
|
|
181
|
+
"arrow_3d",
|
|
182
|
+
"axes_3d",
|
|
183
|
+
"l_shape",
|
|
184
|
+
"ovaloid",
|
|
185
|
+
"ovaloid_radius",
|
|
186
|
+
"rotor",
|
|
187
|
+
"sphere_and_axes",
|
|
188
|
+
"visualize_euler",
|
|
189
|
+
"ExtendedOperatorBasis",
|
|
190
|
+
"KineticExchange",
|
|
191
|
+
"SiteDependent",
|
|
192
|
+
"abelian_subalgebra",
|
|
193
|
+
"bicommutant",
|
|
194
|
+
"commutant",
|
|
195
|
+
"dual_pairing",
|
|
196
|
+
"inaccessible",
|
|
197
|
+
"is_maximal_abelian",
|
|
198
|
+
"kinetic_exchange_matrix",
|
|
199
|
+
"lie_algebra",
|
|
200
|
+
"permutation_group",
|
|
201
|
+
"polarization_level",
|
|
202
|
+
"singlet_polarization_level",
|
|
203
|
+
"spin_permutation_group",
|
|
204
|
+
"symmetry_adapted_basis",
|
|
205
|
+
"axes_to_euler",
|
|
206
|
+
"axis_system",
|
|
207
|
+
"check_basis",
|
|
208
|
+
"check_operator_basis",
|
|
209
|
+
"define_basis",
|
|
210
|
+
"define_operator_basis",
|
|
211
|
+
"polar_rotation_matrix",
|
|
212
|
+
"polar_to_quaternion",
|
|
213
|
+
"polar_to_vector",
|
|
214
|
+
"product_basis",
|
|
215
|
+
"quaternion_product",
|
|
216
|
+
"quaternion_to_euler",
|
|
217
|
+
"quaternion_to_polar",
|
|
218
|
+
"rank_histories",
|
|
219
|
+
"rotate_euler",
|
|
220
|
+
"rotate_polar",
|
|
221
|
+
"spherical_component_filter",
|
|
222
|
+
"vector_to_polar",
|
|
223
|
+
"shift_superoperator",
|
|
224
|
+
"random_orientations",
|
|
225
|
+
"precalculate",
|
|
226
|
+
"ft2",
|
|
227
|
+
"embed_coordinates",
|
|
228
|
+
"split_coordinates",
|
|
229
|
+
"ft_coordinates",
|
|
230
|
+
"Adiabatic",
|
|
231
|
+
"OperatorTrajectoryFunction",
|
|
232
|
+
"TrajectoryFunction",
|
|
233
|
+
"operator_trajectory_function",
|
|
234
|
+
"trajectory_function",
|
|
235
|
+
"CorrelatedEigensystems",
|
|
236
|
+
"amplitude_bounds",
|
|
237
|
+
"correlated_eigensystems",
|
|
238
|
+
"frequency_axis",
|
|
239
|
+
"reflect_spectrum",
|
|
240
|
+
"combine_complementary_spectra",
|
|
241
|
+
"combine_data",
|
|
242
|
+
"ShapedPulse",
|
|
243
|
+
"PulseSequence",
|
|
244
|
+
"Precalculated",
|
|
245
|
+
"thermalize",
|
|
246
|
+
"thermal_equilibrium",
|
|
247
|
+
"singlet_polarized",
|
|
248
|
+
"secularize",
|
|
249
|
+
"polarized",
|
|
250
|
+
"maximize_amplitude",
|
|
251
|
+
"amplitude_table",
|
|
252
|
+
"Periodic",
|
|
253
|
+
"transform_spherical_tensor",
|
|
254
|
+
"step_beta",
|
|
255
|
+
"step_alpha_beta",
|
|
256
|
+
"spherical_to_cartesian",
|
|
257
|
+
"orientations",
|
|
258
|
+
"orientation_schemes",
|
|
259
|
+
"ensemble_average",
|
|
260
|
+
"cartesian_to_spherical",
|
|
261
|
+
"TimeDependent",
|
|
262
|
+
"spin_quantum_number",
|
|
263
|
+
"signal_1d",
|
|
264
|
+
"natural_abundance",
|
|
265
|
+
"magnetogyric_ratio",
|
|
266
|
+
"lorentzian",
|
|
267
|
+
"larmor_frequency",
|
|
268
|
+
"isotopes",
|
|
269
|
+
"isotope",
|
|
270
|
+
"gaussian",
|
|
271
|
+
"ft",
|
|
272
|
+
"dispersion",
|
|
273
|
+
"dipolar_coupling",
|
|
274
|
+
"constants",
|
|
275
|
+
"apply_line_broadening",
|
|
276
|
+
"absorption",
|
|
277
|
+
"Signal",
|
|
278
|
+
"Basis",
|
|
279
|
+
"Bra",
|
|
280
|
+
"Delay",
|
|
281
|
+
"Ket",
|
|
282
|
+
"Operator",
|
|
283
|
+
"OperatorBasis",
|
|
284
|
+
"Pulse",
|
|
285
|
+
"Repeat",
|
|
286
|
+
"SpinSystem",
|
|
287
|
+
"Superoperator",
|
|
288
|
+
"amplitudes",
|
|
289
|
+
"cartesian_product_basis",
|
|
290
|
+
"clebsch_gordan",
|
|
291
|
+
"coherence_filter",
|
|
292
|
+
"commutation",
|
|
293
|
+
"commutator",
|
|
294
|
+
"default_operator_basis",
|
|
295
|
+
"double_commutation",
|
|
296
|
+
"euler_matrix",
|
|
297
|
+
"left_multiplication",
|
|
298
|
+
"lindbladian",
|
|
299
|
+
"liouvillian",
|
|
300
|
+
"permutation_superoperator",
|
|
301
|
+
"phenomenological_relaxation",
|
|
302
|
+
"projection",
|
|
303
|
+
"propagate",
|
|
304
|
+
"propagator",
|
|
305
|
+
"right_multiplication",
|
|
306
|
+
"rotation_euler_superoperator",
|
|
307
|
+
"rotation_superoperator",
|
|
308
|
+
"shift_and_polarization_basis",
|
|
309
|
+
"shift_and_z_basis",
|
|
310
|
+
"singlet_triplet_operator_basis",
|
|
311
|
+
"spherical_tensor_basis",
|
|
312
|
+
"spins_of",
|
|
313
|
+
"superpropagator",
|
|
314
|
+
"trajectory",
|
|
315
|
+
"unity_superoperator",
|
|
316
|
+
"wigner_D",
|
|
317
|
+
"wigner_d",
|
|
318
|
+
"zeeman_ket_bra_basis",
|
|
319
|
+
]
|