Esempio n. 1
0
    def callback_gen_plot_command(self):
        dialog = gpvdm_open(self.sim_dir, act_as_browser=False)
        ret = dialog.exec_()

        if ret == QDialog.Accepted:
            full_file_name = dialog.get_filename()
            #dialog.destroy()
            #print cur_dir=os.getcwd()
            #print full_file_name
            file_name = os.path.basename(full_file_name)

            plot_data = dat_file()
            plot_data.path = self.sim_dir
            plot_data.example_file0 = full_file_name
            plot_data.example_file1 = full_file_name

            plot_now = False
            if check_info_file(file_name) == True:
                plot_data.file0 = file_name
                plot_xy_window = plot_dlg_class(plot_data)
                plot_xy_window.run()
                plot_now = plot_xy_window.ret
            else:
                plot_data.file0 = file_name
                plot_data.tag0 = ""
                plot_data.file1 = ""
                plot_data.tag1 = ""
                plot_now = True

            if plot_now == True:
                self.plot_results(plot_data)
Esempio n. 2
0
	def append(self,file_name):
		plot_token=dat_file()
		if plot_load_info(plot_token,file_name)==True:
			menu_item = gtk.MenuItem(os.path.basename(file_name).split(".")[0])
			self.menu.append(menu_item)
			self.list.append(plot_token)
			menu_item.connect("activate", self.callback,self.list[len(self.list)-1])
			menu_item.show()
Esempio n. 3
0
    def on_selection_changed(self):
        if len(self.selectedItems()) > 0:
            item = self.selectedItems()[0]

            if type(item) != None:
                file_name = self.decode_name(item.text())
                if file_name == None:
                    return

                self.file_path = os.path.join(self.path, file_name)
            return

            if (file_name.endswith(".dat") == True):
                state = dat_file()
                get_plot_file_info(state, full_path)
                summary = "<big><b>" + file_name + "</b></big><br><br>" + _(
                    "title") + ": " + state.title + "<br>" + _(
                        "x axis"
                    ) + ": " + state.x_label + " (" + latex_to_html(
                        state.x_units) + ")<br>" + _(
                            "y axis"
                        ) + ": " + state.data_label + " (" + latex_to_html(
                            state.data_units) + ")<br><br><big><b>" + _(
                                "Double click to open") + "</b></big>"
                help_window().help_set_help(["dat_file.png", summary])

            if file_name.endswith("equilibrium"):
                state = dat_file()
                get_plot_file_info(state, full_path)
                summary = "<big><b>" + _(
                    "equilibrium"
                ) + "</b></big><br><br>" + _(
                    "This contains the simulation output at 0V in the dark.")
                help_window().help_set_help(["folder.png", summary])

            if os.path.isdir(full_path) == True:
                if os.path.isfile(os.path.join(full_path, "mat.inp")):
                    summary = "<b><big>" + file_name + "</b></big><br>"
                    ref_path = os.path.join(full_path, "n.ref")
                    ref = get_ref_text(ref_path)
                    if ref != None:
                        summary = summary + ref
                    help_window().help_set_help(["organic_material", summary])
Esempio n. 4
0
    def callback_reopen_xy_window(self, widget, data=None):
        if len(self.plotted_graphs) > 0:
            pos = len(self.plotted_graphs) - 1
            plot_data = dat_file()
            plot_data.file0 = self.plotted_graphs[pos].file0
            plot_xy_window = plot_dlg_class(plot_data)
            plot_xy_window.run()
            plot_now = plot_xy_window.ret

            if plot_now == True:
                self.plot_results(plot_data)
                self.plotted_graphs.refresh()
