def test(): from UnitCell import UnitCell, Site from Atom import Atom uc = UnitCell() at0 = Atom(symbol="Al") at1 = Atom(symbol="Fe") site0 = Site([0.0, 0.0, 0.0], at0) site1 = Site([0.5, 0.5, 0.5], at1) uc.addSite(site0, "") uc.addSite(site1, "") print uc print from python.parsing.parse_phon_results import parse phonlist = parse("phon.out_dos_noIBZ") wvectors = [[qx, 0.0, 0.0] for qx in range(30)] dwc = DebyeWallerCalculator(uc, phonlist, phonlist) dwlist = [ dwc.getDWFactorForAtom(0, wavevector, 300) for wavevector in wvectors ] #print dwlist return dwlist
def test(): from UnitCell import UnitCell,Site from Atom import Atom uc = UnitCell() at0 = Atom(symbol="Al") at1 = Atom(symbol="Fe") site0=Site([0.0, 0.0, 0.0],at0) site1=Site([0.5, 0.5, 0.5],at1) uc.addSite(site0,"") uc.addSite(site1, "") print uc print from python.parsing.parse_phon_results import parse phonlist = parse("phon.out_dos_noIBZ") wvectors = [[qx, 0.0, 0.0] for qx in range(30)] dwc = DebyeWallerCalculator(uc, phonlist, phonlist) dwlist = [dwc.getDWFactorForAtom(0, wavevector, 300) for wavevector in wvectors] #print dwlist return dwlist
def buildFromXYZ(self): """Builds the unitcell atom coordinates from an XYZ format file.""" self._uc = UnitCell(self._cellvec) try: f = open(self._filename, 'r') except IOError, (errno, strerror): print "I/O error(%s): %s" % (errno, strerror)
def _create_primitive_unitcell(self): # the ctor from UnitCell import UnitCell base = self._lattice.getPrimitiveLattice(self.sg) base = numpy.array(base) puc = UnitCell(base=base) for atom in self: if puc.hasAtom(atom): continue puc.addAtom(atom) continue return puc # check symmetry sg = self.sg verdict, atompos, symop = self.symConsistent() if not verdict: raise RuntimeError, \ "inconsistent structure: atom position: %s, sym operation %s" % ( atompos, symop) # if sg.number == 225: # face centered--below is only for cubic...need to generalize a = self.lattice.a base = numpy.array([[0,1,1], [1,0,1], [1,1,0]])*0.5*a elif sg.number == 229: # body centered--below is only for cubic...need to generalize a = self.lattice.a base = numpy.array([[1,0,0], [0,1,0], [0.5,0.5,0.5]])*a elif sg.short_name[0] == 'P': # primitive base = self.lattice else: # not implemented return
def _create_primitive_unitcell(self): # the ctor from UnitCell import UnitCell base = self._lattice.getPrimitiveLattice(self.sg) base = numpy.array(base) puc = UnitCell(base=base) for atom in self: if puc.hasAtom(atom): continue puc.addAtom(atom) continue return puc # check symmetry sg = self.sg verdict, atompos, symop = self.symConsistent() if not verdict: raise RuntimeError, \ "inconsistent structure: atom position: %s, sym operation %s" % ( atompos, symop) # if sg.number == 225: # face centered--below is only for cubic...need to generalize a = self.lattice.a base = numpy.array([[0, 1, 1], [1, 0, 1], [1, 1, 0]]) * 0.5 * a elif sg.number == 229: # body centered--below is only for cubic...need to generalize a = self.lattice.a base = numpy.array([[1, 0, 0], [0, 1, 0], [0.5, 0.5, 0.5]]) * a elif sg.short_name[0] == 'P': # primitive base = self.lattice else: # not implemented return
except IOError, (errno, strerror): print "I/O error(%s): %s" % (errno, strerror) string = ifile.readlines() cell_params = [] cell_dict = {} for parser in cell_parsers: for data, dataStart, dataEnd in parser.scanString(string): cell_params.append(data[1]) cell_dict[data[0]]=data[1] ifile.close() ### end of fix t=Translator() t.filenameIn = fileInString ciflist = t.cifToAtomAndCoordinateList() cellvectors = MInv(cell_params) uc = UnitCell(cellvectors) for item in ciflist: X = item[0] pos = [float(x) for x in item[1:4]] uc.addAtom(Atom(symbol=X), pos, "") # Note: this only works if elements' symbols in CIF are "Ab" format
#resonators = decorated_resonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'Peter-graphene') # #########decorated Euyclidean #test1 = EuclideanLayout(3,3,lattice_type = 'kagome', modeType = 'FW') #ucell = UnitCell('PeterChain_tail', side = 1) #resonators = test1.resonators #LGresonators = generate_line_graph(resonators) #resonators = LGresonators #decorated_resonators = decorate_layout(resonators, ucell.resonators) #resonators = decorated_resonators #testLattice = GeneralLayout(resonators , modeType = test1.modeType, name = 'Peter-kagome') # #########decorated Euyclidean test1 = EuclideanLayout(3, 2, lattice_type='Huse', modeType='FW') ucell = UnitCell('PeterChain_tail', side=1) resonators = test1.resonators decorated_resonators = decorate_layout(resonators, ucell.resonators) resonators = decorated_resonators testLattice = GeneralLayout(resonators, modeType=test1.modeType, name='Peter-HPG') # # #######decorated hyperbolic #test1 = PlanarLayout(gon = 7, vertex = 3, side =1, radius_method = 'lin') #test1.populate(2, resonatorsOnly=False) ##resonators = test1.get_all_resonators() ##splitGraph = split_resonators(resonators) ##resonators = splitGraph #ucell = UnitCell('PeterChain_tail', side = 1)
ifile = open(fileInString, 'r') except IOError, (errno, strerror): print "I/O error(%s): %s" % (errno, strerror) string = ifile.readlines() cell_params = [] cell_dict = {} for parser in cell_parsers: for data, dataStart, dataEnd in parser.scanString(string): cell_params.append(data[1]) cell_dict[data[0]] = data[1] ifile.close() ### end of fix t = Translator() t.filenameIn = fileInString ciflist = t.cifToAtomAndCoordinateList() cellvectors = MInv(cell_params) uc = UnitCell(cellvectors) for item in ciflist: X = item[0] pos = [float(x) for x in item[1:4]] uc.addAtom(Atom(symbol=X), pos, "") # Note: this only works if elements' symbols in CIF are "Ab" format