diffpy.srreal package
Calculators for PDF, bond valence sum, and other quantities based on atom pair interaction.
Submodules
diffpy.srreal.atomradiitable module
Class AtomRadiiTable – storage of empirical atom radii.
- class diffpy.srreal.atomradiitable.AtomRadiiTable(*args, **kwargs)
Bases:
objectBase class for looking up empirical atom radii. This class has virtual methods and cannot be used as is.
A derived class has to overload the following methods:
create(self) clone(self) type(self) _standardLookup(self, smbl)
Derived class can be added to the global registry of AtomRadiiTable types by calling the _registerThisType method with any instance.
- clone(self) diffpy.srreal.srreal_ext.AtomRadiiTable
Return a new instance that is a copy of self.
This method must be overloaded in a derived class.
- create(self) diffpy.srreal.srreal_ext.AtomRadiiTable
Return a new instance of the same type as self.
This method must be overloaded in a derived class.
- createByType = <nanobind.nb_func object>
- fromString(self, s: str) None
Define custom radius for one or more atom types from string.
s – string with custom atom radii in ‘A1:r1, A2:r2, …’ format.
No return value. Raise ValueError for an invalid string format.
- getAliasedTypes = <nanobind.nb_func object>
- getRegisteredTypes = <nanobind.nb_func object>
- isRegisteredType = <nanobind.nb_func object>
- lookup(self, smbl: str) float
Return empirical radius of an atom in Angstroms.
smbl – string symbol for atom, ion or isotope
Return atom radius in Angstroms. This method cannot be overloaded in Python.
- resetCustom(self, smbl: str) None
Remove custom radius for the specified atom type.
smbl – string symbol for atom, ion or isotope
No return value.
- setCustom(self, smbl: str, radius: float) None
Define custom radius for a specified atom type.
smbl – string symbol for atom, ion or isotope radius – custom radius that will be returned by the lookup method
No return value.
- class diffpy.srreal.atomradiitable.ConstantRadiiTable(*args, **kwargs)
Bases:
AtomRadiiTableAtom radii table with the same radius for all atoms, by default 0.
See setDefault() for changing the default radius or setCustom() and fromString() for setting a special radius for selected atoms.
- clone(self) diffpy.srreal.srreal_ext.AtomRadiiTable
Return a duplicate of this ConstantRadiiTable object
- create(self) diffpy.srreal.srreal_ext.AtomRadiiTable
Return a new instance of ConstantRadiiTable.
- class diffpy.srreal.atomradiitable.CovalentRadiiTable(*args, **kwargs)[source]
Bases:
AtomRadiiTableCovalent radii from Cordero et al., 2008, doi:10.1039/b801115j.
Instantiation of this class requires the periodictable module.
diffpy.srreal.attributes module
class Attributes – wrapper to C++ class diffpy::Attributes A base to PairQuantity and quite a few other classes.
diffpy.srreal.bondcalculator module
Class BondCalculator – distances between atoms in the structure.
diffpy.srreal.bvparameterstable module
Class BVParametersTable – storage of bond valence parameters class BVParam – bond valence data associated with specific cation-anion pair.
- class diffpy.srreal.bvparameterstable.BVParam(*args, **kwargs)
Bases:
objectStorage of bond valence parameters for a given cation-anion pair.
- property B
Bond valence parameter B in Angstroms.
- property Ro
Bond valence parameter Ro in Angstroms.
- property atom0
Bare symbol of the cation atom without charge specification.
- property atom1
Bare symbol of the anion atom without charge specification.
- bondvalenceToDistance(self, valence: float) float
Distance in Angstroms corresponding to specified bond valence.
- property ref_id
code of the reference paper in bvparm2011.cif.
- setFromCifLine(self, arg: str, /) None
Update bond valence data from a string formatted as in bvparm2011.cif.
- property valence0
Positive integer valence of the cation.
- property valence1
Negative integer valence of the anion.
- class diffpy.srreal.bvparameterstable.BVParametersTable(*args, **kwargs)
Bases:
objectLookup table for bond valence parameters of a cation-anion pairs.
- getAll(self) object
Return all bond valence parameter values in this table.
Return a set of BVParam objects.
- getAtomValence(self, smbl: str) int
Return signed valence for the specified atom or ion symbol.
Return valence previously defined by setAtomValence or interpret the charge suffix, for example, use -2 for “S2-“.
- lookup(self, bvparam: diffpy.srreal.srreal_ext.BVParam) diffpy.srreal.srreal_ext.BVParam
- lookup(self, smbl0: str, smbl1: str) diffpy.srreal.srreal_ext.BVParam
- lookup(self, atom0: str, valence0: int, atom1: str, valence1: int) diffpy.srreal.srreal_ext.BVParam
Overloaded function.
lookup(self, bvparam: diffpy.srreal.srreal_ext.BVParam) -> diffpy.srreal.srreal_ext.BVParam
Lookup bond valence parameters by a BVParam instance.
- bvparam – BVParam object. The only attributes considered for
lookup are atom0, valence0, atom1, valence1.
Return a BVParam object with the looked up data. Return BVParametersTable.none() if bond valence data do not exist.
lookup(self, smbl0: str, smbl1: str) -> diffpy.srreal.srreal_ext.BVParam
Lookup bond valence parameters by cation-anion pair. The cation-anion order may be flipped.
smbl0 – symbol of the first ion with charge, e.g., “Na+” smbl1 – symbol of the second ion with charge, e.g., “O2-”
Return a BVParam object with the looked up data. Return BVParametersTable.none() if bond valence data do not exist.
lookup(self, atom0: str, valence0: int, atom1: str, valence1: int) -> diffpy.srreal.srreal_ext.BVParam
Lookup bond valence parameters by cation-anion pair. The cation-anion order may be flipped.
atom0 – bare symbol of the cation atom valence0 – positive integer cation valence atom1 – bare symbol of the anion atom valence1 – negative integer anion valence
Return a BVParam object with the looked up data. Return BVParametersTable.none() if bond valence data do not exist.
- none = <nanobind.nb_func object>
- resetAtomValences(self) None
Unset any custom valences defined by setAtomValence.
Valences are thereafter obtained from charge suffixes only.
- resetCustom(self, bvparam: diffpy.srreal.srreal_ext.BVParam) None
- resetCustom(self, atom0: str, valence0: int, atom1: str, valence1: int) None
Overloaded function.
resetCustom(self, bvparam: diffpy.srreal.srreal_ext.BVParam) -> None
Remove custom bond valence data for the specified cation-anion pair.
- bvparam – BVParam object. The only attributes considered for
custom entry lookup are atom0, valence0, atom1, valence1.
No return value.
resetCustom(self, atom0: str, valence0: int, atom1: str, valence1: int) -> None
Remove custom bond valence data for the specified cation-anion pair. The cation-anion order may be flipped.
atom0 – bare symbol of the cation atom valence0 – positive integer cation valence atom1 – bare symbol of the anion atom valence1 – negative integer anion valence
No return value.
- setAtomValence(self, smbl: str, value: int) None
Define custom valence for the specified atom or ion symbol.
smbl – string symbol of atom or ion, for example “F”. value – signed valence to be used for the symbol, e.g., -1.
No return value.
- setCustom(self, bvparm: diffpy.srreal.srreal_ext.BVParam) None
- setCustom(self, bvparam: diffpy.srreal.srreal_ext.BVParam) None
- setCustom(self, atom0: str, valence0: int, atom1: str, valence1: int, Ro: float, B: float, ref_id: str = '') None
Overloaded function.
setCustom(self, bvparm: diffpy.srreal.srreal_ext.BVParam) -> None
Insert custom bond valence data to the table.
bvparam – BVParam object with the custom bond valence data.
No return value.
setCustom(self, bvparam: diffpy.srreal.srreal_ext.BVParam) -> None
Insert custom bond valence data to the table.
bvparam – BVParam object with the custom bond valence data.
No return value.
setCustom(self, atom0: str, valence0: int, atom1: str, valence1: int, Ro: float, B: float, ref_id: str = '') -> None
Insert custom bond valence data to the table.
atom0 – bare symbol of the cation atom valence0 – positive integer cation valence atom1 – bare symbol of the anion atom valence1 – negative integer anion valence Ro – valence parameter Ro in Angstroms B – valence parameter B in Angstroms ref_id – optional reference code in bvparm2011.cif
No return value.
diffpy.srreal.bvscalculator module
Class BVSCalculator – bond valence sums calculator.
- class diffpy.srreal.bvscalculator.BVSCalculator(**kwargs)[source]
Bases:
BVSCalculatorCalculator of bond valence sums in the specified structure.
- property 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]
- property 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.
- property rmin
Lower bound for the summed bond lengths. [0 A]
- property valenceprecision
Cutoff value for valence contributions at long distances. [1e-5]
diffpy.srreal.eventticker module
Class EventTicker – storage of modification times of dependent objects.
- class diffpy.srreal.eventticker.EventTicker(*args, **kwargs)
Bases:
objectClass for storing modification ‘times’ of dependent objects The default EventTicker object is initialized to a zero time.
- updateFrom(self, other: diffpy.srreal.srreal_ext.EventTicker) None
Update ticker time to the value of other, newer ticker. Keep original value if the other ticker is older.
other – instance of another EventTicker object
No return value.
diffpy.srreal.overlapcalculator module
Class OverlapCalculator – calculator of atom overlaps in a structure.
- class diffpy.srreal.overlapcalculator.OverlapCalculator(**kwargs)[source]
Bases:
OverlapCalculatorCalculate the overlap of atom radii and coordination numbers at each site.
- property rmax
Upper bound for the bond distances. [5 A]
- property rmaxused
Effective upper bound for the bond distances. rmaxused equals either a double of the maximum atom radius in the structure or rmax.
- property rmin
Lower bound for the bond distances. [0 A]
diffpy.srreal.overlapcalculator module
Class OverlapCalculator – calculator of atom overlaps in a structure.
- class diffpy.srreal.overlapcalculator.OverlapCalculator(**kwargs)[source]
Bases:
OverlapCalculatorCalculate the overlap of atom radii and coordination numbers at each site.
- property rmax
Upper bound for the bond distances. [5 A]
- property rmaxused
Effective upper bound for the bond distances. rmaxused equals either a double of the maximum atom radius in the structure or rmax.
- property rmin
Lower bound for the bond distances. [0 A]
diffpy.srreal.pairquantity module
Class PairQuantity – base class for Python defined calculators.
- class diffpy.srreal.pairquantity.PairQuantity(*args, **kwargs)
Bases:
BasePairQuantityBase class for Python defined pair quantity calculators. No action by default. Concrete calculators must override the _addPairContribution method to get some results.
- ticker(self) diffpy.srreal.srreal_ext.EventTicker
- ticker(self) diffpy.srreal.srreal_ext.EventTicker
Overloaded function.
ticker(self) -> diffpy.srreal.srreal_ext.EventTickerticker(self) -> diffpy.srreal.srreal_ext.EventTicker
Return EventTicker object with the last configuration change time.
The ticker should be clicked on every configuration change that requires reevaluation of the PairQuantity even for an unchanged structure.
This method can be overridden in the derived class.
diffpy.srreal.parallel module
ParallelPairQuantity – proxy class for converting PairQuantity types into parallel calculators.
- diffpy.srreal.parallel.createParallelCalculator(pqobj, ncpu, pmap)[source]
Create a proxy parallel calculator to a PairQuantity instance.
- diffpy.srreal.parallel.pqobj
instance of PairQuantity calculator to be run in parallel
- diffpy.srreal.parallel.ncpu
number of parallel jobs
- diffpy.srreal.parallel.pmap
a parallel map function used to submit job to workers
- The ``pqobj.evaluatortype`` is reset to 'BASIC' because other
- evaluator types are not supported within parallel calculations.
- Return a proxy calculator instance that has the same interface,
- but executes the calculation in parallel split among ncpu jobs.
diffpy.srreal.pdfbaseline module
- Classes for configuring PDF baseline:
PDFBaseline, ZeroBaseline, LinearBaseline
- class diffpy.srreal.pdfbaseline.LinearBaseline(*args, **kwargs)
Bases:
PDFBaselinePDF baseline function equal to (slope * r).
- property slope
Slope of an unscaled linear baseline. For crystal structures it is preset to (-4 * pi * rho0).
- class diffpy.srreal.pdfbaseline.PDFBaseline(*args, **kwargs)
Bases:
AttributesBase class and registry for functions that calculate PDF baseline.
- clone(self) diffpy.srreal.srreal_ext.PDFBaseline
Return a new instance that is a copy of self.
This method must be overloaded in a derived class.
- create(self) diffpy.srreal.srreal_ext.PDFBaseline
Return a new instance of the same type as self.
This method must be overloaded in a derived class.
- createByType = <nanobind.nb_func object>
- getAliasedTypes = <nanobind.nb_func object>
- getRegisteredTypes = <nanobind.nb_func object>
- isRegisteredType = <nanobind.nb_func object>
- class diffpy.srreal.pdfbaseline.ZeroBaseline(*args, **kwargs)
Bases:
PDFBaselineTrivial baseline function that is always zero, no baseline.
- diffpy.srreal.pdfbaseline.makePDFBaseline(name, fnc, replace=False, **dbattrs)[source]
Helper function for registering Python function as a PDFBaseline. This is required for using Python function as PDFCalculator.baseline.
- diffpy.srreal.pdfbaseline.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.
- diffpy.srreal.pdfbaseline.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.
- diffpy.srreal.pdfbaseline.replace
when set replace any PDFBaseline type already registered under the name. Otherwise raise RuntimeError when the name is taken.
- diffpy.srreal.pdfbaseline.dbattrs
optional float parameters of the wrapped function. These will be registered as double attributes in the functor class. The wrapped function must be callable as fnc(x, **dbattrs). Make sure to pick attribute names that do not conflict with other PDFCalculator attributes.
- Return an instance of the new PDFBaseline class.
- diffpy.srreal.pdfbaseline.Example
# Python baseline function def fshiftedline(x, aline, bline):
return aline * x + bline
# wrap it as a PDFBaseline and register as a “shiftedline” type makePDFBaseline(“shiftedline”, fshiftedline, aline=-1, bline=0) baseline = PDFBaseline.createByType(“shiftedline”) print map(baseline, range(5)) # use it in PDFCalculator pdfc = PDFCalculator() pdfc.baseline = baseline # or pdfc.baseline = “shiftedline”
diffpy.srreal.pdfcalculator module
- Top-level classes for PDF calculation:
DebyePDFCalculator – simulate PDF by evaluating Debye sum in Q-space PDFCalculator – calculate PDF by peak summation in real space
- class diffpy.srreal.pdfcalculator.DebyePDFCalculator(**kwargs)[source]
Bases:
DebyePDFCalculatorCalculate PDF using the Debye scattering equation.
- property debyeprecision
Cutoff amplitude for the sine contributions to the F(Q). [1e-6 unitless]
- property delta1
Coefficient for (1/r) contribution to the peak sharpening. Active for JeongPeakWidth model. [0 A]
- property delta2
Coefficient for (1/r**2) contribution to the peak sharpening. Active for JeongPeakWidth model. [0 A**2]
- property extendedrmax
Upper boundary of the extended r-range, read-only. [A]
- property extendedrmin
Low boundary of the extended r-range, read-only. [A]
- property maxextension
Maximum extension of the r-range that accounts for contributions from the out of range peaks. [10 A]
- property qbroad
PDF peak broadening from increased intensity noise at high Q. Not applied when equal zero. Active for JeongPeakWidth model. [0 1/A]
- property qdamp
PDF Gaussian dampening factor due to limited Q-resolution. Not applied when equal to zero. Active for QResolutionEnvelope. [0 1/A]
- property qmax
Upper bound of the Q-grid for the calculated F(Q). Affects the termination ripples. [25 1/A]
- property qmin
Lower bound of the Q-grid for the calculated F(Q). Affects the shape envelope. [0 1/A]
- property qstep
Spacing in the Q-grid. Q-values are at the multiples of qstep. [PI/extendedrmax A] unless user overridden. See also setOptimumQstep, isOptimumQstep.
- property rmax
Upper bound of the r-grid for PDF calculation. [10 A]
- property rmin
Lower bound of the r-grid for PDF calculation. [0 A]
- property rstep
Spacing in the calculated r-grid. r-values are at the multiples of rstep. [0.01 A]
- property scale
Scale factor of the calculated PDF. Active for ScaleEnvelope. [1.0 unitless]
- class diffpy.srreal.pdfcalculator.PDFCalculator(**kwargs)[source]
Bases:
PDFCalculatorCalculate PDF using the real-space summation of PeakProfile functions.
- property delta1
Coefficient for (1/r) contribution to the peak sharpening. Active for JeongPeakWidth model. [0 A]
- property delta2
Coefficient for (1/r**2) contribution to the peak sharpening. Active for JeongPeakWidth model. [0 A**2]
- property extendedrmax
Upper boundary of the extended r-range, read-only. [A]
- property extendedrmin
Low boundary of the extended r-range, read-only. [A]
- property maxextension
Maximum extension of the r-range that accounts for contributions from the out of range peaks. [10 A]
- property peakprecision
Cutoff amplitude of the peak tail relative to the peak maximum. [3.33e-6 unitless]
- property qbroad
PDF peak broadening from increased intensity noise at high Q. Not applied when equal zero. Active for JeongPeakWidth model. [0 1/A]
- property qdamp
PDF Gaussian dampening factor due to limited Q-resolution. Not applied when equal to zero. Active for QResolutionEnvelope. [0 1/A]
- property qmax
Upper bound of the experimental Q-range used. Affects the termination ripples. Not used when zero. [0 1/A]
- property qmin
Lower bound of the experimental Q-range used. Affects the shape envelope. [0 1/A]
- property qstep
Spacing in the Q-grid. Q-values are at the multiples of qstep. The value is padded by rsteps so that PI/qstep > extendedrmax and PI/(qstep * rstep) is a power of 2. Read-only. [PI/(padded extendedrmax) A]
- property rmax
Upper bound of the r-grid for PDF calculation. [10 A]
- property rmin
Lower bound of the r-grid for PDF calculation. [0 A]
- property rstep
Spacing in the calculated r-grid. r-values are at the multiples of rstep. [0.01 A]
- property scale
Scale factor of the calculated PDF. Active for ScaleEnvelope. [1.0 unitless]
- property slope
Slope of the linear PDF background. Assigned according to number density of the evaluated structure at each PDF calculation. Active for LinearBaseline. [-4*pi*numdensity unitless]
- property spdiameter
Spherical particle diameter for PDF shape damping correction. Not used when zero. Active for SphericalShapeEnvelope. [0 A]
- property stepcut
r-boundary for a step cutoff of the calculated PDF. Not used when negative or zero. Active for StepCutEnvelope. Not used when zero. Active for StepCutEnvelope. [0 A]
diffpy.srreal.pdfenvelope module
- Classes for configuring PDF scaling envelope:
PDFEnvelope, ScaleEnvelope, QResolutionEnvelope, SphericalShapeEnvelope, StepCutEnvelope
- class diffpy.srreal.pdfenvelope.PDFEnvelope(*args, **kwargs)
Bases:
AttributesBase class and registry for functions that return PDF scaling envelopes.
- clone(self) diffpy.srreal.srreal_ext.PDFEnvelope
Return a new instance that is a copy of self.
This method must be overloaded in a derived class.
- create(self) diffpy.srreal.srreal_ext.PDFEnvelope
Return a new instance of the same type as self.
This method must be overloaded in a derived class.
- createByType = <nanobind.nb_func object>
- getAliasedTypes = <nanobind.nb_func object>
- getRegisteredTypes = <nanobind.nb_func object>
- isRegisteredType = <nanobind.nb_func object>
- class diffpy.srreal.pdfenvelope.QResolutionEnvelope(*args, **kwargs)
Bases:
PDFEnvelopeGaussian dampening envelope function due to limited Q-resolution.
Returns exp(-qdamp * x**2). Returns 1 when qdamp is zero or negative.
- property qdamp
Dampening parameter in the Gaussian envelope function.
- class diffpy.srreal.pdfenvelope.ScaleEnvelope(*args, **kwargs)
Bases:
PDFEnvelopeUniform scaling envelope function.
Returns scale.
- property scale
Overall scale for a uniform scaling envelope.
- class diffpy.srreal.pdfenvelope.SphericalShapeEnvelope(*args, **kwargs)
Bases:
PDFEnvelopeDampening PDF envelope due to finite spherical particle shape.
Returns (1 - 1.5*tau + 0.5*tau**3), where tau = x/spdiameter. Returns 1 when spdiameter <= 0.
- property spdiameter
Particle diameter in Angstroms for a spherical shape damping.
- class diffpy.srreal.pdfenvelope.StepCutEnvelope(*args, **kwargs)
Bases:
PDFEnvelopeStep function damping envelope.
Returns 1 when x <= stepcut or if stepcut <= 0. Returns 0 when x > stepcut.
- property stepcut
Cutoff for a step-function envelope.
- diffpy.srreal.pdfenvelope.makePDFEnvelope(name, fnc, replace=False, **dbattrs)[source]
Helper function for registering Python function as a PDFEnvelope. This is required for using Python function as PDFCalculator envelope.
- diffpy.srreal.pdfenvelope.name
unique string name for registering Python function in the global registry of PDFEnvelope types. This will be the string identifier for the createByType factory.
- diffpy.srreal.pdfenvelope.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.
- diffpy.srreal.pdfenvelope.replace
when set replace any PDFEnvelope type already registered under the name. Otherwise raise RuntimeError when the name is taken.
- diffpy.srreal.pdfenvelope.dbattrs
optional float parameters of the wrapped function. These will be registered as double attributes in the functor class. The wrapped function must be callable as fnc(x, **dbattrs). Make sure to pick attribute names that do not conflict with other PDFCalculator attributes.
- Return an instance of the new PDFEnvelope class.
- diffpy.srreal.pdfenvelope.Example
# Python envelope function def fexpdecay(x, expscale, exptail):
from math import exp return expscale * exp(-x / exptail)
# wrap it as a PDFEnvelope and register as a “expdecay” type makePDFEnvelope(“expdecay”, fexpdecay, expscale=5, exptail=4) envelope = PDFEnvelope.createByType(“expdecay”) print map(envelope, range(9)) # use it in PDFCalculator pdfc = PDFCalculator() pdfc.addEnvelope(envelope) # or pdfc.addEnvelope(“expdecay”)
diffpy.srreal.peakprofile module
- Class for configuring PDF profile function:
PeakProfile GaussianProfile, CroppedGaussianProfile
- class diffpy.srreal.peakprofile.CroppedGaussianProfile(*args, **kwargs)
Bases:
GaussianProfileGaussian function cropped to zero at its crossing with peakprecision.
The profile is also rescaled to keep the integrated area of 1.
- class diffpy.srreal.peakprofile.GaussianProfile(*args, **kwargs)
Bases:
PeakProfileGaussian profile function.
- class diffpy.srreal.peakprofile.PeakProfile(*args, **kwargs)
Bases:
AttributesBase class and registry for PDF peak profile functions. The peak profile functions must be centered at 0 and their integrated area must be 1.
- clone(self) diffpy.srreal.srreal_ext.PeakProfile
Return a new instance that is a copy of self.
This method must be overloaded in a derived class.
- create(self) diffpy.srreal.srreal_ext.PeakProfile
Return a new instance of the same type as self.
This method must be overloaded in a derived class.
- createByType = <nanobind.nb_func object>
- getAliasedTypes = <nanobind.nb_func object>
- getRegisteredTypes = <nanobind.nb_func object>
- isRegisteredType = <nanobind.nb_func object>
- property peakprecision
Profile amplitude relative to the peak maximum for evaluating peak bounds xboundlo and xboundhi.
[3.33e-6 unitless]
- ticker(self) diffpy.srreal.srreal_ext.EventTicker
- ticker(self) diffpy.srreal.srreal_ext.EventTicker
Overloaded function.
ticker(self) -> diffpy.srreal.srreal_ext.EventTickerticker(self) -> diffpy.srreal.srreal_ext.EventTicker
Return EventTicker that marks last modification time of this object. This ticker object is used in fast PDF update, to check if PeakProfile has changed since the last calculation. The ticker.click() method needs to be therefore called after every change in PeakProfile configuration.
Return EventTicker object. This method can be overridden in a Python-derived class.
- type(self) str
Return a unique string type that identifies a PeakProfile-derived class. The string type is used for class registration and in the createByType function.
This method must be overloaded in a derived class.
- xboundhi(self, fwhm: float) float
Upper x-bound where profile function becomes smaller than precision. The bound is evaluated relative to profile maximum, i.e., for each x above xboundhi the profile function must be smaller than (peakprecision * maximum).
fwhm – Full Width at Half Maximum of the profile function
Return float. See also the peakprecision property.
- xboundlo(self, fwhm: float) float
Lower x-bound where profile function becomes smaller than precision. The bound is evaluated relative to profile maximum, i.e., for each x below xboundlo the profile function must be smaller than (peakprecision * maximum).
fwhm – Full Width at Half Maximum of the profile function
Return float. See also the peakprecision property.
diffpy.srreal.peakwidthmodel module
- Classes for configuring peak width evaluation in PDF calculations:
PeakWidthModel, ConstantPeakWidth, DebyeWallerPeakWidth, JeongPeakWidth
- class diffpy.srreal.peakwidthmodel.ConstantPeakWidth(*args, **kwargs)
Bases:
PeakWidthModelPeak width model returning constant width.
- property bisowidth
Equivalent uniform Biso for this constant width.
- property uisowidth
Equivalent uniform Uiso for this constant width.
- property width
Constant FWHM value returned by this model.
- class diffpy.srreal.peakwidthmodel.DebyeWallerPeakWidth(*args, **kwargs)
Bases:
PeakWidthModelCalculate PDF peak width from a Debye-Waller model of atom vibrations. This returns mean-square displacement of atoms in the pair along their bond scaled as FWHM. The atom displacements are assumed independent.
- class diffpy.srreal.peakwidthmodel.JeongPeakWidth(*args, **kwargs)
Bases:
DebyeWallerPeakWidthCalculate PDF peak width assuming I.-K. Jeong model of correlated motion. This returns mean-square displacement of atoms in the pair along their bond corrected for correlated motion and data noise at high-Q by a scaling factor sqrt(1 - delta1/r - delta2/r**2 + (qbroad * r)**2).
- property delta1
Coefficient for (1/r) contribution to the peak sharpening.
- property delta2
Coefficient for (1/r**2) contribution to the peak sharpening.
- property qbroad
PDF peak broadening from increased intensity noise at high Q.
- class diffpy.srreal.peakwidthmodel.PeakWidthModel(*args, **kwargs)
Bases:
AttributesBase class for functors that calculate the PDF peak widths. Peak width is defined as full width at half maximum (FWHM).
- calculate(self, bnds: diffpy.srreal.srreal_ext.BaseBondGenerator) float
Calculate the FWHM peak width for the specified bond.
bnds – instance of BaseBondGenerator with the current bond data.
Return float. This method must be overridden in a derived class.
- clone(self) diffpy.srreal.srreal_ext.PeakWidthModel
Return a new instance that is a copy of self.
This method must be overloaded in a derived class.
- create(self) diffpy.srreal.srreal_ext.PeakWidthModel
Return a new instance of the same type as self.
This method must be overloaded in a derived class.
- createByType = <nanobind.nb_func object>
- getAliasedTypes = <nanobind.nb_func object>
- getRegisteredTypes = <nanobind.nb_func object>
- isRegisteredType = <nanobind.nb_func object>
- maxWidth(self, stru: diffpy.srreal.srreal_ext.StructureAdapter | None, rmin: float, rmax: float) float
- maxWidth(self, stru: object, rmin: float, rmax: float) float
Overloaded function.
maxWidth(self, stru: diffpy.srreal.srreal_ext.StructureAdapter | None, rmin: float, rmax: float) -> float
Return maximum peak width for the specified structure and distance range
stru – StructureAdapter object or an object convertible to StructureAdapter. rmin – lower bound for the PDF calculation rmax – upper bound for the PDF calculation
isotropically vibrating atoms this
Return float.
maxWidth(self, stru: object, rmin: float, rmax: float) -> float
- ticker(self) diffpy.srreal.srreal_ext.EventTicker
- ticker(self) diffpy.srreal.srreal_ext.EventTicker
Overloaded function.
ticker(self) -> diffpy.srreal.srreal_ext.EventTickerticker(self) -> diffpy.srreal.srreal_ext.EventTicker
Return EventTicker that marks last modification time of this object. This ticker object is used in fast PDF update, to check if PeakWidthModel has changed since the last calculation. The ticker.click() method needs to be therefore called after every change in PeakWidthModel configuration.
Return EventTicker object. This method can be overridden in a Python-derived class.
diffpy.srreal.scatteringfactortable module
Class ScatteringFactorTable – scattering factors for atoms, ions and isotopes.
- class diffpy.srreal.scatteringfactortable.SFAverage[source]
Bases:
objectCalculate compositional statistics of atom scattering factors.
Compositional averages can be calculated for an array of Q-values. Results are stored in the class attributes.
- f1sum
Sum of scattering factors from all atoms. Float or NumPy array.
- f2sum
Sum of squared scattering factors from all atoms. Float or NumPy array.
- count
Total number of atoms. Can be non-integer in case of fractional occupancies.
- f1avg
Compositional average of scattering factors. Float or NumPy array.
- f2avg
Compositional average of squared scattering factors. Float or NumPy array.
- composition
Dictionary of atom symbols and their total abundance.
- composition = None
- count = 0
- f1avg = 0
- f1sum = 0
- f2avg = 0
- f2sum = 0
- classmethod fromComposition(composition, sftb, q=0)[source]
Calculate average scattering factors from atom concentrations.
- Parameters:
composition (dictionary or a list of (symbol, amount) pairs.) – The chemical composition for evaluating the average. Atom symbols may repeat when it is a list of (symbol, amount) pairs.
sftb (ScatteringFactorTable or str) – The ScatteringFactorTable object for looking up the values. When string use ScatteringFactorTable.createByType to create a new lookup table of the specified type.
q (float or NumPy array (optional)) – The Q value in inverse Angstroms for which to lookup the scattering factor values.
- Returns:
The calculated scattering factor averages.
- Return type:
- classmethod fromStructure(stru, sftb, q=0)[source]
Calculate average scattering factors from a structure object.
- Parameters:
stru (diffpy Structure or pyobjcryst Crystal or StructureAdapter) – The structure object that stores the atom species and their occupancies. Can be any type with a registered conversion to the StructureAdapter class.
sftb (ScatteringFactorTable or str) – The ScatteringFactorTable object for looking up the values. When string use ScatteringFactorTable.createByType to create a new lookup table of the specified type.
q (float or NumPy array (optional)) – The Q value in inverse Angstroms for which to lookup the scattering factor values.
See also
RegisterStructureAdapterto add support for more structure types.
- Returns:
The calculated scattering factor averages.
- Return type:
- class diffpy.srreal.scatteringfactortable.SFTElectron(*args, **kwargs)
Bases:
ScatteringFactorTableElectron scattering factors table.
Q-dependence is derived from X-ray scattering factors according to the International Tables Volume C.
- class diffpy.srreal.scatteringfactortable.SFTElectronNumber(*args, **kwargs)
Bases:
ScatteringFactorTableTable of electron numbers for elements and ions.
Can be used as Q-indendent scattering factors for X-rays.
- class diffpy.srreal.scatteringfactortable.SFTNeutron(*args, **kwargs)
Bases:
ScatteringFactorTableTable of neutron scattering lengths in fm.
- class diffpy.srreal.scatteringfactortable.SFTXray(*args, **kwargs)
Bases:
ScatteringFactorTableX-ray scattering factors table.
Q-dependence of scattering factors is calculated using Waasmaier - Kirfel approximation valid up to Q=75/A.
- class diffpy.srreal.scatteringfactortable.ScatteringFactorTable(*args, **kwargs)
Bases:
objectBase class for looking up scattering factors by atom symbols. This class has virtual methods and cannot be used as is.
A derived class has to override the following methods:
create(self) clone(self) type(self) radiationType(self) _standardLookup(self, smbl, q)
Derived class can be added to the global registry of ScatteringFactorTable types by calling the _registerThisType method with any instance.
- clone(self) diffpy.srreal.srreal_ext.ScatteringFactorTable
Return a new instance that is a copy of self.
This method must be overloaded in a derived class.
- create(self) diffpy.srreal.srreal_ext.ScatteringFactorTable
Return a new instance of the same type as self.
This method must be overloaded in a derived class.
- createByType = <nanobind.nb_func object>
- getAliasedTypes = <nanobind.nb_func object>
- getRegisteredTypes = <nanobind.nb_func object>
- isRegisteredType = <nanobind.nb_func object>
- lookup(self, smbl: str, qarray: object) object
- lookup(self, smbl: str, q: float = 0.0) float
Overloaded function.
lookup(self, smbl: str, qarray: object) -> objectlookup(self, smbl: str, q: float = 0.0) -> float
Scattering factor of a specified atom at Q in 1/A. The standard value can be redefined using the setCustomAs method.
smbl – string symbol for atom, ion or isotope. Q – Q value in inverse Angstroms, by default 0.
Q can be either float or NumPy array.
Return float or NumPy array of the same shape as Q. No support for Python override.
- radiationType(self) str
Return a string identifying the radiation type. ‘X’ for x-rays, ‘N’ for neutrons. This method must be overridden in a derived class.
- resetAll(self) None
Reset all custom scattering factor values.
No return value. No support for Python override.
- resetCustom(self, smbl: str) None
Revert scattering factor for the specified symbol to a standard value.
smbl – string symbol for atom, ion or isotope.
No return value. No support for Python override.
- setCustomAs(self, smbl: str, src: str) None
- setCustomAs(self, smbl: str, src: str, sf: float, q: float = 0.0) None
Overloaded function.
setCustomAs(self, smbl: str, src: str) -> None
Define custom alias for the specified atom symbol. Example: setCustomAs(‘12-C’, ‘C’) will declare the same scattering factors for ‘12-C’ as for ‘C’.
smbl – custom string alias for an existing standard symbol. src – standard atom symbol (cannot be another alias).
No return value. No support for Python override.
setCustomAs(self, smbl: str, src: str, sf: float, q: float = 0.0) -> None
Define custom scattering factor for the specified atom symbol. The custom value is calculated by rescaling standard value from a source atom type.
smbl – string symbol of the atom with custom scattering factor. src – atom symbol for the source standard scattering factor. sf – new scattering factor value, defaults to the standard src factor. q – optional Q value for the new custom scattering factor.
The internal scaling of the standard value is calculated at this Q.
No return value. No support for Python override.
- ticker(self) diffpy.srreal.srreal_ext.EventTicker
- ticker(self) diffpy.srreal.srreal_ext.EventTicker
Overloaded function.
ticker(self) -> diffpy.srreal.srreal_ext.EventTickerticker(self) -> diffpy.srreal.srreal_ext.EventTicker
Return EventTicker that marks last modification time of this object. This ticker object is used in fast PDF update, to check if scattering factors changed since the last calculation. The ticker.click() method thus needs to be used for _standardLookup that returns variable values.
Return EventTicker object. This method can be overridden in a Python-derived class.
diffpy.srreal.sfaverage module
Compositional averaging of atom scattering factors.
Examples
import numpy as np
from diffpy.srreal.scatteringfactortable import SFTXray
xtb = SFTXray()
qa = np.linspace(0, 25)
sfavg1 = SFAverage.fromComposition({'Na' : 1, 'Cl' : 1}, xtb, qa)
sfavg2 = SFAverage.fromComposition([('Mn', 1), ('O', 2)], xtb, qa)
from diffpy.structure import load_structure
from diffpy.srreal.pdfcalculator import DebyePDFCalculator
dpdfc = DebyePDFCalculator()
dpdfc(load_structure('rutile.cif'))
sfavg3 = SFAverage.fromStructure(dpdfc.getStructure(),
dpdfc.scatteringfactortable, dpdfc.qgrid)
- class diffpy.srreal.sfaverage.SFAverage[source]
Bases:
objectCalculate compositional statistics of atom scattering factors.
Compositional averages can be calculated for an array of Q-values. Results are stored in the class attributes.
- f1sum
Sum of scattering factors from all atoms. Float or NumPy array.
- f2sum
Sum of squared scattering factors from all atoms. Float or NumPy array.
- count
Total number of atoms. Can be non-integer in case of fractional occupancies.
- f1avg
Compositional average of scattering factors. Float or NumPy array.
- f2avg
Compositional average of squared scattering factors. Float or NumPy array.
- composition
Dictionary of atom symbols and their total abundance.
- composition = None
- count = 0
- f1avg = 0
- f1sum = 0
- f2avg = 0
- f2sum = 0
- classmethod fromComposition(composition, sftb, q=0)[source]
Calculate average scattering factors from atom concentrations.
- Parameters:
composition (dictionary or a list of (symbol, amount) pairs.) – The chemical composition for evaluating the average. Atom symbols may repeat when it is a list of (symbol, amount) pairs.
sftb (ScatteringFactorTable or str) – The ScatteringFactorTable object for looking up the values. When string use ScatteringFactorTable.createByType to create a new lookup table of the specified type.
q (float or NumPy array (optional)) – The Q value in inverse Angstroms for which to lookup the scattering factor values.
- Returns:
The calculated scattering factor averages.
- Return type:
- classmethod fromStructure(stru, sftb, q=0)[source]
Calculate average scattering factors from a structure object.
- Parameters:
stru (diffpy Structure or pyobjcryst Crystal or StructureAdapter) – The structure object that stores the atom species and their occupancies. Can be any type with a registered conversion to the StructureAdapter class.
sftb (ScatteringFactorTable or str) – The ScatteringFactorTable object for looking up the values. When string use ScatteringFactorTable.createByType to create a new lookup table of the specified type.
q (float or NumPy array (optional)) – The Q value in inverse Angstroms for which to lookup the scattering factor values.
See also
RegisterStructureAdapterto add support for more structure types.
- Returns:
The calculated scattering factor averages.
- Return type: