def getDielectric(self, x): dom = x.manager.DOM d = dom.getElementsByTagName("dielectricfunction")[0] imag = d.getElementsByTagName("imag")[0].getElementsByTagName( "array")[0] real = d.getElementsByTagName("real")[0].getElementsByTagName( "array")[0] ai = Array(imag, fastflag=1) ar = Array(real, fastflag=1) return (ai, ar)
def getPartialDOS_L(self,x): msg().status("Parsing partial DOS") try: dom=x.manager.DOM dos = dom.getElementsByTagName("dos")[0] partial= dos.getElementsByTagName("partial")[0] array = partial.getElementsByTagName("array")[0] a=Array() a.readFromNode(array,late=1,fastflag=1) msg().status("OK") return a except: msg().error("Error - no partial DOS available") msg().exception() raise
def getPartialDOS_L(self, x): msg().status("Parsing partial DOS") try: dom = x.manager.DOM dos = dom.getElementsByTagName("dos")[0] partial = dos.getElementsByTagName("partial")[0] array = partial.getElementsByTagName("array")[0] a = Array() a.readFromNode(array, late=1, fastflag=1) msg().status("OK") return a except: msg().error("Error - no partial DOS available") msg().exception() raise
def getEigenvalues_L(self,x): msg().status("Parsing eigenvalues (L)") try: dom=x.manager.DOM # projected = dom.getElementsByTagName("projected")[0] # eigenvalues = projected.getElementsByTagName("eigenvalues")[0] eigenvalues = dom.getElementsByTagName("eigenvalues")[0] array = eigenvalues.getElementsByTagName("array")[0] a=Array() a.readFromNode(array,late=1,fastflag=1) msg().status("OK") return a except: msg().error("Error - no eigenvalues available") msg().exception() raise
def getEigenvalues_L(self, x): msg().status("Parsing eigenvalues (L)") try: dom = x.manager.DOM # projected = dom.getElementsByTagName("projected")[0] # eigenvalues = projected.getElementsByTagName("eigenvalues")[0] eigenvalues = dom.getElementsByTagName("eigenvalues")[0] array = eigenvalues.getElementsByTagName("array")[0] a = Array() a.readFromNode(array, late=1, fastflag=1) msg().status("OK") return a except: msg().error("Error - no eigenvalues available") msg().exception() raise
def getProjectedEigenvalues_L(self,x): msg().status("Parsing projected eigenvalues (L)") try: dom=x.manager.DOM projected = dom.getElementsByTagName("projected")[0] for x in projected.childNodes: if x.nodeType==x.ELEMENT_NODE: if x.nodeName=="array": a=Array() a.readFromNode(x,late=1,fastflag=1) msg().status("OK") return a except: msg().error("Error - no projected eigenvalues available") msg().exception() raise msg().error("Error - no projected eigenvalues available")
def getProjectedEigenvalues_L(self, x): msg().status("Parsing projected eigenvalues (L)") try: dom = x.manager.DOM projected = dom.getElementsByTagName("projected")[0] for x in projected.childNodes: if x.nodeType == x.ELEMENT_NODE: if x.nodeName == "array": a = Array() a.readFromNode(x, late=1, fastflag=1) msg().status("OK") return a except: msg().error("Error - no projected eigenvalues available") msg().exception() raise msg().error("Error - no projected eigenvalues available")
def readDOSCAR(f="DOSCAR", closeflag=0): if type(f) == type(""): f = open(f) closeflag = 1 tdos = Array() tdos.dimension = ['gridpoints', 'spin'] tdos.setupFields(['energy', 'total', 'integrated'], [FLOAT_TYPE, FLOAT_TYPE, FLOAT_TYPE], ['%+14.10f', '%+14.10f', '%+14.10f']) d = [] tdos.append(d) s = f.readline() s = f.readline() s = f.readline() s = f.readline() s = f.readline() s = f.readline() v = split(s) Ef = float(v[3]) s = f.readline() while s != "": v = split(s) if len(v) != 3: break d.append((float(v[0]), float(v[1]), float(v[2]))) s = f.readline() if closeflag: f.close() return tdos
def readDOSCAR(f="DOSCAR",closeflag=0): if type(f)==type(""): f=open(f) closeflag=1 tdos=Array() tdos.dimension=['gridpoints','spin'] tdos.setupFields(['energy','total','integrated'], [FLOAT_TYPE,FLOAT_TYPE,FLOAT_TYPE], ['%+14.10f','%+14.10f','%+14.10f']) d=[] tdos.append(d) s=f.readline() s=f.readline() s=f.readline() s=f.readline() s=f.readline() s=f.readline() v=split(s) Ef=float(v[3]) s=f.readline() while s!="": v=split(s) if len(v)!=3: break d.append((float(v[0]),float(v[1]),float(v[2]))) s=f.readline() if closeflag: f.close() return tdos
def createAtomsArray(self,fields=["element","atomtype"]): """Create an array containing atomtype for every atom. Fields can be specified. The field *atomtype* would containt *atomtype* ( *specie* ) index. This is used by *writexml* method. """ a=Array(name="atoms") a.dimension=["ion"] a.field=fields a.type=[] for x in a.field: if x in self.atomtypes.field: a.type.append(self.atomtypes.getFieldType(x)) elif x=="atomtype": a.type.append(INT_TYPE) else: raise "Unknown field '%s'."%x for i in range(0,self.Natoms): r=ArrayRecord(a) ai=self.speciesIndex(i) t=self.getRecord(ai) for x in fields: if x=="atomtype": r.atomtype=ai+1 else: r[x]=t[x] a.append(r.getRecord()) return a
def getTotalDOS(self, x): msg().status("Parsing DOS, please wait") try: dom = x.manager.DOM dos = dom.getElementsByTagName("dos")[0] total = dos.getElementsByTagName("total")[0] array = total.getElementsByTagName("array")[0] a = Array(array, fastflag=1) msg().status("OK") return a except: try: msg().error("Reading DOS from DOSCAR") return readDOSCAR(x.manager.PATH + "DOSCAR") except: msg().exception() raise