v-pvmismatch 0.0.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- v_PVMismatch/__init__.py +21 -0
- v_PVMismatch/circuit_comb.py +272 -0
- v_PVMismatch/pvmismatch/__init__.py +12 -0
- v_PVMismatch/pvmismatch/pvcell.py +339 -0
- v_PVMismatch/pvmismatch/pvconstants.py +268 -0
- v_PVMismatch/pvmismatch/pvexceptions.py +22 -0
- v_PVMismatch/pvmismatch/pvmodule.py +635 -0
- v_PVMismatch/pvmismatch/pvstring.py +231 -0
- v_PVMismatch/pvmismatch/pvsystem.py +237 -0
- v_PVMismatch/utils.py +361 -0
- v_PVMismatch/vpvcell.py +162 -0
- v_PVMismatch/vpvmodule.py +322 -0
- v_PVMismatch/vpvstring.py +104 -0
- v_PVMismatch/vpvsystem.py +365 -0
- v_PVMismatch-0.0.8.dist-info/LICENSE +21 -0
- v_PVMismatch-0.0.8.dist-info/METADATA +34 -0
- v_PVMismatch-0.0.8.dist-info/RECORD +19 -0
- v_PVMismatch-0.0.8.dist-info/WHEEL +5 -0
- v_PVMismatch-0.0.8.dist-info/top_level.txt +1 -0
v_PVMismatch/__init__.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Initialization file for the vectorized PVMismatch (v_PVMismatch) Package.
|
|
4
|
+
|
|
5
|
+
This package contains the basic library modules, methods, classes and
|
|
6
|
+
attributes to model PV system mismatch.
|
|
7
|
+
>>> from v_pvmismatch import pvcell # imports the PVcell methods
|
|
8
|
+
>>> # import pvcell, pvmodule, pvstring and pvsystem
|
|
9
|
+
>>> from v_pvmismatch import *
|
|
10
|
+
"""
|
|
11
|
+
# from v_pvmismatch.version import __version__
|
|
12
|
+
|
|
13
|
+
from v_PVMismatch import (
|
|
14
|
+
utils,
|
|
15
|
+
circuit_comb,
|
|
16
|
+
vpvcell,
|
|
17
|
+
vpvmodule,
|
|
18
|
+
vpvstring,
|
|
19
|
+
vpvsystem,
|
|
20
|
+
pvmismatch
|
|
21
|
+
)
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Circuit combination and bypass diode configuration functions that are vectorized."""
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
from scipy.interpolate import interp1d
|
|
6
|
+
from pvmismatch import pvconstants
|
|
7
|
+
|
|
8
|
+
# ------------------------------------------------------------------------------
|
|
9
|
+
# CIRCUIT COMBINATION FUNCTIONS-------------------------------------------------
|
|
10
|
+
|
|
11
|
+
DEFAULT_BYPASS = 0
|
|
12
|
+
MODULE_BYPASS = 1
|
|
13
|
+
CUSTOM_SUBSTR_BYPASS = 2
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def calcSeries(Curr, V, meanIsc, Imax, Imod_pts, Imod_negpts, npts):
|
|
17
|
+
"""
|
|
18
|
+
Calculate IV curve for cells and substrings in series.
|
|
19
|
+
|
|
20
|
+
Given current and voltage in increasing order by voltage,
|
|
21
|
+
the average short circuit current and the max current at the breakdown voltage.
|
|
22
|
+
|
|
23
|
+
:param Curr: cell or substring currents [A]
|
|
24
|
+
:param V: cell or substring voltages [V]
|
|
25
|
+
:param meanIsc: average short circuit current [A]
|
|
26
|
+
:param Imax: maximum current [A]
|
|
27
|
+
:return: current [A] and voltage [V] of series
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
# make sure all inputs are numpy arrays, but don't make extra copies
|
|
31
|
+
Curr = np.asarray(Curr) # currents [A]
|
|
32
|
+
V = np.asarray(V) # voltages [V]
|
|
33
|
+
meanIsc = np.asarray(meanIsc) # mean Isc [A]
|
|
34
|
+
Imax = np.asarray(Imax) # max current [A]
|
|
35
|
+
# create array of currents optimally spaced from mean Isc to max VRBD
|
|
36
|
+
Ireverse = (Imax - meanIsc) * Imod_pts + meanIsc
|
|
37
|
+
Imin = np.minimum(Curr.min(), 0.) # minimum cell current, at most zero
|
|
38
|
+
# range of currents in forward bias from min current to mean Isc
|
|
39
|
+
Iforward = (Imin - meanIsc) * Imod_negpts + meanIsc
|
|
40
|
+
# create range for interpolation from forward to reverse bias
|
|
41
|
+
Itot = np.concatenate((Iforward, Ireverse), axis=0).flatten()
|
|
42
|
+
Vtot = np.zeros((2 * npts,))
|
|
43
|
+
# add up all series cell voltages
|
|
44
|
+
# t0 = time.time()
|
|
45
|
+
for i, v in zip(Curr, V):
|
|
46
|
+
# interp requires x, y to be sorted by x in increasing order
|
|
47
|
+
Vtot += pvconstants.npinterpx(Itot, np.flipud(i), np.flipud(v))
|
|
48
|
+
# print('Time elapsed to run loopy interp: ' + str(time.time() - t0) + ' s')
|
|
49
|
+
# Itot = np.repeat(Itot[:,np.newaxis], Curr.shape[0], axis=1).T
|
|
50
|
+
# t0 = time.time()
|
|
51
|
+
# Vtot = interp2d_wrap(np.flip(Curr, axis = 1), Itot, np.flip(V, axis = 1))
|
|
52
|
+
# Vtot = Vtot.sum(axis=1)
|
|
53
|
+
# print('Time elapsed to run vectorized interp: ' + str(time.time() - t0) + ' s')
|
|
54
|
+
return np.flipud(Itot), np.flipud(Vtot)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def calcSeries_with_bypass(Curr, V, meanIsc, Imax, Imod_pts, Imod_negpts, npts, substr_bypass, run_bpact=True):
|
|
58
|
+
"""
|
|
59
|
+
Calculate IV curve for cells and substrings in series.
|
|
60
|
+
|
|
61
|
+
Given current and voltage in increasing order by voltage,
|
|
62
|
+
the average short circuit current and the max current at
|
|
63
|
+
the breakdown voltage.
|
|
64
|
+
|
|
65
|
+
:param Curr: cell or substring currents [A]
|
|
66
|
+
:param V: cell or substring voltages [V]
|
|
67
|
+
:param meanIsc: average short circuit current [A]
|
|
68
|
+
:param Imax: maximum current [A]
|
|
69
|
+
:return: current [A] and voltage [V] of series
|
|
70
|
+
"""
|
|
71
|
+
# make sure all inputs are numpy arrays, but don't make extra copies
|
|
72
|
+
Curr = np.asarray(Curr) # currents [A]
|
|
73
|
+
V = np.asarray(V) # voltages [V]
|
|
74
|
+
meanIsc = np.asarray(meanIsc) # mean Isc [A]
|
|
75
|
+
Imax = np.asarray(Imax) # max current [A]
|
|
76
|
+
|
|
77
|
+
# create array of currents optimally spaced from mean Isc to max VRBD
|
|
78
|
+
Ireverse = (Imax - meanIsc) * Imod_pts + meanIsc
|
|
79
|
+
Imin = np.minimum(Curr.min(), 0.) # minimum cell current, at most zero
|
|
80
|
+
# range of currents in forward bias from min current to mean Isc
|
|
81
|
+
Iforward = (Imin - meanIsc) * Imod_negpts + meanIsc
|
|
82
|
+
# create range for interpolation from forward to reverse bias
|
|
83
|
+
Itot = np.concatenate((Iforward, Ireverse), axis=0).flatten()
|
|
84
|
+
Vtot = np.zeros((2 * npts,))
|
|
85
|
+
|
|
86
|
+
# t0 = time.time()
|
|
87
|
+
# add up all series cell voltages
|
|
88
|
+
for i, v in zip(Curr, V):
|
|
89
|
+
# interp requires x, y to be sorted by x in increasing order
|
|
90
|
+
Vtot += pvconstants.npinterpx(Itot, np.flipud(i), np.flipud(v))
|
|
91
|
+
|
|
92
|
+
# Logic to check the shape of substr_bypass and ensure interpolations is done correctly
|
|
93
|
+
# Case 1 (Module): I, V, sb have same shape (n x npt)
|
|
94
|
+
# Case 2 (String): I, & V and sb have different dimensions (n x npt and m x n x npt)
|
|
95
|
+
if run_bpact:
|
|
96
|
+
if len(Curr.shape) == len(substr_bypass.shape):
|
|
97
|
+
bypassed_mod = []
|
|
98
|
+
for i, v, bypassed in zip(Curr, V, substr_bypass):
|
|
99
|
+
if ~bypassed.all():
|
|
100
|
+
bp_interp = bypassed[0]*np.ones(Itot.shape)
|
|
101
|
+
else:
|
|
102
|
+
interpolator = interp1d(np.flipud(i), np.flipud(bypassed),
|
|
103
|
+
kind='previous', fill_value='extrapolate')
|
|
104
|
+
bp_interp = interpolator(Itot)
|
|
105
|
+
bp_interp = bp_interp.astype(bool)
|
|
106
|
+
bypassed_mod.append(np.flipud(bp_interp))
|
|
107
|
+
bypassed_mod = np.asarray(bypassed_mod)
|
|
108
|
+
else:
|
|
109
|
+
bypassed_mod = np.zeros((Curr.shape[0], substr_bypass.shape[1], 2 * npts))
|
|
110
|
+
idx_mod = 0
|
|
111
|
+
for i, v, bypassed_strs in zip(Curr, V, substr_bypass):
|
|
112
|
+
for idx_substr in range(bypassed_strs.shape[0]):
|
|
113
|
+
bypassed = bypassed_strs[idx_substr, :]
|
|
114
|
+
if ~bypassed.all() or bypassed.all():
|
|
115
|
+
bp_interp = bypassed[0]*np.ones(Itot.shape)
|
|
116
|
+
else:
|
|
117
|
+
interpolator = interp1d(np.flipud(i), np.flipud(bypassed),
|
|
118
|
+
kind='previous', fill_value='extrapolate')
|
|
119
|
+
bp_interp = interpolator(Itot)
|
|
120
|
+
bp_interp = bp_interp.astype(bool)
|
|
121
|
+
bypassed_mod[idx_mod, idx_substr, :] = np.flipud(bp_interp)
|
|
122
|
+
idx_mod += 1
|
|
123
|
+
else:
|
|
124
|
+
bypassed_mod = np.nan
|
|
125
|
+
return np.flipud(Itot), np.flipud(Vtot), bypassed_mod
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def calcParallel(Curr, V, Vmax, Vmin, negpts, pts, npts):
|
|
129
|
+
"""
|
|
130
|
+
Calculate IV curve for cells and substrings in parallel.
|
|
131
|
+
|
|
132
|
+
:param Curr: currents [A]
|
|
133
|
+
:type: Curr: list, :class:`numpy.ndarray`
|
|
134
|
+
:param V: voltages [V]
|
|
135
|
+
:type: V: list, :class:`numpy.ndarray`
|
|
136
|
+
:param Vmax: max voltage limit, should be max Voc [V]
|
|
137
|
+
:param Vmin: min voltage limit, could be zero or Vrbd [V]
|
|
138
|
+
"""
|
|
139
|
+
Curr, V = np.asarray(Curr), np.asarray(V)
|
|
140
|
+
Vmax = np.asarray(Vmax)
|
|
141
|
+
Vmin = np.asarray(Vmin)
|
|
142
|
+
Vreverse = Vmin * negpts
|
|
143
|
+
Vforward = Vmax * pts
|
|
144
|
+
Vtot = np.concatenate((Vreverse, Vforward), axis=0).flatten()
|
|
145
|
+
Itot = np.zeros((2 * npts,))
|
|
146
|
+
for i, v in zip(Curr, V):
|
|
147
|
+
Itot += pvconstants.npinterpx(Vtot, v, i)
|
|
148
|
+
return Itot, Vtot
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def calcParallel_with_bypass(Curr, V, Vmax, Vmin, negpts, pts, npts, substr_bypass, run_bpact=True):
|
|
152
|
+
"""
|
|
153
|
+
Calculate IV curve for cells and substrings in parallel.
|
|
154
|
+
|
|
155
|
+
:param Curr: currents [A]
|
|
156
|
+
:type: Curr: list, :class:`numpy.ndarray`
|
|
157
|
+
:param V: voltages [V]
|
|
158
|
+
:type: V: list, :class:`numpy.ndarray`
|
|
159
|
+
:param Vmax: max voltage limit, should be max Voc [V]
|
|
160
|
+
:param Vmin: min voltage limit, could be zero or Vrbd [V]
|
|
161
|
+
"""
|
|
162
|
+
Curr, V = np.asarray(Curr), np.asarray(V)
|
|
163
|
+
Vmax = np.asarray(Vmax)
|
|
164
|
+
Vmin = np.asarray(Vmin)
|
|
165
|
+
Vreverse = Vmin * negpts
|
|
166
|
+
Vforward = Vmax * pts
|
|
167
|
+
Vtot = np.concatenate((Vreverse, Vforward), axis=0).flatten()
|
|
168
|
+
Itot = np.zeros((2 * npts,))
|
|
169
|
+
for i, v in zip(Curr, V):
|
|
170
|
+
Itot += pvconstants.npinterpx(Vtot, v, i)
|
|
171
|
+
|
|
172
|
+
if run_bpact:
|
|
173
|
+
if len(Curr.shape) == len(substr_bypass.shape):
|
|
174
|
+
bypassed_mod = []
|
|
175
|
+
for i, v, bypassed in zip(Curr, V, substr_bypass):
|
|
176
|
+
if ~bypassed.all():
|
|
177
|
+
bp_interp = bypassed[0]*np.ones(Vtot.shape)
|
|
178
|
+
else:
|
|
179
|
+
interpolator = interp1d(v, bypassed, kind='previous',
|
|
180
|
+
fill_value='extrapolate')
|
|
181
|
+
bp_interp = interpolator(Vtot)
|
|
182
|
+
bp_interp = bp_interp.astype(bool)
|
|
183
|
+
bypassed_mod.append(bp_interp)
|
|
184
|
+
bypassed_mod = np.asarray(bypassed_mod)
|
|
185
|
+
# bypassed_mod = interp2d_wrap(V, Vtot1, substr_bypass.astype(float), kind='previous')
|
|
186
|
+
# bypassed_mod = np.round(bypassed_mod).astype(bool)
|
|
187
|
+
else:
|
|
188
|
+
bypassed_mod = np.zeros((Curr.shape[0], substr_bypass.shape[1],
|
|
189
|
+
substr_bypass.shape[2], 2 * npts), dtype=bool)
|
|
190
|
+
idx_str = 0
|
|
191
|
+
for i, v, bypassed_strs in zip(Curr, V, substr_bypass):
|
|
192
|
+
idx_mod = 0
|
|
193
|
+
for idx_mod in range(bypassed_strs.shape[0]):
|
|
194
|
+
for idx_substr in range(bypassed_strs.shape[1]):
|
|
195
|
+
bypassed = bypassed_strs[idx_mod, idx_substr, :]
|
|
196
|
+
if ~bypassed.all() or bypassed.all():
|
|
197
|
+
bp_interp = bypassed[0]*np.ones(Vtot.shape)
|
|
198
|
+
else:
|
|
199
|
+
interpolator = interp1d(v, bypassed, kind='previous',
|
|
200
|
+
fill_value='extrapolate')
|
|
201
|
+
bp_interp = interpolator(Vtot)
|
|
202
|
+
bp_interp = bp_interp.astype(bool)
|
|
203
|
+
bypassed_mod[idx_str, idx_mod, idx_substr, :] = bp_interp
|
|
204
|
+
idx_mod += 1
|
|
205
|
+
idx_str += 1
|
|
206
|
+
else:
|
|
207
|
+
bypassed_mod = np.nan
|
|
208
|
+
|
|
209
|
+
return Itot, Vtot, bypassed_mod
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def combine_parallel_circuits(IVprev_cols, pvconst,
|
|
213
|
+
negpts, pts, Imod_pts, Imod_negpts, npts):
|
|
214
|
+
"""
|
|
215
|
+
Combine crosstied circuits in a substring.
|
|
216
|
+
|
|
217
|
+
:param IVprev_cols: lists of IV curves of crosstied and series circuits
|
|
218
|
+
:return:
|
|
219
|
+
"""
|
|
220
|
+
# combine crosstied circuits
|
|
221
|
+
Irows, Vrows = [], []
|
|
222
|
+
Isc_rows, Imax_rows = [], []
|
|
223
|
+
for IVcols in zip(*IVprev_cols):
|
|
224
|
+
Iparallel, Vparallel = zip(*IVcols)
|
|
225
|
+
Iparallel = np.asarray(Iparallel)
|
|
226
|
+
Vparallel = np.asarray(Vparallel)
|
|
227
|
+
Irow, Vrow = calcParallel(
|
|
228
|
+
Iparallel, Vparallel, Vparallel.max(),
|
|
229
|
+
Vparallel.min(), negpts, pts, npts
|
|
230
|
+
)
|
|
231
|
+
Irows.append(Irow)
|
|
232
|
+
Vrows.append(Vrow)
|
|
233
|
+
Isc_rows.append(np.interp(np.float64(0), Vrow, Irow))
|
|
234
|
+
Imax_rows.append(Irow.max())
|
|
235
|
+
Irows, Vrows = np.asarray(Irows), np.asarray(Vrows)
|
|
236
|
+
Isc_rows = np.asarray(Isc_rows)
|
|
237
|
+
Imax_rows = np.asarray(Imax_rows)
|
|
238
|
+
return calcSeries(
|
|
239
|
+
Irows, Vrows, Isc_rows.mean(), Imax_rows.max(),
|
|
240
|
+
Imod_pts, Imod_negpts, npts
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def parse_diode_config(Vbypass, cell_pos):
|
|
245
|
+
"""
|
|
246
|
+
Parse diode configuration from the Vbypass argument.
|
|
247
|
+
|
|
248
|
+
:param Vbypass: Vbypass config
|
|
249
|
+
:type Vbypass: float|list|tuple
|
|
250
|
+
:param cell_pos:
|
|
251
|
+
:type cell_pos:
|
|
252
|
+
:return: bypass config
|
|
253
|
+
:rtype: str
|
|
254
|
+
"""
|
|
255
|
+
try:
|
|
256
|
+
# check if float or list/tuple
|
|
257
|
+
num_bypass = len(Vbypass)
|
|
258
|
+
except TypeError:
|
|
259
|
+
# float passed - default case - Vbypass across every cell string
|
|
260
|
+
return DEFAULT_BYPASS
|
|
261
|
+
else:
|
|
262
|
+
# if only one value is passed in the list- assume only one
|
|
263
|
+
# bypass diode across the PV module
|
|
264
|
+
if len(Vbypass) == 1:
|
|
265
|
+
return MODULE_BYPASS
|
|
266
|
+
# if more than 1 values are passed, apply them across
|
|
267
|
+
# the cell strings in ascending order
|
|
268
|
+
elif len(cell_pos) == num_bypass:
|
|
269
|
+
return CUSTOM_SUBSTR_BYPASS
|
|
270
|
+
else:
|
|
271
|
+
print("wrong number of bypass diode values passed : %d" %
|
|
272
|
+
(len(Vbypass)))
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
This is the PVMismatch Library. Configuration constants and classes like
|
|
4
|
+
:class:`~pvmismatch.pvmismatch_lib.pvconstants.PVconstants`,
|
|
5
|
+
:class:`~pvmismatch.pvmismatch_lib.pvcell.PVcell`,
|
|
6
|
+
:class:`~pvmismatch.pvmismatch_lib.pvmodule.PVmodule`,
|
|
7
|
+
:class:`~pvmismatch.pvmismatch_lib.pvstring.PVstring` and
|
|
8
|
+
:class:`~pvmismatch.pvmismatch_lib.pvsystem.PVsystem`, objects are all defined
|
|
9
|
+
here.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from v_PVMismatch.pvmismatch import pvconstants, pvexceptions, pvcell, pvmodule, pvstring, pvsystem
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
This module contains the :class:`~pvmismatch.pvmismatch_lib.pvcell.PVcell`
|
|
5
|
+
object which is used by modules, strings and systems.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import absolute_import
|
|
9
|
+
from future.utils import iteritems
|
|
10
|
+
from pvmismatch.pvmismatch_lib.pvconstants import PVconstants
|
|
11
|
+
import numpy as np
|
|
12
|
+
from matplotlib import pyplot as plt
|
|
13
|
+
from scipy.optimize import newton
|
|
14
|
+
|
|
15
|
+
# Defaults
|
|
16
|
+
RS = 0.004267236774264931 # [ohm] series resistance
|
|
17
|
+
RSH = 10.01226369025448 # [ohm] shunt resistance
|
|
18
|
+
ISAT1_T0 = 2.286188161253440E-11 # [A] diode one saturation current
|
|
19
|
+
ISAT2_T0 = 1.117455042372326E-6 # [A] diode two saturation current
|
|
20
|
+
ISC0_T0 = 6.3056 # [A] reference short circuit current
|
|
21
|
+
TCELL = 298.15 # [K] cell temperature
|
|
22
|
+
ARBD = 1.036748445065697E-4 # reverse breakdown coefficient 1
|
|
23
|
+
BRBD = 0. # reverse breakdown coefficient 2
|
|
24
|
+
VRBD_ = -5.527260068445654 # [V] reverse breakdown voltage
|
|
25
|
+
NRBD = 3.284628553041425 # reverse breakdown exponent
|
|
26
|
+
EG = 1.1 # [eV] band gap of cSi
|
|
27
|
+
ALPHA_ISC = 0.0003551 # [1/K] short circuit current temperature coefficient
|
|
28
|
+
EPS = np.finfo(np.float64).eps
|
|
29
|
+
|
|
30
|
+
class PVcell(object):
|
|
31
|
+
"""
|
|
32
|
+
Class for PV cells.
|
|
33
|
+
|
|
34
|
+
:param Rs: series resistance [ohms]
|
|
35
|
+
:param Rsh: shunt resistance [ohms]
|
|
36
|
+
:param Isat1_T0: first saturation diode current at ref temp [A]
|
|
37
|
+
:param Isat2_T0: second saturation diode current [A]
|
|
38
|
+
:param Isc0_T0: short circuit current at ref temp [A]
|
|
39
|
+
:param aRBD: reverse breakdown coefficient 1
|
|
40
|
+
:param bRBD: reverse breakdown coefficient 2
|
|
41
|
+
:param VRBD: reverse breakdown voltage [V]
|
|
42
|
+
:param nRBD: reverse breakdown exponent
|
|
43
|
+
:param Eg: band gap [eV]
|
|
44
|
+
:param alpha_Isc: short circuit current temp coeff [1/K]
|
|
45
|
+
:param Tcell: cell temperature [K]
|
|
46
|
+
:param Ee: incident effective irradiance [suns]
|
|
47
|
+
:param pvconst: configuration constants object
|
|
48
|
+
:type pvconst: :class:`~pvmismatch.pvmismatch_lib.pvconstants.PVconstants`
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
_calc_now = False #: if True ``calcCells()`` is called in ``__setattr__``
|
|
52
|
+
|
|
53
|
+
def __init__(self, Rs=RS, Rsh=RSH, Isat1_T0=ISAT1_T0, Isat2_T0=ISAT2_T0,
|
|
54
|
+
Isc0_T0=ISC0_T0, aRBD=ARBD, bRBD=BRBD, VRBD=VRBD_,
|
|
55
|
+
nRBD=NRBD, Eg=EG, alpha_Isc=ALPHA_ISC,
|
|
56
|
+
Tcell=TCELL, Ee=1., pvconst=PVconstants()):
|
|
57
|
+
# user inputs
|
|
58
|
+
self.Rs = Rs #: [ohm] series resistance
|
|
59
|
+
self.Rsh = Rsh #: [ohm] shunt resistance
|
|
60
|
+
self.Isat1_T0 = Isat1_T0 #: [A] diode one sat. current at T0
|
|
61
|
+
self.Isat2_T0 = Isat2_T0 #: [A] diode two saturation current
|
|
62
|
+
self.Isc0_T0 = Isc0_T0 #: [A] short circuit current at T0
|
|
63
|
+
self.aRBD = aRBD #: reverse breakdown coefficient 1
|
|
64
|
+
self.bRBD = bRBD #: reverse breakdown coefficient 2
|
|
65
|
+
self.VRBD = VRBD #: [V] reverse breakdown voltage
|
|
66
|
+
self.nRBD = nRBD #: reverse breakdown exponent
|
|
67
|
+
self.Eg = Eg #: [eV] band gap of cSi
|
|
68
|
+
self.alpha_Isc = alpha_Isc #: [1/K] short circuit temp. coeff.
|
|
69
|
+
self.Tcell = Tcell #: [K] cell temperature
|
|
70
|
+
self.Ee = Ee #: [suns] incident effective irradiance on cell
|
|
71
|
+
self.pvconst = pvconst #: configuration constants
|
|
72
|
+
self.Icell = None #: cell currents on IV curve [A]
|
|
73
|
+
self.Vcell = None #: cell voltages on IV curve [V]
|
|
74
|
+
self.Pcell = None #: cell power on IV curve [W]
|
|
75
|
+
self.VocSTC = self._VocSTC() #: estimated Voc at STC [V]
|
|
76
|
+
# set calculation flag
|
|
77
|
+
self._calc_now = True # overwrites the class attribute
|
|
78
|
+
|
|
79
|
+
def __str__(self):
|
|
80
|
+
fmt = '<PVcell(Ee=%g[suns], Tcell=%g[K], Isc=%g[A], Voc=%g[V])>'
|
|
81
|
+
return fmt % (self.Ee, self.Tcell, self.Isc, self.Voc)
|
|
82
|
+
|
|
83
|
+
def __repr__(self):
|
|
84
|
+
return str(self)
|
|
85
|
+
|
|
86
|
+
def __setattr__(self, key, value):
|
|
87
|
+
# check for floats
|
|
88
|
+
try:
|
|
89
|
+
value = np.float64(value)
|
|
90
|
+
except (TypeError, ValueError):
|
|
91
|
+
pass # fail silently if not float, eg: pvconst or _calc_now
|
|
92
|
+
super(PVcell, self).__setattr__(key, value)
|
|
93
|
+
# recalculate IV curve
|
|
94
|
+
if self._calc_now:
|
|
95
|
+
Icell, Vcell, Pcell = self.calcCell()
|
|
96
|
+
self.__dict__.update(Icell=Icell, Vcell=Vcell, Pcell=Pcell)
|
|
97
|
+
|
|
98
|
+
def update(self, **kwargs):
|
|
99
|
+
"""
|
|
100
|
+
Update user-defined constants.
|
|
101
|
+
"""
|
|
102
|
+
# turn off calculation flag until all attributes are updated
|
|
103
|
+
self._calc_now = False
|
|
104
|
+
# don't use __dict__.update() instead use setattr() to go through
|
|
105
|
+
# custom __setattr__() so that numbers are cast to floats
|
|
106
|
+
for k, v in iteritems(kwargs):
|
|
107
|
+
setattr(self, k, v)
|
|
108
|
+
self._calc_now = True # recalculate
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def Vt(self):
|
|
112
|
+
"""
|
|
113
|
+
Thermal voltage in volts.
|
|
114
|
+
"""
|
|
115
|
+
return self.pvconst.k * self.Tcell / self.pvconst.q
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def Isc(self):
|
|
119
|
+
return self.Ee * self.Isc0
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
def Aph(self):
|
|
123
|
+
"""
|
|
124
|
+
Photogenerated current coefficient, non-dimensional.
|
|
125
|
+
"""
|
|
126
|
+
# Aph is undefined (0/0) if there is no irradiance
|
|
127
|
+
if self.Isc == 0: return np.nan
|
|
128
|
+
# short current (SC) conditions (Vcell = 0)
|
|
129
|
+
Vdiode_sc = self.Isc * self.Rs # diode voltage at SC
|
|
130
|
+
Idiode1_sc = self.Isat1 * (np.exp(Vdiode_sc / self.Vt) - 1.)
|
|
131
|
+
Idiode2_sc = self.Isat2 * (np.exp(Vdiode_sc / 2. / self.Vt) - 1.)
|
|
132
|
+
Ishunt_sc = Vdiode_sc / self.Rsh # diode voltage at SC
|
|
133
|
+
# photogenerated current coefficient
|
|
134
|
+
return 1. + (Idiode1_sc + Idiode2_sc + Ishunt_sc) / self.Isc
|
|
135
|
+
|
|
136
|
+
@property
|
|
137
|
+
def Isat1(self):
|
|
138
|
+
"""
|
|
139
|
+
Diode one saturation current at Tcell in amps.
|
|
140
|
+
"""
|
|
141
|
+
_Tstar = self.Tcell ** 3. / self.pvconst.T0 ** 3. # scaled temperature
|
|
142
|
+
_inv_delta_T = 1. / self.pvconst.T0 - 1. / self.Tcell # [1/K]
|
|
143
|
+
_expTstar = np.exp(
|
|
144
|
+
self.Eg * self.pvconst.q / self.pvconst.k * _inv_delta_T
|
|
145
|
+
)
|
|
146
|
+
return self.Isat1_T0 * _Tstar * _expTstar # [A] Isat1(Tcell)
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def Isat2(self):
|
|
150
|
+
"""
|
|
151
|
+
Diode two saturation current at Tcell in amps.
|
|
152
|
+
"""
|
|
153
|
+
_Tstar = self.Tcell ** 3. / self.pvconst.T0 ** 3. # scaled temperature
|
|
154
|
+
_inv_delta_T = 1. / self.pvconst.T0 - 1. / self.Tcell # [1/K]
|
|
155
|
+
_expTstar = np.exp(
|
|
156
|
+
self.Eg * self.pvconst.q / (2.0 * self.pvconst.k) * _inv_delta_T
|
|
157
|
+
)
|
|
158
|
+
return self.Isat2_T0 * _Tstar * _expTstar # [A] Isat2(Tcell)
|
|
159
|
+
|
|
160
|
+
@property
|
|
161
|
+
def Isc0(self):
|
|
162
|
+
"""
|
|
163
|
+
Short circuit current at Tcell in amps.
|
|
164
|
+
"""
|
|
165
|
+
_delta_T = self.Tcell - self.pvconst.T0 # [K] temperature difference
|
|
166
|
+
return self.Isc0_T0 * (1. + self.alpha_Isc * _delta_T) # [A] Isc0
|
|
167
|
+
|
|
168
|
+
@property
|
|
169
|
+
def Voc(self):
|
|
170
|
+
"""
|
|
171
|
+
Estimate open circuit voltage of cells.
|
|
172
|
+
Returns Voc : numpy.ndarray of float, estimated open circuit voltage
|
|
173
|
+
"""
|
|
174
|
+
C = self.Aph * self.Isc + self.Isat1 + self.Isat2
|
|
175
|
+
delta = self.Isat2 ** 2. + 4. * self.Isat1 * C
|
|
176
|
+
return self.Vt * np.log(
|
|
177
|
+
((-self.Isat2 + np.sqrt(delta)) / 2. / self.Isat1) ** 2.
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
def _VocSTC(self):
|
|
181
|
+
"""
|
|
182
|
+
Estimate open circuit voltage of cells.
|
|
183
|
+
Returns Voc : numpy.ndarray of float, estimated open circuit voltage
|
|
184
|
+
"""
|
|
185
|
+
Vdiode_sc = self.Isc0_T0 * self.Rs # diode voltage at SC
|
|
186
|
+
Idiode1_sc = self.Isat1_T0 * (np.exp(Vdiode_sc / self.Vt) - 1.)
|
|
187
|
+
Idiode2_sc = self.Isat2_T0 * (np.exp(Vdiode_sc / 2. / self.Vt) - 1.)
|
|
188
|
+
Ishunt_sc = Vdiode_sc / self.Rsh # diode voltage at SC
|
|
189
|
+
# photogenerated current coefficient
|
|
190
|
+
Aph = 1. + (Idiode1_sc + Idiode2_sc + Ishunt_sc) / self.Isc0_T0
|
|
191
|
+
# estimated Voc at STC
|
|
192
|
+
C = Aph * self.Isc0_T0 + self.Isat1_T0 + self.Isat2_T0
|
|
193
|
+
delta = self.Isat2_T0 ** 2. + 4. * self.Isat1_T0 * C
|
|
194
|
+
return self.Vt * np.log(
|
|
195
|
+
((-self.Isat2_T0 + np.sqrt(delta)) / 2. / self.Isat1_T0) ** 2.
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
@property
|
|
199
|
+
def Igen(self):
|
|
200
|
+
"""
|
|
201
|
+
Photovoltaic generated light current (AKA IL or Iph)
|
|
202
|
+
Returns Igen : numpy.ndarray of float, PV generated light current [A]
|
|
203
|
+
|
|
204
|
+
Photovoltaic generated light current is zero if irradiance is zero.
|
|
205
|
+
"""
|
|
206
|
+
if self.Ee == 0: return 0
|
|
207
|
+
return self.Aph * self.Isc
|
|
208
|
+
|
|
209
|
+
def calcCell(self):
|
|
210
|
+
"""
|
|
211
|
+
Calculate cell I-V curves.
|
|
212
|
+
Returns (Icell, Vcell, Pcell) : tuple of numpy.ndarray of float
|
|
213
|
+
"""
|
|
214
|
+
Vreverse = self.VRBD * self.pvconst.negpts
|
|
215
|
+
Vff = self.Voc
|
|
216
|
+
delta_Voc = self.VocSTC - self.Voc
|
|
217
|
+
# to make sure that the max voltage is always in the 4th quadrant, add
|
|
218
|
+
# a third set of points log spaced with decreasing density, from Voc to
|
|
219
|
+
# Voc @ STC unless Voc *is* Voc @ STC, then use an arbitrary voltage at
|
|
220
|
+
# 80% of Voc as an estimate of Vmp assuming a fill factor of 80% and
|
|
221
|
+
# Isc close to Imp, or if Voc > Voc @ STC, then use Voc as the max
|
|
222
|
+
if delta_Voc == 0:
|
|
223
|
+
Vff = 0.8 * self.Voc
|
|
224
|
+
delta_Voc = 0.2 * self.Voc
|
|
225
|
+
elif delta_Voc < 0:
|
|
226
|
+
Vff = self.VocSTC
|
|
227
|
+
delta_Voc = -delta_Voc
|
|
228
|
+
Vquad4 = Vff + delta_Voc * self.pvconst.Vmod_q4pts
|
|
229
|
+
Vforward = Vff * self.pvconst.pts
|
|
230
|
+
Vdiode = np.concatenate((Vreverse, Vforward, Vquad4), axis=0)
|
|
231
|
+
Idiode1 = self.Isat1 * (np.exp(Vdiode / self.Vt) - 1.)
|
|
232
|
+
Idiode2 = self.Isat2 * (np.exp(Vdiode / 2. / self.Vt) - 1.)
|
|
233
|
+
Ishunt = Vdiode / self.Rsh
|
|
234
|
+
fRBD = 1. - Vdiode / self.VRBD
|
|
235
|
+
# use epsilon = 2.2204460492503131e-16 to avoid "divide by zero"
|
|
236
|
+
fRBD[fRBD == 0] = EPS
|
|
237
|
+
Vdiode_norm = Vdiode / self.Rsh / self.Isc0_T0
|
|
238
|
+
fRBD = self.Isc0_T0 * fRBD ** (-self.nRBD)
|
|
239
|
+
IRBD = (self.aRBD * Vdiode_norm + self.bRBD * Vdiode_norm ** 2) * fRBD
|
|
240
|
+
Icell = self.Igen - Idiode1 - Idiode2 - Ishunt - IRBD
|
|
241
|
+
Vcell = Vdiode - Icell * self.Rs
|
|
242
|
+
Pcell = Icell * Vcell
|
|
243
|
+
return Icell, Vcell, Pcell
|
|
244
|
+
|
|
245
|
+
# diode model
|
|
246
|
+
# *-->--*--->---*--Rs->-Icell--+
|
|
247
|
+
# ^ | | ^
|
|
248
|
+
# | | | |
|
|
249
|
+
# Igen Idiode Ishunt Vcell
|
|
250
|
+
# | | | |
|
|
251
|
+
# | v v v
|
|
252
|
+
# *--<--*---<---*--<-----------=
|
|
253
|
+
# http://en.wikipedia.org/wiki/Diode_modelling#Shockley_diode_model
|
|
254
|
+
# http://en.wikipedia.org/wiki/Diode#Shockley_diode_equation
|
|
255
|
+
# http://en.wikipedia.org/wiki/William_Shockley
|
|
256
|
+
|
|
257
|
+
@staticmethod
|
|
258
|
+
def f_Icell(Icell, Vcell, Igen, Rs, Vt, Isat1, Isat2, Rsh):
|
|
259
|
+
"""
|
|
260
|
+
Objective function for Icell.
|
|
261
|
+
:param Icell: cell current [A]
|
|
262
|
+
:param Vcell: cell voltage [V]
|
|
263
|
+
:param Igen: photogenerated current at Tcell and Ee [A]
|
|
264
|
+
:param Rs: series resistance [ohms]
|
|
265
|
+
:param Vt: thermal voltage [V]
|
|
266
|
+
:param Isat1: first diode saturation current at Tcell [A]
|
|
267
|
+
:param Isat2: second diode saturation current [A]
|
|
268
|
+
:param Rsh: shunt resistance [ohms]
|
|
269
|
+
:return: residual = (Icell - Icell0) [A]
|
|
270
|
+
"""
|
|
271
|
+
# arbitrary current condition
|
|
272
|
+
Vdiode = Vcell + Icell * Rs # diode voltage
|
|
273
|
+
Idiode1 = Isat1 * (np.exp(Vdiode / Vt) - 1.) # diode current
|
|
274
|
+
Idiode2 = Isat2 * (np.exp(Vdiode / 2. / Vt) - 1.) # diode current
|
|
275
|
+
Ishunt = Vdiode / Rsh # shunt current
|
|
276
|
+
return Igen - Idiode1 - Idiode2 - Ishunt - Icell
|
|
277
|
+
|
|
278
|
+
def calcIcell(self, Vcell):
|
|
279
|
+
"""
|
|
280
|
+
Calculate Icell as a function of Vcell.
|
|
281
|
+
:param Vcell: cell voltage [V]
|
|
282
|
+
:return: Icell
|
|
283
|
+
"""
|
|
284
|
+
args = (np.float64(Vcell), self.Igen, self.Rs, self.Vt,
|
|
285
|
+
self.Isat1, self.Isat2, self.Rsh)
|
|
286
|
+
return newton(self.f_Icell, x0=self.Isc, args=args)
|
|
287
|
+
|
|
288
|
+
@staticmethod
|
|
289
|
+
def f_Vcell(Vcell, Icell, Igen, Rs, Vt, Isat1, Isat2, Rsh):
|
|
290
|
+
return PVcell.f_Icell(Icell, Vcell, Igen, Rs, Vt, Isat1, Isat2, Rsh)
|
|
291
|
+
|
|
292
|
+
def calcVcell(self, Icell):
|
|
293
|
+
"""
|
|
294
|
+
Calculate Vcell as a function of Icell.
|
|
295
|
+
:param Icell: cell current [A]
|
|
296
|
+
:return: Vcell
|
|
297
|
+
"""
|
|
298
|
+
args = (np.float64(Icell), self.Igen, self.Rs, self.Vt,
|
|
299
|
+
self.Isat1, self.Isat2, self.Rsh)
|
|
300
|
+
return newton(self.f_Vcell, x0=self.Voc, args=args)
|
|
301
|
+
|
|
302
|
+
def plot(self):
|
|
303
|
+
"""
|
|
304
|
+
Plot cell I-V curve.
|
|
305
|
+
Returns cellPlot : matplotlib.pyplot figure
|
|
306
|
+
"""
|
|
307
|
+
cell_plot = plt.figure()
|
|
308
|
+
plt.subplot(2, 2, 1)
|
|
309
|
+
plt.plot(self.Vcell, self.Icell)
|
|
310
|
+
plt.title('Cell Reverse I-V Characteristics')
|
|
311
|
+
plt.ylabel('Cell Current, I [A]')
|
|
312
|
+
plt.xlim(self.VRBD - 1, 0)
|
|
313
|
+
plt.ylim(0, self.Isc + 10)
|
|
314
|
+
plt.grid()
|
|
315
|
+
plt.subplot(2, 2, 2)
|
|
316
|
+
plt.plot(self.Vcell, self.Icell)
|
|
317
|
+
plt.title('Cell Forward I-V Characteristics')
|
|
318
|
+
plt.ylabel('Cell Current, I [A]')
|
|
319
|
+
plt.xlim(0, self.Voc)
|
|
320
|
+
plt.ylim(0, self.Isc + 1)
|
|
321
|
+
plt.grid()
|
|
322
|
+
plt.subplot(2, 2, 3)
|
|
323
|
+
plt.plot(self.Vcell, self.Pcell)
|
|
324
|
+
plt.title('Cell Reverse P-V Characteristics')
|
|
325
|
+
plt.xlabel('Cell Voltage, V [V]')
|
|
326
|
+
plt.ylabel('Cell Power, P [W]')
|
|
327
|
+
plt.xlim(self.VRBD - 1, 0)
|
|
328
|
+
plt.ylim((self.Isc + 10) * (self.VRBD - 1), -1)
|
|
329
|
+
plt.grid()
|
|
330
|
+
plt.subplot(2, 2, 4)
|
|
331
|
+
plt.plot(self.Vcell, self.Pcell)
|
|
332
|
+
plt.title('Cell Forward P-V Characteristics')
|
|
333
|
+
plt.xlabel('Cell Voltage, V [V]')
|
|
334
|
+
plt.ylabel('Cell Power, P [W]')
|
|
335
|
+
plt.xlim(0, self.Voc)
|
|
336
|
+
plt.ylim(0, (self.Isc + 1) * self.Voc)
|
|
337
|
+
plt.grid()
|
|
338
|
+
plt.tight_layout()
|
|
339
|
+
return cell_plot
|