def callback_button_click(self):
		from gpvdm_open import gpvdm_open
		dialog=gpvdm_open(get_materials_path(),act_as_browser=False)

		ret=dialog.exec_()
		if ret==QDialog.Accepted:
			file_name=dialog.get_filename()
			rel_path=subtract_paths(get_materials_path(),file_name)
			rel_path=rel_path.replace("\\", "/")
			self.setText(rel_path)
			self.changed.emit()
Example #2
0
 def fill_store(self):
     self.materials.clear()
     print(get_materials_path())
     all_files = find_materials()
     for fl in all_files:
         text = get_ref_text(os.path.join(get_materials_path(), fl,
                                          "n.omat"),
                             html=False)
         if text != None:
             itm = QListWidgetItem(os.path.basename(fl) + " " + text)
             itm.setIcon(self.mat_icon)
             itm.setToolTip(text)
             self.materials.addItem(itm)
Example #3
0
def scan_items_populate_from_files():
    name = os.path.join(get_sim_path(), "sim.gpvdm")
    if os.path.isfile(name) == True:
        file_list = zip_lsdir(name)

        for i in range(0, len(file_list)):
            if file_list[i].startswith(
                    "dos") == True and file_list[i].endswith(".inp") == True:
                scan_populate_from_file(file_list[i])

            if file_list[i].startswith("jv") == True and file_list[i].endswith(
                    ".inp") == True:
                scan_populate_from_file(file_list[i])
            #if my_token_lib[i].file_name!="":
            #	scan_item_add(my_token_lib[i].file_name,my_token_lib[i].token,my_token_lib[i].info,1)

        mat = find_materials()

        for i in range(0, len(mat)):
            scan_remove_file(os.path.join(get_materials_path(), mat[i]))
            scan_item_add(os.path.join("materials", mat[i],
                                       "fit.inp"), "#wavelength_shift_alpha",
                          "Absorption spectrum wavelength shift", 1)
            scan_item_add(os.path.join("materials", mat[i], "fit.inp"),
                          "#n_mul", "Refractive index spectrum multiplier", 1)
            scan_item_add(os.path.join("materials", mat[i], "fit.inp"),
                          "#alpha_mul", "Absorption spectrum multiplier", 1)
Example #4
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 #5
0
	def thread_download_updates(self):
		self.status_bar.showMessage("Downloading updates.....")
		self.update.updates_get()
		self.update.updates_download()
		self.update.updates_install(get_materials_path())
		self.status_bar.showMessage("Done..")
		self.got_updates.emit()
Example #6
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 #7
0
	def rebuild_mat_list(self):
		self.material_files=[]
		mat=find_materials()
		for i in range(0,len(mat)):
			self.material_files.append(mat[i])
			scan_remove_file(os.path.join(get_materials_path(),mat[i]))			
			scan_item_add(os.path.join("materials",mat[i],"fit.inp"),"#wavelength_shift_alpha","Absorption spectrum wavelength shift",1)
			scan_item_add(os.path.join("materials",mat[i],"fit.inp"),"#n_mul","Refractive index spectrum multiplier",1)
			scan_item_add(os.path.join("materials",mat[i],"fit.inp"),"#alpha_mul","Absorption spectrum multiplier",1)
Example #8
0
	def callback_view_materials(self):
		self.dialog=gpvdm_open(get_materials_path(),big_toolbar=True)
		self.new_materials = QAction(icon_get("add_material"), wrap_text(_("Add Material"),8), self)
		self.new_materials.triggered.connect(self.on_new_materials_clicked)
		self.dialog.toolbar.addAction(self.new_materials)

		self.dialog.show_inp_files=False
		self.dialog.menu_new_material_enabled=True
		ret=self.dialog.exec_()
Example #9
0
def find_materials():
	ret=[]

	path=get_materials_path()

	for file in glob.glob(os.path.join(path,"*")):
		if os.path.isdir(file)==True:
			ret.append(os.path.splitext(os.path.basename(file))[0])

	return ret
Example #10
0
def find_light_source():
	ret=[]

	path=get_materials_path()

	
	for file in glob.glob(os.path.join(path,"*.spectra")):
		ret.append(os.path.splitext(os.path.basename(file))[0])

	return ret
Example #11
0
	def callback_view_materials(self):
		dialog=gpvdm_open(get_materials_path())
		dialog.show_inp_files=False
		ret=dialog.window.exec_()

		if ret==QDialog.Accepted:
			if os.path.isfile(os.path.join(dialog.get_filename(),"mat.inp"))==True:
				self.mat_window=materials_main(dialog.get_filename())
				self.mat_window.show()
			else:
				plot_gen([dialog.get_filename()],[],"auto")
