Skip to content
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

Fix mpp temperature sensitivity #68

Merged
merged 6 commits into from
Mar 21, 2018

Conversation

rayhickey
Copy link
Contributor

Fixes I_mp and V_mp sensitivity to temperature caused by selecting Isys and Vsys values at the maximum Psys index. This is accomplished by linear interpolation between the points surrounding MPP.
Previously:
i_mp_temp_old
Now:
i_mp_temp_new

* improve python 3 compatibility in pvsys, strs and mods, require future

* change dict.iter*() to iter*(dic), fix import * in tests

* fix two diode test for SymPy-1.1.1

* fixes SunPower#55
* replace string keys in expected_data with the actual symbol objects,
so instead of {'ic': IC}, use {ic: IC} where ic is the SymPy symbol
object
* replace string substitutions in expressions with the actual SymPy
symbols, so use didv.subs(vc + rs*ic, 'vd') instead of
didv.subs('vc + rs * ic(vc)', 'vd') which is error prone anyway, because
the string could change, how do you know what string to use?
* leave these subs in for now, but they are not necessary, since vd =
vc + ic*rs can evaluate just fine
* when numerically evaluating expressions using evalf(subs=expected_data)
substitute values for the symbol di_dv, NOT the string
"Derivative(ic(vc), vc)" since this doesn't work anymore!
* don't substitute for the string 'ic(vc)', instead use the SymPy
symbols ic, since parentheses don't work in SymPy substitutions or
evaluations anymore, and this is more explicit since ic was defined as
f(vc) when it was initialized!
* freeze versions in requirements so this doesn't an issue again
* ignore .spyproject - the new spyder-IDE project file

Signed-off-by: Mark Mikofski <bwana.marko@yahoo.com>

* update travis to test Py3, update setup with correct install and test reqs, add setup.cfg for universal wheel

* ENH: BUG: add _calc_now flag to determine when cell is recalculated (GH59) (SunPower#61)

* fixes SunPower#59

* add class attr _calc_now
* override _calc_now with instance attribte at the end of constructor
* check if _calc_now is True to decide to call self.calcCell() instead
  of checking for pvconst
* use self.__dict__.update() instead of using
  super(PVcell, self).__setattr__(key, value)
* in update, remove TODO, b/c even tho __dict__.update() would bypass
  __setattr__() then would have to check for floats, and still set
  _calc_now = True to trigger recalc, so instead, just set
  _calc_now = False first to turn calculations off, until all attr are
  set, then recalc

* don't set pvcell.pvconst in pvstring

* just raise an exception if they don't match for now
* remove comments about "deepcopy" everywhere

* oops, recalculate means _calc_now = True, duh!

* remove commented legacy code in __setattr__, add comment in update re checking for floats

* add test for new _calc_now flag

* if _calc_now == False, then calcCell() is not called in __setattr__
* if _calc_now == True, then calcCell() is called in __setattr__

* BUG: pvconst is not a singleton, inconsistent, doesn't update (GH38) (SunPower#62)

* fixes SunPower#59

* add class attr _calc_now
* override _calc_now with instance attribte at the end of constructor
* check if _calc_now is True to decide to call self.calcCell() instead
  of checking for pvconst
* use self.__dict__.update() instead of using
  super(PVcell, self).__setattr__(key, value)
* in update, remove TODO, b/c even tho __dict__.update() would bypass
  __setattr__() then would have to check for floats, and still set
  _calc_now = True to trigger recalc, so instead, just set
  _calc_now = False first to turn calculations off, until all attr are
  set, then recalc

* don't set pvcell.pvconst in pvstring

* just raise an exception if they don't match for now
* remove comments about "deepcopy" everywhere

* oops, recalculate means _calc_now = True, duh!

* remove commented legacy code in __setattr__, add comment in update re checking for floats

* add test for new _calc_now flag

* if _calc_now == False, then calcCell() is not called in __setattr__
* if _calc_now == True, then calcCell() is called in __setattr__

* closes SunPower#38 consistent pvconst behavior

* use duck typing to check pvstrs in PVsystem() for list, object or none
* set pvconst from pvstrs if given
* set numbstrs from pvstrs if given
* set numbermods form pvstrs.pvmods if given
* check that pvconst and pvmods are consistent
* add tests

* apply same changes in pvsystem from last commit to pvstr

* change default pvconst arg to None
* use duck typing to check if pvmods is a list, an object, or None
* relax requirement that all strings have same number of modules
* change pvsys.numberMods to a list of number of modules in each string
* add test to check pvstring
* check that all pvconst are the same for all modules
* add docstring for members

* also test that pvsys.numberMods is now a list

* each item in list is number of modules in corresponding string

* use ducktyping to determine if pvcells is list or obj or None

* add missing blank lines and wrap long lines per pep8
* add pvcell object to pvcells docstring arg type
* add tests in test_module to check that pvconst is the same for module
  and all cells

* add test for update method

* replace npts attr with a property

* add new private _npts attribute, return for npts in getter
* set npts, pts, negpts, Imod_pts, and Imod_negpts in setter
* add test to show that changing npts changes pts, negpts, Imod_pts, and
  Imod_negpts

* add pvsystem update method

* make system calculation DRY, use everywhere calcSystem and
  calcMPP_IscVocFFeff are called back to back to set Isys, Vsys, Psys,
  etc.
* also makes it explicity to recalc the system after a change, like
  change pvconst.npts

* Update example.py

Isat2 => Isat2_T0

* reverting changes - didn't mean to commit master

* Isat2fix (SunPower#64)

* 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

* Update .travis.yml

added new pipy credentials
Fixes I_mp and V_mp sensitivity to temperature caused by selecting Isys and Vsys values at the maximum Psys index. This is accomplished by linear interpolation between the points surrounding MPP.
@rayhickey
Copy link
Contributor Author

TODO:

  • Benchmark runtime and evaluate best approach for finding MPP (interpolation method, number of points)
  • Replace values in test_setsuns to reflect new default MPP values

@mikofski
Copy link
Contributor

See #67 for more comments on this topic.

@chetan201
Copy link
Contributor

chetan201 commented Mar 6, 2018

@rayhickey
This PR can be merged when the Travis CI tests pass. Please let us know if you need any help.

@mikofski
Copy link
Contributor

Should close #65

Also changed MPP calc to return float rather than array
@rayhickey
Copy link
Contributor Author

Runtime benchmarking using the following code:

import timeit
setup = """
# from pvmismatch.pvmismatch_lib
import pvsystem
from pvconstants import PVconstants
pvs = pvsystem.PVsystem(pvconst=PVconstants())
"""
code = 'pvs.setTemps(300.)'
timeit.timeit(setup=setup, stmt=code, number=100)

Baseline, 101 points, 100 runs: 1.01 s/run
Baseline, 1001 points, 100 runs: 2.66 s/run
Baseline, 10001 points, 10 runs: 28.73 s/run
Linear interpolation, 101 points, 100 runs: 1.03 s/run
Linear interpolation, 1001 points, 100 runs: 2.74 s/run
Linear interpolation, 10001 points, 10 runs: 27.48 s/run

Linear interpolation has the most predictable behavior, especially with fewer points. Increasing the number of points reduces the variation additionally when interpolating, but with systems larger than one module the number of points required adds too much time. I think keeping the number of points at 101 is fine for now.
imp_npts

@chetan201
Copy link
Contributor

@rayhickey
I take it this is safe to merge now?

Copy link
Contributor

@mikofski mikofski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's got my thumbs up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants