예제 #1
0
def code_ctrl_load():
    lines = []
    global store_enable_webupdates
    global store_enable_webbrowser
    global store_enable_cluster
    global store_enable_betafeatures
    lines = inp_load_file(os.path.join(get_inp_file_path(), "ver.inp"),
                          archive="base.gpvdm")
    if lines != False:
        store_enable_webupdates = str2bool(
            inp_search_token_value(lines, "#enable_webupdates"))
        store_enable_webbrowser = str2bool(
            inp_search_token_value(lines, "#enable_webbrowser"))
        store_enable_cluster = str2bool(
            inp_search_token_value(lines, "#enable_cluster"))
        beta = inp_search_token_value(lines, "#enable_betafeatures")
        store_enable_betafeatures = str2bool(beta)
        if os.path.isdir(os.path.join(get_inp_file_path(),
                                      "enablebeta")) == True:
            store_enable_betafeatures = True
    else:
        print("Can not load ver.inp file")
        store_enable_webupdates = False
        store_enable_webbrowser = False
        store_enable_cluster = False
        store_enable_betafeatures = False
예제 #2
0
    def load_config(self):
        self.cache_config_file = os.path.join(get_user_settings_dir(),
                                              "cache.inp")
        self.max_size = 1000
        self.enabled = True
        if os.path.isfile(self.cache_config_file) == False:
            speed = disk_test(get_user_settings_dir())
            lines = []
            lines.append("#cache_size")
            lines.append(str(self.max_size))
            lines.append("#cache_disk_speed")
            lines.append(str(speed))
            if (speed < 200):
                self.enabled = False
            lines.append("#cache_enabled")
            lines.append(str(self.enabled))
            lines.append("#ver")
            lines.append("1.0")
            lines.append("#end")

            inp_save_lines_to_file(self.cache_config_file, lines)

        else:
            lines = inp_load_file(
                os.path.join(get_user_settings_dir(), "cache.inp"))
            self.max_size = int(inp_search_token_value(lines, "#cache_size"))
            self.enabled = str2bool(
                inp_search_token_value(lines, "#cache_enabled"))
예제 #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)
예제 #4
0
def copy_check_ver(dest_archive,src_archive,file_name,only_over_write,clever):
	if dest_archive==src_archive:
		print "I can't opperate on the same .opvdm file"
		return
	#remove the dest file if both exist ready to copy
	do_copy=True
	src_ver=""
	dest_ver=""
	orig_exists=False
	dest_exists=False
	src_lines=[]
	dest_lines=[]

	orig_exists=read_lines_from_archive(src_lines,src_archive,file_name)

	if orig_exists==True:
		src_ver=inp_search_token_value(src_lines, "#ver")
	else:
		print "Warning: ",src_archive,file_name," no origonal file to copy"
		return

	#read in the dest file where ever it may be
	dest_exists=read_lines_from_archive(dest_lines,dest_archive,file_name)

	if dest_exists==True:
		dest_ver=inp_search_token_value(dest_lines, "#ver")

		
	#if we are only over writing only copy if dest file exists
	if (only_over_write==True):
		if dest_exists==True:
			do_copy=True
		else:
			print "Warning: ", file_name," - only exists in the source"
			do_copy=False
			return

	if dest_exists==True:
		if src_ver!=dest_ver:
			print "Warning: Verstion numbers do not match for files",dest_archive,src_archive,file_name
			print "src_ver=",src_ver,"dest ver=",dest_ver

			if clever==False:
				print "Not copying that file you will have to deal that with by hand"
				return

	if clever==True and dest_exists==True:
		errors=inp_merge(dest_lines,src_lines) 
		if len(errors)!=0:
			print "File ",file_name,errors
	else:
		dest_lines=src_lines

	if (do_copy==True):
		write_lines_to_archive(dest_archive,file_name,dest_lines)
예제 #5
0
def uid_get():
    uid = ""
    if running_on_linux() == True:
        path = os.path.join(expanduser("~"), ".gpvdm_uid.inp")
    else:
        path = os.path.join(get_exe_path(), "uid.inp")

    try:
        lines = []
        found = False

        lines = inp_load_file(path)
        if lines != False:
            uid = inp_search_token_value(lines, "#uid")
            found = True

        if found == False:
            uid = str(uuid.uuid4())[0:8]
            lines = []
            lines.append("#uid")
            lines.append(uid)
            lines.append("#ver")
            lines.append("1.0")
            lines.append("#end")

            inp_save(path, lines)
    except:
        print("uid error")

    return uid
예제 #6
0
	def update(self,config_file):
		self.config_file=config_file
		self.sim_mode.blockSignals(True)
		self.sim_mode.clear()
		lines=[]

		files=inp_lsdir("sim.gpvdm")
		if files!=False:
			for i in range(0,len(files)):
				if files[i].endswith(".inp"):
					lines=inp_load_file(files[i])
					value=inp_search_token_value(lines, "#laser_name")
					if value!=False:
						value=value.rstrip()
						self.sim_mode.addItem(value)

			token=inp_get_token_value(self.config_file, "#pump_laser")

			all_items  = [self.sim_mode.itemText(i) for i in range(self.sim_mode.count())]

			for i in range(0,len(all_items)):
				if all_items[i] == token:
					self.sim_mode.setCurrentIndex(i)
					found=True

		self.sim_mode.blockSignals(False)
예제 #7
0
 def update(self):
     lines = inp_load_file(self.get_file_name())
     if lines != False:
         enabled = str2bool(inp_search_token_value(lines, "#enabled"))
         if enabled == True:
             self.tmesh_real.update()
             self.tmesh.update()
예제 #8
0
파일: fit_tab.py 프로젝트: mandulaj/gpvdm
	def update(self):
		lines=inp_load_file(os.path.join(get_sim_path(),"fit"+str(self.index)+".inp"))
		if lines!=False:
			enabled=str2bool(inp_search_token_value(lines, "#enabled"))
			if enabled==True:
				self.tmesh_real.update()
				self.tmesh.update()
예제 #9
0
파일: fit_tab.py 프로젝트: mandulaj/gpvdm
	def __init__(self,file_name):
		QTabWidget.__init__(self)
		css_apply(self,"tab_default.css")
		lines=[]
		self.file_name=file_name
		self.index=int(extract_number_from_file_name(file_name))
		lines=inp_load_file(os.path.join(get_sim_path(),"fit"+str(self.index)+".inp"))
		if lines!=False:
			self.tab_name=inp_search_token_value(lines, "#fit_name")
		else:
			self.tab_name=""

		#self.setTabsClosable(True)
		#self.setMovable(True)

		self.tmesh = fit_window_plot(self.index)
		self.addTab(self.tmesh,_("Fit error"))

		config=tab_class()
		config.init(os.path.join(get_sim_path(),"fit"+str(self.index)+".inp"),self.tab_name)
		self.addTab(config,_("Configure fit"))
		
		self.tmesh_real = fit_window_plot_real(self.index)
		self.addTab(self.tmesh_real,_("Experimental data"))

		self.fit_patch = fit_patch(self.index)
		self.addTab(self.fit_patch, _("Fit patch"))

		self.matlab_editor = matlab_editor(self.index)
		self.addTab(self.matlab_editor, _("MATLAB code"))
예제 #10
0
	def load_data(self):

		lines=[]
		self.start_fx=0.0
		self.list=[]

		file_name="fxmesh"+str(self.index)+".inp"

		ret=inp_load_file(lines,file_name)
		if ret==True:
			if inp_search_token_value(lines, "#ver")=="1.0":
				pos=0
				token,value,pos=inp_read_next_item(lines,pos)
				self.fx_start=float(value)

				token,value,pos=inp_read_next_item(lines,pos)
				segments=int(value)

				for i in range(0, segments):
					token,length,pos=inp_read_next_item(lines,pos)
					token,dfx,pos=inp_read_next_item(lines,pos)
					token,mul,pos=inp_read_next_item(lines,pos)
					self.list.append((length,dfx,mul))

				print self.list
				return True
			else:
				print "file "+file_name+"wrong version"
				exit("")
				return False
		else:
			print "file "+file_name+" not found"
			return False

		return False
