"""class BondCalculator -- distances between atoms in the structure.
"""


# exported items, these also makes them show in pydoc.
__all__ = ["BondCalculator"]

from diffpy.srreal.wraputils import propertyFromExtDoubleAttr
from diffpy.srreal.wraputils import setattrFromKeywordArguments
from diffpy.srreal.srreal_ext import BondCalculator

# property wrappers to C++ double attributes

BondCalculator.rmin = propertyFromExtDoubleAttr(
    "rmin",
    """Lower bound for the bond distances.
        [0 A]""",
)

BondCalculator.rmax = propertyFromExtDoubleAttr(
    "rmax",
    """Upper bound for the bond distances.
        [5 A]""",
)


# method overrides that support keyword arguments


def _init_kwargs(self, **kwargs):
    """Create a new instance of BondCalculator.
示例#2
0
# inject pickle methods to the base class

PeakWidthModel.__reduce__ = _peakwidthmodel_reduce_with_state
PeakWidthModel.__getstate__ = _pickle_getstate
PeakWidthModel.__setstate__ = _pickle_setstate

# Derived C++ classes are pickled without dictionary

ConstantPeakWidth.__reduce__ = _peakwidthmodel_reduce
DebyeWallerPeakWidth.__reduce__ = _peakwidthmodel_reduce
JeongPeakWidth.__reduce__ = _peakwidthmodel_reduce

# add attribute wrappers for the derived classes

ConstantPeakWidth.width = propertyFromExtDoubleAttr(
    'width', '''Constant FWHM value returned by this model.
    ''')

JeongPeakWidth.delta1 = propertyFromExtDoubleAttr(
    'delta1', 'Coefficient for (1/r) contribution to the peak sharpening.')

JeongPeakWidth.delta2 = propertyFromExtDoubleAttr(
    'delta2', 'Coefficient for (1/r**2) contribution to the peak sharpening.')

JeongPeakWidth.qbroad = propertyFromExtDoubleAttr(
    'qbroad', 'PDF peak broadening from increased intensity noise at high Q.')

# Import delayed tweaks of the extension classes.

_final_imports.import_now()
del _final_imports
"""

# module version
__id__ = "$Id$"

# exported items, these also makes them show in pydoc.
__all__ = ['BondCalculator']

from diffpy.srreal.wraputils import propertyFromExtDoubleAttr
from diffpy.srreal.wraputils import setattrFromKeywordArguments
from diffpy.srreal.srreal_ext import BondCalculator

# property wrappers to C++ double attributes

BondCalculator.rmin = propertyFromExtDoubleAttr('rmin',
        '''Lower bound for the bond distances.
        [0 A]''')

BondCalculator.rmax = propertyFromExtDoubleAttr('rmax',
        '''Upper bound for the bond distances.
        [5 A]''')


# method overrides that support keyword arguments

