コード例 #1
0
    def update_material(self):
        # Convert the sites back to the material data format
        info_array = []
        type_array = []
        U_array = []

        for site in self.sites:
            for atom in site['atoms']:
                info_array.append(
                    (*site['fractional_coords'], atom['occupancy']))
                type_array.append(ptable[atom['symbol']])
                U_array.append(atom['U'])

        mat = self.material
        mat._atominfo = np.array(info_array)
        mat._atomtype = np.array(type_array)
        mat._U = np.array(U_array)

        old_unitcell = mat.unitcell

        # Re-create the unit cell from scratch. This is easier to do
        # right now than setting the variables and figuring out which
        # properties need to be updated and in what order...
        mat.unitcell = unitcell(mat._lparms, mat.sgnum,
                                mat._atomtype, mat._atominfo, mat._U,
                                mat._dmin.getVal('nm'), mat._beamEnergy.value,
                                mat._sgsetting)

        # Set the stiffness back on it if it existed
        if hasattr(old_unitcell, 'stiffness'):
            mat.unitcell.stiffness = old_unitcell.stiffness

        # Update the structure factor of the PData
        mat.update_structure_factor()
コード例 #2
0
    def __init__(self,
                 name=None,
                 material_file=None,
                 dmin=DFLT_DMIN,
                 kev=DFLT_KEV,
                 sgsetting=DFLT_SGSETTING):
        """Constructor for Material

        name -- (str) name of crystal
        material_file -- (str) name of the material file
        which contains the crystal. this could be either cif
        or hdf5
        """
        self.name = name
        self.description = ''

        self._dmin = dmin

        self._beamEnergy = kev

        self.sgsetting = sgsetting

        if material_file:
            # Get values from configuration
            # self._readCfg(material_file)
            # >> @ date 08/20/2020 SS removing dependence on hklmax
            #self._hklMax = Material.DFLT_SSMAX
            # self._beamEnergy = Material.DFLT_KEV
            form = Path(material_file).suffix[1:]

            if (form == 'cif'):
                self._readCif(material_file)
            elif (form in ['h5', 'hdf5', 'xtal']):
                self._readHDFxtal(fhdf=material_file, xtal=name)
        else:
            # Use default values
            self._lparms = Material.DFLT_LPARMS
            # self._hklMax = Material.DFLT_SSMAX
            #
            self.description = ''
            #
            self.sgnum = Material.DFLT_SGNUM
            self._sgsetting = Material.DFLT_SGSETTING
            #
            self._atominfo = Material.DFLT_ATOMINFO
            #
            self._U = Material.DFLT_U
            #
            self._atomtype = Material.DFLT_ATOMTYPE
            #

        self.unitcell = unitcell.unitcell(self._lparms, self.sgnum,
                                          self._atomtype, self._atominfo,
                                          self._U, self._dmin.getVal('nm'),
                                          self._beamEnergy.value,
                                          self._sgsetting)

        self._newPdata()
        self.update_structure_factor()
コード例 #3
0
ファイル: material.py プロジェクト: saransh13/hexrd3
    def __init__(self, name=None, cfgP=None, dmin=DFLT_DMIN, kev=DFLT_KEV, sgsetting=DFLT_SGSETTING):
        """Constructor for Material

        name -- (str) name of material
        cfgP -- (instance) configuration file parser with
             -- the material name as a section
        """
        self.name = name
        self.description = ''
        
        self._dmin = dmin

        self._beamEnergy = kev
        
        self.sgsetting = sgsetting

        if(self._dmin.unit == 'angstrom'):
            # convert to nm
            uc_dmin = self._dmin.value * 0.1

        elif(self._dmin.unit == 'nm'):
            uc_dmin = self._dmin.value

        if cfgP:
            # Get values from configuration
            # self._readCfg(cfgP)
            self._hklMax = Material.DFLT_SSMAX
            # self._beamEnergy = Material.DFLT_KEV
            n = cfgP.find('.')
            form = cfgP[n+1:]

            if(form == 'cif'):
                self._readCif(cfgP)
            elif(form in ['h5', 'hdf5', 'xtal']):
                self._readHDFxtal(fhdf=cfgP, xtal=name)
        else:
            # Use default values
            self._lparms = Material.DFLT_LPARMS
            self._hklMax = Material.DFLT_SSMAX
            #
            self.description = ''
            #
            self.sgnum = Material.DFLT_SGNUM
            self._sgsetting = Material.DFLT_SGSETTING
            #
            self._atominfo = Material.DFLT_ATOMINFO
            #
            self._atomtype = Material.DFLT_ATOMTYPE
            #

        self.unitcell = unitcell(self._lparms, self.sgnum, self._atomtype,
                                self._atominfo, self._U, uc_dmin, 
                                self._beamEnergy.value, self._sgsetting)

        hkls = self.planeData.getHKLs(allHKLs=True)
        sf = numpy.zeros([hkls.shape[0],])
        for i,g in enumerate(hkls):
            sf[i] = self.unitcell.CalcXRSF(g)

        self.planeData.set_structFact(sf[~self.planeData.exclusions])

        return