Example #12
0
def epitaxy_populate_rgb():
    global epi
    path = os.path.join(get_materials_path(), epi[-1].mat_file, "mat.inp")
    mat_lines = inp_load_file(path)
    ret = inp_search_token_array(mat_lines, "#red_green_blue")

    if ret != False:
        epi[-1].r = float(ret[0])
        epi[-1].g = float(ret[1])
        epi[-1].b = float(ret[2])
        epi[-1].alpha = float(inp_search_token_value(mat_lines, "#mat_alpha"))
Example #13
0
	def fill_store(self):
		self.materials.clear()
		all_files=find_materials()
		for fl in all_files:
			b=bibtex()
			if b.load(os.path.join(get_materials_path(),fl,"mat.bib"))!=False:
				text=b.get_text(html=False)
				if text!="":
					itm = QListWidgetItem(os.path.basename(fl)+" "+text)
					itm.setIcon(self.mat_icon)
					itm.setToolTip(text)
					self.materials.addItem(itm)
Example #14
0
def clone_materials(dest):
	src_dir=os.path.join(get_materials_path())
	dest_dir=os.path.join(dest,"materials")
	if os.path.isdir(dest_dir)==False:
		os.makedirs(dest_dir)

	copy_gasses(dest_dir,src_dir)

	files=find_materials()
	for i in range(0,len(files)):
		src_file=os.path.join(src_dir,files[i])
		dest_file=os.path.join(dest_dir,files[i])

		clone_material(dest_file,src_file)
Example #15
0
	def cal_rgb(self):
		#print(self.r, self.g,self.b)
		if self.r==0.0 and self.g==0.8 and self.b==0.0:

			f=inp()
			if f.load(os.path.join(os.path.join(get_materials_path(),self.optical_material),"mat.inp"))==False:
				return

			ret=f.get_array("#red_green_blue")

			if ret!=False:
				self.r=float(ret[0])
				self.g=float(ret[1])
				self.b=float(ret[2])
				self.alpha=float(f.get_token( "#mat_alpha"))
Example #16
0
	def callback_view_materials(self, widget, data=None):
		dialog=opvdm_open()

		dialog.init(get_materials_path())
		dialog.show_inp_files=False
		response=dialog.run()


		if response == True:
			full_file_name=dialog.get_filename()
			plot_gen([dialog.get_filename()],[],"auto")

		elif response == gtk.RESPONSE_CANCEL:
		    print _("Closed, no files selected")
		dialog.destroy()
Example #17
0
def find_materials():
    ret = []
    mat_path = get_materials_path()
    for root, dirs, files in os.walk(mat_path):
        for file in files:
            path = os.path.join(root, file)
            if is_mat_file(path) == True:
                if os.path.isdir(path) == True:
                    path = os.path.dirname(path)
                else:
                    path = path[:-4]
                s = os.path.relpath(path, mat_path)
                s = s.replace("\\", "/")

                ret.append(s)

    return ret
Example #18
0
    def update_layer_type(self, layer, data):
        l = self.layers[layer]

        if data == "active" and l.dos_file.startswith("dos") == False:

            l.dos_file = self.new_electrical_file("dos")

            mat_dir = os.path.join(get_materials_path(), l.optical_material)

            new_dos_file = l.dos_file + ".inp"

            if inp().isfile(new_dos_file) == False:
                dos_path_generic = os.path.join(get_default_material_path(),
                                                "dos.inp")
                inp_copy_file(new_dos_file, dos_path_generic)

                dos_path_material = os.path.join(mat_dir, "dos.inp")
                if os.path.isfile(dos_path_material) == True:
                    archive_merge_file(
                        os.path.join(get_sim_path(), "sim.gpvdm"),
                        os.path.join(mat_dir, "sim.gpvdm"), new_dos_file,
                        "dos.inp")

        if data == "active" and l.pl_file.startswith("pl") == False:
            l.pl_file = self.gen_new_electrical_file("pl")

        if data == "active" and l.lumo_file.startswith("lumo") == False:
            l.lumo_file = self.gen_new_electrical_file("lumo")

        if data == "active" and l.homo_file.startswith("h**o") == False:
            l.homo_file = self.gen_new_electrical_file("h**o")

        #if l.electrical_file=="none" or inp().isfile(l.electrical_file+".inp")==False:
        #	l.electrical_file=self.gen_new_electrical_file("electrical")

        l.layer_type = data

        if data != "active":
            l.dos_file = data
            l.pl_file = "none"
            l.lumo_file = "none"
            l.homo_file = "none"

        self.clean_unused_files()
Example #19
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 #20
0
def epitaxy_populate_rgb():
    global epi
    path = os.path.join(os.path.join(get_materials_path(), epi[-1].mat_file),
                        "mat.inp")

    zip_file = os.path.basename(epi[-1].mat_file) + ".zip"

    mat_lines = inp_load_file(path, archive=zip_file)

    if mat_lines == False:
        return

    ret = inp_search_token_array(mat_lines, "#red_green_blue")

    if ret != False:
        epi[-1].r = float(ret[0])
        epi[-1].g = float(ret[1])
        epi[-1].b = float(ret[2])
        epi[-1].alpha = float(inp_search_token_value(mat_lines, "#mat_alpha"))
Example #21
0
    def updates_install(self):
        self.state = "installing"
        for i in range(0, len(self.file_list)):
            f = self.file_list[i]
            if f.status == "on-disk":
                out_sub_dir = f.file_name
                zip_file = os.path.join(get_web_cache_path(), self.sub_dir,
                                        f.file_name)
                install_path = os.path.join(
                    os.path.dirname(get_materials_path()), f.target)
                #print(install_path,zip_file)
                if install_path != "":
                    archive_extract(install_path, zip_file)
                    #self.emit_decompress()
                    self.update_progress.emit(i, 1.0)
                    f.status = "up-to-date"
                    self.installed = self.installed + 1
                    #addasdas

        self.write_cache_status()
Example #22
0
	def layer_type_edit(self):
		for i in range(0,self.tab.rowCount()):
			if tab_get_value(self.tab,i,3).lower()=="active layer" and tab_get_value(self.tab,i,4).startswith("dos")==False:
				tab_set_value(self.tab,i,4,epitay_get_next_dos())
				tab_set_value(self.tab,i,5,epitay_get_next_pl())

				mat_dir=os.path.join(get_materials_path(),tab_get_value(self.tab,i,2))
				
				new_file=tab_get_value(self.tab,i,4)+".inp"
				if inp_isfile(new_file)==False:
					inp_copy_file(new_file,os.path.join(mat_dir,"dos.inp"))

				new_file=tab_get_value(self.tab,i,5)+".inp"
				if inp_isfile(new_file)==False:
					inp_copy_file(new_file,os.path.join(mat_dir,"pl.inp"))

			if tab_get_value(self.tab,i,3).lower()!="active layer" and tab_get_value(self.tab,i,4).startswith("dos")==True:
				tab_set_value(self.tab,i,4,tab_get_value(self.tab,i,3))
				tab_set_value(self.tab,i,5,"none")

		self.save_model()
		self.emit_change()
Example #23
0
    def layer_type_edit(self):
        for i in range(0, self.tab.rowCount()):
            if tab_get_value(self.tab, i,
                             3).lower() == "active layer" and tab_get_value(
                                 self.tab, i, 4).startswith("dos") == False:
                tab_set_value(self.tab, i, 4, epitay_get_next_dos())
                tab_set_value(self.tab, i, 5, epitay_get_next_pl())

                mat_dir = os.path.join(get_materials_path(),
                                       tab_get_value(self.tab, i, 2))

                new_file = tab_get_value(self.tab, i, 4) + ".inp"
                if inp_isfile(new_file) == False:
                    dos_path = os.path.join(mat_dir, "dos.inp")
                    if os.path.isfile(dos_path) == False:
                        dos_path = os.path.join(get_default_material_path(),
                                                "dos.inp")
                    inp_copy_file(new_file, dos_path)

                new_file = tab_get_value(self.tab, i, 5) + ".inp"
                if inp_isfile(new_file) == False:
                    inp_copy_file(new_file, os.path.join(mat_dir, "pl.inp"))

            if tab_get_value(self.tab, i,
                             3).lower() != "active layer" and tab_get_value(
                                 self.tab, i, 4).startswith("dos") == True:
                tab_set_value(self.tab, i, 4, tab_get_value(self.tab, i, 3))
                tab_set_value(self.tab, i, 5, "none")

            if tab_get_value(self.tab, i, 3).lower() == "other":
                tab_set_value(self.tab, i, 4, tab_get_value(self.tab, i, 3))

            if tab_get_value(self.tab, i, 3).lower() == "contact":
                tab_set_value(self.tab, i, 4, tab_get_value(self.tab, i, 3))

        self.save_model()
        self.emit_change()
        global_object_run("dos_update")
        global_object_run("pl_update")
