def device_lib_replace(file_name,dir_name=""):
	if dir_name=="":
		dir_name=get_device_lib_path()
	archives=glob.glob(os.path.join(dir_name,"*.gpvdm"))
	for i in range(0,len(archives)):
		print("replace ",archives[i],file_name)
		archive_add_file(archives[i],file_name,"")
Example #2
0
    def on_ok_clicked(self, button):

        selection = self.treeview.get_selection()
        model, iter = selection.get_selected()

        model, iter = selection.get_selected()

        if iter:
            path = model.get_path(iter)[0]
            self.file_path = os.path.join(get_device_lib_path(), model[path][0])
            md = gtk.MessageDialog(
                None,
                0,
                gtk.MESSAGE_QUESTION,
                gtk.BUTTONS_YES_NO,
                "You are about to import the simulation file "
                + self.file_path
                + " into this simulation.  The result will be that all model parameters will be overwritten.  Do you really want to do that?",
            )

            response = md.run()

            if response == gtk.RESPONSE_YES:
                self.response(True)
            elif response == gtk.RESPONSE_NO:
                return
            md.destroy()
Example #3
0
    def __init__(self):
        QDialog.__init__(self)
        self.main_vbox = QVBoxLayout()
        self.setMinimumSize(900, 580)
        self.setWindowTitle(_("New simulation") + " (https://www.gpvdm.com)")
        self.setWindowIcon(icon_get("si"))
        self.title = QLabel(
            "<big><b>" +
            _("Which type of device would you like to simulate?") +
            "</b></big>")

        self.viewer = gpvdm_viewer(get_device_lib_path())
        self.viewer.open_own_files = False
        self.viewer.set_back_arrow(True)
        self.viewer.set_enable_menu(False)
        self.viewer.setViewMode(QListView.IconMode)
        self.viewer.setSpacing(8)
        self.viewer.setWordWrap(True)
        gridsize = self.size()
        gridsize.setWidth(100)
        gridsize.setHeight(140)
        self.viewer.setGridSize(gridsize)

        self.viewer.setTextElideMode(Qt.ElideNone)
        #gridsize=self.size()
        #gridsize.setWidth(100)
        #gridsize.setHeight(90)
        #self.setGridSize(gridsize)
        self.main_vbox.addWidget(self.title)
        self.main_vbox.addWidget(self.viewer)

        self.hwidget = QWidget()

        self.nextButton = QPushButton(_("Next"))
        self.cancelButton = QPushButton(_("Cancel"))

        self.files = []

        hbox = QHBoxLayout()
        self.show_hidden = QCheckBox(_("Show hidden"))
        self.show_hidden.clicked.connect(self.callback_toggle_hidden)
        hbox.addWidget(self.show_hidden)
        hbox.addStretch(1)
        hbox.addWidget(self.cancelButton)
        hbox.addWidget(self.nextButton)
        self.hwidget.setLayout(hbox)

        self.main_vbox.addWidget(self.hwidget)

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

        self.ret_path = None
        # Create a new window

        self.viewer.accept.connect(self.callback_next)
        self.nextButton.clicked.connect(self.callback_next)
        self.cancelButton.clicked.connect(self.callback_close)
Example #4
0
	def on_ok_clicked(self):
		ret=tab_get_selected(self.tab)
		if ret==False:
			error_dlg(self,_("You have not selected anything"))
		else:
			file_path=os.path.join(get_device_lib_path(),ret[0])
			md = yes_no_dlg(self,"You are about to import the simulation file "+file_path+" into this simulation.  The result will be that all model parameters will be overwritten.  Do you really want to do that?")

			if response == True:
				self.file_path=file_path
				self.close()
Example #5
0
	def on_ok_clicked(self):
		ret=tab_get_selected(self.tab)
		if ret==False:
			error_dlg(self,_("You have not selected anything"))
		else:
			file_path=os.path.join(get_device_lib_path(),ret[0])
			md = yes_no_dlg(self,"You are about to import the simulation file "+file_path+" into this simulation.  The result will be that all model parameters will be overwritten.  Do you really want to do that?")

			if response == True:
				self.file_path=file_path
				self.close()
def find_device_libs():
	out=[]
	for root, dirs, files in os.walk(get_device_lib_path()):
		for name in files:
			if name.endswith(".gpvdm")==True:
				out.append(os.path.join(root, name))

	for root, dirs, files in os.walk(get_backup_path()):
		for name in files:
			if name.endswith(".gpvdm")==True:
				out.append(os.path.join(root, name))

	return out
Example #7
0
	def create_model(self):

		self.tab.clear()
		self.tab.setColumnCount(3)
		self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)
		self.tab.setHorizontalHeaderLabels([_("File name"), _("Device type"), _("Description")])
		self.tab.setColumnWidth(0, 150);
		self.tab.setColumnWidth(2, 500);
		self.tab.verticalHeader().setDefaultSectionSize(80);
		files=glob.glob(os.path.join(get_device_lib_path(),"*.gpvdm"))
		for i in range(0,len(files)):
			print("working on",files[i],zip_lsdir(files[i]))
			lines=read_lines_from_archive(lines,files[i],"info.inp")
			if lines!=False:
				tab_add(self.tab,[os.path.basename(files[i]), " ".join(inp_search_token_value_multiline(lines,"#info_device_type"))," ".join(inp_search_token_value_multiline(lines,"#info_description"))])
