Example #1
0
    def linearPlot(self, checked):

        # check if Xdata type is selected
        if not self.radioLoop.isChecked() and not self.radioPos.isChecked():
            msg = QMessageBox()
            msg.setWindowTitle("Processing error")
            msg.setIcon(QMessageBox.Critical)
            msg.setText("No X data type chosen.")
            msg.setEscapeButton(QMessageBox.Ok)
            msg.exec_()
            return

        # get data files names
        files = [self.filesList[self.dataList.row(i)]\
                for i in self.dataList.selectedItems()
        ]
        # sort ascii order first, then by length of the name so that files are
        # in ascending order
        files.sort()
        files.sort(key=len)
        if len(files) == 0:
            msg = QMessageBox()
            msg.setWindowTitle("Processing error")
            msg.setIcon(QMessageBox.Critical)
            msg.setText("No data files were selected.")
            msg.setEscapeButton(QMessageBox.Ok)
            msg.exec_()
            return

        # test what kind of plot we are making
        exec("Xdata = {0}".format(self.Xdata.text()), globals())
        txt = self.quantity2.currentText()

        if self.radioLoop.isChecked():
            try:
                iter(Xdata)
            except TypeError:
                msg = QMessageBox()
                msg.setWindowTitle("Processing error")
                msg.setIcon(QMessageBox.Critical)
                msg.setText("The loop values expression is not iterable.")
                msg.setEscapeButton(QMessageBox.Ok)
                msg.exec_()
                return

            if len(Xdata) != len(files):
                msg = QMessageBox()
                msg.setWindowTitle("Processing error")
                msg.setIcon(QMessageBox.Critical)
                msg.setText("Number of selected files does not match number of loop values.")
                msg.setEscapeButton(QMessageBox.Ok)
                msg.exec_()
                return

        if self.radioPos.isChecked() and not isinstance(Xdata[0], tuple):
            msg = QMessageBox()
            msg.setWindowTitle("Processing error")
            msg.setIcon(QMessageBox.Critical)
            msg.setText("Provide two tuples defining a line as the X data.")
            msg.setEscapeButton(QMessageBox.Ok)
            msg.exec_()
            return           

 
        # get system
        settings = self.table.build.getSystemSettings()
        gui_system = parseSettings(settings)

        # scalings
        vt = gui_system.scaling.energy
        N  = gui_system.scaling.density
        G  = gui_system.scaling.generation
        J  = gui_system.scaling.current
        x0 = gui_system.scaling.length

        # Ydata is a list for the quantities looped over
        Ydata = []

        are_all_equal = True
        # loop over the files and plot
        for fdx, fileName in enumerate(files):
            system, data = sesame.load_sim(fileName)

            # check to see if data file sim settings are the same as gui sim settings!
            are_equal = check_equal_sim_settings(system, gui_system)
            if are_equal == False:
                are_all_equal = False


            #data = np.load(fileName)
            az = Analyzer(system, data)

            # get sites and coordinates of a line or else
            if isinstance(Xdata[0], tuple):
                if system.dimension == 1:
                    X = system.xpts
                    sites = np.arange(system.nx, dtype=int)
                if system.dimension == 2:
                    X, sites = az.line(system, Xdata[0], Xdata[1])
                    X = X * system.scaling.length
            else:
                X = Xdata

            # get the corresponding Y data
            if txt == "Generation rate density":
                Ydata = system.g[sites] * G
                YLabel = r'G [$\mathregular{s^{-1}cm^{-3}}$]'
            if txt == "Electron quasi-Fermi level":
                Ydata = vt * az.efn[sites]
                YLabel = r'$\mathregular{E_{F_n}}$ [eV]'
            if txt == "Hole quasi-Fermi level":
                Ydata = vt * az.efp[sites]
                YLabel = r'$\mathregular{E_{F_p}}$ [eV]'
            if txt == "Electrostatic potential":
                Ydata = vt * az.v[sites]
                YLabel = 'V [eV]'
            if txt == "Electron density":
                Ydata = N * az.electron_density()[sites]
                YLabel = r'n [$\mathregular{cm^{-3}}$]'
            if txt == "Hole density":
                Ydata = N * az.hole_density()[sites]
                YLabel = r'p [$\mathregular{cm^{-3}}$]'
            if txt == "Bulk SRH recombination":
                Ydata = G * az.bulk_srh_rr()[sites]
                YLabel = r'Bulk SRH [$\mathregular{cm^{-3}s^{-1}}$]'
            if txt == "Radiative recombination":
                Ydata = G * az.radiative_rr()[sites]
                YLabel = r'Radiative recombination [$\mathregular{cm^{-3}s^{-1}}$]'
            if txt == "Auger recombination":
                Ydata = G * az.auger_rr()[sites]
                YLabel = r'Auger recombination [$\mathregular{cm^{-3}s^{-1}}$]'
            if txt == "Electron current along x":
                Ydata = J * az.electron_current(component='x')[sites] * 1e3
                YLabel = r'$\mathregular{J_{n,x}\ [mA\cdot cm^{-2}]}$'
            if txt == "Hole current along x":
                Ydata = J * az.hole_current(component='x')[sites] * 1e3
                YLabel = r'$\mathregular{J_{p,x}\ [mA\cdot cm^{-2}]}$'
            if txt == "Electron current along y":
                Ydata = J * az.electron_current(component='y')[sites] * 1e3
                YLabel = r'$\mathregular{J_{n,y}\ [mA\cdot cm^{-2}]}$'
            if txt == "Hole current along y":
                Ydata = J * az.hole_current(component='y')[sites] * 1e3
                YLabel = r'$\mathregular{J_{p,y}\ [mA\cdot cm^{-2}]}$'
            if txt == "Integrated planar defects recombination":
                if system.ypts.size == 1:
                    Ydata.append(G * x0 * sum(az.integrated_defect_recombination(d)\
                                for d in system.defects_list))
                    YLabel = r'[$\mathregular{G_{pl. defect}\ cm^{-2}\cdot s^{-1}}$]'
                if system.ypts.size > 1:
                    Ydata.append(G * x0**2 * sum(az.integrated_defect_recombination(d)\
                                for d in system.defects_list))
                    YLabel = r'[$\mathregular{G_{pl. defect}\ cm^{-1}\cdot s^{-1}}$]'
            if txt == "Integrated total recombination":
                j_srh = az.integrated_bulk_srh_recombination()
                j_rad = az.integrated_radiative_recombination()
                j_aug = az.integrated_auger_recombination()
                j_def = sum(az.integrated_defect_recombination(d)\
                                for d in system.defects_list)
                if system.ypts.size == 1:
                    Ydata.append(G * x0 * (j_srh + j_rad + j_aug + j_def))
                    YLabel = r'[$G_{tot}\ \mathregular{cm^{-2}\cdot s^{-1}}$]'
                if system.ypts.size > 1:
                    Ydata.append(G * x0**2 * (j_srh + j_rad + j_aug + j_def))
                    YLabel = r'[$G_{tot}\ \mathregular{cm^{-1}\cdot s^{-1}}$]'
            if txt == "Full steady state current":
                if system.ypts.size == 1:
                    Ydata.append(J * az.full_current() * 1e3)
                    YLabel = r'J [$\mathregular{mA\cdot cm^{-2}}$]'
                if system.ypts.size > 1:
                    Ydata.append(J * az.full_current() * 1e3 * x0)
                    YLabel = r'J [$\mathregular{mA\cdot cm^{-1}}$]'

            # plot
            if txt not in ["Full steady state current",\
                           "Integrated total recombination",\
                           "Integrated planar defects recombination"]:
                if txt != "Band diagram":
                    ax = self.linearFig.figure.add_subplot(111)
                    X = X * 1e4  # set length in um
                    ax.plot(X, Ydata)
                    ax.set_ylabel(YLabel)
                    ax.set_xlabel(r'Position [$\mathregular{\mu m}$]')
                else:
                    az.band_diagram((Xdata[0], Xdata[1]), fig=self.linearFig.figure)

        # For quantities looped over
        if txt in ["Full steady state current",\
                   "Integrated total recombination",\
                   "Integrated planar defects recombination"]:
            try:
                c = next(self.iterColors)
            except StopIteration:
                self.iterColors = iter(self.colors)
                c = next(self.iterColors)
            ax = self.linearFig.figure.add_subplot(111)
            ax.plot(X, Ydata, marker='o', color=c)
            ax.set_ylabel(YLabel)
       
        self.linearFig.canvas.figure.tight_layout()
        self.linearFig.canvas.draw()

        # check to see if data file sim settings are the same as gui sim settings!
        if are_all_equal == False:
            msg = QMessageBox()
            msg.setWindowTitle("Warning!")
            msg.setIcon(QMessageBox.Critical)
            msg.setText("System parameters from GUI and data file do not match!")
            msg.setEscapeButton(QMessageBox.Ok)
            msg.exec_()
