Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ENH: Port PVsyst and Desoto parameter estimation from MATLAB #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 148 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
c00d419
ENH: porting pvsyst and single diode param est
Aug 1, 2016
e3d8235
change function name from est_single_diode_params
mikofski Oct 4, 2018
99d2f3f
use int indices, make docstring, test still fails
mikofski May 4, 2019
55d1c0b
isolate iv fitting and parameter generation
mikofski May 4, 2019
857d896
TST: schumaker test is passing! Yoohoo!
mikofski May 4, 2019
0433136
TST: fix imports and path to test data
mikofski May 4, 2019
1d418dd
fix Io test sortof, some stickler
mikofski May 4, 2019
1a055e7
Merge branch 'master' into pvsyst_parameter_estimation
mikofski Dec 4, 2019
a1bdf55
fix tests, merge ivtools
mikofski Dec 5, 2019
b886dc8
fixing test_PVsyst_parameter_estimation
mikofski Dec 5, 2019
db58d39
include statsmodels and mpl in ci/conda-envs
mikofski Dec 5, 2019
f19f1de
stickler fixes, long lines, code tweaks
mikofski Dec 5, 2019
2875438
rename update io and rsh tests so they run
mikofski Dec 5, 2019
5252c8a
concise indexing in Schumaker QSpline
mikofski Dec 5, 2019
38ee9b8
add test for numdiff
mikofski Dec 5, 2019
90bb48b
move pvsyst parameter estimation tests
mikofski Dec 5, 2019
4e27551
use maximum not max in estRsh
mikofski Dec 5, 2019
2faed73
fudge tolerance for pvsyst_parameter_estimation for fun
mikofski Dec 5, 2019
aa1210b
restrict pvsyst estimation test to first 3000 points
mikofski Dec 5, 2019
b59227e
rename pvsyst parameter estimation tests folder
mikofski Dec 5, 2019
de85d38
move test_numdiff inside test_pvsyst_parameter_estimation.py
mikofski Dec 5, 2019
82d452d
add requires_scipy to update_io_know_n tests
mikofski Dec 6, 2019
d6622f5
pycodestyle passing, rm xtra sp, fix indent
mikofski Dec 6, 2019
18e2cb6
shuffle functions into different modules. Rename to fit_sdX_ pattern
cwhanse Dec 9, 2019
9268fe8
fix import names
cwhanse Dec 9, 2019
836a9b5
fix import in ivtools
mikofski Dec 9, 2019
edf872c
refactor deux: rm old files
mikofski Dec 17, 2019
8b2d102
remove old pvsyst parma estimation tests
mikofski Dec 17, 2019
d9abba1
stickler fixes
mikofski Dec 17, 2019
1508b1d
Merge branch 'master' into pvsyst_parameter_estimation
mikofski Dec 17, 2019
152dd24
Merge branch 'master' into pvsyst_parameter_estimation
mikofski Dec 17, 2019
9b56560
using lambertw requires scipy in tests
mikofski Dec 17, 2019
a7dfe45
align with scipy.intepolate pattern
cwhanse Dec 18, 2019
8d67a97
refactor fit_sde_cocontent, change argument order
cwhanse Dec 18, 2019
780db42
stickler
cwhanse Dec 18, 2019
5207c60
fix argument order in fit_pvsyst_sandia
cwhanse Dec 19, 2019
b5270da
fix rectify function, add test
cwhanse Dec 20, 2019
47e4465
stickler
cwhanse Dec 20, 2019
1e1496c
corrections, add rcond=None
cwhanse Dec 20, 2019
98bcc25
more corrections
cwhanse Dec 20, 2019
a9c908d
undo change in rs, rsh order
cwhanse Dec 20, 2019
b2cbb11
fix test for rectify_iv_curve, use np.expm1
cwhanse Dec 20, 2019
2e973fe
exclude curve #2540
cwhanse Dec 20, 2019
383a1f8
fix expected outcome for test_rectify_
cwhanse Dec 20, 2019
e22942f
messed up csv
cwhanse Dec 20, 2019
1484e39
exclude curve #2540
cwhanse Dec 20, 2019
7f90f26
correct rounding for test_rectify_
cwhanse Dec 23, 2019
9c00ac8
move exclude to line 2540 was on 2536
cwhanse Dec 23, 2019
d52dade
create exclude mask for individual curves
cwhanse Dec 23, 2019
f934275
use umask
cwhanse Dec 23, 2019
ed378ac
helper functions, some streamlining
cwhanse Dec 23, 2019
41ca062
rename _update_io_known_n
cwhanse Dec 23, 2019
de1b493
docstring improvements
cwhanse Dec 24, 2019
e202506
split _calc_theta_phi_exact, overhaul tests
cwhanse Dec 24, 2019
d3baff3
remove unused lines
cwhanse Dec 25, 2019
08a5627
stickler
cwhanse Dec 25, 2019
a8059cb
remove test_ivtools.py
cwhanse Dec 25, 2019
9fc68b5
renaming, update api.rst
cwhanse Dec 25, 2019
e1544a3
update name
cwhanse Dec 25, 2019
0626805
improve _update_rsh_fixed_pt
cwhanse Dec 26, 2019
fdc0e66
fix typo
cwhanse Dec 26, 2019
8465bc0
fix error
cwhanse Dec 26, 2019
82669f4
correct convergence in _update_rsh_fixed_pt
cwhanse Dec 30, 2019
027f2ee
flake8
cwhanse Dec 30, 2019
5e7cc77
docstring for fit_sdm
cwhanse Jan 1, 2020
6ae5927
docstring for fit_sdm
cwhanse Jan 1, 2020
0a6fcab
docstring for fit_sdm
cwhanse Jan 1, 2020
317b92c
docstring for fit_sdm
cwhanse Jan 2, 2020
385a14b
docstring for fit_sde, utility
cwhanse Jan 2, 2020
0f7fab2
update api.rst
cwhanse Jan 2, 2020
11c98e5
add helper to deal with numpy<1.14
cwhanse Jan 2, 2020
291e086
fix workaround for numpy version
cwhanse Jan 2, 2020
4e80ea1
rename modules and functions, move tests to ivtools/test
cwhanse Jan 17, 2020
a9a4b7a
merge master, fix conflict
cwhanse Jan 17, 2020
0450815
fix merge conflicts, contains duplicated files
cwhanse Jan 17, 2020
d547521
move tests from ivtools/test to pvlib/tests/ivtools
cwhanse Jan 17, 2020
e98652e
remove old test folder
cwhanse Jan 17, 2020
f5351a9
remove old pvlib/test folder
cwhanse Jan 17, 2020
6a413d2
name correction, remove old test files
cwhanse Jan 17, 2020
6fe3c33
fix test, move test_fit_sde_cocontent into test_sde
cwhanse Jan 19, 2020
9f2e474
move test_schumaker_qspline to test_utility
cwhanse Jan 19, 2020
104052b
docstring work
cwhanse Jan 19, 2020
4392f70
resolve conflict
cwhanse Jan 19, 2020
ab31257
docstring work
cwhanse Jan 19, 2020
6c7c071
test corrections
cwhanse Jan 19, 2020
8d1b8b0
fix order in parametrize
cwhanse Jan 20, 2020
5e18986
one comma
cwhanse Jan 20, 2020
f08e1f6
corrections
cwhanse Jan 20, 2020
ea6a157
remove old files, update api.rst
cwhanse Jan 20, 2020
f7911fc
update names in ivtools\__init__.py
cwhanse Jan 20, 2020
488726d
docstring work, rename outputs from fit_pvsyst_sandia to be consisten…
cwhanse Jan 20, 2020
949aad7
docstring work, use cells_in_series throughout
cwhanse Jan 20, 2020
499ff7b
docstring work, use mu_gamma instead of mugamma
cwhanse Jan 20, 2020
a1ddcf9
missed one
cwhanse Jan 20, 2020
09127c6
sort of Rs vs R_s vs R_s_ref
cwhanse Jan 21, 2020
27e4200
refactor to prepare for adding desoto, cec estimation; remove logging
cwhanse Jan 22, 2020
0e4485b
merge
cwhanse Jan 22, 2020
f5b7ee4
add fit_desoto_sandia
cwhanse Jan 22, 2020
182f95b
correct argument order, lint
cwhanse Jan 22, 2020
987257d
change to pvlib-consistent key names
cwhanse Jan 22, 2020
37ee5d9
add test for fit_desoto_sandia
cwhanse Jan 22, 2020
d4c1950
corrections
cwhanse Jan 22, 2020
a2423e5
more corrections
cwhanse Jan 22, 2020
59f69be
use canonical order iph, io, rs, rsh, n
cwhanse Jan 23, 2020
15d4d6b
convert update_rsh test, move to test_sdm.py
cwhanse Jan 23, 2020
e168ead
fix update_rsh tests, improve function
cwhanse Jan 23, 2020
e605483
remove old update_rsh test file
cwhanse Jan 23, 2020
a33fed7
convert tests for _update_io
cwhanse Jan 23, 2020
9f8a0e1
remove old tests for _update_io
cwhanse Jan 23, 2020
64a51c1
convert tests for calc_theta_phi
cwhanse Jan 23, 2020
89d6442
remove old test for calc_theta
cwhanse Jan 23, 2020
6c45599
take care of float div by 0 test failures
cwhanse Jan 23, 2020
579b80d
move sde functions to canonical argument order
cwhanse Jan 23, 2020
d5ace89
fix bugs
cwhanse Jan 23, 2020
88c8995
more raid for bugs
cwhanse Jan 23, 2020
cad323b
die bugs die
cwhanse Jan 24, 2020
20b7e6d
maintain order of variables in the text file
cwhanse Jan 24, 2020
64a9fe5
test repair
cwhanse Jan 26, 2020
d44dbe7
minor editing
cwhanse Jan 26, 2020
83a2c30
pin pysam version to 1.2.1
cwhanse Jan 28, 2020
d0aed99
pysam to current version, patch over numpy 1.14 change
cwhanse Jan 28, 2020
22e8b7e
module docstring
cwhanse May 4, 2020
bb2af7e
Merge branch 'pvsyst_parameter_estimation' of https://github.com/miko…
cwhanse May 4, 2020
0f9896a
Merge remote-tracking branch 'upstream/master' into pvsyst_parameter_…
cwhanse May 4, 2020
d3a52e3
remove ivtools.py
cwhanse May 4, 2020
adb8290
separate sam_estimate_failure into its own function
cwhanse May 4, 2020
5bd14c7
Merge branch 'master' of https://github.com/pvlib/pvlib-python into p…
cwhanse Jun 10, 2020
157c2ab
Merge branch 'master' of https://github.com/pvlib/pvlib-python into p…
cwhanse Aug 24, 2020
a5d5ffa
fix stickler
cwhanse Aug 24, 2020
f46287e
'mispelling'
cwhanse Aug 24, 2020
c8b4b00
fix error in _calc_I0
cwhanse Aug 25, 2020
eea759b
more fixing of that error
cwhanse Aug 25, 2020
fa8d8a6
improvements from review
cwhanse Aug 25, 2020
944c16b
another fix for mistake in _calc_I0
cwhanse Aug 25, 2020
eb8d986
docstring edits
cwhanse Aug 25, 2020
8cc8249
improve coverage
cwhanse Aug 26, 2020
fce9b04
tpo
cwhanse Aug 26, 2020
b548f63
use the correct error Class
cwhanse Aug 26, 2020
df7520e
improvements from review
cwhanse Aug 27, 2020
cad96ef
changes from review: helper functions for test, _numdiff and _schum p…
cwhanse Aug 28, 2020
4831cfd
whatsnew
cwhanse Aug 28, 2020
83308a3
Merge branch 'master' of https://github.com/pvlib/pvlib-python into p…
cwhanse Aug 28, 2020
a1dc575
add renamed and moved data files
cwhanse Aug 28, 2020
ab4f99b
use pathlib.Path.open()
cwhanse Aug 28, 2020
cad3949
duh
cwhanse Aug 28, 2020
6866922
add return, doing three things at once = poor quality
cwhanse Aug 28, 2020
e9dba7d
add statsmodels for py38, fix dict declarations
cwhanse Aug 28, 2020
0c41ed2
()
cwhanse Aug 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
renaming, update api.rst
  • Loading branch information
cwhanse committed Dec 25, 2019
commit 9fc68b53dde7be2aaa5a2023caa8f1acadad74ee
12 changes: 8 additions & 4 deletions 12 docs/sphinx/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,14 @@ Functions for fitting PV models
.. autosummary::
:toctree: generated/

ivtools.fit_sde_sandia
ivtools.fit_sdm_cec_sam
ivtools.fit_sdm_desoto
ivtools.pvsyst_parameter_estimation
ivtools.fit_sde.fit_sandia
ivtools.fit_sde.fit_cocontent
ivtools.fit_sdm.fit_cec_sam
ivtools.fit_sdm.fit_desoto
ivtools.fit_sdm.fit_pvsyst_sandia
ivtools.utility.numdiff
ivtools.utility.rectify_iv_curve
ivtools.utility.schumaker_qspline

Other
-----
Expand Down
18 changes: 9 additions & 9 deletions 18 pvlib/ivtools/fit_sde.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from pvlib.ivtools.utility import schumaker_qspline


def fit_sde_sandia(voltage, current, v_oc=None, i_sc=None, v_mp_i_mp=None,
vlim=0.2, ilim=0.1):
def fit_sandia(voltage, current, v_oc=None, i_sc=None, v_mp_i_mp=None,
vlim=0.2, ilim=0.1):
r"""
Fits the single diode equation (SDE) [1]_ to an IV curve. Uses the method
described in [2]_.
Expand Down Expand Up @@ -75,7 +75,7 @@ def fit_sde_sandia(voltage, current, v_oc=None, i_sc=None, v_mp_i_mp=None,
assumed to be from a single IV curve at constant irradiance and cell
temperature.

:py:func:`fit_single_diode_sandia` obtains values for the five parameters
:py:func:`fit_sandia` obtains values for the five parameters
for the single diode equation [1]:

.. math::
Expand Down Expand Up @@ -192,7 +192,7 @@ def _find_mp(voltage, current):


def _sandia_beta0_beta1(v, i, vlim, v_oc):
# Helper for fit_sde_sandia.
# Helper for fit_sandia.
# Get intercept and slope of linear portion of IV curve.
# Start with V =< vlim * v_oc, extend by adding points until slope is
# negative (downward).
Expand All @@ -215,7 +215,7 @@ def _sandia_beta0_beta1(v, i, vlim, v_oc):


def _sandia_beta3_beta4(voltage, current, beta0, beta1, ilim, i_sc):
# Helper for fit_sde_sandia.
# Helper for fit_sandia.
# Subtract the IV curve from the linear fit.
y = beta0 - beta1 * voltage - current
x = np.array([np.ones_like(voltage), voltage, current]).T
Expand All @@ -233,7 +233,7 @@ def _sandia_beta3_beta4(voltage, current, beta0, beta1, ilim, i_sc):


def _sandia_calc_sde_params(beta0, beta1, beta3, beta4, v_mp, i_mp, v_oc):
# Helper for fit_sde_sandia.
# Helper for fit_sandia.
nNsVth = 1.0 / beta3
Rs = beta4 / beta3
Gp = beta1 / (1.0 - Rs * beta1)
Expand All @@ -257,7 +257,7 @@ def _calc_I0(IL, I, V, Gp, Rs, nNsVth):
return (IL - I - Gp * V - Gp * Rs * I) / np.exp((V + Rs * I) / nNsVth)


def fit_sde_cocontent(voltage, current, nsvth):
def fit_cocontent(voltage, current, nsvth):
"""
Regression technique to fit the single diode equation to data for a single
IV curve.
Expand Down Expand Up @@ -363,7 +363,7 @@ def fit_sde_cocontent(voltage, current, nsvth):