예제 #11
0
	def update(self):
		self.sim_mode.get_model().clear()
		lines=[]
		self.store_list=[]

		files=inp_lsdir()
		if files!=False:
			for i in range(0,len(files)):
				if files[i].endswith(".inp"):
					inp_load_file(lines,files[i])
					value=inp_search_token_value(lines, "#sim_menu_name")
					if value!=False:
						if value.count("@")==1:
							value=value.rstrip()
							command,module=value.split("@")
							self.sim_mode.append_text(command)
							self.store_list.append(store(command,module))


			token=inp_get_token_value("sim.inp", "#simmode")
			command,module=token.split("@")
			liststore = self.sim_mode.get_model()
			for i in xrange(len(liststore)):
				if liststore[i][0] == command:
					self.sim_mode.set_active(i)
    def init(self, index):
        QTabWidget.__init__(self)

        self.index = index

        lines = []
        self.file_name = os.path.join(get_sim_path(),
                                      "is" + str(self.index) + ".inp")
        lines = inp_load_file(self.file_name)
        if lines != False:
            self.tab_name = inp_search_token_value(lines, "#sim_menu_name")
        else:
            self.tab_name = ""

        self.tmesh = tab_fxmesh(self.index)
        self.addTab(self.tmesh, _("Frequency mesh"))
        #if inp().isfile("diagram.inp")==False:
        self.circuit = circuit(self.index,
                               base_file_name="is_fxdomain_data",
                               token="#fxdomain_sim_mode")
        self.addTab(self.circuit, _("Circuit"))

        widget = tab_class(self.file_name)
        self.addTab(widget, _("Simulation"))

        self.fx_domain_file_name = os.path.join(
            get_sim_path(), "is_fxdomain_data" + str(self.index) + ".inp")
        widget = tab_class(self.fx_domain_file_name)
        self.addTab(widget, _("FX domain simulation"))
예제 #13
0
    def __init__(self, index):
        QTabWidget.__init__(self)
        css_apply(self, "tab_default.css")
        self.index = index
        lines = []
        self.file_name = os.path.join(get_sim_path(),
                                      "pulse" + str(self.index) + ".inp")
        lines = inp_load_file(self.file_name)
        if lines != False:
            self.tab_name = inp_search_token_value(lines, "#sim_menu_name")
        else:
            self.tab_name = ""

        self.setMovable(True)

        self.tmesh = tab_time_mesh(self.index)
        self.addTab(self.tmesh, _("time mesh"))

        self.circuit = circuit(self.index)

        self.addTab(self.circuit, _("Circuit"))

        tab = tab_class()
        tab.init(self.file_name, _("Configure"))
        self.addTab(tab, _("Configure"))
예제 #14
0
    def load(self):
        self.tab.blockSignals(True)
        self.tab.clear()
        self.tab.setHorizontalHeaderLabels(
            [_("File Name"), _("Width"),
             _("Start"), _("Stop")])
        layers = epitaxy_get_layers()

        for i in range(0, layers):
            dos_file = epitaxy_get_dos_file(i)
            width = epitaxy_get_width(i)
            if dos_file != "none":
                lines = []
                print("loading", dos_file)
                file_name = os.path.join(get_sim_path(), dos_file + ".inp")
                lines = inp_load_file(file_name)
                if lines != False:
                    doping_start = float(
                        inp_search_token_value(lines, "#doping_start"))
                    doping_stop = float(
                        inp_search_token_value(lines, "#doping_stop"))

                    print("add", dos_file)

                    count = self.tab.rowCount()
                    self.tab.insertRow(count)

                    item1 = QTableWidgetItem(str(dos_file))
                    self.tab.setItem(count, 0, item1)

                    item2 = QTableWidgetItem(str(width))
                    self.tab.setItem(count, 1, item2)

                    item3 = QTableWidgetItem(str(doping_start))
                    self.tab.setItem(count, 2, item3)

                    item3 = QTableWidgetItem(str(doping_stop))
                    self.tab.setItem(count, 3, item3)

        self.tab.blockSignals(False)

        return
예제 #15
0
	def sync_to_electrical_mesh(self):
		tot=0
		for i in range(0,len(self.model)):
			if yes_no(self.model[i][COLUMN_DEVICE])==True:
				tot=tot+float(self.model[i][COLUMN_THICKNES])

		lines=[]
		if inp_load_file(lines,os.path.join(os.getcwd(),"mesh.inp"))==True:
			mesh_layers=int(inp_search_token_value(lines, "#mesh_layers"))
			if mesh_layers==1:
				inp_update_token_value(os.path.join(os.getcwd(),"mesh.inp"), "#mesh_layer_length0", str(tot),1)
예제 #16
0
def ver_load_info():
	lines=[]
	global core
	global ver_error
	global subver
	
	core=""
	ver_error=""


	ver_file_path=os.path.join(get_inp_file_path(),"ver.inp")

	lines=inp_load_file(ver_file_path,archive="base.gpvdm")
	if lines!=False:
		core=inp_search_token_value(lines,"#core")
		subver=inp_search_token_value(lines,"#sub_ver")
		return True
	else:
		ver_error="I can not find the file sim.gpvdm/ver.inp.\n\nI have tried looking in "+ver_file_path+"\n\nThe share path is"+get_share_path()+"\n\nThe bin path is"+get_bin_path()+"\n\nThe current working dir is "+get_sim_path()+"\n\nTry reinstalling a new version of gpvdm and/or report the bug to me at  [email protected]."
		return False
예제 #17
0
    def process_sync_packet_two(self, data):
        lines = data.split("\n")
        target = inp_search_token_value(lines, "#target")
        src = inp_search_token_value(lines, "#src")
        size = int(inp_search_token_value(lines, "#size"))

        packet_len = int(int(size) / int(512) + 1) * 512
        data = self.recvall(packet_len)
        data = data[0:size]
        lines = data.split("\n")
        pos = 0
        copy_list = []
        #print(lines)
        for i in range(0, len(lines)):
            fname = lines[pos]
            pos = pos + 1
            if fname != "":
                copy_list.append(fname)

        self.send_files(target, src, copy_list)
예제 #18
0
    def config_load(self):
        lines = inp_load_file("gui_cmp_config.inp")
        if lines != False:

            if self.snapshot_list.count(
                    inp_search_token_value(lines, "#entry0")) != 0:
                self.entry0.set_active(
                    self.snapshot_list.index(
                        inp_search_token_value(lines, "#entry0")))
            else:
                self.entry0.set_active(0)

            if self.snapshot_list.count(
                    inp_search_token_value(lines, "#entry1")) != 0:
                self.entry1.set_active(
                    self.snapshot_list.index(
                        inp_search_token_value(lines, "#entry1")))
            else:
                self.entry1.set_active(0)

            self.entry2.set_text(inp_search_token_value(lines, "#entry2"))
            self.entry3.set_text(inp_search_token_value(lines, "#entry3"))

        else:
            self.entry0.set_active(0)
            self.entry1.set_active(0)
            self.entry2.set_text("n p")
            self.entry3.set_text("")
예제 #19
0
def ver_check_compatibility(file_name):
	lines=[]
	core=""

	lines=read_lines_from_archive(file_name,"ver.inp")
	if lines!=False:
		core=inp_search_token_value(lines,"#core")
		if core==ver_core():
			return True
		else:
			return False

	return False
