-
Notifications
You must be signed in to change notification settings - Fork 34
BUG: pvconst is not a singleton, inconsistent, doesn't update (GH38) #62
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
Conversation
* 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
… checking for floats
* 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
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
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:
|
* 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
okay, I added
which is WET code that's repeated 3 times. Anyway, after users changes |
@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]>
@mikofski |
@chetan201 too L8, I just did it 😜 |
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
@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. |
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 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, 😃 |
@mikofski |
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 😑 |
* 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
* 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
fixes #38
pvconst
is used throughout the next lower level, cascading down frompvsystem
topvstring
topvmodule
topvcell
, otherwise weird things can happen