Example #1
0
    def create_model(self):
        self.tab.clear()
        self.tab.setColumnCount(6)
        if enable_betafeatures() == False:
            self.tab.setColumnHidden(5, True)
            self.tab.setColumnHidden(4, True)

        self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tab.setHorizontalHeaderLabels([
            _("Layer name"),
            _("Thicknes"),
            _("Optical material"),
            _("Layer type"),
            _("DoS Layer"),
            _("PL Layer")
        ])
        self.tab.setColumnWidth(2, 250)
        self.tab.setRowCount(epitaxy_get_layers())

        for i in range(0, epitaxy_get_layers()):
            thick = epitaxy_get_width(i)
            material = epitaxy_get_mat_file(i)
            dos_layer = epitaxy_get_electrical_layer(i)
            pl_file = epitaxy_get_pl_file(i)
            name = epitaxy_get_name(i)

            self.add_row(i, thick, material, dos_layer, pl_file, name)
        return
Example #2
0
		def recalculate(self):
			self.colors=[]
			lines=[]

			if dat_file_read(self.graph_data,self.graph_path)==True:
				#print(self.graph_path)
				self.graph_z_max,self.graph_z_min=dat_file_max_min(self.graph_data)
				#print(self.graph_z_max,self.graph_z_min)
			val=inp_get_token_value("light.inp", "#Psun")
			self.suns=float(val)
			l=epitaxy_get_layers()-1
			for i in range(0,epitaxy_get_layers()):

				path=os.path.join(get_materials_path(),epitaxy_get_mat_file(l-i),"mat.inp")


				if inp_load_file(lines,path)==True:
					red=float(inp_search_token_value(lines, "#Red"))
					green=float(inp_search_token_value(lines, "#Green"))
					blue=float(inp_search_token_value(lines, "#Blue"))
				else:

					red=0.0
					green=0.0
					blue=0.0
				self.colors.append(color(red,green,blue))
			self.colors.reverse()
			self.update()
Example #3
0
	def draw(self):
		emission=False
		lines=[]
		for i in range(0,epitaxy_get_layers()):
			if epitaxy_get_pl_file(i)!="none":
				if inp_load_file(lines,epitaxy_get_pl_file(i)+".inp")==True:
					if str2bool(lines[1])==True:
						emission=True				

		tot=0
		for i in range(0,epitaxy_get_layers()):
			tot=tot+epitaxy_get_width(i)

		pos=0.0
		l=epitaxy_get_layers()-1
		lines=[]

		for i in range(0,epitaxy_get_layers()):
			thick=200.0*epitaxy_get_width(l-i)/tot
			pos=pos+thick
			path=os.path.join(get_materials_path(),epitaxy_get_mat_file(l-i),"mat.inp")

			if inp_load_file(lines,path)==True:
				red=float(inp_search_token_value(lines, "#Red"))
				green=float(inp_search_token_value(lines, "#Green"))
				blue=float(inp_search_token_value(lines, "#Blue"))
			else:
				print "Could not load",path
				red=0.0
				green=0.0
				blue=0.0

			self.draw_box(200,450.0-pos,thick*0.9,red,green,blue,l-i)
		step=50.0

		lines=[]
		if inp_load_file(lines,os.path.join(os.getcwd(),"light.inp"))==True:
			self.sun=float(inp_search_token_value(lines, "#Psun"))

		if self.sun<=0.01:
			step=200
		elif self.sun<=0.1:
			step=100
		elif self.sun<=1.0:
			step=50
		elif self.sun<=10.0:
			step=10
		else:
			step=5.0
		if self.sun!=0:
			for x in range(0,200,step):
				self.draw_photon(270+x,50)

		if emission==True:
			for x in range(0,200,50):
				self.draw_photon_up(240+x,180)

		self.draw_mode(200,250,200)
