scatterkit 0.1__cp314-cp314-win_amd64.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 +15 -0
- scatterkit/__main__.py +29 -0
- scatterkit/_version.py +21 -0
- scatterkit/diporderstructurefactor.py +174 -0
- scatterkit/lib/_cmath.c +30896 -0
- scatterkit/lib/_cmath.cp314-win_amd64.pyd +0 -0
- scatterkit/lib/_cmath.pyx +126 -0
- scatterkit/lib/math.py +193 -0
- scatterkit/lib/tables.py +54 -0
- scatterkit/lib/util.py +134 -0
- scatterkit/lib/weights.py +24 -0
- scatterkit/rdfdiporder.py +198 -0
- scatterkit/saxs.py +346 -0
- scatterkit/share/scatteringfactors.dat +221 -0
- scatterkit-0.1.dist-info/METADATA +136 -0
- scatterkit-0.1.dist-info/RECORD +20 -0
- scatterkit-0.1.dist-info/WHEEL +5 -0
- scatterkit-0.1.dist-info/entry_points.txt +2 -0
- scatterkit-0.1.dist-info/licenses/AUTHORS.rst +15 -0
- scatterkit-0.1.dist-info/top_level.txt +1 -0
scatterkit/__init__.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""scatterkit: scattering analysis of MD trajectories."""
|
|
2
|
+
|
|
3
|
+
__authors__ = "MAICoS Developer Team"
|
|
4
|
+
|
|
5
|
+
from ._version import get_versions
|
|
6
|
+
from .diporderstructurefactor import DiporderStructureFactor
|
|
7
|
+
from .rdfdiporder import RDFDiporder
|
|
8
|
+
from .saxs import Saxs
|
|
9
|
+
|
|
10
|
+
#: Version information for Scatterkit, following :pep:`440`
|
|
11
|
+
#: and `semantic versioning <http://semver.org/>`_.
|
|
12
|
+
__version__ = get_versions()["version"]
|
|
13
|
+
del get_versions
|
|
14
|
+
|
|
15
|
+
__all__ = ["Saxs", "DiporderStructureFactor", "RDFDiporder"]
|
scatterkit/__main__.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2025 Authors and contributors
|
|
4
|
+
# (see the AUTHORS.rst file for the full list of names)
|
|
5
|
+
#
|
|
6
|
+
# Released under the GNU Public Licence, v3 or any higher version
|
|
7
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
8
|
+
"""Analyse scattering in molecular dynamics simulation."""
|
|
9
|
+
|
|
10
|
+
from maicos.core import AnalysisBase
|
|
11
|
+
from mdacli import cli
|
|
12
|
+
|
|
13
|
+
from scatterkit import __version__
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main():
|
|
17
|
+
"""Execute main CLI entry point."""
|
|
18
|
+
cli(
|
|
19
|
+
name="scatterkit",
|
|
20
|
+
module_list=["scatterkit"],
|
|
21
|
+
base_class=AnalysisBase,
|
|
22
|
+
version=__version__,
|
|
23
|
+
description=__doc__,
|
|
24
|
+
ignore_warnings=True,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if __name__ == "__main__":
|
|
29
|
+
main()
|
scatterkit/_version.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
# This file was generated by 'versioneer.py' (0.29) from
|
|
3
|
+
# revision-control system data, or from the parent directory name of an
|
|
4
|
+
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
|
5
|
+
# of this file.
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
|
|
9
|
+
version_json = '''
|
|
10
|
+
{
|
|
11
|
+
"date": "2025-11-11T14:34:49+0100",
|
|
12
|
+
"dirty": false,
|
|
13
|
+
"error": null,
|
|
14
|
+
"full-revisionid": "305b9879b5e6b0ee5f6ec51a6bdc0a7c2dd24256",
|
|
15
|
+
"version": "0.1"
|
|
16
|
+
}
|
|
17
|
+
''' # END VERSION_JSON
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_versions():
|
|
21
|
+
return json.loads(version_json)
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2025 Authors and contributors
|
|
4
|
+
# (see the AUTHORS.rst file for the full list of names)
|
|
5
|
+
#
|
|
6
|
+
# Released under the GNU Public Licence, v3 or any higher version
|
|
7
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
8
|
+
"""Module for computing structure factor for dipoles."""
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
|
|
12
|
+
import MDAnalysis as mda
|
|
13
|
+
import numpy as np
|
|
14
|
+
from maicos.core import AnalysisBase
|
|
15
|
+
from maicos.lib.util import get_center, render_docs, unit_vectors_planar
|
|
16
|
+
from maicos.lib.weights import diporder_weights
|
|
17
|
+
|
|
18
|
+
from .lib.math import compute_structure_factor
|
|
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="cos_theta",
|
|
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 = dict(
|
|
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
|
+
)
|