예제 #20
0
    def update(self):
        self.sim_mode.clear()

        lines = []
        self.store_list = []
        temp = []
        files = inp_lsdir("sim.gpvdm")
        if files != False:
            for i in range(0, len(files)):
                if files[i].endswith(".inp") and files[i].count("/") == 0:
                    lines = inp_load_file(files[i])
                    value = inp_search_token_value(lines, "#sim_menu_name")
                    if value != False:
                        if value.count("@") == 1:
                            temp.append(value)

            temp.sort()

            for i in range(0, len(temp)):
                value = temp[i].rstrip()
                command, module = value.split("@")
                self.sim_mode.addItem(command)
                a = store(command, module)
                self.store_list.append(a)
            print(os.getcwd())
            token = inp_get_token_value("sim.inp", "#simmode")
            print(token)
            if token.count("@") != 0:
                command, module = token.split("@")
            else:
                command = token

            found = False

            all_items = [
                self.sim_mode.itemText(i) for i in range(self.sim_mode.count())
            ]
            for i in range(0, len(all_items)):
                if all_items[i] == command:
                    self.sim_mode.setCurrentIndex(i)
                    found = True

            #if there is no known mode, just set it to jv mode
            if found == False:
                for i in range(0, len(self.store_list)):
                    if self.store_list[i].token == "jv":
                        self.sim_mode.setCurrentIndex(i)
                        inp_update_token_value(
                            os.path.join(get_sim_path(), "sim.inp"),
                            "#simmode", "jv@jv")
                        break
예제 #21
0
    def init(self):
        total = 0
        self.pos = 0
        lines = inp_load_file(lines, "mesh_y.inp")
        if lines != False:
            total = inp_sum_items(lines, "#mesh_layer_points0")

        lines = inp_load_file(lines, "dump.inp")
        if lines != False:
            self.pos = str2bool(
                inp_search_token_value(lines, "#dump_energy_slice_pos"))

        label = gtk.Label("Energy slice dump")
        label.show()
        self.pack_start(label, True, True, 0)

        check = gtk.CheckButton("Enable")
        self.pack_start(check, True, True, 0)

        print("total=", total)
        adj = gtk.Adjustment(self.pos, 0, total, 1.0, 1.0, 1.0)
        adj.connect("value_changed", self.scroll)
        self.vscale = gtk.HScale(adj)
        self.vscale.set_size_request(150, 30)
        self.pack_start(self.vscale, True, True, 0)
        self.vscale.show()

        self.enable = False
        lines = inp_load_file(lines, "dump.inp")
        if lines != False:
            self.enable = str2bool(
                inp_search_token_value(lines, "#dump_energy_slice_switch"))

        check.set_active(self.enable)
        self.vscale.set_sensitive(self.enable)

        check.unset_flags(gtk.CAN_FOCUS)
        check.connect("clicked", self.check_clicked)
예제 #22
0
	def init(self):
		total=0
		self.pos=0
		lines=[]
		if inp_load_file(lines,"mesh.inp")==True:
			total=inp_sum_items(lines, "#mesh_layer_points0")

		if inp_load_file(lines,"dump.inp")==True:
			self.pos=str2bool(inp_search_token_value(lines, "#dump_energy_slice_pos"))


		label=gtk.Label("Energy slice dump")
		label.show()
		self.pack_start(label, True, True, 0)

		check = gtk.CheckButton("Enable")
		self.pack_start(check, True, True, 0)

		print "total=",total
		adj=gtk.Adjustment(self.pos, 0, total, 1.0, 1.0, 1.0)
		adj.connect("value_changed", self.scroll)
		self.vscale = gtk.HScale(adj)
		self.vscale.set_size_request(150, 30)
		self.pack_start(self.vscale, True, True, 0)
		self.vscale.show()


		self.enable=False
		if inp_load_file(lines,"dump.inp")==True:
			self.enable=str2bool(inp_search_token_value(lines, "#dump_energy_slice_switch"))

		check.set_active(self.enable)
		self.vscale.set_sensitive(self.enable)

		check.unset_flags(gtk.CAN_FOCUS)
		check.connect("clicked", self.check_clicked)
예제 #23
0
	def init(self,index):
		self.tab_label=None


		self.index=index
		lines=[]

		if inp_load_file(lines,"fxdomain"+str(self.index)+".inp")==True:
			self.tab_name=inp_search_token_value(lines, "#sim_menu_name")
		else:
			self.tab_name=""


		self.title_hbox=gtk.HBox()

		self.title_hbox.set_size_request(-1, 25)
		self.label=gtk.Label(self.tab_name.split("@")[0])
		self.label.set_justify(gtk.JUSTIFY_LEFT)
		self.title_hbox.pack_start(self.label, False, True, 0)

		self.close_button = gtk.Button()
		close_image = gtk.Image()
   		close_image.set_from_file(os.path.join(get_image_file_path(),"close.png"))
		close_image.show()
		self.close_button.add(close_image)
		self.close_button.props.relief = gtk.RELIEF_NONE

		self.close_button.set_size_request(25, 25)
		self.close_button.show()

		self.title_hbox.pack_end(self.close_button, False, False, 0)
		self.title_hbox.show_all()

		self.notebook=gtk.Notebook()
		self.notebook.show()
		self.fxmesh = tab_fxmesh()
		self.fxmesh.init(self.index)

		self.notebook.append_page(self.fxmesh, gtk.Label(_("Frequency mesh")))

		self.pack_start(self.notebook, False, False, 0)

		self.circuit=circuit()
		self.circuit.init(self.index)

		self.notebook.append_page(self.circuit, gtk.Label(_("Circuit")))

		self.show()
예제 #24
0
    def __init__(self, file_name):
        QTabWidget.__init__(self)
        css_apply(self, "tab_default.css")

        lines = []
        self.file_name = os.path.join(get_sim_path(), file_name)
        lines = inp_load_file(self.file_name)
        if lines != False:
            self.tab_name = inp_search_token_value(lines, "#sim_menu_name")
        else:
            self.tab_name = ""

        self.setMovable(True)

        tab = tab_class(self.file_name)
        self.addTab(tab, _("Configure"))
예제 #25
0
파일: fxmesh.py 프로젝트: xj361685640/gpvdm
    def load_data(self):
        self.tab.clear()
        self.tab.setColumnCount(4)
        self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tab.setHorizontalHeaderLabels([
            _("Frequency start"),
            _("Frequency stop"),
            _("points"),
            _("Multiply")
        ])
        self.tab.setColumnWidth(0, 200)
        self.tab.setColumnWidth(1, 200)

        lines = []
        self.start_fx = 0.0

        file_name = "fxmesh" + str(self.index) + ".inp"

        lines = inp_load_file(os.path.join(get_sim_path(), file_name))
        if lines != False:
            if inp_search_token_value(lines, "#ver") == "1.1":
                pos = 0

                while (1):
                    token, start, pos = inp_read_next_item(lines, pos)
                    if token == "#ver" or token == "#end":
                        break
                    token, stop, pos = inp_read_next_item(lines, pos)
                    token, points, pos = inp_read_next_item(lines, pos)
                    token, mul, pos = inp_read_next_item(lines, pos)

                    tab_add(self.tab,
                            [str(start),
                             str(stop),
                             str(points),
                             str(mul)])

                return True
            else:
                print("file " + file_name + "wrong version")
                exit("")
                return False
        else:
            print("file " + file_name + " not found")
            return False

        return False