Esempio n. 5
0
def make_man():
	file_paths = []  # List which will store all of the full filepaths.
	out=""
	files=glob.glob("*.dat")
	section_one=[]
	section_two=[]
	text_list=[]
	for filename in files:

		if filename.endswith(".dat")==True:

			temp=dat_file()
			ret=plot_load_info(temp,filename)
			if ret==True:

				section_one.append(temp.section_one)
				section_two.append(temp.section_two)
				out=""
				filename=filename.replace("_","\\_")
				out=out+"\\textbf{"+filename+"}:"+ temp.title+"\\newline\n"
				out=out+"x-axis:"+temp.x_label+"($"+temp.x_units+"$)\\newline\n"
				out=out+"y-axis:"+temp.data_label+"($"+temp.data_units+"$)\\newline\n"
				out=out+"\\newline\n"
				text_list.append(out)


				file_paths.append(filename)

	section_one, section_two, text_list = zip(*sorted(zip(section_one, section_two,text_list),key = operator.itemgetter(1, 2)))



	text_file = open("./man_src/files.tex", "w")
	last_section_one=""
	last_section_two=""
	for i in range(0,len(text_list)):
		if section_one[i]!="":
			if last_section_one!=section_one[i]:
				last_section_one=section_one[i]
				text_file.write("\subsubsection{"+section_one[i]+"}\n")

			if last_section_two!=section_two[i]:
				last_section_two=section_two[i]
				text_file.write("\paragraph{"+section_two[i]+"}\n")

			text_file.write(text_list[i])
	text_file.close()
Esempio n. 6
0
def gen_workbook(input_file_or_dir, output_file):
    if work_book_enabled == False:
        print("python3-openpyxl not found")
        return

    wb = Workbook()
    if os.path.isfile(input_file_or_dir):
        files = [input_file_or_dir]
    if os.path.isdir(input_file_or_dir):
        files = glob.glob(os.path.join(input_file_or_dir, "*.dat"))
    else:
        return

    ws = wb.active
    pos = 1
    for i in range(0, epitaxy_get_layers()):
        dos_layer = epitaxy_get_electrical_layer(i)
        if dos_layer.startswith("dos") == True:
            pos = workbook_from_inp(ws,
                                    pos,
                                    dos_layer + ".inp",
                                    title=epitaxy_get_name(i))

    for my_file in files:
        #print("about to save1",my_file)
        #print(my_file)
        data = dat_file()
        if dat_file_read(data, my_file, guess=False) == True:
            x = []
            y = []
            z = []
            if dat_file_read(data, my_file) == True:
                #print("read",my_file)
                ws = wb.create_sheet(
                    title=title_truncate(os.path.basename(my_file)))
                ws.cell(column=1, row=1, value=data.title)
                ws.cell(column=1,
                        row=2,
                        value=data.x_label + " (" + data.x_units + ") ")
                ws.cell(column=2,
                        row=2,
                        value=data.data_label + " (" + data.data_units + ") ")

                for i in range(0, data.y_len):
                    ws.cell(column=1, row=i + 3, value=data.y_scale[i])
                    ws.cell(column=2, row=i + 3, value=data.data[0][0][i])

                c1 = ScatterChart()
                c1.title = data.title
                c1.style = 13
                c1.height = 20
                c1.width = 20
                c1.y_axis.title = data.data_label + " (" + data.data_units + ") "
                c1.x_axis.title = data.x_label + " (" + data.x_units + ") "

                xdata = Reference(ws,
                                  min_col=1,
                                  min_row=3,
                                  max_row=3 + data.y_len)
                ydata = Reference(ws,
                                  min_col=2,
                                  min_row=3,
                                  max_row=3 + data.y_len)

                series = Series(ydata, xdata, title_from_data=True)
                c1.series.append(series)
                ws.add_chart(c1, "G4")
    #print("about to save1")
    try:
        wb.save(filename=output_file)
    except:
        return False

    return True
Esempio n. 7
0
def command_args(argc, argv):
    if test_arg_for_sim_file() != False:
        return

    if argc >= 2:
        if args.version:
            print(version())
            sys.exit(0)
        elif args.ver:
            print(ver())
            sys.exit(0)
        elif args.syncver:
            ver_sync_ver()
            sys.exit(0)
        elif args.importscandirs:
            import_scan_dirs(os.getcwd(), args.importscandirs[0])
            exit(0)
        elif args.replace:
            device_lib_replace(args.replace[0], dir_name=args.replace[1])
            exit(0)
        elif args.delete:
            device_lib_delete(args.delete[0], dir_name=args.delete[1])
            exit(0)
        elif args.clean:
            clean_sim_dir()
            sys.exit(0)
        elif args.export:
            export_as(args.export[0])
            sys.exit(0)
        elif args.makeman:
            make_man()
            sys.exit(0)
        elif args.cleanscandirs:
            clean_scan_dirs(os.getcwd())
            sys.exit(0)
        elif args.importfile:
            import_archive(args.importfile[0],
                           os.path.join(os.getcwd(), "sim.gpvdm"), False)
            sys.exit(0)
        elif args.dumptab:
            export_as(args.dumptab[0])
            sys.exit(0)
        elif args.patch:
            import_archive(args.patch[0], args.patch[1], True)
            sys.exit(0)
        elif args.patchfile:
            patch_file(args.patchfile[0], args.patchfile[1], args.patchfile[2])
            sys.exit(0)
        elif args.clone:
            gpvdm_clone(os.getcwd(), copy_dirs=True)
            sys.exit(0)
        elif args.matcompress:
            archive_materials(os.path.join(os.getcwd(), "materials"))
            sys.exit(0)
        elif args.clonesrc:
            gpvdm_copy_src(clone - src[0])
            sys.exit(0)
        elif args.editvalue:
            inp_update_token_value(args.editvalue[0], args.editvalue[1],
                                   args.editvalue[2])
            sys.exit(0)
        elif args.load:
            set_sim_path(os.path.dirname(args.load[0]))
            #print("a")
        elif args.encrypt:
            inp_encrypt(args.encrypt[0])
            sys.exit(0)
        elif args.extract:
            archive_decompress("sim.gpvdm")
            sys.exit(0)
        elif args.scanplot:
            plot_token = dat_file()
            oplot_file = args.scan - plot[0]
            if plot_load_info(plot_token, oplot_file) == True:
                print("file0=", plot_token.file0, "<")
                plot_files, plot_labels, save_file = scan_gen_plot_data(
                    plot_token, os.path.dirname(oplot_file))
                print("written data to", save_file)
            else:
                print("Problem loading oplot file")
            sys.exit(0)

        if args.unpack:
            archive_unpack(args.unpack[0])
            sys.exit()
        if args.runscan:
            set_gui(False)
            scan_dir_path = args.runscan[0]  #program file
            exe_command = get_exe_command()
            program_list = tree_load_program(scan_dir_path)

            watch_dir = os.path.join(os.getcwd(), scan_dir_path)

            commands = []
            #server_find_simulations_to_run(commands,scan_dir_path)
            commands = tree_load_flat_list(scan_dir_path)
            print(commands)

            myserver = base_server()
            myserver.base_server_init(watch_dir)

            for i in range(0, len(commands)):
                myserver.base_server_add_job(commands[i], "")
                print("Adding job" + commands[i])

            myserver.print_jobs()
            myserver.simple_run()
            #simple_run(exe_command)

            sys.exit(0)

        if args.scanarchive:
            set_gui(False)
            scan_archive(args.scanarchive[0])
            sys.exit(0)

        if args.buildscan:
            set_gui(False)
            scan_items_clear()
            scan_items_populate_from_known_tokens()
            scan_items_populate_from_files()

            scan_dir_path = args.buildscan[0]  #program file
            base_dir = args.buildscan[1]  #base dir

            build_scan(scan_dir_path, base_dir)

            sys.exit(0)

        if args.scanbuildvectors:
            set_gui(False)
            scan_ml_build_vector(args.scanbuildvectors[0])
            sys.exit(0)

        if args.buildnestedscan:
            set_gui(False)

            scan_items_clear()
            scan_items_populate_from_known_tokens()
            scan_items_populate_from_files()

            scan_dir_path = os.path.abspath(
                args.buildnestedscan[0])  #program file
            sim_to_nest = os.path.abspath(
                args.buildnestedscan[1])  #program file
            scan_build_nested_simulation(
                scan_dir_path, os.path.join(os.getcwd(), sim_to_nest))

            sys.exit(0)
