Skip to content

Conversation

mikofski
Copy link
Contributor

@mikofski mikofski commented Jan 20, 2018

fixes #38

  • use ducktyping instead of instance check to see if arg is list, obj, or none
  • don't set an argument default with a constructor, instead use None
  • make sure that the same pvconst is used throughout the next lower level, cascading down from pvsystem to pvstring to pvmodule to pvcell, otherwise weird things can happen

* 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
* just raise an exception if they don't match for now
* remove comments about "deepcopy" everywhere
* if _calc_now == False, then calcCell() is not called in __setattr__
* if _calc_now == True, then calcCell() is called in __setattr__
* 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
* 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
* each item in list is number of modules in corresponding string
* 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
@mikofski
Copy link
Contributor Author

this is a WIP, still one more thing to add from #38 to close this

* 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
@mikofski
Copy link
Contributor Author

mikofski commented Jan 21, 2018

okay @chetan201 I think this PR is ready to be merged now, @bmeyers you might be interested in this PR since you reported #38 - so this should PR should do 2 things:

  1. more or less makes sure that all pvconst are the same, and
  2. allows the user to change pvconst.npts anytime to change resolution of IV curve calculations, even after creating a system BUT it still doesn't recalculate the system (unless they call setsuns or settemps), so that's another issue.

* 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
@mikofski
Copy link
Contributor Author

okay, I added PVsystem.update() that basically executes:

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

which is WET code that's repeated 3 times. Anyway, after users changes pvconst.npts they could call pvsys.update() and it will recalc the system.

@mikofski mikofski changed the title Gh38 BUG: pvconst is not a singleton, inconsistent, doesn't update (GH38) Feb 5, 2018
@mikofski
Copy link
Contributor Author

mikofski commented Feb 5, 2018

@chetan201 I can probably resolve these conflicts if you want, they're probably just artifacts of the squash and merge, since this branch is based on gh59.

Signed-off-by: Mark Mikofski <[email protected]>
@chetan201
Copy link
Contributor

@mikofski
Could we have merged the two PRs then to avoid the conflicts? Just curious!

@mikofski
Copy link
Contributor Author

mikofski commented Feb 5, 2018

@chetan201 too L8, I just did it 😜

@mikofski
Copy link
Contributor Author

mikofski commented Feb 5, 2018

sorry, I didn't see you response, oops. The two PR's were merged already, since gh38 was built on top of gh59, if you look at their history - I think the reason there were conflicts was because you did a "squash-and-merge" versus a "pull-and-merge". When you do a "squash-and-merge" it rebases the PR on your master branch into a single commit, so the commits in gh38 where gh59 was already merged, were "squashed", ie: they didn't exist, the history was replaced with a new single commit. Read more about merging pull requests.

@@ -40,6 +41,30 @@ def test_calc_pct_bridges():
pvmod = PVmodule(cell_pos=pct492_bridges)
return pvmod


def check_same_pvconst_and_lengths(pvmod):
assert len(pvmod.pvcells) == 96
Copy link
Contributor

Choose a reason for hiding this comment

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

why 96? Is it because the default PVmodule has the std96 patten?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, because STD96 is the default module, that's created when you don't specify a cell pattern, but it's confusing to hardcode it, probably better to grab the value from the default directly?

@chetan201
Copy link
Contributor

@mikofski is this PR still valid then if the PRs were merged? I just reviewed it and I think the commits looked good. I have created a tag based off last merge but holding off on this possible merge now before drafting a release.

@mikofski
Copy link
Contributor Author

mikofski commented Feb 5, 2018

you need to also merge this PR as well. GH59 (#61) only covered up to commit 1b674e1 but this PR (#62) continues on for 7 more commits. Look at them on a graph:
gh38

@mikofski
Copy link
Contributor Author

mikofski commented Feb 5, 2018

your call regarding tags, it's okay to release two tags in a row. As soon as you push the tag up to GitHub SunPower/PVMismatch, it will automatically trigger the test, build, and deploy to PyPI and GitHub releases.

If you haven't pushed the tag yet, you can also move it to the latest commit using the -f to force it. Google git push --tags <remote> <branch> to read more.

Don't worry about Anaconda for now, unless you want to, it's a PITA, and I haven't automated it. Let me know if you want to hear more about building conda packages, or you could read about it .yourself of course, 😃

@chetan201 chetan201 merged commit 42a21c0 into SunPower:master Feb 6, 2018
@chetan201
Copy link
Contributor

@mikofski
This one seems to be done, including the release! I wonder if I have followed the sequence of cool release names correctly ! ;)

@mikofski
Copy link
Contributor Author

mikofski commented Feb 6, 2018

Yes I like the name! Thanks. I had to manually upload using twine. Pypi sense to be broken, or else my Travis tokens no longer work 😑

@mikofski mikofski deleted the gh38 branch February 6, 2018 06:11
rayhickey added a commit to rayhickey/PVMismatch that referenced this pull request Feb 26, 2018
* 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 <[email protected]>

* 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
chetan201 pushed a commit that referenced this pull request Mar 21, 2018
* Merging v4 branch before submitting PR (#1)

* 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 #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 <[email protected]>

* 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) (#61)

* fixes #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) (#62)

* fixes #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 #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 (#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 MPP Sensitivity to Temperature

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.

* Correct indices

* Cleanup

* Changed setsuns test for new MPP calculation

Also changed MPP calc to return float rather than array
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.

PVconst behavior
2 participants