Example #2
0
    def surfacePlot(self, checked):
        # get system
        settings = self.table.build.getSystemSettings()
        gui_system = parseSettings(settings)

        # get data from file
        files = [self.filesList[self.dataList.row(i)]\
                for i in self.dataList.selectedItems()
        ]
        if len(files) == 0:
            msg = QMessageBox()
            msg.setWindowTitle("Processing error")
            msg.setIcon(QMessageBox.Critical)
            msg.setText("No data files were selected.")
            msg.setEscapeButton(QMessageBox.Ok)
            msg.exec_()
            return
        elif len(files) > 1:
            msg = QMessageBox()
            msg.setWindowTitle("Processing error")
            msg.setIcon(QMessageBox.Critical)
            msg.setText("Select a single data file for a surface plot.")
            msg.setEscapeButton(QMessageBox.Ok)
            msg.exec_()
            return
        else:
            fileName = files[0]
            system, data = sesame.load_sim(fileName)

            # check to see if data file sim settings are the same as gui sim settings!
            are_equal = check_equal_sim_settings(system, gui_system)
            if are_equal == False:
                msg = QMessageBox()
                msg.setWindowTitle("Warning!")
                msg.setIcon(QMessageBox.Critical)
                msg.setText("System parameters from GUI and data file do not match!")
                msg.setEscapeButton(QMessageBox.Ok)
                msg.exec_()


            # make an instance of the Analyzer
            az = Analyzer(system, data)

            # scalings
            vt = system.scaling.energy
            N  = system.scaling.density
            G  = system.scaling.generation

            # plot
            txt = self.quantity.currentText()
            self.surfaceFig.figure.clear()
            if txt == "Electron quasi-Fermi level":
                dataMap = vt * az.efn
                title = r'$\mathregular{E_{F_n}}$ [eV]'
            if txt == "Hole quasi-Fermi level":
                dataMap = vt * az.efp
                title = r'$\mathregular{E_{F_p}}$ [eV]'
            if txt == "Electrostatic potential":
                dataMap = vt * az.v
                title = r'$\mathregular{V}$ [eV]'
            if txt == "Electron density":
                dataMap = N * az.electron_density()
                title = r'n [$\mathregular{cm^{-3}}$]'
            if txt == "Hole density":
                dataMap = N * az.hole_density()
                title = r'p [$\mathregular{cm^{-3}}$]'
            if txt == "Bulk SRH recombination":
                dataMap = G * az.bulk_srh_rr()
                title = r'Bulk SRH [$\mathregular{cm^{-3}s^{-1}}$]'
            if txt == "Radiative recombination":
                dataMap = G * az.radiative_rr()
                title = r'Radiative Recomb. [$\mathregular{cm^{-3}s^{-1}}$]'
            if txt == "Auger recombination":
                dataMap = G * az.auger_rr()
                title = r'Auger Recomb. [$\mathregular{cm^{-3}s^{-1}}$]'
            if txt == "Total recombination":
                dataMap = G * az.total_rr()
                title = r'Total Recomb. [$\mathregular{cm^{-3}s^{-1}}$]'
            if txt != "Electron current" and txt != "Hole current":
                plot(system, dataMap, cmap='viridis',\
                     fig=self.surfaceFig.figure, title=title)
 
            if txt == "Electron current":
                az.current_map(True, 'viridis', 1e4, fig=self.surfaceFig.figure)

            if txt == "Hole current":
                az.current_map(False, 'viridis', 1e4, fig=self.surfaceFig.figure)

            self.linearFig.figure.tight_layout()
            self.surfaceFig.canvas.draw()