예제 #26
0
    def rx_packet(self):
        head = self.recvall(32)
        if head == None:
            return None

        head = decrypt(head)

        head = head[5:]
        lengths = [int(s) for s in head.split() if s.isdigit()]
        #print(lengths)
        packet_len = lengths[0]
        head_len = lengths[1]

        packet = self.recvall(packet_len)
        if len(packet) != packet_len:
            print("packet len does not match size", len(packet), packet_len)

        packet = decrypt(packet)

        ret = tx_struct()

        lines = packet[0:head_len].decode("utf-8").split("\n")
        ret.id = inp_search_token_value(lines, "#id")
        ret.file_name = inp_search_token_value(lines, "#file_name")
        ret.size = int(inp_search_token_value(lines, "#size"))
        ret.target = inp_search_token_value(lines, "#target")
        ret.zip = int(inp_search_token_value(lines, "#zip"))
        ret.uzipsize = int(inp_search_token_value(lines, "#uzipsize"))
        ret.message = inp_search_token_value(lines, "#message")
        ret.token = inp_search_token_value(lines, "#token")

        #print(lines)
        #print(ret.file_name,ret.size,ret.uzipsize,len(data))

        if ret.size != 0:
            ret.data = packet[head_len:head_len + ret.size]
            if ret.zip == 1:
                ret.data = zlib.decompress(ret.data)
                ret.size = len(ret.data)

        #print(lines,ret.data)
        return ret
예제 #27
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"))
예제 #28
0
	def load_data(self):

		lines=[]
		self.start_time=0.0
		self.fs_laser_time=0.0
		self.list=[]

		file_name="time_mesh_config"+str(self.index)+".inp"

		ret=inp_load_file(lines,file_name)
		if ret==True:
			if inp_search_token_value(lines, "#ver")=="1.1":
				pos=0
				token,value,pos=inp_read_next_item(lines,pos)
				self.start_time=float(value)

				token,value,pos=inp_read_next_item(lines,pos)
				self.fs_laser_time=float(value)

				token,value,pos=inp_read_next_item(lines,pos)
				segments=int(value)

				for i in range(0, segments):
					token,length,pos=inp_read_next_item(lines,pos)
					token,dt,pos=inp_read_next_item(lines,pos)
					token,voltage_start,pos=inp_read_next_item(lines,pos)
					token,voltage_stop,pos=inp_read_next_item(lines,pos)
					token,mul,pos=inp_read_next_item(lines,pos)
					token,sun,pos=inp_read_next_item(lines,pos)
					token,laser,pos=inp_read_next_item(lines,pos)
					self.list.append((length,dt,voltage_start,voltage_stop,mul,sun,laser))

				print self.list
				return True
			else:
				print "file "+file_name+"wrong version"
				exit("")
				return False
		else:
			print "file "+file_name+" not found"
			return False

		return False
예제 #29
0
	def init(self,index):
		QTabWidget.__init__(self)

		self.index=index

		lines=[]
		self.file_name=os.path.join(get_sim_path(),"cv"+str(self.index)+".inp")
		lines=inp_load_file(self.file_name)
		if lines!=False:
			self.tab_name=inp_search_token_value(lines, "#sim_menu_name")
		else:
			self.tab_name=""

		widget=tab_class(self.file_name)
		self.addTab(widget,_("CV Configure"))


		file_name=os.path.join(get_sim_path(),"cv_fxdomain_data"+str(self.index)+".inp")
		widget=tab_class(file_name)
		self.addTab(widget,_("FX domain simulation"))

		self.file_name=os.path.join(get_sim_path(),"cv"+str(self.index)+".inp")
예제 #30
0
def is_mat_file(file_path):
	if os.path.isdir(file_path)==True:
		gpvdm_file_type=inp_get_token_value(os.path.join(file_path,"mat.inp"), "#gpvdm_file_type")
		if gpvdm_file_type=="mat":
			return True
		return False

	zfile=file_path

	if os.path.isfile(zfile)==False:
		zfile=zfile+".zip"

	if os.path.isfile(zfile)==True:
		lines=read_lines_from_archive(zfile,"mat.inp",mode="l")

		if lines!=False:
			gpvdm_file_type=inp_search_token_value(lines, "#gpvdm_file_type")

			if gpvdm_file_type=="mat":
				return True

		return False
예제 #31
0
	def init(self,index):
		QTabWidget.__init__(self)

		self.index=index
		lines=[]
		self.file_name=os.path.join(get_sim_path(),"fxdomain"+str(self.index)+".inp")
		lines=inp_load_file(self.file_name)
		if lines!=False:
			self.tab_name=inp_search_token_value(lines, "#sim_menu_name")
		else:
			self.tab_name=""

		self.tmesh = tab_fxmesh(self.index)
		self.addTab(self.tmesh,_("Frequency mesh"))


		self.circuit=circuit(self.index)

		self.addTab(self.circuit,_("Circuit"))

		widget=tab_class()
		widget.init(self.file_name,_("Configure"))
		self.addTab(widget,_("Configure"))
예제 #32
0
	def callback_node(self, widget, data=None):
		lines=[]
		a = open("../hpc/allowed_nodes", "w")

		if inp_load_file(lines,"./server.inp")==True:
			cpus_per_job=int(inp_search_token_value(lines, "#server_cpus"))
			print "CPUs per job=",cpus_per_job

		a.write(str(cpus_per_job)+"\n")

		for i in range(0, len(self.button)):
			print "cpus=",self.name[i]
			if self.button[i].get_active()==True:
				print "active=",self.name[i]
				a.write(self.name[i]+"\n")
				a.write(str(self.cpus[i])+"\n")
		a.close()

		now_dir=os.getcwd()

		os.chdir("../hpc")
		os.system("./make_node_list.py")

		os.chdir(now_dir)
예제 #33
0
	def config_load(self):
		lines=[]
		if inp_load_file(lines,"gui_cmp_config.inp")==True:

			if self.snapshot_list.count(inp_search_token_value(lines, "#entry0"))!=0:
				self.entry0.set_active(self.snapshot_list.index(inp_search_token_value(lines, "#entry0")))
			else:
				self.entry0.set_active(0)

			if self.snapshot_list.count(inp_search_token_value(lines, "#entry1"))!=0:
				self.entry1.set_active(self.snapshot_list.index(inp_search_token_value(lines, "#entry1")))
			else:
				self.entry1.set_active(0)

			self.entry2.set_text(inp_search_token_value(lines, "#entry2"))
			self.entry3.set_text(inp_search_token_value(lines, "#entry3"))

		else:
			self.entry0.set_active(0)
			self.entry1.set_active(0)
			self.entry2.set_text("n p")
			self.entry3.set_text("")