def _init_kwargs(self, **kwargs):
    '''Create a new instance of BondCalculator.
    Keyword arguments can be used to configure
    calculator properties, for example:

    bdc = BondCalculator(rmin=1.5, rmax=2.5)
#
##############################################################################
"""class OverlapCalculator -- calculator of atom overlaps in a structure.
"""

# exported items, these also makes them show in pydoc.
__all__ = ['OverlapCalculator']

from diffpy.srreal.wraputils import propertyFromExtDoubleAttr
from diffpy.srreal.wraputils import setattrFromKeywordArguments
from diffpy.srreal.srreal_ext import OverlapCalculator

# 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

示例#5
0
from diffpy.srreal.srreal_ext import SphericalShapeEnvelope, StepCutEnvelope
from diffpy.srreal.wraputils import propertyFromExtDoubleAttr

# class PDFEnvelope ----------------------------------------------------------

# disable dictionary pickling for wrapped C++ classes

QResolutionEnvelope.__getstate_manages_dict__ = None
ScaleEnvelope.__getstate_manages_dict__ = None
SphericalShapeEnvelope.__getstate_manages_dict__ = None
StepCutEnvelope.__getstate_manages_dict__ = None

# attribute wrappers

QResolutionEnvelope.qdamp = propertyFromExtDoubleAttr(
    'qdamp', '''Dampening parameter in the Gaussian envelope function.
    ''')

ScaleEnvelope.scale = propertyFromExtDoubleAttr(
    'scale', '''Overall scale for a uniform scaling envelope.
    ''')

SphericalShapeEnvelope.spdiameter = propertyFromExtDoubleAttr(
    'spdiameter',
    '''Particle diameter in Angstroms for a spherical shape damping.
    ''')

StepCutEnvelope.stepcut = propertyFromExtDoubleAttr(
    'stepcut', '''Cutoff for a step-function envelope.
    ''')
示例#6
0
    args = (_PeakProfile_tostring(self), )
    rv = (_peakprofile_create, args)
    return rv


def _peakprofile_reduce_with_state(self):
    rv = _peakprofile_reduce(self) + (self.__getstate__(), )
    return rv


# inject pickle methods to the base class

PeakProfile.__reduce__ = _peakprofile_reduce_with_state
PeakProfile.__getstate__ = _pickle_getstate
PeakProfile.__setstate__ = _pickle_setstate

# Derived C++ classes are pickled without dictionary

GaussianProfile.__reduce__ = _peakprofile_reduce
CroppedGaussianProfile.__reduce__ = _peakprofile_reduce

# add attribute wrappers for PeakProfile and derived classes

PeakProfile.peakprecision = propertyFromExtDoubleAttr(
    'peakprecision',
    '''Profile amplitude relative to the peak maximum for evaluating peak
    bounds xboundlo and xboundhi. [3.33e-6 unitless]
    ''')

# End of file
示例#7
0
        rv = (self.rgrid, self.pdf)
        return rv
    cls.__call__ = _call_kwargs

# _defineCommonInterface

# class DebyePDFCalculator ---------------------------------------------------

# shared interface of the PDF calculator classes

_defineCommonInterface(DebyePDFCalculator)

# Property wrappers to double attributes of the C++ DebyePDFCalculator

DebyePDFCalculator.debyeprecision = propertyFromExtDoubleAttr('debyeprecision',
        '''Cutoff amplitude for the sine contributions to the F(Q).
        [1e-6 unitless]''')

DebyePDFCalculator.qmin = propertyFromExtDoubleAttr('qmin',
        '''Lower bound of the Q-grid for the calculated F(Q).
        Affects the shape envelope.
        [0 1/A]
        ''')

DebyePDFCalculator.qmax = propertyFromExtDoubleAttr('qmax',
        '''Upper bound of the Q-grid for the calculated F(Q).
        Affects the termination ripples.
        [25 1/A]
        ''')

DebyePDFCalculator.qstep = propertyFromExtDoubleAttr('qstep',
"""

# module version
__id__ = "$Id$"

# exported items
__all__ = ['BVSCalculator']

from diffpy.srreal.srreal_ext import BVSCalculator
from diffpy.srreal.wraputils import propertyFromExtDoubleAttr
from diffpy.srreal.wraputils import 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
"""class OverlapCalculator -- calculator of atom overlaps in a structure.
"""


# exported items, these also makes them show in pydoc.
__all__ = ['OverlapCalculator']

from diffpy.srreal.wraputils import propertyFromExtDoubleAttr
from diffpy.srreal.wraputils import setattrFromKeywordArguments
from diffpy.srreal.srreal_ext import OverlapCalculator

# 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):
示例#10
0
    'ConstantPeakWidth',
    'DebyeWallerPeakWidth',
    'JeongPeakWidth'
]

from diffpy.srreal import _final_imports
from diffpy.srreal.srreal_ext import PeakWidthModel, ConstantPeakWidth
from diffpy.srreal.srreal_ext import DebyeWallerPeakWidth, JeongPeakWidth
from diffpy.srreal.wraputils import propertyFromExtDoubleAttr

# class PeakWidthModel -------------------------------------------------------

# add attribute wrappers for the derived classes

ConstantPeakWidth.width = propertyFromExtDoubleAttr('width',
    '''Constant FWHM value returned by this model.
    ''')

ConstantPeakWidth.bisowidth = propertyFromExtDoubleAttr('bisowidth',
    '''Equivalent uniform Biso for this constant `width`.
    ''')

ConstantPeakWidth.uisowidth = propertyFromExtDoubleAttr('uisowidth',
    '''Equivalent uniform Uiso for this constant `width`.
    ''')

JeongPeakWidth.delta1 = propertyFromExtDoubleAttr('delta1',
        'Coefficient for (1/r) contribution to the peak sharpening.')

JeongPeakWidth.delta2 = propertyFromExtDoubleAttr('delta2',
        'Coefficient for (1/r**2) contribution to the peak sharpening.')
示例#11
0
from diffpy.srreal import _final_imports
from diffpy.srreal.srreal_ext import PDFBaseline
from diffpy.srreal.srreal_ext import ZeroBaseline, LinearBaseline
from diffpy.srreal.wraputils import propertyFromExtDoubleAttr

# class PDFBaseline ----------------------------------------------------------

# disable dictionary pickling for wrapped C++ classes

LinearBaseline.__getstate_manages_dict__ = None
ZeroBaseline.__getstate_manages_dict__ = None

# attribute wrapper

LinearBaseline.slope = propertyFromExtDoubleAttr('slope',
    '''Slope of an unscaled linear baseline.  For crystal structures it
    is preset to (-4 * pi * rho0).''')

# Python functions wrapper

def makePDFBaseline(name, fnc, replace=False, **dbattrs):
    '''Helper function for registering Python function as a PDFBaseline.
    This is required for using Python function as PDFCalculator.baseline.

    name     -- unique string name for registering Python function in the
                global registry of PDFBaseline types.  This will be the
                string identifier for the createByType factory.
    fnc      -- Python function of a floating point argument and optional
                float parameters.  The parameters need to be registered as
                double attributes in the functor class.  The function fnc
                must be picklable and it must return a float.