Example #24
0
def clone_materials(dest,materials=["all"]):
	src_dir=os.path.join(get_materials_path())
	dest_dir=os.path.join(dest,"materials")
	if os.path.isdir(dest_dir)==False:
		os.mkdir(dest_dir)

	files=os.listdir(src_dir)
	for i in range(0,len(files)):
		src_file=os.path.join(src_dir,files[i])
		dest_file=os.path.join(dest_dir,files[i])

		if files[i].endswith(".spectra"):
			copyfile(src_file, dest_file)

		if os.path.isdir(src_file)==True:
			lines=[]
			mat_sub_path=os.path.join("materials",files[i],"mat.inp")
			if read_lines_from_archive(lines,os.path.join(get_inp_file_path(),"sim.gpvdm"),mat_sub_path)==True:
				do_copy=False
				mat_type=inp_search_token_value(lines, "#material_type")
				if mat_type!=False:
					if materials.count("all")!=0:
						do_copy=True

					if materials.count(mat_type)!=0:
						do_copy=True


				if do_copy==True:
					print("copy",dest_file)
					if os.path.isdir(dest_file)==False:
						os.mkdir(dest_file)

					for copy_file in ["alpha_eq.inp","alpha.omat","dos.inp","info.txt","n_eq.inp","n.omat","alpha_gen.omat","cost.xlsx","fit.inp","mat.inp","n_gen.omat","pl.inp"]:
						src_mat_file=os.path.join(src_file,copy_file)
						if os.path.isfile(src_mat_file)==True:
							copyfile(src_mat_file,os.path.join(dest_file,copy_file))
				else:
					print("not copy",dest_file)
Example #25
0
def find_materials(
        mat_path=get_materials_path(), file_type="material", from_src=None):
    ret = []

    for root, dirs, files in os.walk(mat_path):
        #for file in files:
        #path=os.path.join(root, file)
        #print(root)
        if get_dir_type(root) == file_type:

            add = True
            if from_src != None:
                f = inp()
                f.load(os.path.join(root, "mat.inp"))
                if f.get_token("#mat_src") != from_src:
                    add = False

            if add == True:
                s = os.path.relpath(root, mat_path)
                s = s.replace("\\", "/")
                ret.append(s)

    return ret