예제 #34
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()
예제 #35
0
파일: gl.py 프로젝트: mandulaj/gpvdm
		def render(self):
			#print("do draw")
			clear_color()
			glClearColor(self.view.bg_color[0], self.view.bg_color[1], self.view.bg_color[2], 0.5)
			gl_save_clear()


			dos_start=-1
			dos_stop=-1
			epi_y_len=epitaxy_get_y_len()
			
			if epi_y_len<=0:
				return

			self.x_mul=1e3
			self.y_mul=self.gl_device_height/epi_y_len
			self.z_mul=1e3


			x_len=mesh_get_xlen()

			max_gui_device_x=x_len*self.x_mul
			max_gui_device_y=1.0
			max_gui_device_z=mesh_get_zlen()*self.z_mul

			l=epitaxy_get_layers()-1

			xpoints=int(mesh_get_xpoints())
			ypoints=int(mesh_get_ypoints())
			zpoints=int(mesh_get_zpoints())

			if ypoints>10:
				ypoints=10
			
			if xpoints>10:
				xpoints=10
				
			if ypoints>10:
				ypoints=10

			self.emission=False
			self.ray_model=False
			
			lines=inp_load_file(os.path.join(get_sim_path(),"led.inp"))
			if lines!=False:
				self.ray_model=val=str2bool(inp_search_token_value(lines, "#led_on"))
				
			lines=[]

			for i in range(0,epitaxy_get_layers()):
				if epitaxy_get_pl_file(i)!="none":
					lines=inp_load_file(os.path.join(get_sim_path(),epitaxy_get_pl_file(i)+".inp"))
					if lines!=False:
						if str2bool(lines[1])==True:
							self.emission=True
					
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
			glLoadIdentity()

			glTranslatef(self.view.x_pos, self.view.y_pos, self.view.zoom) # Move Into The Screen
			
			glRotatef(self.view.xRot, 1.0, 0.0, 0.0)
			glRotatef(self.view.yRot, 0.0, 1.0, 0.0)
			glRotatef(self.view.zRot, 0.0, 0.0, 1.0)

			glColor3f( 1.0, 1.5, 0.0 )
			glPolygonMode(GL_FRONT, GL_FILL);

			threed_files=glob.glob("*.3d")
			if len(threed_files)>0:
				gl_save_load()
				gl_save_draw()
				draw_grid()
				return

			#glClearColor(0.92, 0.92, 0.92, 0.5) # Clear to black.

			lines=[]

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

				thick=epitaxy_get_width(l-i)*self.y_mul
				obj=epitaxy_get_layer(l-i)
				red=obj.r
				green=obj.g
				blue=obj.b
				alpha=obj.alpha
				if i==l-self.selected_layer:
					box_lines(0.0,pos,0,max_gui_device_x,thick,max_gui_device_z)

				if epitaxy_get_electrical_layer(l-i).startswith("dos")==True and ypoints!=0 and xpoints!=0 and zpoints!=0:
					dy=thick/float(ypoints)
					dx=max_gui_device_x/float(xpoints)
					dz=max_gui_device_z/float(zpoints)
					xshrink=0.8
					zshrink=0.8
					
					if dos_start==-1:
						dos_start=pos
					
					dos_stop=pos+thick
			
					if xpoints==1:
						xshrink=1.0

					if zpoints==1:
						zshrink=1.0

					if xpoints==1 and zpoints==1:
						box(0.0,pos,0,max_gui_device_x,thick,max_gui_device_z,red,green,blue,alpha)
					else:
						for y in range(0,ypoints):
							for x in range(0,xpoints):
								for z in range(0,zpoints):
									box(dx*x,pos+y*(dy),z*dz,dx*xshrink,dy*0.8,dz*zshrink,red,green,blue,alpha)
					if self.tab_active_layers==True:
						tab(0.0,pos,max_gui_device_z,max_gui_device_x,thick,max_gui_device_z)
				
				elif epitaxy_get_electrical_layer(l-i).lower()=="contact" and (i==l or i==0):
					for c in contacts_get_array():
						if (c.position=="top" and i==l) or (c.position=="bottom" and i==0):
							if xpoints==1 and zpoints==1:
								xstart=0.0
								xwidth=max_gui_device_x
							else:
								xstart=max_gui_device_x*(c.start/x_len)
								xwidth=max_gui_device_x*(c.width/x_len)
								#print("contacts",xstart,xwidth,c.width,x_len)
								if (c.start+c.width)>x_len:
									xwidth=max_gui_device_x-xstart
								
							if c.depth>0.0:
								etch_depth=c.depth*self.y_mul
								if c.position=="top":
									box(xstart,pos-etch_depth-self.dy_layer_offset,0,xwidth,etch_depth,max_gui_device_z,0.0,0.0,1.0,1.0)
								else:
									box(xstart,pos+self.dy_layer_offset+thick,0,xwidth,etch_depth,max_gui_device_z,0.0,0.0,1.0,1.0)
									
							if c.active==True:
								box(xstart,pos,0,xwidth,thick,max_gui_device_z,0.0,1.0,0.0,alpha)
							else:
								box(xstart,pos,0,xwidth,thick,max_gui_device_z,red,green,blue,alpha)


				else:
					box(0.0,pos,0,max_gui_device_x,thick,max_gui_device_z,red,green,blue,alpha)
				

				if self.view.render_text==True:
					if epitaxy_get_electrical_layer(l-i).startswith("dos")==True:
						text=epitaxy_get_name(l-i)+" ("+_("active")+")"
					else:
						text=epitaxy_get_name(l-i)

					set_color(1.0,1.0,1.0,"text")

					font = QFont("Arial")
					font.setPointSize(18)
					if self.view.zoom>-20:
						self.renderText (max_gui_device_x+0.1,pos+thick/2,max_gui_device_z, text,font)

				pos=pos+thick+self.dy_layer_offset

			draw_mode(pos-self.dy_layer_offset,max_gui_device_z)
			draw_rays(self.ray_file,pos-self.dy_layer_offset,max_gui_device_x,self.y_mul,max_gui_device_z*1.05)
			#print(self.graph_path)

			if self.view.render_photons==True:
				#print(pos)
				self.draw_photons(max_gui_device_x,pos,max_gui_device_z)

			full_data_range=self.graph_z_max-self.graph_z_min
			graph(0.0,dos_start,max_gui_device_z+0.5,max_gui_device_x,dos_stop-dos_start,full_data_range,self.graph_data)

			if self.view.render_grid==True:
				draw_grid()

			if self.view.zoom<-60:
				draw_stars()
예제 #36
0
def export_as(output):
	tex=True
	dollar="$"
	col=" & "
	eol=" \\\\"
	ext= os.path.splitext(output)[1]
	line=""
	if (ext==".pdf") or (ext==".jpg") or (ext==".tex")  or (ext==".csv"):
		if ext==".csv":
			tex=False
			dollar=""
			col="\t"
			eol=""

		lines=[]
		if tex==True:
			line=line+"\\documentclass{article}\n"
			line=line+"\\providecommand{\\e}[1]{\\ensuremath{\\times 10^{#1}}}\n"
			line=line+"\\begin{document}\n"
			line=line+"\\pagenumbering{gobble}\n"
			line=line+"\n"
		files=[]

		f_list=glob.iglob(os.path.join("./", "dos*.inp"))
		for in_file in f_list:
                         files.append(in_file)
		print files
		if tex==True:
			line=line+"\\begin{table}[H]\n"
			line=line+"\\begin{center}\n"
			line=line+"  \\begin{tabular}{lll}\n"
			line=line+"  \\hline\n"
		     
		line=line+"  Parameter"+col+"label"+col+"unit "+eol+"\n"

		if tex==True:
			line=line+"  \\hline\n"
			

		dos_lines=[]
		for i in range(0,len(files)):
			lines=[]
			inp_load_file(lines,files[i])
			dos_lines.append(lines)

		t=tokens()
		for i in range(0,len(dos_lines[0]),2):
			my_token=t.find(dos_lines[0][i])

			if my_token!=False:
				number=""
				if my_token.number_type=="e":
					for ii in range(0,len(files)):

						if len(files)>0:
							sub="_{"+str(ii)+"}"
						else:
							sub=""

						if dos_lines[0][i+1]!=dos_lines[ii][i+1] or ii==0:
							if tex==True:
								number=to_exp(dos_lines[ii][i+1])
							else:
								number=dos_lines[ii][i+1]

							line=line+my_token.info+sub+col+dollar+number+dollar+col+dollar+pygtk_to_latex_subscript(my_token.units)+dollar+eol+"\n"
		if tex==True:
			line=line+"  \\hline\n"
			line=line+"\\end{tabular}\n"
			line=line+"\\end{center}\n"
			line=line+"\\caption{Density of states}\n"
			line=line+"\\end{table}\n"
			line=line+"\n"

		files=["./device.inp","./device_epitaxy.inp", "./stark.inp", "./materials/redf/fit.inp", "./materials/redf/patch.inp"]
		names=["Device", "Device Epitaxy","Stark","Fit redf","Fit patch"]
		if tex==True:
			line=line+"\\begin{table}[H]\n"
			line=line+"\\begin{center}\n"
			line=line+"  \\begin{tabular}{lll}\n"
			line=line+"  \\hline\n"
		     
		line=line+"  Parameter"+col+"label"+col+"unit "+eol+"\n"

		if tex==True:
			line=line+"  \\hline\n"

		config_lines=[]
		cur_file=0
		inp_load_file(config_lines,"/home/rod/juan/hpc/j17/orig/latex_export_info.inp")
		for cur_file in range(0,len(files)):


			if os.path.isfile(files[cur_file])==True:
				inp_load_file(lines,files[cur_file])
				t=tokens()

				for i in range(0,len(lines),2):
					dump_token=inp_search_token_value(config_lines, lines[i])
					if dump_token=="1":
						my_token=t.find(lines[i])
						if my_token!=False:
							if my_token.number_type=="e":
								number=""
								if tex==True:
									#print lines
									#print lines[i]
									number=to_exp(dos_lines[ii][i+1])
								else:
									number=dos_lines[ii][i+1]
								line=line+my_token.info+col+dollar+number+dollar+col+dollar+pygtk_to_latex_subscript(my_token.units)+dollar+eol+"\n"

		if tex==True:
			line=line+"  \\hline\n"
			line=line+"\\end{tabular}\n"
			line=line+"\\end{center}\n"
			line=line+"\\caption{"+names[cur_file]+"}\n"
			line=line+"\\end{table}\n"
			line=line+"\n"

		if tex==True:
			line=line+"\\end{document}\n"

		text_file = open("doc.tex", "w")
		text_file.write(line)
		text_file.close()

		if (ext==".pdf"):
			os.system("latex -interaction=batchmode doc")
			os.system("dvipdf doc.dvi")
			os.system("mv doc.pdf "+output)

		if (ext==".jpg"):
			os.system("latex -interaction=batchmode doc")
			os.system("convert -trim -bordercolor White -border 20x10 +repage -density 300 doc.dvi doc.jpg")
			os.system("mv doc.jpg "+output)

		if (ext==".tex"):
			os.system("mv doc.tex "+output)

		if (ext==".csv"):
			os.system("mv doc.tex "+output)
