diffpy.cmistructure package
Modules and classes that adapt structure representations to the ParameterSet interface and automatic structure constraint generation from space group information.
- diffpy.cmistructure.constrain_as_space_group(phase, spacegroup, scatterers=None, sgoffset=[0, 0, 0], constrainlat=True, constrainadps=True, adpsymbols=None, isosymbol='Uiso')[source]
Constrain a P1 structure to a space group.
This applies space group constraints to a structure ParameterSet with P1 symmetry. The passed scatterers are explicitly constrained to the specified space group, and the ADPs and lattice may be constrained as well. New Parameters used in the constraints are created within the returned SpaceGroupParameters object. Constraints are created in the ParameterSet that contains the constrained Parameter. This erases any constraints or constant flags on the scatterers, lattice or ADPs that are to be constrained.
- Parameters:
phase (BaseStructureParSet or object with a .phase attribute) – The structure ParameterSet to constrain, or a generator such as a PDFGenerator whose
.phaseis the structure ParameterSet.spacegroup (int, str or diffpy.structure.spacegroups.SpaceGroup) – The space group number, symbol or SpaceGroup instance.
scatterers (list of ParameterSet, optional) – The scatterer ParameterSets to constrain. If None (default), all scatterers returned by
phase.get_scatterers()are constrained.sgoffset (list of float, optional) – The offset of the space group origin (default [0, 0, 0]).
constrainlat (bool, optional) – The flag indicating whether to constrain the lattice (default True).
constrainadps (bool, optional) – The flag indicating whether to constrain the ADPs (default True).
adpsymbols (list of str, optional) – The ADP names. By default this is diffpy.structure.symmetryutilities.stdUsymbols (U11, U22, etc.). The names must be given in the same order as stdUsymbols.
isosymbol (str, optional) – The name of the isotropic ADP (default “Uiso”). If None, isotropic ADPs are constrained via the anisotropic ADPs.
- Returns:
The free Parameters of the structure that remain after applying the space group constraints.
- Return type:
SpaceGroupParameters
Notes
The lattice constraints are applied as follows.
- Triclinic
No constraints.
- Monoclinic
alpha and beta are fixed to 90 unless alpha != beta and alpha == gamma, in which case alpha and gamma are fixed to 90.
- Orthorhombic
alpha, beta and gamma are fixed to 90.
- Tetragonal
b is constrained to a and alpha, beta and gamma are fixed to 90.
- Trigonal
If gamma == 120, then b is constrained to a, alpha and beta are fixed to 90 and gamma is fixed to 120. Otherwise, b and c are constrained to a, and beta and gamma are fixed to alpha.
- Hexagonal
b is constrained to a, alpha and beta are fixed to 90 and gamma is fixed to 120.
- Cubic
b and c are constrained to a, and alpha, beta and gamma are fixed to 90.
- Raises:
TypeError – If
phaseis neither a structure ParameterSet nor an object whose.phaseis one.
- diffpy.cmistructure.structure_to_parameter_set(name, structure)[source]
Create a ParameterSet adapted to a structure object.
The adapter is chosen from the type of structure. Supported types are diffpy.structure.Structure, pyobjcryst.crystal.Crystal, pyobjcryst.molecule.Molecule and cctbx.crystal.special_position_settings.
- Parameters:
name (str) – The name to give the structure.
structure (object) – The structure object to adapt.
- Returns:
The ParameterSet adapting structure.
- Return type:
- Raises:
TypeError – If structure is not one of the supported structure types.
Submodules
diffpy.cmistructure.objcrystparset module
Wrappers for adapting pyobjcryst.crystal.Crystal to a srfit ParameterSet.
This will adapt a Crystal or Molecule object from pyobjcryst into the ParameterSet interface. The following classes are adapted:
ObjCrystCrystalParSet: adapter for pyobjcryst.crystal.Crystal.
ObjCrystAtomParSet: adapter for pyobjcryst.atom.Atom.
ObjCrystMoleculeParSet: adapter for pyobjcryst.molecule.Molecule.
ObjCrystMolAtomParSet: adapter for pyobjcryst.molecule.MolAtom.
Related to the adaptation of Molecule and MolAtom, there are adaptors for specifying molecule restraints:
ObjCrystBondLengthRestraint
ObjCrystBondAngleRestraint
ObjCrystDihedralAngleRestraint
There are also Parameters for encapsulating and modifying atoms via their relative positions. These Parameters can also act like constraints, and can modify the positions of multiple MolAtoms:
ObjCrystBondLengthParameter
ObjCrystBondAngleParameter
ObjCrystDihedralAngleParameter
- class diffpy.cmistructure.objcrystparset.ObjCrystCrystalParSet(name, crystal)[source]
Bases:
SrRealParSetAdapt a pyobjcryst.crystal.Crystal to the ParameterSet interface.
This class derives from SrRealParSet. See that class for base attributes.
- structure
The adapted crystal.
- Type:
pyobjcryst.crystal.Crystal
- scatterers
The scatterer ParameterSets, provided for convenience.
- Type:
list of ObjCrystAtomParSet or ObjCrystMoleculeParSet
- sgpars
The free structure Parameters after applying the crystal’s space group constraints, created when first accessed. See the diffpy.cmistructure.sgconstraints module.
- Type:
SpaceGroupParameters
- angle_units
The units of the lattice angles, always “rad”.
- Type:
str
- a, b, c, alpha, beta, gamma
The unit cell parameters.
- Type:
ParameterAdapter
- classmethod can_adapt(structure)[source]
Return whether the structure can be adapted by this class.
- Parameters:
structure (object) – The structure object to check.
- Returns:
The flag indicating if structure is a pyobjcryst Crystal.
- Return type:
bool
- get_lattice()[source]
Return the ParameterSet containing the lattice Parameters.
- Returns:
This ParameterSet, which holds the lattice Parameters directly.
- Return type:
- get_scatterers()[source]
Return the list of ParameterSets that represent the scatterers.
- Returns:
The scatterer ParameterSets of the crystal.
- Return type:
list of ObjCrystAtomParSet or ObjCrystMoleculeParSet
- property sgpars
Constrain the space group.
- class diffpy.cmistructure.objcrystparset.ObjCrystMoleculeParSet(name, molecule, parent=None)[source]
Bases:
ObjCrystScattererParSetAdapt a pyobjcryst.molecule.Molecule to the ParameterSet interface.
This class derives from ObjCrystScattererParSet. Other attributes are inherited from diffpy.srfit.fitbase.parameterset.ParameterSet.
- scatterer
The adapted molecule.
- Type:
pyobjcryst.molecule.Molecule
- structure
The adapted molecule.
- Type:
pyobjcryst.molecule.Molecule
- parent
The crystal ParameterSet this belongs to. This is None when the ObjCrystMoleculeParSet is used on its own.
- Type:
ObjCrystCrystalParSet or None
- atoms
The ParameterSets of the atoms in the molecule.
- Type:
list of ObjCrystMolAtomParSet
- occ
The occupancy of the molecule on its crystal location.
- Type:
ParameterAdapter
- q0, q1, q2, q3
The orientational quaternion of the molecule.
- Type:
ParameterAdapter
- add_bond_angle_parameter(name, atom1, atom2, atom3, value=None, const=False)[source]
Add a refinable bond angle to the Molecule.
This adds an ObjCrystBondAngleParameter to the ObjCrystMoleculeParSet that can be adjusted during the fit.
- Parameters:
name (str) – The name of the new Parameter.
atom1 (ObjCrystMolAtomParSet) – The first atom in the bond angle.
atom2 (ObjCrystMolAtomParSet) – The second (central) atom in the bond angle.
atom3 (ObjCrystMolAtomParSet) – The third (mutated) atom in the bond angle.
value (float, optional) – The initial bond angle in radians. If None (default), the current bond angle between the atoms is used.
const (bool, optional) – The flag indicating whether the Parameter is constant (default False).
- Returns:
The new bond angle Parameter.
- Return type:
ObjCrystBondAngleParameter
- add_bond_length_parameter(name, atom1, atom2, value=None, const=False)[source]
Add a refinable bond length to the Molecule.
This adds an ObjCrystBondLengthParameter to the ObjCrystMoleculeParSet that can be adjusted during the fit.
- Parameters:
name (str) – The name of the new Parameter.
atom1 (ObjCrystMolAtomParSet) – The first atom in the bond.
atom2 (ObjCrystMolAtomParSet) – The second (mutated) atom in the bond.
value (float, optional) – The initial bond length. If None (default), the current distance between the atoms is used.
const (bool, optional) – The flag indicating whether the Parameter is constant (default False).
- Returns:
The new bond length Parameter.
- Return type:
ObjCrystBondLengthParameter
- add_dihedral_angle_parameter(name, atom1, atom2, atom3, atom4, value=None, const=False)[source]
Add a refinable dihedral angle to the Molecule.
This adds an ObjCrystDihedralAngleParameter to the ObjCrystMoleculeParSet that can be adjusted during the fit.
- Parameters:
name (str) – The name of the new Parameter.
atom1 (ObjCrystMolAtomParSet) – The first atom in the dihedral angle.
atom2 (ObjCrystMolAtomParSet) – The second (central) atom in the dihedral angle.
atom3 (ObjCrystMolAtomParSet) – The third (central) atom in the dihedral angle.
atom4 (ObjCrystMolAtomParSet) – The fourth (mutated) atom in the dihedral angle.
value (float, optional) – The initial dihedral angle in radians. If None (default), the current dihedral angle between the atoms is used.
const (bool, optional) – The flag indicating whether the Parameter is constant (default False).
- Returns:
The new dihedral angle Parameter.
- Return type:
ObjCrystDihedralAngleParameter
- classmethod can_adapt(structure)[source]
Return whether the structure can be adapted by this class.
- Parameters:
structure (object) – The structure object to check.
- Returns:
The flag indicating if structure is a pyobjcryst Molecule.
- Return type:
bool
- get_lattice()[source]
Return a ParameterSet holding a unit cubic lattice.
A molecule is not periodic, so this returns a new ParameterSet with a = b = c = 1 and alpha = beta = gamma = 90 degrees.
- Returns:
The ParameterSet holding the placeholder lattice Parameters.
- Return type:
ParameterSet
- get_scatterers()[source]
Return the list of ParameterSets that represent the scatterers.
- Returns:
The atom ParameterSets of the molecule.
- Return type:
list of ObjCrystMolAtomParSet
- restrain_bond_angle(atom1, atom2, atom3, angle, sigma, delta, scaled=False)[source]
Add a bond angle restraint between three atoms.
This creates an ObjCrystBondAngleRestraint and adds it to the ObjCrystMoleculeParSet.
- Parameters:
atom1 (ObjCrystMolAtomParSet) – The first atom in the bond angle.
atom2 (ObjCrystMolAtomParSet) – The second (central) atom in the bond angle.
atom3 (ObjCrystMolAtomParSet) – The third atom in the bond angle.
angle (float) – The bond angle in radians.
sigma (float) – The uncertainty of the bond angle in radians.
delta (float) – The width of the bond angle in radians.
scaled (bool, optional) – The flag indicating if the restraint is scaled (multiplied) by the unrestrained point-average chi^2 (chi^2/numpoints) (default False).
- Returns:
The restraint, for use with the
remove_soft_boundsmethod.- Return type:
ObjCrystBondAngleRestraint
- restrain_bond_angle_parameter(parameter, angle, sigma, delta, scaled=False)[source]
Add a bond angle restraint on a bond angle Parameter.
This creates an ObjCrystBondAngleRestraint between the atoms of parameter and adds it to the ObjCrystMoleculeParSet.
- Parameters:
parameter (ObjCrystBondAngleParameter) – The bond angle Parameter to restrain (see add_bond_angle_parameter).
angle (float) – The bond angle in radians.
sigma (float) – The uncertainty of the bond angle in radians.
delta (float) – The width of the bond angle in radians.
scaled (bool, optional) – The flag indicating if the restraint is scaled (multiplied) by the unrestrained point-average chi^2 (chi^2/numpoints) (default False).
- Returns:
The restraint, for use with the
remove_soft_boundsmethod.- Return type:
ObjCrystBondAngleRestraint
- restrain_bond_length(atom1, atom2, length, sigma, delta, scaled=False)[source]
Add a bond length restraint between two atoms.
This creates an ObjCrystBondLengthRestraint and adds it to the ObjCrystMoleculeParSet.
- Parameters:
atom1 (ObjCrystMolAtomParSet) – The first atom in the bond.
atom2 (ObjCrystMolAtomParSet) – The second atom in the bond.
length (float) – The length of the bond in Angstroms.
sigma (float) – The uncertainty of the bond length in Angstroms.
delta (float) – The width of the bond in Angstroms.
scaled (bool, optional) – The flag indicating if the restraint is scaled (multiplied) by the unrestrained point-average chi^2 (chi^2/numpoints) (default False).
- Returns:
The restraint, for use with the
remove_soft_boundsmethod.- Return type:
ObjCrystBondLengthRestraint
- restrain_bond_length_parameter(parameter, length, sigma, delta, scaled=False)[source]
Add a bond length restraint on a bond length Parameter.
This creates an ObjCrystBondLengthRestraint between the atoms of parameter and adds it to the ObjCrystMoleculeParSet.
- Parameters:
parameter (ObjCrystBondLengthParameter) – The bond length Parameter to restrain (see add_bond_length_parameter).
length (float) – The length of the bond in Angstroms.
sigma (float) – The uncertainty of the bond length in Angstroms.
delta (float) – The width of the bond in Angstroms.
scaled (bool, optional) – The flag indicating if the restraint is scaled (multiplied) by the unrestrained point-average chi^2 (chi^2/numpoints) (default False).
- Returns:
The restraint, for use with the
remove_soft_boundsmethod.- Return type:
ObjCrystBondLengthRestraint
- restrain_dihedral_angle(atom1, atom2, atom3, atom4, angle, sigma, delta, scaled=False)[source]
Add a dihedral angle restraint between four atoms.
This creates an ObjCrystDihedralAngleRestraint and adds it to the ObjCrystMoleculeParSet.
- Parameters:
atom1 (ObjCrystMolAtomParSet) – The first atom in the angle.
atom2 (ObjCrystMolAtomParSet) – The second (central) atom in the angle.
atom3 (ObjCrystMolAtomParSet) – The third (central) atom in the angle.
atom4 (ObjCrystMolAtomParSet) – The fourth atom in the angle.
angle (float) – The dihedral angle in radians.
sigma (float) – The uncertainty of the dihedral angle in radians.
delta (float) – The width of the dihedral angle in radians.
scaled (bool, optional) – The flag indicating if the restraint is scaled (multiplied) by the unrestrained point-average chi^2 (chi^2/numpoints) (default False).
- Returns:
The restraint, for use with the
remove_soft_boundsmethod.- Return type:
ObjCrystDihedralAngleRestraint
- restrain_dihedral_angle_parameter(parameter, angle, sigma, delta, scaled=False)[source]
Add a dihedral angle restraint on a dihedral angle Parameter.
This creates an ObjCrystDihedralAngleRestraint between the atoms of parameter and adds it to the ObjCrystMoleculeParSet.
- Parameters:
parameter (ObjCrystDihedralAngleParameter) – The dihedral angle Parameter to restrain (see add_dihedral_angle_parameter).
angle (float) – The dihedral angle in radians.
sigma (float) – The uncertainty of the dihedral angle in radians.
delta (float) – The width of the dihedral angle in radians.
scaled (bool, optional) – The flag indicating if the restraint is scaled (multiplied) by the unrestrained point-average chi^2 (chi^2/numpoints) (default False).
- Returns:
The restraint, for use with the
remove_soft_boundsmethod.- Return type:
ObjCrystDihedralAngleRestraint
- use_symmetry(use=True)[source]
Set whether this structure uses symmetry.
This structure object does not support symmetry, so this does nothing.
- Parameters:
use (bool, optional) – The flag indicating if symmetry is used (default True).
- using_symmetry()[source]
Return whether symmetry is being used.
- Returns:
The flag indicating if symmetry is used. Always False, since this structure object does not support symmetry.
- Return type:
bool
- wrap_restraints()[source]
Wrap the restraints implicit to the molecule.
This wraps the MolBonds, MolBondAngles and MolDihedralAngles of the Molecule as ObjCrystMoleculeRestraint objects. Restraints wrapped this way cannot be modified from within this class.
- wrap_stretch_mode_parameters()[source]
Wrap the stretch modes implicit to the Molecule as Parameters.
This wraps the StretchModeBondLengths and StretchModeBondAngles of the Molecule as Parameters. The MolBondAtoms in the Molecule must have unique names. Torsion angles are not wrapped, as there is not enough information to determine each MolAtom in the angle.
Each Parameter is named after its constituent atoms, as “bl_aname1_aname2” for bond lengths and “ba_aname1_aname2_aname3” for bond angles.
diffpy.cmistructure.basestructureparset module
Base class for adapting structures to a ParameterSet interface.
The BaseStructureParSet is a ParameterSet with functionality required by all structure adapters.
- class diffpy.cmistructure.basestructureparset.BaseStructureParSet(name)[source]
Bases:
ParameterSetBase class for structure adapters.
BaseStructureParSet derives from ParameterSet and provides methods that help interface the ParameterSet with the space group constraint methods in the sgconstraints module and to ProfileGenerators.
- structure
The adapted structure object.
- Type:
object
- classmethod can_adapt(structure)[source]
Return whether the structure can be adapted by this class.
- Parameters:
structure (object) – The structure object to check.
- Returns:
The flag indicating if structure can be adapted. The base class always returns False.
- Return type:
bool
- get_lattice()[source]
Return the ParameterSet containing the lattice Parameters.
The returned ParameterSet may contain other Parameters than the lattice Parameters. It is assumed that the lattice parameters are named “a”, “b”, “c”, “alpha”, “beta”, “gamma”.
The lattice must also have the “angle_units” attribute, which is either “deg” or “rad”, to signify degrees or radians.
- Returns:
The ParameterSet holding the lattice Parameters.
- Return type:
ParameterSet
- Raises:
NotImplementedError – If the subclass does not override this method.
- get_scatterers()[source]
Return the list of ParameterSets that represent the scatterers.
The site positions must be accessible from the list entries via the names “x”, “y”, and “z”. The ADPs must be accessible as well, but the name and nature of the ADPs (U-factors, B-factors, isotropic, anisotropic) depends on the adapted structure.
- Returns:
The ParameterSets of the scatterers in the structure.
- Return type:
list of ParameterSet
- Raises:
NotImplementedError – If the subclass does not override this method.
diffpy.cmistructure.srrealparset module
Structure wrapper class for structures compatible with SrReal.
- class diffpy.cmistructure.srrealparset.SrRealParSet(*args, **kw)[source]
Bases:
BaseStructureParSetBase class for SrReal-compatible structure adapters.
This derives from BaseStructureParSet and provides some extended functionality provided by SrReal.
- structure
The adapted structure object.
- Type:
object
- _usesymmetry
The flag indicating if SrReal calculators that operate on this object should use symmetry (default True).
- Type:
bool
- restrain_bvs(sig=1, scaled=False)[source]
Restrain the bond-valence sum to zero.
This adds a penalty to the cost function equal to
bvmsdiff / sig**2, wherebvmsdiffis the mean-squared difference between the calculated and expected bond valence sums for the structure. If scaled is True, this is also scaled by the current point-averaged chi^2 value so the restraint is roughly equally weighted in the fit.- Parameters:
sig (float, optional) – The uncertainty on the BVS (default 1).
scaled (bool, optional) – The flag indicating if the restraint is scaled (multiplied) by the unrestrained point-average chi^2 (chi^2/numpoints) (default False).
- Returns:
The restraint, for use with the
remove_soft_boundsmethod.- Return type:
diffpy.cmistructure.diffpyparset module
Adapters for interfacing a diffpy.structure.Structure with SrFit.
A diffpy.structure.Structure object is meant to be passed to a DiffpyStructureParSet object from this module, which can then be used as a ParameterSet. (It has other methods for interfacing with SrReal calculator adapters.) Any change to the lattice or existing atoms will be registered with the Structure. Changes in the number of atoms will not be recognized. Thus, the diffpy.structure.Structure object should be fully configured before passing it to DiffpyStructureParSet.
The following classes are adapted:
DiffpyStructureParSet: adapter for diffpy.structure.Structure.
DiffpyLatticeParSet: adapter for diffpy.structure.Lattice.
DiffpyAtomParSet: adapter for diffpy.structure.Atom.
- class diffpy.cmistructure.diffpyparset.DiffpyStructureParSet(name, structure)[source]
Bases:
SrRealParSetAdapt a diffpy.structure.Structure to the ParameterSet interface.
This class derives from SrRealParSet. See that class for base attributes.
- atoms
The atom ParameterSets, provided for convenience.
- Type:
list of DiffpyAtomParSet
- structure
The structure this is adapting.
- Type:
diffpy.structure.Structure
- lattice
The managed lattice ParameterSet.
- Type:
DiffpyLatticeParSet
- <el><idx>
The managed atom ParameterSets. <el> is the atomic element and <idx> is the index of that element in the structure, starting from zero. For nickel in P1 symmetry, the managed DiffpyAtomParSets are named “Ni0”, “Ni1”, “Ni2” and “Ni3”.
- Type:
DiffpyAtomParSet
- classmethod can_adapt(structure)[source]
Return whether the structure can be adapted by this class.
- Parameters:
structure (object) – The structure object to check.
- Returns:
The flag indicating if structure is a diffpy.structure.Structure.
- Return type:
bool
diffpy.cmistructure.cctbxparset module
Wrappers for interfacing cctbx crystal with SrFit.
This wraps a cctbx.crystal as a ParameterSet with a similar hierarchy, which can then be used within a FitRecipe. Note that all manipulations to the cctbx.crystal should be done before wrapping. Changes made to the cctbx.crystal object after wrapping may not be reflected within the wrapper, which can have unpredictable results during a structure refinement.
The following classes are adapted:
CCTBXCrystalParSet: wrapper for cctbx.crystal.
CCTBXUnitCellParSet: wrapper for the unit cell of cctbx.crystal.
CCTBXScattererParSet: wrapper for cctbx.xray.scatterer.
- class diffpy.cmistructure.cctbxparset.CCTBXCrystalParSet(name, structure)[source]
Bases:
BaseStructureParSetAdapt a cctbx structure to the ParameterSet interface.
- structure
The adapted cctbx structure object.
- Type:
cctbx.crystal.special_position_settings
- scatterers
The scatterer ParameterSets.
- Type:
list of CCTBXScattererParSet
- unitcell
The unit cell ParameterSet for the structure.
- Type:
- classmethod can_adapt(structure)[source]
Return whether the structure can be adapted by this class.
- Parameters:
structure (object) – The structure object to check.
- Returns:
The flag indicating if structure is a cctbx.crystal.special_position_settings. False if cctbx is not installed.
- Return type:
bool
- get_lattice()[source]
Return the ParameterSet containing the lattice Parameters.
- Returns:
The unit cell ParameterSet of the structure.
- Return type:
- get_scatterers()[source]
Return the list of ParameterSets that represent the scatterers.
- Returns:
The scatterer ParameterSets of the structure.
- Return type:
list of CCTBXScattererParSet
- class diffpy.cmistructure.cctbxparset.CCTBXScattererParSet(name, structure_parameter_set, index)[source]
Bases:
ParameterSetAdapt a cctbx.xray.scatterer to the ParameterSet interface.
This class derives from ParameterSet.
- name
The name of the scatterer. The name is always of the form “%s%i” % (element, number), where the number is the running index of that element type (starting at 0).
- Type:
str
- x, y, z
The atom position in crystal coordinates.
- Type:
ParameterAdapter
- occupancy
The occupancy of the atom on its crystal location.
- Type:
ParameterAdapter
- Uiso
The isotropic displacement factor of the atom.
- Type:
ParameterAdapter
- property element
- class diffpy.cmistructure.cctbxparset.CCTBXUnitCellParSet(structure_parameter_set)[source]
Bases:
ParameterSetAdapt a cctbx unit_cell to the ParameterSet interface.
- name
The name of this ParameterSet, always “unitcell”.
- Type:
str
- a, b, c, alpha, beta, gamma
The unit cell parameters.
- Type:
ParameterAdapter
diffpy.cmistructure.bvsrestraint module
Bond-valence sum calculator from SrReal wrapped as a Restraint.
This can be used as an addition to a cost function during a structure refinement to keep the bond-valence sum within tolerable limits.
- class diffpy.cmistructure.bvsrestraint.BVSRestraint(parameter_set, sig=1, scaled=False)[source]
Bases:
RestraintWrapping of BVSCalculator.bvmsdiff as a Restraint.
The restraint penalty is the root-mean-square deviation of the theoretical and calculated bond-valence sum of a structure.
- _calc
The SrReal BVSCalculator instance.
- Type:
BVSCalculator
- _parameter_set
The SrRealParSet that created this BVSRestraint.
- Type:
- sig
The uncertainty on the BVS (default 1).
- Type:
float
- scaled
The flag indicating if the restraint is scaled (multiplied) by the unrestrained point-average chi^2 (chi^2/numpoints) (default False).
- Type:
bool
diffpy.cmistructure.sgconstraints module
Code to set space group constraints for a crystal structure.
- diffpy.cmistructure.sgconstraints.constrain_as_space_group(phase, spacegroup, scatterers=None, sgoffset=[0, 0, 0], constrainlat=True, constrainadps=True, adpsymbols=None, isosymbol='Uiso')[source]
Constrain a P1 structure to a space group.
This applies space group constraints to a structure ParameterSet with P1 symmetry. The passed scatterers are explicitly constrained to the specified space group, and the ADPs and lattice may be constrained as well. New Parameters used in the constraints are created within the returned SpaceGroupParameters object. Constraints are created in the ParameterSet that contains the constrained Parameter. This erases any constraints or constant flags on the scatterers, lattice or ADPs that are to be constrained.
- Parameters:
phase (BaseStructureParSet or object with a .phase attribute) – The structure ParameterSet to constrain, or a generator such as a PDFGenerator whose
.phaseis the structure ParameterSet.spacegroup (int, str or diffpy.structure.spacegroups.SpaceGroup) – The space group number, symbol or SpaceGroup instance.
scatterers (list of ParameterSet, optional) – The scatterer ParameterSets to constrain. If None (default), all scatterers returned by
phase.get_scatterers()are constrained.sgoffset (list of float, optional) – The offset of the space group origin (default [0, 0, 0]).
constrainlat (bool, optional) – The flag indicating whether to constrain the lattice (default True).
constrainadps (bool, optional) – The flag indicating whether to constrain the ADPs (default True).
adpsymbols (list of str, optional) – The ADP names. By default this is diffpy.structure.symmetryutilities.stdUsymbols (U11, U22, etc.). The names must be given in the same order as stdUsymbols.
isosymbol (str, optional) – The name of the isotropic ADP (default “Uiso”). If None, isotropic ADPs are constrained via the anisotropic ADPs.
- Returns:
The free Parameters of the structure that remain after applying the space group constraints.
- Return type:
SpaceGroupParameters
Notes
The lattice constraints are applied as follows.
- Triclinic
No constraints.
- Monoclinic
alpha and beta are fixed to 90 unless alpha != beta and alpha == gamma, in which case alpha and gamma are fixed to 90.
- Orthorhombic
alpha, beta and gamma are fixed to 90.
- Tetragonal
b is constrained to a and alpha, beta and gamma are fixed to 90.
- Trigonal
If gamma == 120, then b is constrained to a, alpha and beta are fixed to 90 and gamma is fixed to 120. Otherwise, b and c are constrained to a, and beta and gamma are fixed to alpha.
- Hexagonal
b is constrained to a, alpha and beta are fixed to 90 and gamma is fixed to 120.
- Cubic
b and c are constrained to a, and alpha, beta and gamma are fixed to 90.
- Raises:
TypeError – If
phaseis neither a structure ParameterSet nor an object whose.phaseis one.