Example #26
0
    def __init__(self):
        super(gpvdm_main_window, self).__init__()
        icon_init_db()
        #from scans_io import scans_io
        #from cal_path import get_sim_path
        #scans=scans_io(get_sim_path())
        #sims=scans.get_scan_dirs()
        #print(sims)
        #asdsa
        self.splash = splash_window()
        self.scan_human_labels = get_scan_human_labels()

        self.splash.inc_value()
        process_events()
        process_events()

        #from wiz import wiz
        #a=wiz()
        #a.exec_()

        #sys.exit()
        do_import()

        if os.path.isdir(os.path.dirname(sys.argv[0])) == False:
            error_dlg(self, _("I can't run from inside a zip file!"))
            sys.exit()

        self.splash.inc_value()
        self.splash.inc_value()

        server_init()
        self.splash.inc_value()

        self.check_sim_exists = check_sim_exists()
        self.splash.inc_value()

        self.check_sim_exists.start_thread()
        self.splash.inc_value()

        self.check_sim_exists.sim_gone.connect(self.sim_gone)
        self.splash.inc_value()

        self.my_server = server_get()
        self.my_server.init(get_sim_path())
        self.splash.inc_value()

        self.undo_list = undo_list_class()
        wpos_load()
        self.splash.inc_value()

        self.ribbon = ribbon()
        self.splash.inc_value()

        self.notebook_active_page = None
        self.setAcceptDrops(True)
        #self.setGeometry(200, 100, 1300, 600)
        self.setWindowTitle(
            "General-purpose Photovoltaic Device Model (https://www.gpvdm.com)"
        )

        self.l = lock_gui()

        #self.l.disable_all.connect(self.disable_interface)
        #self.l.enable_all.connect(self.enable_disable_buttons)

        #super(gpvdm_main_window, self).__init__(parent, QtCore.Qt.FramelessWindowHint)
        #gobject.GObject.__init__(self)

        #self.my_server.setup_gui(self.gui_sim_start)
        self.my_server.sim_started.connect(self.gui_sim_start)
        self.splash.inc_value()

        self.my_server.sim_finished.connect(self.gui_sim_stop)
        self.splash.inc_value()

        help_init()
        self.splash.inc_value()

        #help_window().help_set_help(["star.png",_("<big><b>Update available!</b></big><br>")])

        #self.show()

        if running_on_linux() == True:
            self.bus = dbus.SessionBus()
            self.bus.add_match_string_non_blocking(
                "type='signal',interface='org.my.gpvdm'")
            self.bus.add_message_filter(self.adbus)
        else:
            self.win_pipe = win_pipe()
            self.win_pipe.new_data.connect(self.win_dbus)
            self.win_pipe.start()

        self.notebook = gpvdm_notebook()
        vbox = QVBoxLayout()
        self.splash.inc_value()

        vbox.addWidget(self.ribbon)
        self.ribbon.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        self.notebook.setSizePolicy(QSizePolicy.Expanding,
                                    QSizePolicy.Expanding)
        vbox.addWidget(self.notebook)
        wvbox = QWidget()
        self.splash.inc_value()

        wvbox.setLayout(vbox)
        self.setCentralWidget(wvbox)

        self.splash.inc_value()

        self.statusBar()

        temp_error = ver_error()
        #print(temp_error)
        if len(temp_error) > 0:
            error_dlg(self, temp_error)
            return

        self.setWindowIcon(
            QIcon(os.path.join(get_image_file_path(), "image.jpg")))
        self.splash.inc_value()

        self.show_tabs = True
        self.show_border = True

        self.ribbon.file.home_new.clicked.connect(self.callback_new)
        self.ribbon.file.home_open.clicked.connect(self.callback_open)
        self.ribbon.file.used_files_click.connect(self.load_sim)
        self.ribbon.home.undo.triggered.connect(self.callback_undo)
        self.ribbon.home.run.start_sim.connect(self.callback_simulate)
        self.splash.inc_value()

        #self.ribbon.home.stop.setEnabled(False)

        self.ribbon.home.scan.setEnabled(False)
        self.ribbon.thermal.setEnabled(False)

        self.ribbon.home.help.triggered.connect(self.callback_on_line_help)

        update_init()

        resize_window_to_be_sane(self, 0.7, 0.75)

        self.change_dir_and_refresh_interface(get_sim_path())
        self.splash.inc_value()

        #self.ribbon.home.sun.changed.connect(self.notebook.update)
        self.ribbon.setAutoFillBackground(True)
        self.splash.inc_value()
        self.show()

        help_window().show()

        self.enable_disable_buttons()

        val = inp_get_token_value(os.path.join(get_sim_path(), "config.inp"),
                                  "#use_gpvdm_local")
        if val != "false":
            if os.path.isdir(get_materials_path()) == False:
                clone_materials(get_materials_path(), get_base_material_path(),
                                "material")

            if os.path.isdir(get_emission_path()) == False:
                clone_materials(get_emission_path(), get_base_emission_path(),
                                "emission")

            if os.path.isdir(get_shape_path()) == False:
                clone_materials(get_shape_path(), get_base_shape_path(),
                                "shape")

            if os.path.isdir(get_scripts_path()) == False:
                shutil.copytree(get_base_scripts_path(),
                                get_scripts_path(),
                                symlinks=True)

            if os.path.isdir(get_spectra_path()) == False:
                clone_spectras(get_spectra_path())

        self.cache = cache(only_open_if_full=True)

        #from shape_editor import shape_editor
        #self.shape_window=shape_editor("/home/rod/gpvdm_local/shape/pedot")
        #self.shape_window.show()

        #from shape_import import shape_import
        #self.shape_import=shape_import("/home/rod/gpvdm_local/shape/pedot")
        #self.shape_import.show()
        check_lib_in_bash_rc()
Example #27
0
def pvlighthouse_sync():
    driver = webdriver.Firefox()

    #driver.get("https://www.rodmack.com/index.html&one=1")

    driver.get(
        "https://www2.pvlighthouse.com.au/resources/photovoltaic%20materials/refractive%20index/refractive%20index.aspx"
    )

    time.sleep(5)

    elem = driver.find_element_by_name("btnAcknowledge")
    elem.click()

    html_source = driver.page_source.split("\n")
    lines = extract_materials(html_source, occurrence_to_extract=0)

    for i in range(0, len(lines)):
        mat_name = lines[i]

        if os.path.isdir(
                os.path.join(get_materials_path(), "pvlighthouse.com.au",
                             mat_name)) == False:
            print("doing", mat_name)
            driver.find_element_by_xpath(
                "//select[@name='TabContainer1$TabPanel1$DataPageMaterial']/option[text()=\""
                + lines[i] + "\"]").click()
            time.sleep(5)
            measurments = extract_sub_materials(driver)
            print(measurments)

            for ii in range(0, len(measurments)):
                print("doing", measurments[ii])
                driver.find_element_by_xpath(
                    "//select[@name='TabContainer1$TabPanel1$DataPageSpecifics']/option[text()=\""
                    + measurments[ii] + "\"]").click()
                time.sleep(5)

                clean_measurment_name = measurments[ii].replace("[", "")
                clean_measurment_name = clean_measurment_name.replace("]", "")
                clean_measurment_name = clean_measurment_name.replace(" ", "_")
                clean_measurment_name = clean_measurment_name.replace("(", "")
                clean_measurment_name = clean_measurment_name.replace(")", "")

                #extract_details(driver)
                html_source = driver.page_source.split("\n")

                src_dir = get_materials_path()
                pvlighthouse = os.path.join(get_materials_path(),
                                            "pvlighthouse.com.au")
                if os.path.isdir(pvlighthouse) == False:
                    os.mkdir(pvlighthouse)

                src_file = os.path.join(src_dir, "generic", "air")
                dest_file = os.path.join(pvlighthouse, mat_name,
                                         clean_measurment_name)

                clone_material(dest_file, src_file)

                extract_ref(os.path.join(src_file, "sim.gpvdm"), driver)
                extract_data(os.path.join(src_file, "sim.gpvdm"), driver)

                time.sleep(5)
        else:
            print("done already", mat_name)

    driver.close()
