Exemple #1
0
def test_calc_series():
    pvconst = PVconstants()
    pvcells = [
        PVcell(pvconst=pvconst, Tcell=323),
        PVcell(pvconst=pvconst, Ee=0.75, Tcell=313),
        PVcell(pvconst=pvconst, Ee=0.55, Tcell=303)
    ]
    i_at_vrbd = np.asarray([
        np.interp(pvc.VRBD, pvc.Vcell.flat, pvc.Icell.flat) for pvc in pvcells
    ])
    icells = np.asarray([pvc.Icell.flatten() for pvc in pvcells])
    vcells = np.asarray([pvc.Vcell.flatten() for pvc in pvcells])
    isc = np.asarray([pvc.Isc for pvc in pvcells])
    i, v = pvconst.calcSeries(icells, vcells, isc.mean(), i_at_vrbd.max())
    iv_old = np.loadtxt(os.path.join(BASE_DIR, 'calc_series_test_iv_old.dat'))
    iv_expected = np.loadtxt(os.path.join(BASE_DIR, 'calc_series_test_iv.dat'))
    # noinspection PyTypeChecker
    iv_calc = np.concatenate([[i], [v]], axis=0).T
    # noinspection PyTypeChecker
    ok_(np.allclose(iv_calc, iv_expected))
    assert np.allclose(iv_old[0, :], np.interp(iv_old[1, :], v, i), 0.01, 0.01)
    assert np.allclose(iv_old[1, :],
                       np.interp(iv_old[0, :], np.flipud(i), np.flipud(v)),
                       0.1, 0.1)
    return i, v
Exemple #2
0
def test_pvcell_basic():
    """
    test that pvcell returns a :class:`~pvmismatch.pvmismatch_lib.pvcell.PVcell`
    object.
    """
    pvc = PVcell()
    ok_(isinstance(pvc, PVcell))
Exemple #3
0
 def __init__(self,
              cell_pos=STD96,
              pvcells=None,
              pvconst=PVconstants(),
              Vbypass=VBYPASS,
              cellArea=CELLAREA):
     # TODO: check cell position pattern
     self.cell_pos = cell_pos  #: cell position pattern dictionary
     self.numberCells = sum([len(c) for s in self.cell_pos for c in s])
     """number of cells in the module"""
     self.pvconst = pvconst  #: configuration constants
     self.Vbypass = Vbypass  #: [V] trigger voltage of bypass diode
     self.cellArea = cellArea  #: [cm^2] cell area
     if pvcells is None:
         # faster to use copy instead of making each object in a for-loop
         # use copy instead of deepcopy to keep same pvconst for all objects
         # PVcell.calcCell() creates new np.ndarray if attributes change
         pvcells = PVcell(pvconst=self.pvconst)
     if isinstance(pvcells, PVcell):
         pvcells = [pvcells] * self.numberCells
     if len(pvcells) != self.numberCells:
         # TODO: use pvexception
         raise Exception(
             "Number of cells doesn't match cell position pattern.")
     self.pvcells = pvcells  #: list of `PVcell` objects in this `PVmodule`
     self.numSubStr = len(self.cell_pos)  #: number of substrings
     self.subStrCells = [len(_) for _ in self.cell_pos]  #: cells per substr
     # initialize members so PyLint doesn't get upset
     self.Imod, self.Vmod, self.Pmod, self.Isubstr, self.Vsubstr = self.calcMod(
     )
Exemple #4
0
def test_update():
    pvc = PVcell()
    Rs = pvc.Rs
    itest = pvc.Icell[170]
    pvc.update(Rs=0.001)
    assert np.isclose(pvc.Icell[170], 5.79691674)
    pvc._calc_now = False
    pvc.Rs = Rs
    pvc.update()  # resets _calc_now to True
    assert np.isclose(pvc.Icell[170], itest)
    assert pvc._calc_now
Exemple #5
0
def test_calc_series():
    pvconst = PVconstants()
    pvcells = [
        PVcell(pvconst=pvconst, Tcell=323),
        PVcell(pvconst=pvconst, Ee=0.75, Tcell=313),
        PVcell(pvconst=pvconst, Ee=0.55, Tcell=303)
    ]
    i_at_vrbd = np.asarray([
        np.interp(pvc.VRBD, pvc.Vcell.flat, pvc.Icell.flat) for pvc in pvcells
    ])
    icells = np.asarray([pvc.Icell.flatten() for pvc in pvcells])
    vcells = np.asarray([pvc.Vcell.flatten() for pvc in pvcells])
    isc = np.asarray([pvc.Isc for pvc in pvcells])
    i, v = pvconst.calcSeries(icells, vcells, isc.mean(), i_at_vrbd.max())
    iv = np.loadtxt(os.path.join(BASE_DIR, 'calc_series_test_iv.dat'))
    # noinspection PyTypeChecker
    ok_(np.allclose(i, iv[0]))
    # noinspection PyTypeChecker
    ok_(np.allclose(v, iv[1], rtol=1e-4))
    return i, v