예제 #37
0
    def listen(self):
        self.running = True
        self.stop_listening = False

        while (1):
            understood = False
            if self.stop_listening == True:
                break
            data = self.rx_packet()

            if data == None:
                break

            #print(data.id)
            if data.id == "gpvdmnodelist":
                self.process_node_list(data)
                self.load_update.emit()
                understood = True

            if data.id == "gpvdm_job_list":
                self.process_job_list(data)
                understood = True

            if data.id == "gpvdmfinished":
                self.stop()
                understood = True

            if data.id == "gpvdmheadquit":
                self.stop()
                print("Server quit!")
                understood = True

            if data.id == "gpvdm_message":
                self.new_message.emit(data.message)
                understood = True

            if data.id == "gpvdmfile":
                print("from here", data.id)
                self.rx_file(data)
                understood = True

            if data.id == "gpvdmpercent":
                lines = data.split("\n")
                percent = float(inp_search_token_value(lines, "#percent"))
                self.progress_window.set_fraction(percent / 100.0)
                understood = True

            if data.id == "gpvdmjobfinished":
                lines = data.split("\n")
                name = inp_search_token_value(lines, "#job_name")
                self.label.set_text(gui_print_path("Finished:  ", name, 60))
                understood = True

            if data.id == "gpvdmthingdone":
                wait_update(data.token)
                understood = True

            if data.id == "gpvdm_sync_packet_two":
                self.process_sync_packet_two(data)
                understood = True

            if data.id == "gpvdm_sync_packet_one":
                self.process_sync_packet_one(data)
                understood = True

            if understood == False:
                print("Command >", data, "<not understood")
예제 #38
0
    def load_data(self):
        self.tab.setColumnCount(7)
        self.tab.clear()
        self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)

        lines = []
        self.start_time = 0.0
        self.fs_laser_time = 0.0
        self.list = []

        self.tab.setHorizontalHeaderLabels([
            _("Length"),
            _("dt"),
            _("Start Voltage"),
            _("Stop Voltage"),
            _("step multiplyer"),
            _("Suns"),
            _("Laser")
        ])

        print("loading", self.file_name)
        lines = inp_load_file(self.file_name)
        if lines != False:
            if inp_search_token_value(lines, "#ver") == "1.1":
                pos = 0
                token, value, pos = inp_read_next_item(lines, pos)
                self.start_time = float(value)

                token, value, pos = inp_read_next_item(lines, pos)
                self.fs_laser_time = float(value)

                token, value, pos = inp_read_next_item(lines, pos)
                segments = int(value)

                for i in range(0, segments):
                    token, length, pos = inp_read_next_item(lines, pos)
                    token, dt, pos = inp_read_next_item(lines, pos)
                    token, voltage_start, pos = inp_read_next_item(lines, pos)
                    token, voltage_stop, pos = inp_read_next_item(lines, pos)
                    token, mul, pos = inp_read_next_item(lines, pos)
                    token, sun, pos = inp_read_next_item(lines, pos)
                    token, laser, pos = inp_read_next_item(lines, pos)

                    tab_add(self.tab, [
                        str(length),
                        str(dt),
                        str(voltage_start),
                        str(voltage_stop),
                        str(mul),
                        str(sun),
                        str(laser)
                    ])

                return True
            else:
                print("file " + self.file_name + "wrong version")
                exit("")
                return False
        else:
            print("file " + self.file_name + " not found")
            return False

        return False
예제 #39
0
	def draw_graph(self):
		lines=[]
		total=10
		pos=0
		bands=10

		#circle1=plt.Circle((10,10),4,color='r')

		if inp_load_file(lines,"mesh.inp")==True:
			total=inp_sum_items(lines, "#mesh_layer_points0")

		if inp_load_file(lines,"dump.inp")==True:
			pos=int(inp_search_token_value(lines, "#dump_energy_slice_pos"))

		files=epitaxy_get_dos_files()
		if len(files)>0:
			if inp_load_file(lines,files[0])==True:
				bands=int(inp_search_token_value(lines, "#srh_bands"))

		n=0
		
		self.fig.clf()
		
		self.fig.subplots_adjust(bottom=0.2)
		self.fig.subplots_adjust(left=0.1)
		self.ax1 = self.fig.add_subplot(111)
		#ax2 = ax1.twinx()
		x_pos=0.0
		layer=0
		color =['r','g','b','y','o','r','g','b','y','o']

		self.ax1.set_ylabel('Energy (eV)')
		#ax2.set_ylabel('Energy (eV)')
		self.ax1.set_xlabel('Position (nm)')
		try:

			t,Ec_data = loadtxt(os.path.join("equilibrium","Ec.dat"), unpack=True)
			t=t*1e9
			Ec, = self.ax1.plot(t,Ec_data, 'ro-', linewidth=3 ,alpha=0.5)

			t,Ev_data = loadtxt(os.path.join("equilibrium","Ev.dat"), unpack=True)
			t=t*1e9
			Ev,=self.ax1.plot(t,Ev_data, 'go-', linewidth=3 ,alpha=0.5)

			if len(files)>0:
				if self.emesh_editor.mesh_dump_ctl.enable==True:

					Ec_max=max(Ec_data)
					Ev_min=min(Ev_data)

					x_len=t[len(t)-1]-t[0]
					y_len=Ec_max-Ev_min

					x_pos=t[0]+(x_len)*(float(pos)/float(total))
					x_size=(x_len)/float(total)/4
					start=float(Ev_data[pos])
					stop=float(Ec_data[pos])
					y_pos=start
					dy=(stop-start)/(bands*2)
					while y_pos<stop:
						self.ax1.add_patch(Ellipse((x_pos, y_pos), x_size,x_size*(y_len/x_len), facecolor='red', edgecolor=(0,0.0,0.0), linewidth=0, alpha=1.0))
						y_pos=y_pos+dy


			t,s = loadtxt(os.path.join("equilibrium","Fi.dat"), unpack=True)
			t=t*1e9
			Fi,=self.ax1.plot(t,s, 'bo-', linewidth=3 ,alpha=0.5)

			if self.show_key==True:
				self.fig.legend((Ec, Ev, Fi), ('LUMO', 'H**O', 'Fi'), 'upper right')
			else:
				self.ax1.legend_ = None
			#self.fig.canvas.draw()
		
		except:
			print "No mode file\n"