Example #8
0
	def create_model(self):

		self.tab.clear()
		self.tab.setColumnCount(3)
		self.tab.setSelectionBehavior(QAbstractItemView.SelectRows)
		self.tab.setHorizontalHeaderLabels([_("File name"), _("Device type"), _("Description")])
		self.tab.setColumnWidth(0, 150);
		self.tab.setColumnWidth(2, 500);
		self.tab.verticalHeader().setDefaultSectionSize(80);
		files=glob.glob(os.path.join(get_device_lib_path(),"*.gpvdm"))
		for i in range(0,len(files)):
			print("working on",files[i],zip_lsdir(files[i]))
			lines=[]
			if read_lines_from_archive(lines,files[i],"info.inp")==True:
				tab_add(self.tab,[os.path.basename(files[i]), " ".join(inp_search_token_value_multiline(lines,"#info_device_type"))," ".join(inp_search_token_value_multiline(lines,"#info_description"))])
Example #9
0
    def __init__(self):
        QDialog.__init__(self)
        self.main_vbox = QVBoxLayout()
        self.setFixedSize(450, 580)
        self.setWindowTitle(_("New simulation") + " (https://www.gpvdm.com)")
        self.setWindowIcon(icon_get("si"))
        self.title = QLabel(
            "<big><b>" +
            _("Which type of device would you like to simulate?") +
            "</b></big>")

        self.viewer = gpvdm_viewer(get_device_lib_path())
        self.viewer.open_own_files = False
        self.viewer.set_back_arrow(True)
        self.viewer.set_enable_menu(False)
        self.main_vbox.addWidget(self.title)
        self.main_vbox.addWidget(self.viewer)

        self.hwidget = QWidget()

        self.nextButton = QPushButton(_("Next"))
        self.cancelButton = QPushButton(_("Cancel"))

        self.files = []

        hbox = QHBoxLayout()
        self.show_hidden = QCheckBox(_("Show hidden"))
        self.show_hidden.clicked.connect(self.callback_toggle_hidden)
        hbox.addWidget(self.show_hidden)
        hbox.addStretch(1)
        hbox.addWidget(self.cancelButton)
        hbox.addWidget(self.nextButton)
        self.hwidget.setLayout(hbox)

        self.main_vbox.addWidget(self.hwidget)

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

        self.ret_path = None
        # Create a new window

        self.viewer.accept.connect(self.callback_next)
        self.nextButton.clicked.connect(self.callback_next)
        self.cancelButton.clicked.connect(self.callback_close)
Example #10
0
	def callback_next(self):
		help_window().help_set_help(["save.png",_("<big><b>Now save the simulation</b></big><br>Now select where you would like to save the simulation directory.")])

		if len(self.window.listwidget.selectedItems())>0:

			file_path=save_as_gpvdm(self.window)
			if file_path!=None:
				selection=self.window.listwidget.selectedItems()[0].text()
				selection_file=selection[selection.find("(")+1:selection.find(")")]

				if not os.path.exists(file_path):
					os.makedirs(file_path)

				self.ret_path=file_path
				os.chdir(self.ret_path)
				gpvdm_clone(os.getcwd(),True)
				import_archive(os.path.join(get_device_lib_path(),selection_file),os.path.join(os.getcwd(),"sim.gpvdm"),False)
				self.window.close()
		else:
			error_dlg(self.window,_("Please select a device before clicking next"))
Example #11
0
    def __create_model(self):

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

        # add items

        files = glob.glob(os.path.join(get_device_lib_path(), "*.opvdm"))
        for i in range(0, len(files)):
            print "working on", files[i], zip_lsdir(files[i])
            iter = model.append()
            lines = []
            if read_lines_from_archive(lines, files[i], "info.inp") == True:
                print lines
                model.set(
                    iter,
                    COLUMN_FILENAME,
                    os.path.basename(files[i]),
                    COLUMN_TYPE,
                    " ".join(inp_search_token_value_multiline(lines, "#info_device_type")),
                    COLUMN_INFO,
                    " ".join(inp_search_token_value_multiline(lines, "#info_description")),
                )
        return model
Example #12
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 #13
0
def device_lib_delete(file_name, dir_name=""):
    if dir_name == "":
        dir_name = get_device_lib_path()
    archives = glob.glob(os.path.join(dir_name, "*.gpvdm"))
    for i in range(0, len(archives)):
        zip_remove_file(archives[i], file_name)
Example #14
0
def device_lib_replace(file_name):
	archives=glob.glob(os.path.join(get_device_lib_path(),"*.gpvdm"))
	for i in range(0,len(archives)):
		print("replace ",archives[i],file_name)
		archive_add_file(archives[i],file_name,"")