Exemple #6
0
    def __init__(self,
                 cell_pos=STD96,
                 pvcells=None,
                 pvconst=None,
                 Vbypass=None,
                 cellArea=CELLAREA):
        # TODO: check cell position pattern
        self.cell_pos = cell_pos  #: cell position pattern dictionary
        self.numberCells = sum([len(c) for s in self.cell_pos for c in s])
        """number of cells in the module"""
        # is pvcells a list?
        try:
            pvc0 = pvcells[0]
        except TypeError:
            # is pvcells an object?
            try:
                pvconst = pvcells.pvconst
            except AttributeError:
                #  try to use the pvconst arg or create one if none
                if not pvconst:
                    pvconst = PVconstants()
                # create pvcell
                pvcells = PVcell(pvconst=pvconst)
            # expand pvcells to list
            pvcells = [pvcells] * self.numberCells
        else:
            pvconst = pvc0.pvconst
            for p in pvcells:
                if p.pvconst is not pvconst:
                    raise Exception(
                        'PVconstant must be the same for all cells')
        self.pvconst = pvconst  #: configuration constants

        # set default value of Vbypass if None
        if Vbypass is None:
            self.Vbypass = VBYPASS  #: [V] trigger voltage of bypass diode
        else:
            # if an object is passed, use that to determine the config of bypass diodes
            self.Vbypass = Vbypass
        self.Vbypass_config = parse_diode_config(self.Vbypass, self.cell_pos)

        self.cellArea = cellArea  #: [cm^2] cell area
        # check cell position pattern matches list of cells
        if len(pvcells) != self.numberCells:
            raise PVexception(
                "Number of cells doesn't match cell position pattern.")
        self.pvcells = pvcells  #: list of `PVcell` objects in this `PVmodule`
        self.numSubStr = len(self.cell_pos)  #: number of substrings
        self.subStrCells = [len(_) for _ in self.cell_pos]  #: cells per substr
        # initialize members so PyLint doesn't get upset
        self.Imod, self.Vmod, self.Pmod, self.Isubstr, self.Vsubstr = self.calcMod(
        )
Exemple #7
0
def test_settemp_cell():
    """
    Test setTemp method for a wide range of temperatures. 
    Test added after implementing Isat2 as Isat2(Tcell)
    """
    pvc = PVcell()
    Pmp_arr = []
    Vmp_arr = []
    Voc_arr = []
    Isc_arr = []
    
    temps = [-85, -60, -40, -25, 0, 25, 40, 60, 85]
    for t in temps:
        pvc.Tcell = float(t) + 273.15
        Pmp_arr.append(pvc.Pcell.max())
        Vmp_arr.append(pvc.Vcell[pvc.Pcell.argmax()])
        Voc_arr.append(pvc.calcVcell(0))
        Isc_arr.append(pvc.Isc)
        
    assert(np.all(np.gradient(np.squeeze(Vmp_arr)) < 0))
    assert(np.all(np.gradient(np.squeeze(Voc_arr)) < 0))
    assert(np.all(np.gradient(Isc_arr) > 0))
        
Exemple #8
0
def test_pvcell_calc_now_flag():
    """
    Test ``_calc_now`` turns off recalc in ``__setattr__``.
    """
    pvc = PVcell()
    itest, vtest, ptest = pvc.Icell, pvc.Vcell, pvc.Pcell
    pvc._calc_now = False
    pvc.Rs = 0.001
    assert np.allclose(itest, pvc.Icell)
    assert np.allclose(vtest, pvc.Vcell)
    assert np.allclose(ptest, pvc.Pcell)
    icell, vcell, pcell = pvc.calcCell()
    pvc._calc_now = True
    assert np.allclose(icell, pvc.Icell)
    assert np.allclose(vcell, pvc.Vcell)
    assert np.allclose(pcell, pvc.Pcell)
Exemple #9
0
def test_pvcell_calc_rbd():
    pvc1 = PVcell(bRBD=0.)
    ok_(isinstance(pvc1, PVcell))
    pvc2 = PVcell(bRBD=-0.056)
    ok_(isinstance(pvc2, PVcell))
Exemple #10
0
def test_pvcell_calc_vcell():
    pvc = PVcell()
    ok_(np.isclose(pvc.Vcell[123], pvc.calcVcell(pvc.Icell[123]), 1e-4))
    ok_(np.isclose(pvc.Vcell[153], pvc.calcVcell(pvc.Icell[153]), 1e-4))
    ok_(np.isclose(pvc.Vcell[183], pvc.calcVcell(pvc.Icell[183])))
Exemple #11
0
def test_pvcell_setattr_recalc():
    pvc = PVcell()
    i183 = pvc.Icell[183]
    pvc.Tcell = 323
    pvc.Ee = 0.65
    ok_(pvc.Icell[183] != i183)
Exemple #12
0
def test_pvmodule_with_pvcells_obj():
    pvcells = PVcell()
    pvmod = PVmodule(pvcells=pvcells)
    check_same_pvconst_and_lengths(pvmod)
Exemple #13
0
def test_pvmodule_with_pvcells_list():
    pvcells = [PVcell()] * 96
    pvmod = PVmodule(pvcells=pvcells)
    check_same_pvconst_and_lengths(pvmod)