scatterkit 0.1.2__cp315-cp315t-win32.whl
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.
- scatterkit/__init__.py +12 -0
- scatterkit/__main__.py +28 -0
- scatterkit/_version.py +24 -0
- scatterkit/diporderstructurefactor.py +174 -0
- scatterkit/lib/_cmath.c +34559 -0
- scatterkit/lib/_cmath.cp315t-win32.pyd +0 -0
- scatterkit/lib/_cmath.pyx +126 -0
- scatterkit/lib/math.py +193 -0
- scatterkit/lib/tables.py +53 -0
- scatterkit/lib/util.py +161 -0
- scatterkit/lib/weights.py +23 -0
- scatterkit/rdfdiporder.py +198 -0
- scatterkit/saxs.py +345 -0
- scatterkit/share/scatteringfactors.dat +221 -0
- scatterkit-0.1.2.dist-info/METADATA +137 -0
- scatterkit-0.1.2.dist-info/RECORD +21 -0
- scatterkit-0.1.2.dist-info/WHEEL +5 -0
- scatterkit-0.1.2.dist-info/entry_points.txt +2 -0
- scatterkit-0.1.2.dist-info/licenses/AUTHORS.rst +15 -0
- scatterkit-0.1.2.dist-info/licenses/LICENSE +674 -0
- scatterkit-0.1.2.dist-info/top_level.txt +1 -0
scatterkit/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""scatterkit: scattering analysis of MD trajectories."""
|
|
2
|
+
|
|
3
|
+
__authors__ = "MAICoS Developer Team"
|
|
4
|
+
|
|
5
|
+
#: Version information for Scatterkit, following :pep:`440`
|
|
6
|
+
#: and `semantic versioning <http://semver.org/>`_.
|
|
7
|
+
from ._version import __version__ # noqa: F401
|
|
8
|
+
from .diporderstructurefactor import DiporderStructureFactor
|
|
9
|
+
from .rdfdiporder import RDFDiporder
|
|
10
|
+
from .saxs import Saxs
|
|
11
|
+
|
|
12
|
+
__all__ = ["DiporderStructureFactor", "RDFDiporder", "Saxs"]
|
scatterkit/__main__.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2025 Authors and contributors
|
|
3
|
+
# (see the AUTHORS.rst file for the full list of names)
|
|
4
|
+
#
|
|
5
|
+
# Released under the GNU Public Licence, v3 or any higher version
|
|
6
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
7
|
+
"""Analyse scattering in molecular dynamics simulation."""
|
|
8
|
+
|
|
9
|
+
from maicos.core import AnalysisBase
|
|
10
|
+
from mdacli import cli
|
|
11
|
+
|
|
12
|
+
from scatterkit import __version__
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def main():
|
|
16
|
+
"""Execute main CLI entry point."""
|
|
17
|
+
cli(
|
|
18
|
+
name="scatterkit",
|
|
19
|
+
module_list=["scatterkit"],
|
|
20
|
+
base_class=AnalysisBase,
|
|
21
|
+
version=__version__,
|
|
22
|
+
description=__doc__,
|
|
23
|
+
ignore_warnings=True,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if __name__ == "__main__":
|
|
28
|
+
main()
|
scatterkit/_version.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.1.2'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 2)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = 'g4acf0ea77'
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2025 Authors and contributors
|
|
3
|
+
# (see the AUTHORS.rst file for the full list of names)
|
|
4
|
+
#
|
|
5
|
+
# Released under the GNU Public Licence, v3 or any higher version
|
|
6
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
7
|
+
"""Module for computing structure factor for dipoles."""
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
|
|
11
|
+
import MDAnalysis as mda
|
|
12
|
+
import numpy as np
|
|
13
|
+
from maicos.core import AnalysisBase
|
|
14
|
+
from maicos.lib.util import get_center, unit_vectors_planar
|
|
15
|
+
from maicos.lib.weights import diporder_weights
|
|
16
|
+
|
|
17
|
+
from .lib.math import compute_structure_factor
|
|
18
|
+
from .lib.util import render_docs
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@render_docs
|
|
22
|
+
class DiporderStructureFactor(AnalysisBase):
|
|
23
|
+
r"""Structure factor for dipoles.
|
|
24
|
+
|
|
25
|
+
Extension the standard structure factor :math:`S(q)` by weighting it with different
|
|
26
|
+
the normalized dipole moment :math:`\hat{\boldsymbol{\mu}}` of a ``group`` according
|
|
27
|
+
to
|
|
28
|
+
|
|
29
|
+
.. math::
|
|
30
|
+
S(q)_{\hat{\boldsymbol{\mu}} \hat{\boldsymbol{\mu}}} = \left \langle
|
|
31
|
+
\frac{1}{N} \sum_{i,j=1}^N \hat \mu_i \hat \mu_j \, \exp(-i\boldsymbol q\cdot
|
|
32
|
+
[\boldsymbol r_i - \boldsymbol r_j]) \right \rangle
|
|
33
|
+
|
|
34
|
+
For the correlation time estimation the module will use the value of the structure
|
|
35
|
+
factor with the smallest possible :math:`q` value.
|
|
36
|
+
|
|
37
|
+
For an detailed example on the usage refer to the :ref:`how-to on dipolar
|
|
38
|
+
correlation functions <howto-spatial-dipole-dipole-correlations>`. For general
|
|
39
|
+
details on the theory behind the structure factor refer to :ref:`saxs-explanations`.
|
|
40
|
+
|
|
41
|
+
Parameters
|
|
42
|
+
----------
|
|
43
|
+
${ATOMGROUP_PARAMETER}
|
|
44
|
+
${BASE_CLASS_PARAMETERS}
|
|
45
|
+
${Q_SPACE_PARAMETERS}
|
|
46
|
+
${OUTPUT_PARAMETER}
|
|
47
|
+
|
|
48
|
+
Attributes
|
|
49
|
+
----------
|
|
50
|
+
results.q : numpy.ndarray
|
|
51
|
+
length of binned q-vectors
|
|
52
|
+
results.structure_factors : numpy.ndarray
|
|
53
|
+
Structure factor
|
|
54
|
+
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
def __init__(
|
|
58
|
+
self,
|
|
59
|
+
atomgroup: mda.AtomGroup,
|
|
60
|
+
bin_method: str = "com",
|
|
61
|
+
grouping: str = "molecules",
|
|
62
|
+
refgroup: mda.AtomGroup | None = None,
|
|
63
|
+
unwrap: bool = True,
|
|
64
|
+
pack: bool = True,
|
|
65
|
+
jitter: float = 0.0,
|
|
66
|
+
concfreq: int = 0,
|
|
67
|
+
qmin: float = 0,
|
|
68
|
+
qmax: float = 6,
|
|
69
|
+
dq: float = 0.01,
|
|
70
|
+
output: str = "sq.dat",
|
|
71
|
+
) -> None:
|
|
72
|
+
self._locals = locals()
|
|
73
|
+
super().__init__(
|
|
74
|
+
atomgroup,
|
|
75
|
+
unwrap=unwrap,
|
|
76
|
+
pack=pack,
|
|
77
|
+
refgroup=refgroup,
|
|
78
|
+
jitter=jitter,
|
|
79
|
+
wrap_compound=grouping,
|
|
80
|
+
concfreq=concfreq,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
self.bin_method = str(bin_method).lower()
|
|
84
|
+
self.qmin = qmin
|
|
85
|
+
self.qmax = qmax
|
|
86
|
+
self.dq = dq
|
|
87
|
+
self.output = output
|
|
88
|
+
|
|
89
|
+
def _prepare(self) -> None:
|
|
90
|
+
logging.info("Analysis of the structure factor of dipoles.")
|
|
91
|
+
self.n_bins = int(np.ceil((self.qmax - self.qmin) / self.dq))
|
|
92
|
+
|
|
93
|
+
def _single_frame(self) -> float:
|
|
94
|
+
box = np.diag(mda.lib.mdamath.triclinic_vectors(self._ts.dimensions))
|
|
95
|
+
|
|
96
|
+
positions = get_center(
|
|
97
|
+
atomgroup=self.atomgroup,
|
|
98
|
+
bin_method=self.bin_method,
|
|
99
|
+
compound=self.wrap_compound,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
self._obs.structure_factors = np.zeros(self.n_bins)
|
|
103
|
+
|
|
104
|
+
# Calculate structure factor per vector component and sum them up
|
|
105
|
+
for pdim in range(3):
|
|
106
|
+
|
|
107
|
+
def get_unit_vectors(
|
|
108
|
+
atomgroup: mda.AtomGroup, grouping: str, pdim: int = pdim
|
|
109
|
+
):
|
|
110
|
+
return unit_vectors_planar(
|
|
111
|
+
atomgroup=atomgroup, grouping=grouping, pdim=pdim
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
weights = diporder_weights(
|
|
115
|
+
atomgroup=self.atomgroup,
|
|
116
|
+
grouping=self.wrap_compound,
|
|
117
|
+
order_parameter="P1",
|
|
118
|
+
get_unit_vectors=get_unit_vectors,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
scattering_vectors, structure_factors = compute_structure_factor(
|
|
122
|
+
np.double(positions),
|
|
123
|
+
np.double(box),
|
|
124
|
+
self.qmin,
|
|
125
|
+
self.qmax,
|
|
126
|
+
0,
|
|
127
|
+
np.pi,
|
|
128
|
+
weights,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
scattering_vectors = scattering_vectors.flatten()
|
|
132
|
+
structure_factors = structure_factors.flatten()
|
|
133
|
+
nonzeros = np.where(structure_factors != 0)[0]
|
|
134
|
+
|
|
135
|
+
scattering_vectors = scattering_vectors[nonzeros]
|
|
136
|
+
structure_factors = structure_factors[nonzeros]
|
|
137
|
+
|
|
138
|
+
histogram_kwargs = {
|
|
139
|
+
"a": scattering_vectors,
|
|
140
|
+
"bins": self.n_bins,
|
|
141
|
+
"range": (self.qmin, self.qmax),
|
|
142
|
+
}
|
|
143
|
+
structure_factors_binned, _ = np.histogram(
|
|
144
|
+
weights=structure_factors, **histogram_kwargs
|
|
145
|
+
)
|
|
146
|
+
bincount, _ = np.histogram(weights=None, **histogram_kwargs)
|
|
147
|
+
with np.errstate(invalid="ignore"):
|
|
148
|
+
structure_factors_binned /= bincount
|
|
149
|
+
|
|
150
|
+
self._obs.structure_factors += np.nan_to_num(structure_factors_binned)
|
|
151
|
+
|
|
152
|
+
# Normalize with respect to the number of compounds
|
|
153
|
+
self._obs.structure_factors /= len(positions)
|
|
154
|
+
|
|
155
|
+
return self._obs.structure_factors[-1]
|
|
156
|
+
|
|
157
|
+
def _conclude(self) -> None:
|
|
158
|
+
scattering_vectors = np.arange(self.qmin, self.qmax, self.dq) + 0.5 * self.dq
|
|
159
|
+
nonzeros = np.where(self.means.structure_factors != 0)[0]
|
|
160
|
+
structure_factors = self.means.structure_factors[nonzeros]
|
|
161
|
+
|
|
162
|
+
self.results.scattering_vectors = scattering_vectors[nonzeros]
|
|
163
|
+
self.results.structure_factors = structure_factors
|
|
164
|
+
|
|
165
|
+
@render_docs
|
|
166
|
+
def save(self) -> None:
|
|
167
|
+
"""${SAVE_METHOD_DESCRIPTION}""" # noqa: D415
|
|
168
|
+
self.savetxt(
|
|
169
|
+
self.output,
|
|
170
|
+
np.vstack(
|
|
171
|
+
[self.results.scattering_vectors, self.results.structure_factors]
|
|
172
|
+
).T,
|
|
173
|
+
columns=["q (1/Å)", "S(q) (arb. units)"],
|
|
174
|
+
)
|