Esempio n. 8
0
    def init(self):
        return False
        self.dumps = 0
        self.plot_token = dat_file()

        vbox = gtk.VBox()

        self.multi_plot = False

        self.log_scale_y = "auto"

        menu_items = (
            ("/_Options", None, None, 0, "<Branch>"),
            ("/Options/_Subtract 0th frame", None,
             self.callback_toggle_subtract, 0, "<ToggleItem>", "gtk-save"),
            ("/_Axis/_Multiplot", None, self.callback_multi_plot, 0,
             "<ToggleItem>", "gtk-save"),
            ("/_Axis/_Set y axis to maximum", None, self.callback_set_min_max,
             0, "<ToggleItem>", "gtk-save"),
        )

        self.plot.item_factory.create_items(menu_items)

        primary_hbox.add(self.entry0)
        sim_vbox.add(primary_hbox)

        secondary_hbox = gtk.HBox()

        text = gtk.Label("Secondary dir")
        secondary_hbox.add(text)

        self.entry1 = gtk.combo_box_entry_new_text()
        self.entry1.show()

        for i in range(0, len(self.snapshot_list)):
            self.entry1.append_text(self.snapshot_list[i])

        secondary_hbox.add(self.entry1)
        sim_vbox.add(secondary_hbox)

        sim_vbox.show()
        #hbox.set_size_request(-1, 30)
        vbox.pack_start(sim_vbox, False, False, 0)

        hbox2 = gtk.HBox()
        text = gtk.Label("Files to plot")
        hbox2.add(text)
        self.entry2 = gtk.Entry()
        self.entry2.set_text("pt_map nt_map")
        self.entry2.show()
        hbox2.add(self.entry2)
        hbox2.set_size_request(-1, 30)
        vbox.pack_start(hbox2, False, False, 0)

        hbox3 = gtk.HBox()
        text = gtk.Label("Exprimental data")
        hbox3.add(text)
        self.entry3 = gtk.Entry()
        self.entry3.set_text("")
        self.entry3.show()
        hbox3.add(self.entry3)
        hbox3.set_size_request(-1, 30)
        vbox.pack_start(hbox3, False, False, 0)

        self.update_button = gtk.Button()
        self.update_button.set_label("Update")
        self.update_button.show()
        self.update_button.connect("clicked", self.callback_scale)
        vbox.add(self.update_button)

        self.config_load()
        self.count_dumps()

        if self.dumps == 0:
            md = gtk.MessageDialog(
                None, 0, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,
                "No slice data has been written to disk.  You need to re-run the simulation with the dump_slices set to 1.  Would you like to do this now?  Note: This generates lots of files and will slow down the simulation."
            )

            response = md.run()

            if response == gtk.RESPONSE_YES:
                inp_update_token_value("dump.inp", "#dump_1d_slices", "1")
                os.system(get_exe_command())

            md.destroy()

            self.count_dumps()

        self.entry0.connect("changed", self.callback_edit)
        self.entry1.connect("changed", self.callback_edit)
        self.entry2.connect("changed", self.callback_edit)
        self.entry3.connect("changed", self.callback_edit)

        vbox.show_all()
        self.add(vbox)

        self.update(0)
        if self.dumps != 0:
            self.plot.do_plot()
            print("CONVERT!!!!!!!!!!!", type(self.plot.plot_token.key_units))
        self.set_border_width(10)
        self.set_title("Compare")
        self.set_icon_from_file(
            os.path.join(get_image_file_path(), "image.jpg"))

        self.connect('key_press_event', self.on_key_press_event)

        self.show()
Esempio n. 9
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()