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
def __init__(self, numberMods=NUMBERMODS, pvmods=None, pvconst=None): # is pvmods a list? try: pvmod0 = pvmods[0] except TypeError: # is pvmods an object? try: pvconst = pvmods.pvconst except AttributeError: # try to use the pvconst arg or create one if none if not pvconst: pvconst = PVconstants() # create pvmod pvmods = PVmodule(pvconst=pvconst) # expand pvmods to list pvmods = [pvmods] * numberMods else: pvconst = pvmod0.pvconst numberMods = len(pvmods) for p in pvmods: if p.pvconst is not pvconst: raise Exception('pvconst must be the same for all modules') self.pvconst = pvconst #: ``PVconstants`` used in ``PVstring`` self.numberMods = numberMods #: number of module in string self.pvmods = pvmods #: list of ``PVModule`` in ``PVstring`` # calculate string self.Istring, self.Vstring, self.Pstring = self.calcString()
def __init__(self, Rs=RS, Rsh=RSH, Isat1_T0=ISAT1_T0, Isat2=ISAT2, Isc0_T0=ISC0_T0, aRBD=ARBD, bRBD=BRBD, VRBD=VRBD_, nRBD=NRBD, Eg=EG, alpha_Isc=ALPHA_ISC, Tcell=TCELL, Ee=1., pvconst=PVconstants()): # user inputs self.Rs = Rs #: [ohm] series resistance self.Rsh = Rsh #: [ohm] shunt resistance self.Isat1_T0 = Isat1_T0 #: [A] diode one sat. current at T0 self.Isat2 = Isat2 #: [A] diode two saturation current self.Isc0_T0 = Isc0_T0 #: [A] short circuit current at T0 self.aRBD = aRBD #: reverse breakdown coefficient 1 self.bRBD = bRBD #: reverse breakdown coefficient 2 self.VRBD = VRBD #: [V] reverse breakdown voltage self.nRBD = nRBD #: reverse breakdown exponent self.Eg = Eg #: [eV] band gap of cSi self.alpha_Isc = alpha_Isc #: [1/K] short circuit temp. coeff. self.Tcell = Tcell #: [K] cell temperature self.Ee = Ee #: [suns] incident effective irradiance on cell self.pvconst = pvconst #: configuration constants self.Icell = None #: cell currents on IV curve [A] self.Vcell = None #: cell voltages on IV curve [V] self.Pcell = None #: cell power on IV curve [W]
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( )
def __init__(self, pvconst=None, numberStrs=NUMBERSTRS, pvstrs=None, numberMods=NUMBERMODS, pvmods=None): # is pvstrs a list? try: pvstr0 = pvstrs[0] except TypeError: # is pvstrs a PVstring object? try: pvconst = pvstrs.pvconst except AttributeError: # try to use the pvconst arg or create one if none if not pvconst: pvconst = PVconstants() # create a pvstring pvstrs = PVstring(numberMods=numberMods, pvmods=pvmods, pvconst=pvconst) # expand pvstrs to list pvstrs = [pvstrs] * numberStrs numberMods = [numberMods] * numberStrs else: pvconst = pvstr0.pvconst numberStrs = len(pvstrs) numberMods = [] for p in pvstrs: if p.pvconst is not pvconst: raise Exception('pvconst must be the same for all strings') numberMods.append(len(p.pvmods)) self.pvconst = pvconst #: ``PVconstants`` used in ``PVsystem`` self.numberStrs = numberStrs #: number strings in the system self.numberMods = numberMods #: list of number of modules per string self.pvstrs = pvstrs #: list of ``PVstring`` in system # calculate pvsystem self.update()
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
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( )
def __init__(self, pvconst=PVconstants(), numberStrs=NUMBERSTRS, pvstrs=None, numberMods=NUMBERMODS, pvmods=None): self.pvconst = pvconst self.numberStrs = numberStrs self.numberMods = numberMods if pvstrs is None: pvstrs = PVstring(numberMods=self.numberMods, pvmods=pvmods, pvconst=self.pvconst) # use deep copy instead of making each object in a for-loop if isinstance(pvstrs, PVstring): pvstrs = [pvstrs] * self.numberStrs if len(pvstrs) != self.numberStrs: # TODO: use pvmismatch excecptions raise Exception("Number of strings don't match.") self.pvstrs = pvstrs self.Isys, self.Vsys, self.Psys = self.calcSystem() (self.Imp, self.Vmp, self.Pmp, self.Isc, self.Voc, self.FF, self.eff) = self.calcMPP_IscVocFFeff()
def __init__(self, numberMods=NUMBERMODS, pvmods=None, pvconst=PVconstants()): self.pvconst = pvconst self.numberMods = numberMods if pvmods is None: # use deepcopy instead of making each object in for-loop, 2x faster pvmods = PVmodule(pvconst=self.pvconst) if isinstance(pvmods, PVmodule): pvmods = [pvmods] * self.numberMods # reset pvconsts in all pvcells and pvmodules for p in pvmods: for c in p.pvcells: c.pvconst = self.pvconst p.pvconst = self.pvconst if len(pvmods) != self.numberMods: # TODO: use pvmismatch exceptions raise Exception("Number of modules doesn't match.") self.pvmods = pvmods self.Istring, self.Vstring, self.Pstring = self.calcString()