Example #4
0
	def update(self):
		self.tab.clear()
		self.tab.setColumnCount(5)
		self.tab.setRowCount(0)
		self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)
		self.tab.setHorizontalHeaderLabels([_("material"), _("Volume (m^-3)"), _("Mass (kg)"), _("Cost ($)"), _("Energy (J)")])
		self.tab.setColumnWidth(1, 200)
		self.tab.setColumnWidth(2, 200)
		self.tab.setColumnWidth(3, 200)
		self.tab.setColumnWidth(4, 200)
		energy_tot=0.0
		cost_tot=0.0
		for i in range(0,epitaxy_get_layers()):
			
			volume=epitaxy_get_width(i)*1.0*1.0
			name=epitaxy_get_mat_file(i)
			xls_file_name=os.path.join(get_materials_path(),epitaxy_get_mat_file(i),"cost.xlsx")
			wb = load_workbook(xls_file_name)
			ws= wb.get_sheet_by_name("results")

			density = float(ws['B2'].value)
			mass=density*volume

			cost_per_kg = float(ws['B3'].value)
			cost=mass*cost_per_kg

			energy_per_kg = float(ws['B4'].value)
			energy=energy_per_kg*mass

			tab_add(self.tab,[name,str(volume),str(mass),str(cost),str(energy)])

			energy_tot=energy_tot+energy
			cost_tot=cost_tot+cost
		
		pce=inp_get_token_value("sim_info.dat", "#pce")
		payback_time=-1.0
		if pce!=None:
			pce=float(pce)
			gen_energy=1366.0*pce/100.0
			payback_time=energy_tot/gen_energy/60.0/60.0/24/365
		
		tab_add(self.tab,["sum","","",str(cost_tot),str(energy_tot)])
		tab_add(self.tab,["","","pay back time=",str(payback_time),"years"])
Example #5
0
	def create_model(self):
		self.tab.clear()
		self.tab.setColumnCount(6)
		if enable_betafeatures()==False:
			self.tab.setColumnHidden(5, True)
			self.tab.setColumnHidden(4, True)

		self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)
		self.tab.setHorizontalHeaderLabels([_("Layer name"), _("Thicknes"), _("Optical material"), _("Layer type"), _("DoS Layer"),_("PL Layer")])

		self.tab.setRowCount(epitaxy_get_layers())

		for i in range(0,epitaxy_get_layers()):
			thick=epitaxy_get_width(i)
			material=epitaxy_get_mat_file(i)
			dos_layer=epitaxy_get_electrical_layer(i)
			pl_file=epitaxy_get_pl_file(i)
			name=epitaxy_get_name(i)

			self.add_row(i,thick,material,dos_layer,pl_file,name)
		return
Example #6
0
	def __create_model(self):

		# create list store
		model = gtk.ListStore(str,str,str,str,str,str,str)

		# add items

		self.rebuild_mat_list()

		for i in range(0,epitaxy_get_layers()):
			thick=epitaxy_get_width(i)
			material=epitaxy_get_mat_file(i)
			dos_layer=epitaxy_get_electrical_layer(i)
			pl_file=epitaxy_get_pl_file(i)
			name=epitaxy_get_name(i)

			dos_file=""

			if dos_layer=="none":
				dos_file=_("no")
			else:
				dos_file=_("yes")

			scan_item_add("epitaxy.inp","#layer"+str(i),_("Material for ")+str(material),2)
			scan_item_add("epitaxy.inp","#layer"+str(i),_("Layer width ")+str(material),1)

			iter = model.append()

			model.set (iter,
			  COLUMN_NAME, str(name),
			  COLUMN_THICKNES, str(thick),
			  COLUMN_MATERIAL, str(material),
			  COLUMN_DEVICE, str(dos_file),
			  COLUMN_DOS_LAYER, str(dos_layer),
			  COLUMN_PL_FILE, str(pl_file)
			)
		return model
