Skip to content

Commit

Permalink
Isat2fix (#64)
Browse files Browse the repository at this point in the history
* Added temperature dependance for Isat2, i.e. Isat2(Tcell)

* test for wide range of Tcell values - added after implementing Isat2 as a function of Tcell

* generated new iv curve

* Isat2 to Isat2_T0

* Update example.py

Isat2 => Isat2_T0

* Update test_diode.py

* Deleting the old IV curve

* updated IV curve test file

* fixed isat2 typos caused by replace

* use entire iec matrix
  • Loading branch information
chetan201 authored Feb 20, 2018
1 parent 904ecae commit fbd9a60
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 15 deletions.
4 changes: 2 additions & 2 deletions pvmismatch/contrib/gen_coeffs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
from scipy import optimize
from pvmismatch.contrib.gen_coeffs import diode, two_diode
from pvmismatch.pvmismatch_lib.pvcell import ISAT1_T0, ISAT2, RS, RSH
from pvmismatch.pvmismatch_lib.pvcell import ISAT1_T0, ISAT2_T0, RS, RSH

# IEC 61853 test matrix
TC_C = [15.0, 25.0, 50.0, 75.0]
Expand Down Expand Up @@ -37,7 +37,7 @@ def gen_two_diode(isc, voc, imp, vmp, nseries, nparallel,
vmp_cell = vmp / nseries
if x0 is None:
isat1 = ISAT1_T0 # [A]
isat2 = ISAT2
isat2 = ISAT2_T0
rs = RS # [ohms]
rsh = RSH # [ohms]
else:
Expand Down
14 changes: 7 additions & 7 deletions pvmismatch/contrib/gen_coeffs/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
iec61853 = gen_coeffs.gen_iec_61853_from_sapm(gen_coeffs.PVMODULES[PROD_NAME])
iec61853['i_mp'] = iec61853['p_mp'] / iec61853['v_mp']
#isc0, alpha_isc = gen_coeffs.gen_sapm(iec61853)
x, sol = gen_coeffs.gen_two_diode(ISC0, VOC0, IMP0, VMP0, NS, NP, T0)
#x, sol = gen_coeffs.gen_two_diode(
# iec61853['i_sc'], iec61853['v_oc'], iec61853['i_mp'],
# iec61853['v_mp'], NS, NP, tc=TC, method='lm',
# x0=(2.25e-11, 1.5e-6, 0.004, 10.0)
#)
#x, sol = gen_coeffs.gen_two_diode(ISC0, VOC0, IMP0, VMP0, NS, NP, T0)
x, sol = gen_coeffs.gen_two_diode(
iec61853['i_sc'], iec61853['v_oc'], iec61853['i_mp'],
iec61853['v_mp'], NS, NP, tc=TC, method='lm',
x0=(2.25e-11, 1.5e-6, 0.004, 10.0)
)
isat1, isat2, rs, rsh = x

pvc = pvcell.PVcell(
Rs=rs, Rsh=rsh, Isat1_T0=isat1, Isat2=isat2,
Rs=rs, Rsh=rsh, Isat1_T0=isat1, Isat2_T0=isat2,
Isc0_T0=ISC0/NP, alpha_Isc=AISC
)
f1 = plt.figure()
Expand Down
2 changes: 1 addition & 1 deletion pvmismatch/contrib/gen_coeffs/tests/test_diode.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from pvmismatch.pvmismatch_lib.pvcell import (
RS as RS_2, RSH as RSH_2, ISAT1_T0 as ISAT1_2, ISAT2 as ISAT2_2
RS as RS_2, RSH as RSH_2, ISAT1_T0 as ISAT1_2, ISAT2_T0 as ISAT2_2
)
from pvmismatch.contrib.gen_coeffs import diode
from pvmismatch.contrib.gen_coeffs import PVMODULES
Expand Down
18 changes: 15 additions & 3 deletions pvmismatch/pvmismatch_lib/pvcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
RS = 0.004267236774264931 # [ohm] series resistance
RSH = 10.01226369025448 # [ohm] shunt resistance
ISAT1_T0 = 2.286188161253440E-11 # [A] diode one saturation current
ISAT2 = 1.117455042372326E-6 # [A] diode two saturation current
ISAT2_T0 = 1.117455042372326E-6 # [A] diode two saturation current
ISC0_T0 = 6.3056 # [A] reference short circuit current
TCELL = 298.15 # [K] cell temperature
ARBD = 1.036748445065697E-4 # reverse breakdown coefficient 1
Expand Down Expand Up @@ -50,15 +50,15 @@ class PVcell(object):

_calc_now = False #: if True ``calcCells()`` is called in ``__setattr__``

def __init__(self, Rs=RS, Rsh=RSH, Isat1_T0=ISAT1_T0, Isat2=ISAT2,
def __init__(self, Rs=RS, Rsh=RSH, Isat1_T0=ISAT1_T0, Isat2_T0=ISAT2_T0,
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.Isat2_T0 = Isat2_T0 #: [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
Expand Down Expand Up @@ -142,6 +142,18 @@ def Isat1(self):
)
return self.Isat1_T0 * _Tstar * _expTstar # [A] Isat1(Tcell)

@property
def Isat2(self):
"""
Diode two saturation current at Tcell in amps.
"""
_Tstar = self.Tcell ** 3. / self.pvconst.T0 ** 3. # scaled temperature
_inv_delta_T = 1. / self.pvconst.T0 - 1. / self.Tcell # [1/K]
_expTstar = np.exp(
self.Eg * self.pvconst.q / (2.0 * self.pvconst.k) * _inv_delta_T
)
return self.Isat2_T0 * _Tstar * _expTstar # [A] Isat2(Tcell)

@property
def Isc0(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions pvmismatch/tests/calc_series_test_iv.dat

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions pvmismatch/tests/test_settemps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
from nose.tools import ok_
from pvmismatch.pvmismatch_lib.pvsystem import PVsystem
from pvmismatch.pvmismatch_lib.pvcell import PVcell
import logging

logging.basicConfig(level=logging.DEBUG)
Expand Down Expand Up @@ -150,3 +151,27 @@ def test_settemp():
assert pvsys.pvstrs[2].pvmods[4].pvcells[5].Tcell == 310
assert pvsys.pvstrs[2].pvmods[4].pvcells[3] == pvsys.pvstrs[2].pvmods[4].pvcells[5]
assert pvsys.pvstrs[1].pvmods[0] == pvsys.pvstrs[1].pvmods[2]

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))

0 comments on commit fbd9a60

Please sign in to comment.