示例#12
0
#
##############################################################################
"""class BondCalculator -- distances between atoms in the structure.
"""

# exported items, these also makes them show in pydoc.
__all__ = ['BondCalculator']

from diffpy.srreal.wraputils import propertyFromExtDoubleAttr
from diffpy.srreal.wraputils import setattrFromKeywordArguments
from diffpy.srreal.srreal_ext import BondCalculator

# property wrappers to C++ double attributes

BondCalculator.rmin = propertyFromExtDoubleAttr(
    'rmin', '''Lower bound for the bond distances.
        [0 A]''')

BondCalculator.rmax = propertyFromExtDoubleAttr(
    'rmax', '''Upper bound for the bond distances.
        [5 A]''')

# method overrides that support keyword arguments


def _init_kwargs(self, **kwargs):
    '''Create a new instance of BondCalculator.
    Keyword arguments can be used to configure
    calculator properties, for example:

    bdc = BondCalculator(rmin=1.5, rmax=2.5)
示例#13
0
#
##############################################################################
"""class BVSCalculator -- bond valence sums calculator
"""

# exported items
__all__ = ['BVSCalculator']

from diffpy.srreal.srreal_ext import BVSCalculator
from diffpy.srreal.wraputils import propertyFromExtDoubleAttr
from diffpy.srreal.wraputils import 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
示例#14
0
    rv = _baseline_reduce(self) + (self.__getstate__(),)
    return rv

# inject pickle methods

PDFBaseline.__reduce__ = _baseline_reduce_with_state
PDFBaseline.__getstate__ = _pickle_getstate
PDFBaseline.__setstate__ = _pickle_setstate

ZeroBaseline.__reduce__ = _baseline_reduce
LinearBaseline.__reduce__ = _baseline_reduce

# attribute wrapper

LinearBaseline.slope = propertyFromExtDoubleAttr('slope',
    '''Slope of an unscaled linear baseline.  For crystal structures it
    is preset to (-4 * pi * rho0).''')

# Python functions wrapper

def makePDFBaseline(name, fnc, replace=False, **dbattrs):
    '''Helper function for registering Python function as a PDFBaseline.
    This is required for using Python function as PDFCalculator.baseline.

    name     -- unique string name for registering Python function in the
                global registry of PDFBaseline types.  This will be the
                string identifier for the createByType factory.
    fnc      -- Python function of a floating point argument and optional
                float parameters.  The parameters need to be registered as
                double attributes in the functor class.  The function fnc
                must be picklable and it must return a float.