Example #28
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 #29
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 #30
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")
Example #31
0
def merge_archives(src_archive,dest_archive,only_over_write):
	debug=False

	progress_window=progress_class()
	progress_window.show()
	progress_window.start()

	process_events()

#	src_dir=os.path.dirname(src_archive)
#	dest_dir=os.path.dirname(dest_archive)
	dest_path=os.path.dirname(dest_archive)
	template_archive=gpvdm_paths.get_inp_template_path()

	remove_non_used_index_files(dest_archive,src_archive)

	ls=zip_lsdir(src_archive)

	#copy files without checking ver

	for i in range(0,len(ls)):
		info=get_file_info(ls[i])
		if info!=False:
			if info.copy_opp==file_type().JUST_COPY:
				#print(ls[i])
				archive_copy_file(dest_archive,ls[i],src_archive,ls[i],dest=info.dest)

			
			#src_ver=inp_get_file_ver(src_archive,ls[i])

			if info.copy_opp==file_type().CHECK_VER_THEN_COPY:
				template_ver=inp().get_ver(os.path.join(template_archive,info.base_file))
				src_ver=inp_get_file_ver(src_archive,ls[i])

				if template_ver!=False and src_ver!="":
					if template_ver==src_ver:
						archive_copy_file(dest_archive,ls[i],src_archive,ls[i])
						#print("complex copy")

			if info.copy_opp==file_type().MERGE:
				if only_over_write==False:
					if archive_isfile(dest_archive,ls[i])==False:
						if archive_copy_file(dest_archive,ls[i],template_archive,info.base_file)==False:
							print("problem copying",template_archive,info.base_file)
							#if info.base_file=="dump.inp":
							#	sys.exit(0)
						#print("made new file",dest_archive,ls[i])

				ret=archive_merge_file(dest_archive,src_archive,ls[i],ls[i])
		
		progress_window.set_fraction(float(i)/float(len(ls)))
		progress_window.set_text("Importing "+ls[i])
		process_events()

	#if you find a materials directory in the archive try to merge it
	for i in range(0,len(ls)):
		zip_dir_name=ls[i].split("/")
		if zip_dir_name[0]=="materials":
			dest=os.path.join(os.path.dirname(get_materials_path()))
			#print("Try to read",src_archive,ls[i],dest)
			extract_file_from_archive(dest,src_archive,ls[i])

		if zip_dir_name[0]=="sim":
			extract_file_from_archive(dest_path,src_archive,ls[i])

		if zip_dir_name[0]=="calibrate":
			extract_file_from_archive(dest_path,src_archive,ls[i])

	#search for scan directories
	scan_dirs=[]
	for i in range(0,len(ls)):
		if ls[i].endswith("gpvdm_gui_config.inp"):
			scan_dirs.append(os.path.dirname(ls[i]))

	#extract scan directories
	for i in range(0,len(ls)):
		for ii in range(0,len(scan_dirs)):
			if ls[i].startswith(scan_dirs[ii])==True:
				#print("Try to read",src_archive,ls[i])
				extract_file_from_archive(dest_path,src_archive,ls[i])
	print("search",scan_dirs)

	progress_window.stop()
