forked from diffpy/diffpy.srreal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbvscalculator.py
More file actions
98 lines (77 loc) · 2.84 KB
/
bvscalculator.py
File metadata and controls
98 lines (77 loc) · 2.84 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python
##############################################################################
#
# diffpy.srreal by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2010 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 BVSCalculator -- bond valence sums calculator."""
# exported items
__all__ = ["BVSCalculator"]
from diffpy.srreal.srreal_ext import BVSCalculator
from diffpy.srreal.wraputils import (
propertyFromExtDoubleAttr,
setattrFromKeywordArguments,
)
# Property wrappers to C++ double attributes
BVSCalculator.valenceprecision = propertyFromExtDoubleAttr(
"valenceprecision",
"""Cutoff value for valence contributions at long distances.
[1e-5]""",
)
BVSCalculator.rmaxused = propertyFromExtDoubleAttr(
"rmaxused",
"""Effective bound for bond lengths, where valence contributions
become smaller than valenceprecission, read-only. Always smaller or
equal to rmax. The value depends on ions present in the structure.
""",
)
BVSCalculator.rmin = propertyFromExtDoubleAttr(
"rmin",
"""Lower bound for the summed bond lengths.
[0 A]""",
)
BVSCalculator.rmax = propertyFromExtDoubleAttr(
"rmax",
"""Upper bound for the summed bond lengths. The calculation is
actually cut off much earlier when valence contributions get below
valenceprecission. See also rmaxused and valenceprecission.
[1e6 A]""",
)
# method overrides that support keyword arguments
def _init_kwargs(self, **kwargs):
"""Create a new instance of BVSCalculator.
Keyword arguments can be used to configure the calculator properties,
for example:
bvscalc = BVSCalculator(valenceprecision=0.001)
Raise ValueError for invalid keyword argument.
"""
BVSCalculator.__boostpython__init(self)
setattrFromKeywordArguments(self, **kwargs)
return
def _call_kwargs(self, structure=None, **kwargs):
"""Return bond valence sums at each atom site in the structure.
Attributes
----------
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 an array of calculated valence sums.
See valences for the expected values.
"""
setattrFromKeywordArguments(self, **kwargs)
rv = self.eval(structure)
return rv
BVSCalculator.__boostpython__init = BVSCalculator.__init__
BVSCalculator.__init__ = _init_kwargs
BVSCalculator.__call__ = _call_kwargs
# End of file