Example #7
0
	def draw_graph(self):
		self.layer_end=[]
		self.layer_name=[]

		n=0
		self.my_figure.clf()
		ax1 = self.my_figure.add_subplot(111)
		ax2 = ax1.twinx()
		x_pos=0.0
		layer=0
		color =['r','g','b','y','o','r','g','b','y','o']
		start=0.0

		for i in range(0,epitaxy_get_layers()):
			if epitaxy_get_electrical_layer(i)=="none":
				start=start-epitaxy_get_width(i)
			else:
				break
		print "START=",start
		start=start*1e9

		x_pos=start
		for i in range(0,epitaxy_get_layers()):

			label=epitaxy_get_mat_file(i)
			layer_ticknes=epitaxy_get_width(i)
			layer_material=epitaxy_get_mat_file(i)

			delta=float(layer_ticknes)*1e9
			if epitaxy_get_electrical_layer(i)=="none":
				mat_file=os.path.join(os.getcwd(),'materials',layer_material,'mat.inp')
				myfile = open(mat_file)
				self.mat_file_lines = myfile.readlines()
				myfile.close()
			
				for ii in range(0, len(self.mat_file_lines)):
					self.mat_file_lines[ii]=self.mat_file_lines[ii].rstrip()

				lumo=-float(self.mat_file_lines[1])
				Eg=float(self.mat_file_lines[3])
			else:
				lines=[]
				if inp_load_file(lines,epitaxy_get_electrical_layer(i)+".inp")==True:
					lumo=-float(inp_search_token_value(lines, "#Xi"))
					Eg=float(inp_search_token_value(lines, "#Eg"))

			x = [x_pos,x_pos+delta,x_pos+delta,x_pos]

			lumo_delta=lumo-0.1
			h**o=lumo-Eg
			homo_delta=h**o-0.1
			if Eg==0.0:
				lumo_delta=-7.0
				h**o=0.0
			lumo_shape = [lumo,lumo,lumo_delta,lumo_delta]
			x_pos=x_pos+delta
			self.layer_end.append(x_pos)
			self.layer_name.append(layer_material)
			ax2.fill(x,lumo_shape, color[layer],alpha=0.4)
			ax2.text(x_pos-delta/1.5, lumo-0.4, epitaxy_get_name(i))

			if h**o!=0.0:
				homo_shape = [h**o,h**o,homo_delta,homo_delta]
				ax2.fill(x,homo_shape, color[layer],alpha=0.4)

			layer=layer+1

			n=n+1

		state=plot_state()
		get_plot_file_info(state,self.optical_mode_file)
		#summary="<big><b>"+self.store[path[0]][0]+"</b></big>\n"+"\ntitle: "+state.title+"\nx axis: "+state.x_label+" ("+latex_to_pygtk_subscript(state.x_units)+")\ny axis: "++" ("+latex_to_pygtk_subscript(state.y_units)+")\n\n<big><b>Double click to open</b></big>"

		print "ROD!!!!",state.y_label,self.optical_mode_file
		ax1.set_ylabel(state.y_label)
		ax1.set_xlabel('Position (nm)')
		ax2.set_ylabel('Energy (eV)')
		ax2.set_xlim([start, x_pos])
		#ax2.axis(max=)#autoscale(enable=True, axis='x', tight=None)
		loaded=False

		if os.path.isfile("light_dump.zip"):
			zf = zipfile.ZipFile("light_dump.zip", 'r')
			lines = zf.read(self.optical_mode_file).split("\n")
			zf.close()
			loaded=True
		elif os.path.isfile(self.optical_mode_file):
			print "I want to load",self.optical_mode_file
			f = open(self.optical_mode_file)
			lines = f.readlines()
			f.close()
			loaded=True
		
		if loaded==True:
			xx=[]
			yy=[]
			zz=[]
			lines_to_xyz(xx,yy,zz,lines)
			t = asarray(xx)
			s = asarray(yy)

			t=t*1e9
			ax1.plot(t,s, 'black', linewidth=3 ,alpha=0.5)

			

		self.my_figure.tight_layout()
Example #8
0
    def drawWidget(self, qp):
        font = QFont('Sans', 11, QFont.Normal)
        qp.setFont(font)

        emission = False
        lines = []
        for i in range(0, epitaxy_get_layers()):
            if epitaxy_get_pl_file(i) != "none":
                lines = inp_load_file(epitaxy_get_pl_file(i) + ".inp")
                if lines != False:
                    if str2bool(lines[1]) == True:
                        emission = True

        tot = 0
        for i in range(0, epitaxy_get_layers()):
            tot = tot + epitaxy_get_width(i)

        pos = 0.0
        l = epitaxy_get_layers() - 1
        lines = []

        for i in range(0, epitaxy_get_layers()):
            red = 0.0
            green = 0.0
            blue = 0.0

            thick = 200.0 * epitaxy_get_width(l - i) / tot
            pos = pos + thick
            path = os.path.join(get_materials_path(),
                                epitaxy_get_mat_file(l - i), "mat.inp")
            lines = inp_load_file(path)
            if lines != False:
                ret = inp_search_token_array(lines, "#red_green_blue")
                if ret != False:
                    red = float(ret[0])
                    green = float(ret[1])
                    blue = float(ret[2])

            self.draw_box(qp, 200, 450.0 - pos, thick * 0.9, red, green, blue,
                          l - i)
        step = 50.0

        lines = inp_load_file(os.path.join(get_sim_path(), "light.inp"))
        if lines != False:
            self.sun = float(inp_search_token_value(lines, "#Psun"))

        if self.sun <= 0.01:
            step = 200
        elif self.sun <= 0.1:
            step = 100
        elif self.sun <= 1.0:
            step = 50
        elif self.sun <= 10.0:
            step = 10
        else:
            step = 5.0
        if self.sun != 0:
            for x in range(0, 200, step):
                self.draw_photon(qp, 210 + x, 100, False)

        if emission == True:
            for x in range(0, 200, 50):
                self.draw_photon(qp, 240 + x, 140, True)

        self.draw_mode(qp, 200, 250)
        qp.drawText(40, 540 + 40, "No OpenGL support, using 2D fallback mode")