Example #32
0
def merge_archives(src_archive,dest_archive,only_over_write):
#	src_dir=os.path.dirname(src_archive)
#	dest_dir=os.path.dirname(dest_archive)
	template_archive=os.path.join(get_inp_file_path(),"sim.gpvdm")

	remove_non_used_index_files(dest_archive,src_archive)

	files=[ "sim.inp", "device.inp", "led.inp","stark.inp" ,"shg.inp"   ,"jv.inp" , "math.inp",  "dump.inp",  "dump_file.inp"  , "light.inp", "server.inp", "light_exp.inp","info.inp","config.inp" ]

	base_file=files[:]

	print(src_archive)
	ls=zip_lsdir(src_archive)
	for i in range(0,len(ls)):
		if inp_issequential_file(ls[i],"dos"):
			files.append(ls[i])
			base_file.append(os.path.join(get_materials_path(),"generic","dos.inp"))

		if inp_issequential_file(ls[i],"pl"):
			files.append(ls[i])
			base_file.append(os.path.join(get_materials_path(),"generic","pl.inp"))

		if inp_issequential_file(ls[i],"pulse"):
			files.append(ls[i])
			base_file.append("pulse0.inp")

		if inp_issequential_file(ls[i],"laser"):
			files.append(ls[i])
			base_file.append("laser0.inp")

	for i in range(0,len(files)):
		print("Importing",files[i],"to",dest_archive,template_archive,base_file[i])
		if only_over_write==False:
			if archive_isfile(dest_archive,files[i])==False:
				if archive_copy_file(dest_archive,files[i],template_archive,base_file[i])==False:
					print("problem copying",template_archive,base_file[i])
				print("made new file",dest_archive,files[i])

		ret=archive_merge_file(dest_archive,src_archive,files[i])
		print("merged",dest_archive,src_archive,files[i],ret)


	files=[ "epitaxy.inp", "fit.inp", "constraints.inp","duplicate.inp", "thermal.inp","mesh_x.inp","mesh_y.inp","mesh_z.inp" ]
	base_file=files[:]

	ls=zip_lsdir(src_archive)
	for i in range(0,len(ls)):

		if inp_issequential_file(ls[i],"time_mesh_config"):
			files.append(ls[i])
			base_file.append("time_mesh_config0.inp")

		if inp_issequential_file(ls[i],"h**o"):
			files.append(ls[i])
			base_file.append("homo0.inp")

		if inp_issequential_file(ls[i],"lumo"):
			files.append(ls[i])
			base_file.append("lumo0.inp")

	for i in range(0,len(files)):
		print("Importing",files[i])
		template_ver=archive_get_file_ver(template_archive,base_file[i])
		src_ver=archive_get_file_ver(src_archive,files[i])
		print(template_ver,src_ver,template_ver==src_ver,template_archive,files[i],src_archive)

		if template_ver!="" and src_ver!="":
			if template_ver==src_ver:
				archive_copy_file(dest_archive,files[i],src_archive,files[i])
				print("complex copy",dest_archive,files[i],src_archive,files[i])