def _cocontent(v, c, isc, kflag):
# Used by fit_sde_cocontent
# Used by fit_cocontent
# calculate co-content integral by numerical integration of
# i = (Isc - I) over v
# Here, i = Isc - I is assumed to be represented by the quadratic spline
Expand Down Expand Up @@ -397,7 +397,7 @@ def _cocontent(v, c, isc, kflag):


def _cocontent_regress(v, i, voc, isc, cci):
# Used by fit_sde_content
# Used by fit_content
# For the method coded here see Appendix C of [2] SAND2015-2065
# predictor variables for regression of CC
x = np.vstack((v, isc - i, v * (isc - i), v * v, (i - isc) ** 2)).T
Expand Down
22 changes: 11 additions & 11 deletions 22 pvlib/ivtools/fit_sdm.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
The ``fit_sdm`` module contains functions to fit single diode models.

Function names should follow the pattern "fit_sdm_" + name of model + "_" +
Function names should follow the pattern "fit_" + name of model + "_" +
fitting method.

"""
Expand All @@ -14,11 +14,11 @@
from pvlib.pvsystem import singlediode, v_from_i

from pvlib.ivtools.utility import constants, rectify_iv_curve, numdiff
from pvlib.ivtools.fit_sde import fit_sde_cocontent
from pvlib.ivtools.fit_sde import fit_cocontent


def fit_sdm_cec_sam(celltype, v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc,
gamma_pmp, cells_in_series, temp_ref=25):
def fit_cec_sam(celltype, v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc,
gamma_pmp, cells_in_series, temp_ref=25):
"""
Estimates parameters for the CEC single diode model (SDM) using the SAM
SDK. Uses the method described in [1]_.
Expand Down Expand Up @@ -116,9 +116,9 @@ def fit_sdm_cec_sam(celltype, v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc,
raise RuntimeError('Parameter estimation failed')


def fit_sdm_desoto(v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc,
cells_in_series, EgRef=1.121, dEgdT=-0.0002677,
temp_ref=25, irrad_ref=1000, root_kwargs={}):
def fit_desoto(v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc,
cells_in_series, EgRef=1.121, dEgdT=-0.0002677,
temp_ref=25, irrad_ref=1000, root_kwargs={}):
"""
Calculates the parameters for the De Soto single diode model [1]_ using the
procedure described in [2]_. This procedure has the advantage of
Expand Down Expand Up @@ -213,7 +213,7 @@ def fit_sdm_desoto(v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc,
from scipy.optimize import root
import scipy.constants
except ImportError:
raise ImportError("The fit_sdm_desoto function requires scipy.")
raise ImportError("The fit_desoto function requires scipy.")

# Constants
k = scipy.constants.value('Boltzmann constant in eV/K')
Expand Down Expand Up @@ -260,7 +260,7 @@ def fit_sdm_desoto(v_mp, i_mp, v_oc, i_sc, alpha_sc, beta_voc,
def _system_of_equations_desoto(params, specs):
"""Evaluates the systems of equations used to solve for the single
diode equation parameters. Function designed to be used by
scipy.optimize.root() in fit_sdm_desoto().
scipy.optimize.root() in fit_desoto().

Parameters
----------
Expand Down Expand Up @@ -449,7 +449,7 @@ def fit_pvsyst_sandia(ivcurves, specs, const=constants, maxiter=5,
# initial estimate of Rsh, from integral over voltage regression
# [5] Step 3a; [6] Step 3a
_, _, _, rsh[j], _ = \
fit_sde_cocontent(voltage, current, vth[j] * specs['ns'])
fit_cocontent(voltage, current, vth[j] * specs['ns'])

gamma_ref, mugamma = _fit_pvsyst_sandia_gamma(isc, voc, rsh, vth, tck,
const, specs)
Expand Down Expand Up @@ -942,7 +942,7 @@ def _update_rsh_fixed_pt(rsh, rs, io, il, nnsvth, imp, vmp):
for i in range(niter):
z = _calc_phi_exact(imp, il, io, rsh, nnsvth)
next_rsh = (1 + z) / z * ((il + io) * rsh / imp - nnsvth * z / imp
- 2 * vmp / imp)
- 2 * vmp / imp)
rsh = next_rsh

return next_rsh
Expand Down
36 changes: 19 additions & 17 deletions 36 pvlib/ivtools/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

def numdiff(x, f):
"""
NUMDIFF computes first and second order derivative using possibly unequally
Compute first and second order derivative using possibly unequally
spaced data.

Parameters
Expand All @@ -45,16 +45,17 @@ def numdiff(x, f):
Description
-----------
numdiff computes first and second order derivatives using a 5th order
formula that accounts for possibly unequally spaced data. Because a 5th
order centered difference formula is used, numdiff returns NaNs for the
first 2 and last 2 points in the input vector for x.
formula that accounts for possibly unequally spaced data [1]_. Because a
5th order centered difference formula is used, numdiff returns NaNs for the
first 2 and last 2 points in the input vector for x. Ported from PVLib
Matlab [2]_.

References
----------
[1] PVLib MATLAB
[2] M. K. Bowen, R. Smith, "Derivative formulae and errors for
non-uniformly spaced points", Proceedings of the Royal Society A, vol.
461 pp 1975 - 1997, July 2005. DOI: 10.1098/rpsa.2004.1430
.. [1] M. K. Bowen, R. Smith, "Derivative formulae and errors for
non-uniformly spaced points", Proceedings of the Royal Society A, vol.
461 pp 1975 - 1997, July 2005. DOI: 10.1098/rpsa.2004.1430
.. [2] PVLib MATLAB https://github.com/sandialabs/MATLAB_PV_LIB
"""

n = len(f)
Expand Down Expand Up @@ -133,8 +134,8 @@ def numdiff(x, f):

def rectify_iv_curve(voltage, current, decimals=None):
"""
``rectify_IV_curve`` sorts the IV curve data, removes NaN and negative
values, and combines points with duplicate voltage.
Sort the IV curve data, remove NaNs and negative
values, and combine points with duplicate voltage.

Parameters
----------
Expand All @@ -157,9 +158,9 @@ def rectify_iv_curve(voltage, current, decimals=None):
-----------
``rectify_IV_curve`` ensures that the IV curve lies in the first quadrant
of the (voltage, current) plane. The returned IV curve:
* contains no NaNs
* increases in voltage
* contains no negative current or voltage values
* contains no NaNs
* contains no points with duplicate voltage values. Where voltage values
are repeated, a single data point is substituted with current equal to
the average of current at duplicated voltages.
Expand Down Expand Up @@ -190,7 +191,7 @@ def rectify_iv_curve(voltage, current, decimals=None):

def schumaker_qspline(x, y):
"""
schumaker_qspline fits a quadratic spline which preserves monotonicity and
Fit a quadratic spline which preserves monotonicity and
convexity in the data.

Parameters
Expand Down Expand Up @@ -227,11 +228,12 @@ def schumaker_qspline(x, y):

References
----------
[1] PVLib MATLAB
[2] L. L. Schumaker, "On Shape Preserving Quadratic Spline Interpolation",
SIAM Journal on Numerical Analysis 20(4), August 1983, pp 854 - 864
[3] M. H. Lam, "Monotone and Convex Quadratic Spline Interpolation",
Virginia Journal of Science 41(1), Spring 1990
.. [1] PVLib MATLAB https://github.com/sandialabs/MATLAB_PV_LIB
.. [2] L. L. Schumaker, "On Shape Preserving Quadratic Spline
Interpolation", SIAM Journal on Numerical Analysis 20(4), August 1983,
pp 854 - 864
.. [3] M. H. Lam, "Monotone and Convex Quadratic Spline Interpolation",
Virginia Journal of Science 41(1), Spring 1990
"""
# Make sure vectors are 1D arrays
x = x.flatten()
Expand Down
34 changes: 17 additions & 17 deletions 34 pvlib/test/ivtools_tests/test_fit_sde.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def get_test_iv_params():


@requires_scipy
def test_fit_sde_sandia(get_test_iv_params, get_bad_iv_curves):
def test_fit_sandia(get_test_iv_params, get_bad_iv_curves):
test_params = get_test_iv_params
testcurve = pvsystem.singlediode(photocurrent=test_params['IL'],
saturation_current=test_params['I0'],
Expand All @@ -21,35 +21,35 @@ def test_fit_sde_sandia(get_test_iv_params, get_bad_iv_curves):
ivcurve_pnts=300)
expected = tuple(test_params[k] for k in ['IL', 'I0', 'Rsh', 'Rs',
'nNsVth'])
result = fit_sde.fit_sde_sandia(voltage=testcurve['v'],
current=testcurve['i'])
result = fit_sde.fit_sandia(voltage=testcurve['v'],
current=testcurve['i'])
assert np.allclose(result, expected, rtol=5e-5)
result = fit_sde.fit_sde_sandia(voltage=testcurve['v'],
current=testcurve['i'],
v_oc=testcurve['v_oc'],
i_sc=testcurve['i_sc'])
result = fit_sde.fit_sandia(voltage=testcurve['v'],
current=testcurve['i'],
v_oc=testcurve['v_oc'],
i_sc=testcurve['i_sc'])
assert np.allclose(result, expected, rtol=5e-5)
result = fit_sde.fit_sde_sandia(voltage=testcurve['v'],
current=testcurve['i'],
v_oc=testcurve['v_oc'],
i_sc=testcurve['i_sc'],
v_mp_i_mp=(testcurve['v_mp'],
testcurve['i_mp']))
result = fit_sde.fit_sandia(voltage=testcurve['v'],
current=testcurve['i'],
v_oc=testcurve['v_oc'],
i_sc=testcurve['i_sc'],
v_mp_i_mp=(testcurve['v_mp'],
testcurve['i_mp']))
assert np.allclose(result, expected, rtol=5e-5)
result = fit_sde.fit_sde_sandia(voltage=testcurve['v'],
current=testcurve['i'], vlim=0.1)
result = fit_sde.fit_sandia(voltage=testcurve['v'],
current=testcurve['i'], vlim=0.1)
assert np.allclose(result, expected, rtol=5e-5)


@requires_scipy
def test_fit_sde_sandia_bad_iv(get_bad_iv_curves):
# bad IV curves for coverage of if/then in _calculate_sde_parameters
v1, i1, v2, i2 = get_bad_iv_curves
result = fit_sde.fit_sde_sandia(voltage=v1, current=i1)
result = fit_sde.fit_sandia(voltage=v1, current=i1)
assert np.allclose(result, (-2.4322856072799985, 8.854688976836396,
-63.56227601452038, 111.18558915546389,
-137.9965046659527))
result = fit_sde.fit_sde_sandia(voltage=v2, current=i2)
result = fit_sde.fit_sandia(voltage=v2, current=i2)
assert np.allclose(result, (2.62405311949227, 1.8657963912925288,
110.35202827739991, -65.652554411442,
174.49362093001415))
Expand Down
22 changes: 11 additions & 11 deletions 22 pvlib/test/ivtools_tests/test_fit_sdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def get_cec_params_cansol_cs5p_220p():


@requires_pysam
def test_fit_sdm_cec_sam(get_cec_params_cansol_cs5p_220p):
def test_fit_sdm_sam(get_cec_params_cansol_cs5p_220p):
input_data = get_cec_params_cansol_cs5p_220p['input']
I_L_ref, I_o_ref, R_sh_ref, R_s, a_ref, Adjust = \
fit_sdm.fit_sdm_cec_sam(
fit_sdm.fit_cec_sam(
celltype='polySi', v_mp=input_data['V_mp_ref'],
i_mp=input_data['I_mp_ref'], v_oc=input_data['V_oc_ref'],
i_sc=input_data['I_sc_ref'], alpha_sc=input_data['alpha_sc'],
Expand All @@ -51,18 +51,18 @@ def test_fit_sdm_cec_sam(get_cec_params_cansol_cs5p_220p):
# test for fitting failure
with pytest.raises(RuntimeError):
I_L_ref, I_o_ref, R_sh_ref, R_s, a_ref, Adjust = \
fit_sdm.fit_sdm_cec_sam(
fit_sdm.fit_cec_sam(
celltype='polySi', v_mp=0.45, i_mp=5.25, v_oc=0.55, i_sc=5.5,
alpha_sc=0.00275, beta_voc=0.00275, gamma_pmp=0.0055,
cells_in_series=1, temp_ref=25)


@requires_scipy
def test_fit_sdm_desoto():
result, _ = fit_sdm.fit_sdm_desoto(v_mp=31.0, i_mp=8.71, v_oc=38.3,
i_sc=9.43, alpha_sc=0.005658,
beta_voc=-0.13788,
cells_in_series=60)
def test_fit_desoto():
result, _ = fit_sdm.fit_desoto(v_mp=31.0, i_mp=8.71, v_oc=38.3,
i_sc=9.43, alpha_sc=0.005658,
beta_voc=-0.13788,
cells_in_series=60)
result_expected = {'I_L_ref': 9.45232,
'I_o_ref': 3.22460e-10,
'a_ref': 1.59128,
Expand All @@ -80,9 +80,9 @@ def test_fit_sdm_desoto():
@requires_scipy
def test_fit_sdm_desoto_failure():
with pytest.raises(RuntimeError) as exc:
fit_sdm.fit_sdm_desoto(v_mp=31.0, i_mp=8.71, v_oc=38.3, i_sc=9.43,
alpha_sc=0.005658, beta_voc=-0.13788,
cells_in_series=10)
fit_sdm.fit_desoto(v_mp=31.0, i_mp=8.71, v_oc=38.3, i_sc=9.43,
alpha_sc=0.005658, beta_voc=-0.13788,
cells_in_series=10)
assert ('Parameter estimation failed') in str(exc.value)


Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.