Example #9
0
    def update(self):
        self.tab.clear()
        self.tab.setColumnCount(5)
        self.tab.setRowCount(0)
        self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tab.setHorizontalHeaderLabels([
            _("material"),
            _("Volume") + " (m^-3)",
            _("Mass") + " (kg)",
            _("Cost") + " ($)",
            _("Energy") + " (J)"
        ])
        self.tab.setColumnWidth(1, 200)
        self.tab.setColumnWidth(2, 200)
        self.tab.setColumnWidth(3, 200)
        self.tab.setColumnWidth(4, 200)
        if work_book_enabled == False:
            print(_("python3-openpyxl not found"))
            return

        energy_tot = 0.0
        cost_tot = 0.0
        for i in range(0, epitaxy_get_layers()):

            volume = epitaxy_get_width(i) * 1.0 * 1.0
            name = epitaxy_get_mat_file(i)
            xls_file_name = os.path.join(get_materials_path(),
                                         epitaxy_get_mat_file(i), "cost.xlsx")
            if os.path.isfile(xls_file_name):
                wb = load_workbook(xls_file_name)
                ws = wb.get_sheet_by_name("results")

                density = float(ws['B2'].value)
                mass = density * volume

                cost_per_kg = float(ws['B3'].value)
                cost = mass * cost_per_kg

                energy_per_kg = float(ws['B4'].value)
                energy = energy_per_kg * mass

                tab_add(self.tab,
                        [name,
                         str(volume),
                         str(mass),
                         str(cost),
                         str(energy)])

                energy_tot = energy_tot + energy
                cost_tot = cost_tot + cost

        pce = inp_get_token_value("sim_info.dat", "#pce")
        payback_time = -1.0
        if pce != None:
            pce = float(pce)
            gen_energy = 1366.0 * pce / 100.0
            payback_time = energy_tot / gen_energy / 60.0 / 60.0 / 24 / 365

        tab_add(self.tab, ["sum", "", "", str(cost_tot), str(energy_tot)])
        tab_add(self.tab,
                ["", "", "pay back time=",
                 str(payback_time), "years"])
Example #10
0
	def draw_graph(self):

		self.layer_end=[]
		self.layer_name=[]
		self.optical_mode_file=os.path.join(get_sim_path(),"light_dump",self.data_file)

		self.my_figure.clf()
		ax1 = self.my_figure.add_subplot(111)
		ax2 = ax1.twinx()
		x_pos=0.0
		layer=0
		color =['r','g','b','y','o','r','g','b','y','o']
		start=0.0

		for i in range(0,epitaxy_get_layers()):
			if epitaxy_get_electrical_layer(i).startswith("dos")==False:
				start=start-epitaxy_get_width(i)
			else:
				break

		start=start*1e9

		x_pos=start
		for i in range(0,epitaxy_get_layers()):