Example #33
0
File: about.py Project: Ly0n/gpvdm
    def __init__(self):
        QDialog.__init__(self)
        self.main_hbox = QHBoxLayout()
        self.left_vbox = QVBoxLayout()
        self.main_vbox = QVBoxLayout()
        self.setFixedSize(750, 480)
        self.setWindowTitle(_("About") + " (https://www.gpvdm.com)")
        self.setWindowIcon(icon_get("icon"))
        self.gpvdm = QLabel("<font size=40><b>gpvdm_gui</b></font>")
        self.image = QLabel()
        self.written_by = QLabel(
            _("Written by Roderick MacKenzie 2012-2019, published under the GPL V2.0 license."
              ))
        self.written_by.setWordWrap(True)
        self.ver = QLabel(_("Version ") + ver())
        pixmap = QPixmap(os.path.join(get_image_file_path(), "image.jpg"))
        self.image.setPixmap(pixmap)
        self.left_vbox.addWidget(self.gpvdm)
        self.left_vbox.addWidget(self.image)
        self.left_vbox.addWidget(self.written_by)
        self.left_vbox.addWidget(self.ver)
        self.left = QWidget()
        self.left.setLayout(self.left_vbox)
        self.right = QTabWidget()
        self.right.setMinimumWidth(500)
        self.about = QTextBrowser()
        text = ""
        text = text + _(
            "gpvdm is a general-purpose tool for simulation of light harvesting devices. It was originally written to simulate organic solar cells and OLEDs, but it has recently been extended to simulate other devices including silicon based devices. Currently the model can sumulate:"
        )
        text = text + "<ul>"
        text = text + "<li>" + _("Organic solar cells") + "</li>"
        text = text + "<li>" + _("Organic LEDs") + "</li>"
        text = text + "<li>" + _("Crystalline silicon solar cells") + "</li>"
        text = text + "<li>" + _("a-Si solar cells") + "</li>"
        text = text + "<li>" + _("CIGS solar cells") + "</li>"
        text = text + "</ul> "
        text = text + _(
            "The model solves both electron and hole drift-diffusion, and carrier continuity equations in position space to describe the movement of charge within the device. The model also solves Poisson's equation to calculate the internal electrostatic potential. Recombination and carrier trapping are described within the model using a Shockley-Read-Hall (SRH) formalism, the distribution of trap sates can be arbitrarily defined. All equations can be solved either in steady state or in time domain. A fuller description of the model can be found in the here, in the associated publications and in the manual."
        )
        text = text + "<br>"
        text = text + "<br>"
        text = text + "<center><a href=\"https://www.gpvdm.com\">https://www.gpvdm.com</a></center>"
        self.about.setText(text)
        self.right.addTab(self.about, _("About"))

        self.license = QTextBrowser()
        text = ""
        license_file = os.path.join(get_html_path(), "LICENSE.html")
        if (os.path.isfile(license_file) == True):
            f = open(license_file, mode='rb')
            lines = f.read()
            f.close()
            lines = lines.decode('utf-8')
            lines = lines.split("\n")
            for l in lines:
                text = text + l + "<br>"

        self.license.setText(text)
        self.right.addTab(self.license, _("Legal"))

        self.translations = QTextBrowser()
        text = ""

        text = text + "<big><b>Translations of gpvdm:</b></big>"
        text = text + "<center>"
        text = text + "<br>"
        text = text + "<b>Chinese</b>: Liu Di (刘迪) and Zhao Chenyao (赵辰尧)"
        text = text + "<br>"
        text = text + "<br>"
        text = text + "<b>French</b>: Alexis Prel"
        text = text + "<br>"
        text = text + "<br>"
        text = text + "<b>Russian</b>: Timofey Golubev (Тимофей Голубев)"
        text = text + "<br>"
        text = text + "<br>"
        text = text + "<b>Your language</b>: Translator needed!"
        text = text + "</center>"
        text = text + "<br>"
        text = text + "<br>"
        text = text + "<big>Would you like gpvdm translated into your language?</big>"
        text = text + "<br>"
        text = text + "<big>Would you like your name in the credits of gpvdm?</big>"
        text = text + "<br>"
        text = text + "<br>"
        text = text + "If so then please consider joining the gpvdm translation effort.  This is somthing you can put on your CV and it\'s a way to make sure that speakers of your language have access to high quality scientific tools for simulating solar cells."

        self.translations.setText(text)
        #self.right.addTab(self.translations,_("Translations"))

        self.paths = QTextBrowser()
        text = ""

        text = text + "<b>" + _(
            "Materials library path") + ":</b>" + get_materials_path() + "<br>"
        text = text + "<b>" + _(
            "Device library path") + ":</b>" + get_device_lib_path() + "<br>"
        text = text + "<b>" + _(
            "Binary path") + ":</b>" + get_bin_path() + "<br>"
        text = text + "<b>" + _(
            "Plugins path") + ":</b>" + get_plugins_path() + "<br>"
        text = text + "<b>" + _(
            "Binary name") + ":</b>" + get_exe_name() + "<br>"
        text = text + "<b>" + _(
            "Install ID") + ":</b>" + get_lock().uid + "<br>"

        self.paths.setText(text)
        self.right.addTab(self.paths, _("Paths"))

        #self.materials=QListWidget()
        #self.right.addTab(self.materials,_("Materials"))

        self.main_hbox.addWidget(self.left)
        self.main_hbox.addWidget(self.right)
        self.widget_main_hbox = QWidget()
        self.widget_main_hbox.setLayout(self.main_hbox)
        self.main_vbox.addWidget(self.widget_main_hbox)

        self.hwidget = QWidget()

        self.closeButton = QPushButton(_("Close"))
        self.closeButton.clicked.connect(self.callback_close)
        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addWidget(self.closeButton)

        self.hwidget.setLayout(hbox)

        self.main_vbox.addWidget(self.hwidget)

        self.setLayout(self.main_vbox)
        self.show()

        #QDialog.__init__(self)

        #self.materials.setIconSize(QSize(32,32))
        #self.materials.setViewMode(QListView.ListMode)
        #self.materials.setSpacing(8)
        #self.materials.setWordWrap(True)
        #gridsize=self.materials.size()
        #gridsize.setWidth(80)
        #gridsize.setHeight(40)

        #self.materials.setGridSize(gridsize)
        self.mat_icon = icon_get("organic_material")
Example #34
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()