Example #3
0
import sesame
import numpy as np

sys, result = sesame.load_sim('1dhomo_V_0.gzip')
az = sesame.Analyzer(sys, result)
p1 = (0, 0)
p2 = (3e-4, 0)
az.band_diagram((p1, p2))
Example #4
0
import sesame
import numpy as np
import matplotlib.pyplot as plt
from scipy.io import savemat

J = []
for i in range(10):
    filename = "../tutorial3/2dGB_V_%d.gzip" % i
    sys, results = sesame.load_sim(filename)
    az = sesame.Analyzer(sys, results)
    J.append(az.full_current() * sys.scaling.current * sys.scaling.length)
print("current [A/cm] = ", J)

##################

sys, results = sesame.load_sim("2dGB_V_0.gzip")
az = sesame.Analyzer(sys, results)

# Line endpoints of the grain boundary core
p1 = (20e-7, 1.5e-4)  #[cm]
p2 = (2.9e-4, 1.5e-4)  #[cm]
# get the coordinate indices of the grain boundary core
X, sites = az.line(sys, p1, p2)

# obtain solution data along the GB core
efn_GB = results['efn'][sites]
efp_GB = results['efp'][sites]
v_GB = results['v'][sites]

#In this code we compute the integrated defect recombination along the grain boundary core::
Example #5
0
# define a function for generation profile
f = lambda x, y: 2.3e21 * np.exp(-2.3e4 * x)
# add generation to the system
sys.generation(f)

# Solve problem under short-circuit current conditions
solution = sesame.solve(sys, guess=solution)
# Get analyzer object to compute observables
az = sesame.Analyzer(sys, solution)
# Compute short-circuit current
j = az.full_current()
# Print Jsc
print(j * sys.scaling.current * sys.scaling.length * 1e3)

# specify applied voltages
voltages = np.linspace(0, .9, 10)
# find j-v
j = sesame.IVcurve(sys, voltages, '2dGB_V', guess=solution)

j = j * sys.scaling.current * sys.scaling.length * 1e3
import matplotlib.pyplot as plt
plt.plot(voltages, j, '-o')

# save the result
result = {'voltages': voltages, 'j': j}
np.save('IV_values', result)

# plot results
sys, results = sesame.load_sim('2dGB_V_0.gzip')
sesame.plot(sys, results['v'])