예제 #40
0
        def rebuild_scene(self):
            self.gl_objects_clear()
            self.menu_update()
            self.text_clear_lib()

            x = gl_scale.project_m2screen_x(0)
            z = gl_scale.project_m2screen_z(0)

            if self.enable_draw_rays == True:
                self.draw_rays(self.ray_file)

            if self.enable_draw_light_source == True:

                lines = inp_load_file(os.path.join(get_sim_path(), "ray.inp"))

                if lines != False:
                    point_x = float(inp_search_token_value(lines, "#ray_xsrc"))
                    point_y = float(inp_search_token_value(lines, "#ray_ysrc"))
                    if point_x == -1.0:
                        point_x = 0.0
                        point_y = 0.0
                    else:
                        point_x = gl_scale.project_m2screen_x(point_x)
                        point_y = gl_scale.project_m2screen_y(point_y)

                    a = gl_base_object()
                    a.id = ["ray_src"]
                    a.type = "box"
                    a.xyz.x = point_x
                    a.xyz.y = point_y
                    a.xyz.z = 0.0
                    a.dxyz.dx = 0.2
                    a.dxyz.dy = 0.2
                    a.dxyz.dz = 0.2
                    a.r = 0.0
                    a.g = 0.0
                    a.b = 1.0

                    a.moveable = True
                    a.selectable = True
                    self.gl_objects_add(a)

            if self.draw_electrical_mesh == True:
                self.draw_mesh()

            elif self.view.draw_device == True:
                self.draw_device2(x, z)
                self.draw_contacts()

            if self.plot_circuit == True:
                self.draw_circuit()

            if self.enable_light_profile == True:
                self.draw_light_profile()

            if self.view.render_grid == True:
                o = gl_base_object()
                o.id = ["grid"]
                o.r = 0.5
                o.g = 0.5
                o.b = 0.5
                o.type = "grid"
                self.gl_objects_add(o)

            if self.pre_built_scene != None:
                self.gl_objects_load(self.pre_built_scene)
예제 #41
0
        def render(self):
            self.update_real_to_gl_mul()

            x = gl_scale.project_m2screen_x(0)
            y = 0.0  #project_m2screen_y(0)
            z = gl_scale.project_m2screen_z(0)
            #print(">>>>>>22",project_m2screen_z(0))
            self.clear_color()
            glClearColor(self.view.bg_color[0], self.view.bg_color[1],
                         self.view.bg_color[2], 0.5)

            self.dos_start = -1
            self.dos_stop = -1

            self.emission = False
            self.ray_model = False

            lines = inp_load_file(os.path.join(get_sim_path(), "ray.inp"))

            if lines != False:
                self.ray_model = val = str2bool(
                    inp_search_token_value(lines, "#ray_auto_run"))

            lines = []
            epi = get_epi()
            for i in range(0, len(epi.layers)):
                if epi.layers[i].dos_file != "none":
                    lines = inp_load_file(
                        os.path.join(get_sim_path(),
                                     epi.layers[i].dos_file + ".inp"))
                    if lines != False and len(lines) != 0:
                        if str2bool(lines[3]) == True:
                            self.emission = True

            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
            glLoadIdentity()
            glScalef(1.0, 1.0, -1.0)

            glTranslatef(self.view.x_pos, self.view.y_pos,
                         self.view.zoom)  # Move Into The Screen

            glRotatef(self.view.xRot, 1.0, 0.0, 0.0)
            glRotatef(self.view.yRot, 0.0, 1.0, 0.0)
            glRotatef(self.view.zRot, 0.0, 0.0, 1.0)

            glColor3f(1.0, 1.5, 0.0)
            glPolygonMode(GL_FRONT, GL_FILL)

            #glClearColor(0.92, 0.92, 0.92, 0.5) # Clear to black.

            lines = []

            self.pos = 0.0
            if self.enable_cordinates == True:
                self.draw_cords()

            if self.enable_draw_ray_mesh == True:
                self.draw_ray_mesh()

            if self.view.optical_mode == True:
                self.draw_mode()

            if self.scene_built == False:
                self.build_scene()

            if self.plot_graph == True:
                self.draw_graph()

            #for l in self.lights:
            #	box(l.xyz[0],l.xyz[1],l.xyz[2],0.5,0.5,0.5,1.0,0,0,0.5)

            if self.view.render_photons == True:
                self.draw_photons(x, z)

            self.gl_objects_render()

            if self.view.zoom > self.view.stars_distance:
                self.draw_stars()
예제 #42
0
    def update(self):
        self.clear_toolbar()
        lines = []
        newton_solver = newton_solver_get_type()
        files = inp_lsdir("sim.gpvdm")
        if files != False:
            for i in range(0, len(files)):
                if files[i].endswith(".inp") and files[i].count("/") == 0:
                    lines = inp_load_file(files[i])
                    value = inp_search_token_value(lines, "#sim_menu_name")
                    if value != False:
                        if value.count("@") == 1:
                            value = value.rstrip()
                            command, module = value.split("@")

                            hide = False
                            if newton_solver == "none":
                                if module == "jv":
                                    hide = True

                                if module == "pulse":
                                    hide = True

                                if module == "suns_jsc":
                                    hide = True

                                if module == "sun_voc":
                                    hide = True

                                if module == "is":
                                    hide = True

                            if command not in self.dont_show and hide == False:
                                a = gQAction(self, files[i], command, module)
                                a.setCheckable(True)
                                a.selected.connect(self.callback_click)
                                self.actions.append(a)

                            #temp.append(value)

            #temp.sort()

            token = inp_get_token_value("sim.inp", "#simmode")
            if token == None:
                return
                #print(os.getcwd(),"!!!!!!!!!!!!!")
                #sys.exit(0)
            if token.count("@") != 0:
                command, module = token.split("@")
            else:
                command = token

            found = False
            self.build = []
            added = 0  #This is to stop || appearing in the menu
            for o in self.order:
                if o == "|":
                    if added != 0:
                        self.build.append("|")
                    added = 0
                else:
                    for i in range(0, len(self.actions)):
                        if self.actions[i].command.lower().startswith(
                                o.lower()) == True:
                            if self.actions[i].done == False:
                                self.build.append(self.actions[i])
                                self.actions[i].done = True
                                added = added + 1

            for i in range(0, len(self.actions)):
                if self.actions[i].done == False:
                    #print(self.actions[i].command)
                    self.build.append(self.actions[i])

            self.actions = self.build

            self.blockSignals(True)
            for a in self.actions:
                #self.sim_mode.addItem(command)
                if type(a) == gQAction:
                    self.addAction(a)
                    if command.lower() == a.command.lower():
                        self.callback_click(a, disable_help=True)
                        found = True
                else:
                    self.addSeparator()

            #if there is no known mode, just set it to jv mode
            if found == False:
                for a in self.actions:
                    if a.command == "jv":
                        self.callback_click(a, disable_help=True)
                        inp_update_token_value(
                            os.path.join(get_sim_path(), "sim.inp"),
                            "#simmode", "jv@jv")
                        break

            self.blockSignals(False)