#			label=epitaxy_get_mat_file(i)
			layer_ticknes=epitaxy_get_width(i)
			layer_material=epitaxy_get_mat_file(i)
			lumo=0.0
			h**o=0.0
			
			delta=float(layer_ticknes)*1e9
			#print(epitaxy_get_electrical_layer(i))
			lines=[]
			material_type=inp_get_token_value(os.path.join(get_materials_path(),layer_material,'mat.inp'), "#material_type")
			if epitaxy_get_electrical_layer(i).startswith("dos")==False:
				dos_file=os.path.join(get_materials_path(),layer_material,'dos.inp')
				if os.path.isfile(dos_file)==False:
					dos_file=os.path.join(get_default_material_path(),"dos.inp")

				lines=inp_load_file(dos_file)
				if lines!=False:
					lumo=-float(inp_search_token_value(lines, "#Xi"))
					Eg=float(inp_search_token_value(lines, "#Eg"))
			else:
				lines=inp_load_file(os.path.join(get_sim_path(),epitaxy_get_electrical_layer(i)+".inp"))
				if lines!=False:
					lumo=-float(inp_search_token_value(lines, "#Xi"))
					Eg=float(inp_search_token_value(lines, "#Eg"))
					#print("b")

			x = [x_pos,x_pos+delta,x_pos+delta,x_pos]

			#print("lumo=",lumo)
			lumo_delta=lumo-0.1

			h**o=lumo-Eg
			homo_delta=h**o-0.1

			draw_homo=True
			y_name_pos=lumo-Eg/2

			if Eg==0.0 or material_type=="metal":
				lumo_delta=-7.0
				draw_homo=False
				y_name_pos=lumo-1.0

			x_pos=x_pos+delta
			self.layer_end.append(x_pos)
			self.layer_name.append(layer_material)

			item=ax2.text(x_pos-delta/1.5, y_name_pos, epitaxy_get_name(i))
			item.set_fontsize(15)

			lumo_shape = [lumo,lumo,lumo_delta,lumo_delta]
			ax2.fill(x,lumo_shape, color[layer],alpha=0.4)
			item=ax2.text(x_pos-delta/1.5, lumo+0.1, "%.2f eV" % lumo)
			item.set_fontsize(15)

			if draw_homo==True:
				homo_shape = [h**o,h**o,homo_delta,homo_delta]
				ax2.fill(x,homo_shape, color[layer],alpha=0.4)
				item=ax2.text(x_pos-delta/1.5, lumo-Eg-0.4, "%.2f eV" % h**o)
				item.set_fontsize(15)

			layer=layer+1

		state=dat_file()
		if dat_file_read(state,self.optical_mode_file)==True:
			ax1.set_ylabel(state.data_label+" ("+state.data_units+")")
			ax1.set_xlabel(_("Position")+" (nm)")
			ax2.set_ylabel(_("Energy")+" (eV)")
			ax2.set_xlim([start, x_pos])
			#ax2.axis(max=)#autoscale(enable=True, axis='x', tight=None)

			for i in range(0,len(state.y_scale)):
				state.y_scale[i]=state.y_scale[i]*1e9
			
			ax1.plot(state.y_scale,state.data[0][0], 'black', linewidth=3 ,alpha=0.5)



		self.my_figure.tight_layout()
Example #11
0
    def drawWidget(self, qp):
        font = QFont("Sans", 11, QFont.Normal)
        qp.setFont(font)

        emission = False
        lines = []
        for i in range(0, epitaxy_get_layers()):
            if epitaxy_get_pl_file(i) != "none":
                if inp_load_file(lines, epitaxy_get_pl_file(i) + ".inp") == True:
                    if str2bool(lines[1]) == True:
                        emission = True

        tot = 0
        for i in range(0, epitaxy_get_layers()):
            tot = tot + epitaxy_get_width(i)

        pos = 0.0
        l = epitaxy_get_layers() - 1
        lines = []

        for i in range(0, epitaxy_get_layers()):
            thick = 200.0 * epitaxy_get_width(l - i) / tot
            pos = pos + thick
            path = os.path.join(get_materials_path(), epitaxy_get_mat_file(l - i), "mat.inp")

            if inp_load_file(lines, path) == True:
                red = float(inp_search_token_value(lines, "#Red"))
                green = float(inp_search_token_value(lines, "#Green"))
                blue = float(inp_search_token_value(lines, "#Blue"))
            else:
                print("Could not load", path)
                red = 0.0
                green = 0.0
                blue = 0.0

            self.draw_box(qp, 200, 450.0 - pos, thick * 0.9, red, green, blue, l - i)
        step = 50.0

        lines = []
        if inp_load_file(lines, os.path.join(os.getcwd(), "light.inp")) == True:
            self.sun = float(inp_search_token_value(lines, "#Psun"))

        if self.sun <= 0.01:
            step = 200
        elif self.sun <= 0.1:
            step = 100
        elif self.sun <= 1.0:
            step = 50
        elif self.sun <= 10.0:
            step = 10
        else:
            step = 5.0
        if self.sun != 0:
            for x in range(0, 200, step):
                self.draw_photon(qp, 210 + x, 100, False)

        if emission == True:
            for x in range(0, 200, 50):
                self.draw_photon(qp, 240 + x, 140, True)

        self.draw_mode(qp, 200, 250)
        qp.drawText(40, 540 + 40, "No OpenGL support, using 2D fallback mode")