示例#15
0
def _defineCommonInterface(cls):

    '''This function defines shared properties of PDF calculator classes.
    '''

    cls.scale = propertyFromExtDoubleAttr('scale',
        '''Scale factor of the calculated PDF.  Active for ScaleEnvelope.
        [1.0 unitless]''')

    cls.delta1 = propertyFromExtDoubleAttr('delta1',
        '''Coefficient for (1/r) contribution to the peak sharpening.
        Active for JeongPeakWidth model.
        [0 A]''')

    cls.delta2 = propertyFromExtDoubleAttr('delta2',
        '''Coefficient for (1/r**2) contribution to the peak sharpening.
        Active for JeongPeakWidth model.
        [0 A**2]''')

    cls.qdamp = propertyFromExtDoubleAttr('qdamp',
        '''PDF Gaussian dampening envelope due to limited Q-resolution.
        Not applied when equal to zero.  Active for QResolutionEnvelope.
        [0 1/A]''')

    cls.qbroad = propertyFromExtDoubleAttr('qbroad',
        '''PDF peak broadening from increased intensity noise at high Q.
        Not applied when equal zero.  Active for JeongPeakWidth model.
        [0 1/A]''')

    cls.extendedrmin = propertyFromExtDoubleAttr('extendedrmin',
        '''Low boundary of the extended r-range, read-only.
        [A]''')

    cls.extendedrmax = propertyFromExtDoubleAttr('extendedrmax',
        '''Upper boundary of the extended r-range, read-only.
        [A]''')

    cls.maxextension = propertyFromExtDoubleAttr('maxextension',
        '''Maximum extension of the r-range that accounts for contributions
        from the out of range peaks.
        [10 A]''')

    cls.rmin = propertyFromExtDoubleAttr('rmin',
        '''Lower bound of the r-grid for PDF calculation.
        [0 A]''')

    cls.rmax = propertyFromExtDoubleAttr('rmax',
        '''Upper bound of the r-grid for PDF calculation.
        [10 A]''')

    cls.rstep = propertyFromExtDoubleAttr('rstep',
        '''Spacing in the calculated r-grid.  r-values are at the
        multiples of rstep.
        [0.01 A]''')

    def _call_kwargs(self, structure=None, **kwargs):
        '''Calculate PDF for the given structure as an (r, G) tuple.
        Keyword arguments can be used to configure calculator attributes,
        these override any properties that may be passed from the structure,
        such as spdiameter.

        structure    -- a structure object to be evaluated.  Reuse the last
                        structure when None.
        kwargs       -- optional parameter settings for this calculator

        Example:    pdfcalc(structure, qmax=20, spdiameter=15)

        Return a tuple of (r, G) numpy arrays.
        '''
        setattrFromKeywordArguments(self, **kwargs)
        self.eval(structure)
        # apply kwargs again if structure contained any attribute
        # that may affect the result.
        setattrFromKeywordArguments(self, **kwargs)
        rv = (self.rgrid, self.pdf)
        return rv
    cls.__call__ = _call_kwargs
示例#16
0
def _peakprofile_reduce(self):
    from diffpy.srreal.srreal_ext import _PeakProfile_tostring
    args = (_PeakProfile_tostring(self),)
    rv = (_peakprofile_create, args)
    return rv

def _peakprofile_reduce_with_state(self):
    rv = _peakprofile_reduce(self) + (self.__getstate__(),)
    return rv

# inject pickle methods to the base class

PeakProfile.__reduce__ = _peakprofile_reduce_with_state
PeakProfile.__getstate__ = _pickle_getstate
PeakProfile.__setstate__ = _pickle_setstate

# Derived C++ classes are pickled without dictionary

GaussianProfile.__reduce__ = _peakprofile_reduce
CroppedGaussianProfile.__reduce__ = _peakprofile_reduce

# add attribute wrappers for PeakProfile and derived classes

PeakProfile.peakprecision = propertyFromExtDoubleAttr('peakprecision',
    '''Profile amplitude relative to the peak maximum for evaluating peak
    bounds xboundlo and xboundhi. [3.33e-6 unitless]
    ''')

# End of file
示例#17
0
from diffpy.srreal.srreal_ext import SphericalShapeEnvelope, StepCutEnvelope
from diffpy.srreal.wraputils import propertyFromExtDoubleAttr

# class PDFEnvelope ----------------------------------------------------------

# disable dictionary pickling for wrapped C++ classes

QResolutionEnvelope.__getstate_manages_dict__ = None
ScaleEnvelope.__getstate_manages_dict__ = None
SphericalShapeEnvelope.__getstate_manages_dict__ = None
StepCutEnvelope.__getstate_manages_dict__ = None

# attribute wrappers

QResolutionEnvelope.qdamp = propertyFromExtDoubleAttr('qdamp',
    '''Dampening parameter in the Gaussian envelope function.
    ''')

ScaleEnvelope.scale = propertyFromExtDoubleAttr('scale',
    '''Overall scale for a uniform scaling envelope.
    ''')

SphericalShapeEnvelope.spdiameter = propertyFromExtDoubleAttr('spdiameter',
    '''Particle diameter in Angstroms for a spherical shape damping.
    ''')

StepCutEnvelope.stepcut = propertyFromExtDoubleAttr('stepcut',
    '''Cutoff for a step-function envelope.
    ''')

# Python functions wrapper