예제 #43
0
def export_as(output):
	tex=True
	dollar="$"
	col=" & "
	eol=" \\\\"
	ext= os.path.splitext(output)[1]
	line=""
	if (ext==".pdf") or (ext==".jpg") or (ext==".tex")  or (ext==".csv"):
		print(ext)
		if ext==".csv":
			tex=False
			dollar=""
			col="\t"
			eol=""

		lines=[]
		if tex==True:
			line=line+"\\documentclass{article}\n"
			line=line+"\\providecommand{\\e}[1]{\\ensuremath{\\times 10^{#1}}}\n"
			line=line+"\\begin{document}\n"
			line=line+"\\pagenumbering{gobble}\n"
			line=line+"\n"
		files=[]

		f_list=glob.iglob(os.path.join("./", "dos*.inp"))
		for in_file in f_list:
                         files.append(in_file)
		print(files)
		if tex==True:
			line=line+"\\begin{table}[H]\n"
			line=line+"\\begin{center}\n"
			line=line+"  \\begin{tabular}{lll}\n"
			line=line+"  \\hline\n"

		line=line+"  Parameter"+col+"label"+col+"unit "+eol+"\n"

		if tex==True:
			line=line+"  \\hline\n"


		dos_lines=[]
		for i in range(0,len(files)):
			lines=[]
			lines=inp_load_file(files[i])
			dos_lines.append(lines)

		t=tokens()
		for i in range(0,len(dos_lines[0]),2):
			my_token=t.find(dos_lines[0][i])

			if my_token!=False:
				number=""
				if my_token.number_type=="e":
					for ii in range(0,len(files)):

						if len(files)>0:
							sub="_{"+str(ii)+"}"
						else:
							sub=""

						if dos_lines[0][i+1]!=dos_lines[ii][i+1] or ii==0:
							if tex==True:
								number=to_exp(dos_lines[ii][i+1])
							else:
								number=dos_lines[ii][i+1]

							line=line+my_token.info+sub+col+dollar+number+dollar+col+dollar+pygtk_to_latex_subscript(my_token.units)+dollar+eol+"\n"
		if tex==True:
			line=line+"  \\hline\n"
			line=line+"\\end{tabular}\n"
			line=line+"\\end{center}\n"
			line=line+"\\caption{Density of states}\n"
			line=line+"\\end{table}\n"
			line=line+"\n"

		files=["./device.inp","./ray.inp","./device_epitaxy.inp", "./stark.inp", "./materials/redf/fit.inp", "./materials/redf/patch.inp"]
		names=["Device","Ray","Device Epitaxy","Stark","Fit redf","Fit patch"]
		if tex==True:
			line=line+"\\begin{table}[H]\n"
			line=line+"\\begin{center}\n"
			line=line+"  \\begin{tabular}{lll}\n"
			line=line+"  \\hline\n"

		line=line+"  Parameter"+col+"label"+col+"unit "+eol+"\n"

		if tex==True:
			line=line+"  \\hline\n"

		config_lines=[]
		cur_file=0
		config_lines=inp_load_file("latex_export_info.inp")
		for cur_file in range(0,len(files)):


			if os.path.isfile(files[cur_file])==True:
				lines=inp_load_file(files[cur_file])
				t=tokens()

				for i in range(0,len(lines),2):
					dump_token=inp_search_token_value(config_lines, lines[i])
					if dump_token=="1":
						my_token=t.find(lines[i])
						if my_token!=False:
							if my_token.number_type=="e":
								number=""
								if tex==True:
									#print lines
									#print lines[i]
									number=to_exp(dos_lines[ii][i+1])
								else:
									number=dos_lines[ii][i+1]
								line=line+my_token.info+col+dollar+number+dollar+col+dollar+pygtk_to_latex_subscript(my_token.units)+dollar+eol+"\n"

		if tex==True:
			line=line+"  \\hline\n"
			line=line+"\\end{tabular}\n"
			line=line+"\\end{center}\n"
			line=line+"\\caption{"+names[cur_file]+"}\n"
			line=line+"\\end{table}\n"
			line=line+"\n"

		if tex==True:
			line=line+"\\end{document}\n"

		text_file = open("doc.tex", "w")
		text_file.write(line)
		print(line)
		text_file.close()

		if (ext==".pdf"):
			os.system("latex -interaction=batchmode doc")
			os.system("dvipdf doc.dvi")
			os.system("mv doc.pdf "+output)

		if (ext==".jpg"):
			os.system("latex -interaction=batchmode doc")
			os.system("convert -trim -bordercolor White -border 20x10 +repage -density 300 doc.dvi doc.jpg")
			os.system("mv doc.jpg "+output)

		if (ext==".tex"):
			os.system("mv doc.tex "+output)

		if (ext==".csv"):
			os.system("mv doc.tex "+output)
예제 #44
0
def plot_load_oplot_file(plot_token, file_name):
    lines = []
    if inp_load_file(lines, file_name) == True:
        plot_token.logy = str2bool(inp_search_token_value(lines, "#logy"))
        plot_token.logx = str2bool(inp_search_token_value(lines, "#logx"))
        plot_token.grid = str2bool(inp_search_token_value(lines, "#grid"))
        plot_token.invert_y = str2bool(inp_search_token_value(lines, "#invert_y"))
        plot_token.normalize = str2bool(inp_search_token_value(lines, "#normalize"))
        plot_token.norm_to_peak_of_all_data = str2bool(inp_search_token_value(lines, "#norm_to_peak_of_all_data"))
        plot_token.subtract_first_point = str2bool(inp_search_token_value(lines, "#subtract_first_point"))
        plot_token.add_min = str2bool(inp_search_token_value(lines, "#add_min"))
        plot_token.file0 = inp_search_token_value(lines, "#file0")
        plot_token.file1 = inp_search_token_value(lines, "#file1")
        plot_token.file2 = inp_search_token_value(lines, "#file2")
        plot_token.tag0 = inp_search_token_value(lines, "#tag0")
        plot_token.tag1 = inp_search_token_value(lines, "#tag1")
        plot_token.tag2 = inp_search_token_value(lines, "#tag2")
        plot_token.legend_pos = inp_search_token_value(lines, "#legend_pos")
        plot_token.key_units = inp_search_token_value(lines, "#key_units")
        plot_token.label_data = str2bool(inp_search_token_value(lines, "#label_data"))
        plot_token.type = inp_search_token_value(lines, "#type")
        plot_token.x_label = inp_search_token_value(lines, "#x_label")
        plot_token.y_label = inp_search_token_value(lines, "#y_label")
        plot_token.x_units = inp_search_token_value(lines, "#x_units")
        plot_token.y_units = inp_search_token_value(lines, "#y_units")
        plot_token.x_mul = float(inp_search_token_value(lines, "#x_mul"))
        plot_token.y_mul = float(inp_search_token_value(lines, "#y_mul"))
        plot_token.key_units = inp_search_token_value(lines, "#key_units")
        plot_token.x_start = float(inp_search_token_value(lines, "#x_start"))
        plot_token.x_stop = float(inp_search_token_value(lines, "#x_stop"))
        plot_token.x_points = float(inp_search_token_value(lines, "#x_points"))
        plot_token.y_start = float(inp_search_token_value(lines, "#y_start"))
        plot_token.y_stop = float(inp_search_token_value(lines, "#y_stop"))
        plot_token.y_points = float(inp_search_token_value(lines, "#y_points"))
        plot_token.time = float(inp_search_token_value(lines, "#time"))
        plot_token.Vexternal = float(inp_search_token_value(lines, "#Vexternal"))

        return True
    return False