Exemple #1
0
    def setStructure(self, stru, name="phase", periodic=True):
        """Set the structure that will be used to calculate the PDF.

        This creates a DiffpyStructureParSet, ObjCrystCrystalParSet or
        ObjCrystMoleculeParSet that adapts stru to a ParameterSet interface.
        See those classes (located in diffpy.srfit.structure) for how they are
        used. The resulting ParameterSet will be managed by this generator.

        stru    --  diffpy.structure.Structure, pyobjcryst.crystal.Crystal or
                    pyobjcryst.molecule.Molecule instance.  Default None.
        name    --  A name to give to the managed ParameterSet that adapts stru
                    (default "phase").
        periodic -- The structure should be treated as periodic (default
                    True). Note that some structures do not support
                    periodicity, in which case this will have no effect on the
                    PDF calculation.

        """

        # Create the ParameterSet
        parset = struToParameterSet(name, stru)

        # Set the phase
        self.setPhase(parset, periodic)
        return
    def setStructure(self, stru, name = "phase", periodic = True):
        """Set the structure that will be used to calculate the PDF.

        This creates a DiffpyStructureParSet, ObjCrystCrystalParSet or
        ObjCrystMoleculeParSet that adapts stru to a ParameterSet interface.
        See those classes (located in diffpy.srfit.structure) for how they are
        used. The resulting ParameterSet will be managed by this generator.

        stru    --  diffpy.Structure.Structure, pyobjcryst.crystal.Crystal or
                    pyobjcryst.molecule.Molecule instance . Default None.
        name    --  A name to give to the managed ParameterSet that adapts stru
                    (default "phase").
        periodic -- The structure should be treated as periodic (default
                    True). Note that some structures do not support
                    periodicity, in which case this will have no effect on the
                    PDF calculation.

        """

        # Create the ParameterSet
        parset = struToParameterSet(name, stru)

        # Set the phase
        self.setPhase(parset, periodic)
        return
Exemple #3
0
    def setStructure(self, stru, name=None):
        """Set the structure that will be used to calculate the PDF.
        
        periodic is determined according to stru if not specfied
        if self.periodic is not same as self.periodic then raise error
        """
        self.stru = stru
        # Create the ParameterSet
        name = stru.name if name == None else name
        if stru.periodic == self.periodic:
            periodic = self.periodic
        else:
            raise TypeError('stru.periodic != generator.periodic')

        if isinstance(stru, StructureExt):
            parset = StructureExtParSet(name, stru)
        elif isinstance(stru, Molecule):
            parset = ObjCrystMoleculeParSetExt(name, stru)
        else:
            parset = struToParameterSet(name, stru)
        # Set the phase
        self.setPhase(parset, periodic)

        for par in stru._params:
            self.addParameter(ParameterAdapter(par, stru, attr=par))
        return