diffpy.srreal 1.5.0__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.
- diffpy/__init__.py +15 -0
- diffpy/srreal/__init__.py +37 -0
- diffpy/srreal/_cleanup.py +81 -0
- diffpy/srreal/_docstrings.py +171 -0
- diffpy/srreal/_final_imports.py +50 -0
- diffpy/srreal/_objcrystconverters.py +96 -0
- diffpy/srreal/atomradiitable.py +81 -0
- diffpy/srreal/attributes.py +70 -0
- diffpy/srreal/bondcalculator.py +77 -0
- diffpy/srreal/bvparameterstable.py +23 -0
- diffpy/srreal/bvscalculator.py +99 -0
- diffpy/srreal/data/bvparm2011sel.cif +1919 -0
- diffpy/srreal/data/f0_WaasKirf.dat +913 -0
- diffpy/srreal/data/ionlist.dat +107 -0
- diffpy/srreal/data/nsftable.dat +400 -0
- diffpy/srreal/eventticker.py +23 -0
- diffpy/srreal/licenses/boost/LICENSE_1_0.txt +23 -0
- diffpy/srreal/licenses/gsl/COPYING +674 -0
- diffpy/srreal/licenses/libdiffpy/LICENSE.rst +139 -0
- diffpy/srreal/licenses/libdiffpy/LICENSE_DANSE.rst +40 -0
- diffpy/srreal/overlapcalculator.py +86 -0
- diffpy/srreal/pairquantity.py +23 -0
- diffpy/srreal/parallel.py +237 -0
- diffpy/srreal/pdfbaseline.py +107 -0
- diffpy/srreal/pdfcalculator.py +340 -0
- diffpy/srreal/pdfenvelope.py +131 -0
- diffpy/srreal/peakprofile.py +55 -0
- diffpy/srreal/peakwidthmodel.py +74 -0
- diffpy/srreal/scatteringfactortable.py +46 -0
- diffpy/srreal/sfaverage.py +169 -0
- diffpy/srreal/srreal_ext.cp314-win_amd64.pyd +0 -0
- diffpy/srreal/structureadapter.py +135 -0
- diffpy/srreal/structureconverters.py +99 -0
- diffpy/srreal/version.py +27 -0
- diffpy/srreal/wraputils.py +177 -0
- diffpy_srreal-1.5.0.dist-info/DELVEWHEEL +2 -0
- diffpy_srreal-1.5.0.dist-info/METADATA +206 -0
- diffpy_srreal-1.5.0.dist-info/RECORD +43 -0
- diffpy_srreal-1.5.0.dist-info/WHEEL +5 -0
- diffpy_srreal-1.5.0.dist-info/licenses/AUTHORS.rst +12 -0
- diffpy_srreal-1.5.0.dist-info/licenses/LICENSE.rst +142 -0
- diffpy_srreal-1.5.0.dist-info/licenses/LICENSE_DANSE.rst +42 -0
- diffpy_srreal.libs/msvcp140-7c26614e1d733892c2deac7e245ce115.dll +0 -0
diffpy/__init__.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# (c) 2025 The Trustees of Columbia University in the City of New York.
|
|
5
|
+
# (c) 2026 diffpy.srreal contributors.
|
|
6
|
+
# All rights reserved.
|
|
7
|
+
#
|
|
8
|
+
# File coded by: Billinge Group members and community contributors.
|
|
9
|
+
#
|
|
10
|
+
# See GitHub contributions for a more detailed list of contributors.
|
|
11
|
+
# https://github.com/diffpy/diffpy.srreal/graphs/contributors
|
|
12
|
+
#
|
|
13
|
+
# See LICENSE.rst for license information.
|
|
14
|
+
#
|
|
15
|
+
##############################################################################
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# (c) 2025 The Trustees of Columbia University in the City of New York.
|
|
5
|
+
# (c) 2026 diffpy.srreal contributors.
|
|
6
|
+
# All rights reserved.
|
|
7
|
+
#
|
|
8
|
+
# File coded by: Simon Billinge, Billinge Group members.
|
|
9
|
+
#
|
|
10
|
+
# See GitHub contributions for a more detailed list of contributors.
|
|
11
|
+
# https://github.com/diffpy/diffpy.srreal/graphs/contributors
|
|
12
|
+
#
|
|
13
|
+
# See LICENSE.rst for license information.
|
|
14
|
+
#
|
|
15
|
+
##############################################################################
|
|
16
|
+
"""Calculators for PDF, bond valence sum, and other quantities based on
|
|
17
|
+
atom pair interaction."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# start delvewheel patch
|
|
21
|
+
def _delvewheel_patch_1_13_2():
|
|
22
|
+
import os
|
|
23
|
+
if os.path.isdir(libs_dir := os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'diffpy_srreal.libs'))):
|
|
24
|
+
os.add_dll_directory(libs_dir)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
_delvewheel_patch_1_13_2()
|
|
28
|
+
del _delvewheel_patch_1_13_2
|
|
29
|
+
# end delvewheel patch
|
|
30
|
+
|
|
31
|
+
# package version
|
|
32
|
+
from diffpy.srreal.version import __version__ # noqa
|
|
33
|
+
|
|
34
|
+
# silence the pyflakes syntax checker
|
|
35
|
+
assert __version__ or True
|
|
36
|
+
|
|
37
|
+
# End of file
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal Complex Modeling Initiative
|
|
5
|
+
# (c) 2016 Brookhaven Science Associates,
|
|
6
|
+
# Brookhaven National Laboratory.
|
|
7
|
+
# All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Cancel registration of Python-extended C++ classes when Python exits.
|
|
16
|
+
|
|
17
|
+
Note
|
|
18
|
+
----
|
|
19
|
+
Python finishes before the shared library libdiffpy, but the registry of
|
|
20
|
+
class prototypes is implemented in libdiffpy. Any Python-extended classes
|
|
21
|
+
thus need to be removed from the registry prior to Python exit.
|
|
22
|
+
|
|
23
|
+
This module is not intended for direct use. It is used implicitly within
|
|
24
|
+
a call of _registerThisType.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
import atexit
|
|
28
|
+
import weakref
|
|
29
|
+
|
|
30
|
+
# Routine to be used from srreal_ext module ----------------------------------
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def registerForCleanUp(obj):
|
|
34
|
+
"""Remember to clean up the specified prototype at Python exit.
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
obj : wrapped class that has class registry
|
|
39
|
+
This is an object being added to the C++ registry of prototypes.
|
|
40
|
+
If active at Python exit, the associated string type will be
|
|
41
|
+
removed from the class registry.
|
|
42
|
+
|
|
43
|
+
No return value.
|
|
44
|
+
"""
|
|
45
|
+
_cleanup_handler.add(obj)
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# ----------------------------------------------------------------------------
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class _DerivedClassesCleanUpHandler(object):
|
|
53
|
+
|
|
54
|
+
def __init__(self):
|
|
55
|
+
self._references = set()
|
|
56
|
+
return
|
|
57
|
+
|
|
58
|
+
def add(self, obj):
|
|
59
|
+
wr = weakref.ref(obj)
|
|
60
|
+
self._references.add(wr)
|
|
61
|
+
return
|
|
62
|
+
|
|
63
|
+
def clean(self):
|
|
64
|
+
while self._references:
|
|
65
|
+
wr = self._references.pop()
|
|
66
|
+
obj = wr()
|
|
67
|
+
if obj is not None:
|
|
68
|
+
obj._deregisterType(obj.type())
|
|
69
|
+
return
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# end of class _DerivedClassesCleanUpHandler
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# create singleton instance of the cleanup handler
|
|
76
|
+
_cleanup_handler = _DerivedClassesCleanUpHandler()
|
|
77
|
+
atexit.register(_cleanup_handler.clean)
|
|
78
|
+
|
|
79
|
+
del _DerivedClassesCleanUpHandler
|
|
80
|
+
|
|
81
|
+
# End of file.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal Complex Modeling Initiative
|
|
5
|
+
# (c) 2016 Brookhaven Science Associates,
|
|
6
|
+
# Brookhaven National Laboratory.
|
|
7
|
+
# All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Docstrings for classes and functions in srreal_ext module."""
|
|
16
|
+
|
|
17
|
+
# Shared docstrings for classes derived from HasClassRegistry ----------------
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_registry_docstrings(cls):
|
|
21
|
+
"""Build a dictionary of docstrings per each HasClassRegistry
|
|
22
|
+
method.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
cls : class type that is wrapped
|
|
27
|
+
This parameter is used to extract the class name and substitute
|
|
28
|
+
it in the docstrings template.
|
|
29
|
+
|
|
30
|
+
Returns a dictionary mapping Python method names to their docstrins.
|
|
31
|
+
"""
|
|
32
|
+
n = cls.__name__
|
|
33
|
+
rv = {
|
|
34
|
+
k: v.replace("@NAME@", n)
|
|
35
|
+
for k, v in (
|
|
36
|
+
("create", doc_HasClassRegistry_create),
|
|
37
|
+
("clone", doc_HasClassRegistry_clone),
|
|
38
|
+
("type", doc_HasClassRegistry_type),
|
|
39
|
+
("_registerThisType", doc_HasClassRegistry__registerThisType),
|
|
40
|
+
("_aliasType", doc_HasClassRegistry__aliasType),
|
|
41
|
+
("_deregisterType", doc_HasClassRegistry__deregisterType),
|
|
42
|
+
("createByType", doc_HasClassRegistry_createByType),
|
|
43
|
+
("isRegisteredType", doc_HasClassRegistry_isRegisteredType),
|
|
44
|
+
("getAliasedTypes", doc_HasClassRegistry_getAliasedTypes),
|
|
45
|
+
("getRegisteredTypes", doc_HasClassRegistry_getRegisteredTypes),
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
return rv
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
doc_HasClassRegistry_create = """\
|
|
52
|
+
Return a new instance of the same type as self.
|
|
53
|
+
|
|
54
|
+
This method must be overloaded in a derived class.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
doc_HasClassRegistry_clone = """\
|
|
59
|
+
Return a new instance that is a copy of self.
|
|
60
|
+
|
|
61
|
+
This method must be overloaded in a derived class.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
doc_HasClassRegistry_type = """\
|
|
66
|
+
Return a unique string type that identifies a @NAME@-derived class.
|
|
67
|
+
The string type is used for class registration and in the `createByType`
|
|
68
|
+
function.
|
|
69
|
+
|
|
70
|
+
This method must be overloaded in a derived class.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
doc_HasClassRegistry__registerThisType = """\
|
|
75
|
+
Add this class to the global registry of @NAME@ types.
|
|
76
|
+
|
|
77
|
+
This method must be called once after definition of the derived
|
|
78
|
+
class to support pickling and the `createByType` factory.
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
doc_HasClassRegistry__aliasType = """\
|
|
83
|
+
Register the specified class type under another string alias.
|
|
84
|
+
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
tp : str
|
|
88
|
+
string type identifying a registered @NAME@ class.
|
|
89
|
+
alias : str
|
|
90
|
+
string alias to be used for the `tp` type.
|
|
91
|
+
|
|
92
|
+
Raises
|
|
93
|
+
------
|
|
94
|
+
RuntimeError
|
|
95
|
+
When they `tp` type is unknown or if the `alias` type is already
|
|
96
|
+
registered.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
doc_HasClassRegistry__deregisterType = """\
|
|
101
|
+
Cancel registration of the specified string type and any of its aliases.
|
|
102
|
+
|
|
103
|
+
Parameters
|
|
104
|
+
----------
|
|
105
|
+
tp : str
|
|
106
|
+
string type or an alias of a registered @NAME@ class.
|
|
107
|
+
|
|
108
|
+
Returns
|
|
109
|
+
-------
|
|
110
|
+
count : int
|
|
111
|
+
Number of unregistered names or aliases.
|
|
112
|
+
Return 0 if `tp` is not a registered type.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
doc_HasClassRegistry_createByType = """\
|
|
117
|
+
Return a new @NAME@ instance of the specified string type.
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
tp : str
|
|
122
|
+
string type identifying a registered @NAME@ class.
|
|
123
|
+
|
|
124
|
+
Returns
|
|
125
|
+
-------
|
|
126
|
+
@NAME@
|
|
127
|
+
A new instance of the @NAME@-derived class named `tp`.
|
|
128
|
+
|
|
129
|
+
See Also
|
|
130
|
+
--------
|
|
131
|
+
getRegisteredTypes : Return set of the recognized type strings.
|
|
132
|
+
getAliasedTypes : Return dictionary of string aliases.
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
doc_HasClassRegistry_isRegisteredType = """\
|
|
137
|
+
Check if the given string is registered as a named @NAME@ type.
|
|
138
|
+
|
|
139
|
+
Parameters
|
|
140
|
+
----------
|
|
141
|
+
tp : str
|
|
142
|
+
string name or an alias to be checked.
|
|
143
|
+
|
|
144
|
+
Returns
|
|
145
|
+
-------
|
|
146
|
+
bool
|
|
147
|
+
``True`` if `tp` is known to the registry either as a standard
|
|
148
|
+
type or its alias.
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
doc_HasClassRegistry_getAliasedTypes = """\
|
|
153
|
+
Get all aliases registered for the @NAME@ string types.
|
|
154
|
+
|
|
155
|
+
Returns
|
|
156
|
+
-------
|
|
157
|
+
dict
|
|
158
|
+
a map of registered aliases to their corresponding standard names.
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
doc_HasClassRegistry_getRegisteredTypes = """\
|
|
163
|
+
Get string types of all registered @NAME@ classes.
|
|
164
|
+
|
|
165
|
+
These are the allowed arguments for the `createByType` factory.
|
|
166
|
+
|
|
167
|
+
Returns
|
|
168
|
+
-------
|
|
169
|
+
set
|
|
170
|
+
the registered string types.
|
|
171
|
+
"""
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal Complex Modeling Initiative
|
|
5
|
+
# (c) 2016 Brookhaven Science Associates,
|
|
6
|
+
# Brookhaven National Laboratory.
|
|
7
|
+
# All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Finalize tweak of classes from the extension module srreal_ext.
|
|
16
|
+
|
|
17
|
+
This private module handles loading of Python-level tweaks of the
|
|
18
|
+
extension-defined classes. Any client that imports this module must
|
|
19
|
+
call the `import_now` function. If this module is not loaded by the
|
|
20
|
+
time of srreal_ext initialization, `import_now` is executed from
|
|
21
|
+
srreal_ext.
|
|
22
|
+
|
|
23
|
+
This avoids unresolvable import dependencies for any order of imports.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
_import_now_called = False
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def import_now():
|
|
30
|
+
"""Import all Python modules that tweak extension-defined
|
|
31
|
+
classes."""
|
|
32
|
+
global _import_now_called
|
|
33
|
+
if _import_now_called:
|
|
34
|
+
return
|
|
35
|
+
_import_now_called = True
|
|
36
|
+
from importlib import import_module
|
|
37
|
+
|
|
38
|
+
import_module("diffpy.srreal.attributes")
|
|
39
|
+
import_module("diffpy.srreal.atomradiitable")
|
|
40
|
+
import_module("diffpy.srreal.bondcalculator")
|
|
41
|
+
import_module("diffpy.srreal.bvscalculator")
|
|
42
|
+
import_module("diffpy.srreal.overlapcalculator")
|
|
43
|
+
import_module("diffpy.srreal.pdfbaseline")
|
|
44
|
+
import_module("diffpy.srreal.pdfenvelope")
|
|
45
|
+
import_module("diffpy.srreal.peakprofile")
|
|
46
|
+
import_module("diffpy.srreal.peakwidthmodel")
|
|
47
|
+
import_module("diffpy.srreal.scatteringfactortable")
|
|
48
|
+
import_module("diffpy.srreal.pdfcalculator")
|
|
49
|
+
import_module("diffpy.srreal.structureconverters")
|
|
50
|
+
return
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Copy ObjCryst structures without crossing a C++ library ABI boundary.
|
|
2
|
+
|
|
3
|
+
Use only pyobjcryst's Python API so both its Boost.Python releases and
|
|
4
|
+
its nanobind migration (with a private, static ObjCryst++ library) can
|
|
5
|
+
be used. Keep the numerical conventions of libdiffpy's
|
|
6
|
+
ObjCrystStructureAdapter.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
|
|
11
|
+
from diffpy.srreal.srreal_ext import (
|
|
12
|
+
Atom,
|
|
13
|
+
AtomicStructureAdapter,
|
|
14
|
+
CrystalStructureAdapter,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _check_type(obj, name):
|
|
19
|
+
# Import lazily: pyobjcryst is an optional runtime dependency.
|
|
20
|
+
from pyobjcryst import _pyobjcryst
|
|
21
|
+
|
|
22
|
+
if not isinstance(obj, getattr(_pyobjcryst, name)):
|
|
23
|
+
raise TypeError(f"Expected a pyobjcryst {name} object.")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _atom_from_scattering_power(sp):
|
|
27
|
+
atom = Atom()
|
|
28
|
+
atom.atomtype = sp.GetSymbol()
|
|
29
|
+
atom.anisotropy = not sp.IsIsotropic()
|
|
30
|
+
if atom.anisotropy:
|
|
31
|
+
bij = np.array(
|
|
32
|
+
[[sp.GetBij(i, j) for j in range(1, 4)] for i in range(1, 4)]
|
|
33
|
+
)
|
|
34
|
+
else:
|
|
35
|
+
bij = np.eye(3) * sp.GetBiso()
|
|
36
|
+
atom.uij_cartn = bij / (8 * np.pi**2)
|
|
37
|
+
return atom
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def convertObjCrystMolecule(molecule):
|
|
41
|
+
"""Copy molecule atoms in local Cartesian coordinates, omitting
|
|
42
|
+
dummies."""
|
|
43
|
+
_check_type(molecule, "Molecule")
|
|
44
|
+
adapter = AtomicStructureAdapter()
|
|
45
|
+
adapter.reserve(molecule.GetNbComponent())
|
|
46
|
+
for i in range(molecule.GetNbComponent()):
|
|
47
|
+
source = molecule.GetAtom(i)
|
|
48
|
+
if source.IsDummy():
|
|
49
|
+
continue
|
|
50
|
+
atom = _atom_from_scattering_power(source.GetScatteringPower())
|
|
51
|
+
atom.xyz_cartn = [source.X, source.Y, source.Z]
|
|
52
|
+
atom.occupancy = source.Occupancy
|
|
53
|
+
adapter.append(atom)
|
|
54
|
+
return adapter
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def convertObjCrystCrystal(crystal):
|
|
58
|
+
"""Copy the asymmetric unit and complete space-group symmetry
|
|
59
|
+
operations."""
|
|
60
|
+
_check_type(crystal, "Crystal")
|
|
61
|
+
adapter = CrystalStructureAdapter()
|
|
62
|
+
lattice = [crystal.GetLatticePar(i) for i in range(6)]
|
|
63
|
+
lattice[3:] = np.degrees(lattice[3:])
|
|
64
|
+
adapter.setLatPar(*lattice)
|
|
65
|
+
components = crystal.GetScatteringComponentList()
|
|
66
|
+
adapter.reserve(len(components))
|
|
67
|
+
for source in components:
|
|
68
|
+
sp = source.mpScattPow
|
|
69
|
+
if sp is None:
|
|
70
|
+
continue
|
|
71
|
+
atom = _atom_from_scattering_power(sp)
|
|
72
|
+
atom.xyz_cartn = [source.mX, source.mY, source.mZ]
|
|
73
|
+
atom.occupancy = source.mOccupancy
|
|
74
|
+
# Isotropic U is already Cartesian. Only anisotropic U follows the
|
|
75
|
+
# lattice transformation; coordinates always need that transformation.
|
|
76
|
+
uij = atom.uij_cartn.copy()
|
|
77
|
+
adapter.toCartesian(atom)
|
|
78
|
+
if not atom.anisotropy:
|
|
79
|
+
atom.uij_cartn = uij
|
|
80
|
+
adapter.append(atom)
|
|
81
|
+
|
|
82
|
+
sg = crystal.GetSpaceGroup()
|
|
83
|
+
operations = [
|
|
84
|
+
(np.asarray(rotation), np.asarray(translation) + offset)
|
|
85
|
+
for offset in sg.GetTranslationVectors()
|
|
86
|
+
for translation, rotation in sg.GetSymmetryOperations()
|
|
87
|
+
]
|
|
88
|
+
if len(operations) < sg.GetNbSymmetrics():
|
|
89
|
+
inversion = 2 * np.asarray(sg.GetInversionCenter())
|
|
90
|
+
operations += [(-r, inversion - t) for r, t in operations]
|
|
91
|
+
if len(operations) != sg.GetNbSymmetrics():
|
|
92
|
+
raise ValueError("Inconsistent pyobjcryst space-group operations.")
|
|
93
|
+
for rotation, translation in operations:
|
|
94
|
+
adapter.addSymOp(rotation, translation)
|
|
95
|
+
adapter.updateSymmetryPositions()
|
|
96
|
+
return adapter
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal by DANSE Diffraction group
|
|
5
|
+
# Simon J. L. Billinge
|
|
6
|
+
# (c) 2011 The Trustees of Columbia University
|
|
7
|
+
# in the City of New York. All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE_DANSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Class AtomRadiiTable -- storage of empirical atom radii."""
|
|
16
|
+
|
|
17
|
+
# exported items, these also makes them show in pydoc.
|
|
18
|
+
__all__ = ["AtomRadiiTable", "ConstantRadiiTable", "CovalentRadiiTable"]
|
|
19
|
+
|
|
20
|
+
from diffpy.srreal.srreal_ext import AtomRadiiTable, ConstantRadiiTable
|
|
21
|
+
|
|
22
|
+
# class CovalentRadiiTable ---------------------------------------------------
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CovalentRadiiTable(AtomRadiiTable):
|
|
26
|
+
"""Covalent radii from Cordero et al., 2008, doi:10.1039/b801115j.
|
|
27
|
+
|
|
28
|
+
Instantiation of this class requires the periodictable module.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
# class variable that holds the periodictable.elements object
|
|
32
|
+
_elements = None
|
|
33
|
+
|
|
34
|
+
def _standardLookup(self, smbl):
|
|
35
|
+
"""Return covalent atom radius in Angstroms.
|
|
36
|
+
|
|
37
|
+
Attributes
|
|
38
|
+
----------
|
|
39
|
+
smbl
|
|
40
|
+
string symbol of an element
|
|
41
|
+
|
|
42
|
+
Return float. Raise ValueError for unknown element symbol.
|
|
43
|
+
"""
|
|
44
|
+
if CovalentRadiiTable._elements is None:
|
|
45
|
+
from periodictable import elements
|
|
46
|
+
|
|
47
|
+
CovalentRadiiTable._elements = elements
|
|
48
|
+
e = self._elements.isotope(smbl)
|
|
49
|
+
rv = e.covalent_radius
|
|
50
|
+
if rv is None:
|
|
51
|
+
emsg = "Undefined covalent radius for %r." % smbl
|
|
52
|
+
raise ValueError(emsg)
|
|
53
|
+
return rv
|
|
54
|
+
|
|
55
|
+
# HasClassRegistry overloads:
|
|
56
|
+
|
|
57
|
+
def create(self):
|
|
58
|
+
"""Create new instance of the CovalentRadiiTable."""
|
|
59
|
+
return CovalentRadiiTable()
|
|
60
|
+
|
|
61
|
+
def clone(self):
|
|
62
|
+
"""Return a new duplicate instance of self."""
|
|
63
|
+
import copy
|
|
64
|
+
|
|
65
|
+
return copy.copy(self)
|
|
66
|
+
|
|
67
|
+
def type(self):
|
|
68
|
+
"""Unique string identifier of the CovalentRadiiTable type.
|
|
69
|
+
|
|
70
|
+
This is used for class registration and as an argument for the
|
|
71
|
+
createByType function.
|
|
72
|
+
|
|
73
|
+
Return string.
|
|
74
|
+
"""
|
|
75
|
+
return "covalent"
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# End of class CovalentRadiiTable
|
|
79
|
+
CovalentRadiiTable()._registerThisType()
|
|
80
|
+
|
|
81
|
+
# End of file
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal by DANSE Diffraction group
|
|
5
|
+
# Simon J. L. Billinge
|
|
6
|
+
# (c) 2010 The Trustees of Columbia University
|
|
7
|
+
# in the City of New York. All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE_DANSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""class Attributes -- wrapper to C++ class diffpy::Attributes
|
|
16
|
+
A base to PairQuantity and quite a few other classes.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
__all__ = ["Attributes"]
|
|
20
|
+
|
|
21
|
+
from diffpy.srreal.srreal_ext import Attributes
|
|
22
|
+
|
|
23
|
+
# Inject the __getattr__ and __setattr__ methods to the Attributes class
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _getattr(self, name):
|
|
27
|
+
"""Lookup a C++ double attribute if standard Python lookup fails.
|
|
28
|
+
|
|
29
|
+
Raise AttributeError if C++ double attribute does not exist.
|
|
30
|
+
"""
|
|
31
|
+
rv = self._getDoubleAttr(name)
|
|
32
|
+
return rv
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
Attributes.__getattr__ = _getattr
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _setattr(self, name, value):
|
|
39
|
+
"""Assign to C++ double attribute if Python attribute does not
|
|
40
|
+
exist."""
|
|
41
|
+
try:
|
|
42
|
+
object.__getattribute__(self, name)
|
|
43
|
+
except AttributeError:
|
|
44
|
+
if self._hasDoubleAttr(name):
|
|
45
|
+
self._setDoubleAttr(name, value)
|
|
46
|
+
return
|
|
47
|
+
object.__setattr__(self, name, value)
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
Attributes.__setattr__ = _setattr
|
|
52
|
+
|
|
53
|
+
# Helper accessor functions used by the _registerDoubleAttribute method
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _pyattrgetter(name):
|
|
57
|
+
def f(obj):
|
|
58
|
+
return object.__getattribute__(obj, name)
|
|
59
|
+
|
|
60
|
+
return f
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _pyattrsetter(name):
|
|
64
|
+
def f(obj, value):
|
|
65
|
+
object.__setattr__(obj, name, value)
|
|
66
|
+
|
|
67
|
+
return f
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# End of file
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal by DANSE Diffraction group
|
|
5
|
+
# Simon J. L. Billinge
|
|
6
|
+
# (c) 2011 The Trustees of Columbia University
|
|
7
|
+
# in the City of New York. All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE_DANSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Class BondCalculator -- distances between atoms in the structure."""
|
|
16
|
+
|
|
17
|
+
# exported items, these also makes them show in pydoc.
|
|
18
|
+
__all__ = ["BondCalculator"]
|
|
19
|
+
|
|
20
|
+
from diffpy.srreal import srreal_ext as _srreal_ext
|
|
21
|
+
from diffpy.srreal.srreal_ext import BondCalculator as _BondCalculator
|
|
22
|
+
from diffpy.srreal.wraputils import (
|
|
23
|
+
propertyFromExtDoubleAttr,
|
|
24
|
+
setattrFromKeywordArguments,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class BondCalculator(_BondCalculator):
|
|
29
|
+
__doc__ = _BondCalculator.__doc__
|
|
30
|
+
|
|
31
|
+
def __init__(self, **kwargs):
|
|
32
|
+
"""Create a new instance of BondCalculator. Keyword arguments can be
|
|
33
|
+
used to configure calculator properties, for example:
|
|
34
|
+
|
|
35
|
+
bdc = BondCalculator(rmin=1.5, rmax=2.5)
|
|
36
|
+
|
|
37
|
+
Raise ValueError for invalid keyword argument.
|
|
38
|
+
"""
|
|
39
|
+
super().__init__()
|
|
40
|
+
setattrFromKeywordArguments(self, **kwargs)
|
|
41
|
+
return
|
|
42
|
+
|
|
43
|
+
def __call__(self, structure=None, **kwargs):
|
|
44
|
+
"""Return sorted bond distances in the specified structure.
|
|
45
|
+
|
|
46
|
+
Attributes
|
|
47
|
+
----------
|
|
48
|
+
structure
|
|
49
|
+
structure to be evaluated, an instance of diffpy Structure
|
|
50
|
+
or pyobjcryst Crystal. Reuse the last structure when None.
|
|
51
|
+
kwargs
|
|
52
|
+
optional parameter settings for this calculator
|
|
53
|
+
|
|
54
|
+
Return a sorted numpy array.
|
|
55
|
+
"""
|
|
56
|
+
setattrFromKeywordArguments(self, **kwargs)
|
|
57
|
+
self.eval(structure)
|
|
58
|
+
return self.distances
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# property wrappers to C++ double attributes
|
|
62
|
+
|
|
63
|
+
BondCalculator.rmin = propertyFromExtDoubleAttr(
|
|
64
|
+
"rmin",
|
|
65
|
+
"Lower bound for the bond distances. [0 A]",
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
BondCalculator.rmax = propertyFromExtDoubleAttr(
|
|
69
|
+
"rmax",
|
|
70
|
+
"Upper bound for the bond distances. [5 A]",
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# Historical pickles and direct extension imports use this public name.
|
|
75
|
+
_srreal_ext.BondCalculator = BondCalculator
|
|
76
|
+
|
|
77
|
+
# End of file
|