def updateSystem(self,x=None): s=self.getCurrentStructure() s.updateRecipBasis() self.b11.set_text(str(s.rbasis[0][0])) self.b12.set_text(str(s.rbasis[0][1])) self.b13.set_text(str(s.rbasis[0][2])) self.b21.set_text(str(s.rbasis[1][0])) self.b22.set_text(str(s.rbasis[1][1])) self.b23.set_text(str(s.rbasis[1][2])) self.b31.set_text(str(s.rbasis[2][0])) self.b32.set_text(str(s.rbasis[2][1])) self.b33.set_text(str(s.rbasis[2][2])) s=getCurrentSystemPM() primitive_cell = s.PRIMITIVE_STRUCTURE dyna=s.DYNA if dyna is None: dyna=Dyna() dyna.addSegment() if primitive_cell is not None: dyna=dyna.withBasis(primitive_cell.basis).reciprocal() self.model = KPathTreeModel(dyna) self.stepsPerSegment.set_text(str(dyna.size)) dynaPublisher().updateDyna(dyna) self.treeview.set_model(self.model)
def __init__(self): GraphWindowApplet.__init__(self) # self.gladefile="graphapplet.glade" # self.gladename="applet_frame" self.world_name = "phonondispersion" self.required = ["NAME"] dynaPublisher().addListener(self)
def on_add_clicked_handler(self,w,*arg): if self.selected is not None: self.model.dyna.insertSegment(self.selected) p=str(self.selected) self.model.row_inserted(p,self.model.get_iter(p)) else: self.model.dyna.addSegment() p=str(len(self.model.dyna.segments)-1) self.model.row_inserted(p,self.model.get_iter(p)) dynaPublisher().updateDyna(self.model.dyna)
def edited_h(self,renderer,path,txt,model,column): value = txt row=int(path) if column==0: self.model.dyna.labels[row][0]=value if column==4: self.model.dyna.labels[row][1]=value if column in (1,2,3): value= float(value.replace(",",".")) newpoint=Vector(self.model.dyna.segments[row][0]) newpoint[column-1]=float(str(value).replace(",",".")) newsegment=(newpoint,self.model.dyna.segments[row][1]) self.model.dyna.segments[row]=newsegment if column in (5,6,7): value= float(value.replace(",",".")) newpoint=Vector(self.model.dyna.segments[row][1]) newpoint[column-5]=float(str(value).replace(",",".")) newsegment=(self.model.dyna.segments[row][0],newpoint) self.model.dyna.segments[row]=newsegment dynaPublisher().updateDyna(self.model.dyna)
def __init__(self): Applet.__init__(self) self.celltype=self.PRIMITIVE_CELL self.dyna=None dynaPublisher().addListener(self)
def on_delete_clicked_handler(self,w,*arg): if self.selected is not None: self.model.dyna.deleteSegment(self.selected) self.model.row_deleted(str(self.selected)) dynaPublisher().updateDyna(self.model.dyna)
def on_stepsPerSegment_activate_handler(self,w,*arg): self.model.dyna.size=int(self.stepsPerSegment.get_text()) dynaPublisher().updateDyna(self.model.dyna)
def updateSystemGen(self, x=None): msg().status("Update System in Energy Convergence applet") system = self.system self.world[0].subtitle = "" # self.window_world[0].subtitle="" self.setGraphData([[]]) self.update() yield 1 if system is not None: name = system.current("NAME") if name is not None: self.world[0].subtitle = "(%s)" % name super_cell = system.INITIAL_STRUCTURE system.scheduleFirst("FORCE_CONSTANTS") force_const_mat = system.FORCE_CONSTANTS primitive_cell = system.PRIMITIVE_STRUCTURE if primitive_cell is None: return basis_masses = [ primitive_cell.getRecordForAtom(x)["mass"] for x in range(len(primitive_cell)) ] yield 1 msg().status("Reading DYNA") dyna = dynaPublisher().dyna if dyna is None: dyna = system.DYNA if dyna is None: msg().error("DYNA file not found, k-point path not specified.") self.setGraphData([[]]) yield 1 else: print "Dyna in dispersion:" print dyna.toString() dyna = dyna.withBasis(primitive_cell.basis).reciprocal() steps = dyna.size if len(dyna.segments) < 1: msg().error( "At least one segment is necessary for a k-point path") return msg().status("Generating k-point path") yield 1 k_path = list(dyna.pointsAlongPath(steps)) k_path_ext = list( dyna.pointsAlongPathWithDistanceAndLabel(steps)) msg().status("Start phonon calculation") yield 1 p_calc = PhononsCalculation(primitive_cell, super_cell, force_const_mat, basis_masses) omega = [] for i, x in enumerate(p_calc.calcPhononFrequencies(k_path)): msg().step(i, len(k_path_ext)) msg().status("Calculation k-point %s" % str(k_path[i])) omega.append(x) if (i % 5 == 0): yield 1 msg().step(0, 1) msg().status("OK") yield 1 msg().status("Filling in graph") yield 1 if omega is not None: assert (len(omega) == len(k_path_ext)) g = [] for i in range(len(omega[0])): gd = [] for j in range(len(omega)): point, distance, label = k_path_ext[j] gd.append((distance, omega[j][i])) g.append(gd) self.setGraphData([g]) # Create lines self.viewAll() self.update() w = self.canvas.world wg = w[0] x1 = wg.world_xmin x2 = wg.world_xmax y1 = wg.world_ymin y2 = wg.world_ymax wg.graph_lines = [ GraphLine(distance, y1, distance, y2, 7) for point, distance, label in k_path_ext if label is not None and distance > x1 and distance < x2 ] self.viewAll() self.update() else: self.setGraphData([[]]) wg.graph_lines = [] self.update() self.viewAll() msg().step(0, 1) msg().status("OK")
def destroy(self): GraphWindowApplet.destroy(self) dynaPublisher().removeListener(self)