forked from diffpy/diffpy.srreal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoverlapcalculator.py
More file actions
83 lines (64 loc) · 2.44 KB
/
overlapcalculator.py
File metadata and controls
83 lines (64 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
##############################################################################
#
# diffpy.srreal by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2011 The Trustees of Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
#
# See AUTHORS.txt for a list of people who contributed.
# See LICENSE_DANSE.txt for license information.
#
##############################################################################
"""Class OverlapCalculator -- calculator of atom overlaps in a structure."""
# exported items, these also makes them show in pydoc.
__all__ = ["OverlapCalculator"]
from diffpy.srreal.srreal_ext import OverlapCalculator
from diffpy.srreal.wraputils import (
propertyFromExtDoubleAttr,
setattrFromKeywordArguments,
)
# property wrappers to C++ double attributes
OverlapCalculator.rmin = propertyFromExtDoubleAttr(
"rmin",
"""Lower bound for the bond distances.
[0 A]""",
)
OverlapCalculator.rmax = propertyFromExtDoubleAttr(
"rmax",
"""Upper bound for the bond distances.
[5 A]""",
)
OverlapCalculator.rmaxused = propertyFromExtDoubleAttr(
"rmaxused",
"""Effective upper bound for the bond distances.
rmaxused equals either a double of the maximum atom radius
in the structure or rmax.
""",
)
# method overrides that support keyword arguments
def _init_kwargs(self, **kwargs):
"""Create a new instance of OverlapCalculator. Keyword arguments can be
used to configure calculator properties, for example:
olc = OverlapCalculator(rmax=2.5)
Raise ValueError for invalid keyword argument.
"""
OverlapCalculator.__boostpython__init(self)
setattrFromKeywordArguments(self, **kwargs)
return
def _call_kwargs(self, structure=None, **kwargs):
"""Return siteSquareOverlaps per each site of the structure.
structure -- structure to be evaluated, an instance of diffpy Structure
or pyobjcryst Crystal. Reuse the last structure when None.
kwargs -- optional parameter settings for this calculator
Return a numpy array.
"""
setattrFromKeywordArguments(self, **kwargs)
self.eval(structure)
return self.sitesquareoverlaps
OverlapCalculator.__boostpython__init = OverlapCalculator.__init__
OverlapCalculator.__init__ = _init_kwargs
OverlapCalculator.__call__ = _call_kwargs
# End of file