Skip to content

Commit

Permalink
fixes #9
Browse files Browse the repository at this point in the history
* fix issue with `CalcMPP_IscVocFFeff()` was trying to use dP/dV = 0 to
 get better estimate of Vmp, but this is at most as accurate as simply
 using the index found from max(Psys), and probably less accurate, also
 it was using all Vsys, so it would jump to local extrema
* finally add setup.py and create distribution so users can install

Signed-off-by: Mark Mikofski <mark.mikofski@sunpowercorp.com>
  • Loading branch information
mikofski committed May 16, 2015
1 parent 72a37db commit 623adb8
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 21 deletions.
17 changes: 12 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
*.pyc
# ide
.spyderproject
.project
.pydevproject
.settings/
testPV/
.idea/
pvmismatch.sublime-project
pvmismatch.sublime-workspace
benchmark_*/

# files
*.pyc
*.orig

# folders
_*/
!docs/_templates/


testPV/
benchmark_*/
dist/
pvmismatch.egg-info
venv/
95 changes: 95 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
CHANGES
=======

v1.6 German Goulash
-------------------


v1.5 French Falafel
-------------------
* bug fixes
* corrects pt spacing for module current
* simplifies Istring calc
* multithreading of some pvsys and pvstring calcs
* TODO multithread calcMod if possible
* benchmarked vs older code
* pretty up & optimize code

v1.4.1 European Eclair
----------------------
* bug fix PVconstants use self.npts, not NPTS!
* remove commented legacy code

v1.4 European Eggplant
----------------------
* Isc0 is also temp dependent but rename Isc0 to Isc0_T0
and Isat1 to Isat1_T0
* add alpha_Isc input arg to PVconstants
* cast all pvconst inputs to float to avoid integer errors
* fix advCnf to use Isc0_T0 and Isat1_T0
* in PVconstants.update() check for Isat1, Isc0, Eg,
alpha_Isc and Tcell
* add calc_Isat1 and calc_Isc0 functions

v1.3.1 Danish Delicatessen
--------------------------
* Isat1 temperature dependence
* add Eg, band gap energy
* set default npts to 101, let user specify to constructor
* change pts to be logspace

v1.3 Danish Donuts
------------------
* pvmismatch_tk has advanced configuration button to set nearly all
diode model parameters
* pvmodules, pvstring and pvsystem all use deepcopy to make cheap copies
of modules, instead of looping over and constructing every module
individually - huge time savings
* bug fixes: be 163/123 increase range of Imod & Istr for Ee > 1 sun, be
163/9e9 temp dep, be 163/069 hook up all widgets on main screen
* move validation const & messages to json files
* add pvexceptions
* add waitbox during long actions and startup
* numerous improvements

v1.2 Canadian Cheese
--------------------
* main app page completely refactored
* matplotlib graph of system IV curve on main page
* only set strings, modules/string & cells/module
* all validation limits to integers and max value
* string button
* scale connected to I, V & P entry output
* TODO: entry widegt should be 2 way with scale
* TODO: scale and entry widgets should move cursor on plot
* see cursor example on matplotlib
* TODO: use asynchronous thread to show progress bar during calculations
* TODO: still need to hook up other buttons
* TODO: other screens
* TODO: advanced settings button
* TODO: temp dependent Isat's and R's

v1.1 Belgian Banana
-------------------
* Tkinter front end
* input all variables, some validation
* reset, load, save, quit
* separate buttons to view results
* TODO: make results buttons work
* TODO: connect to pvmismatch
* TODO: validaton actually limits to correct ranges
* TODO: validation allows deletions and insertions

v1.0 Appalachian Apple
----------------------
* 2-diode model
* avalanche reverse bias and breakdown characteristics
* composed of pvmodule, pvstring and pvsystem
* testscript creates output in testPV folder
* bypass diodes simply represented by trigger voltage
* extrapolation used out of range, could pose problems
* noJac temperature, ie assumed explicit
* TODO: add max power function, return I,V,P
* TODO: create user interface
* TODO: register event so update is automatic
* TODO: test bypass diodes, extrapolation and other corner cases
7 changes: 7 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include pvmismatch_json/*.json
include res/*.png
include CHANGES
recursive-include docs *.rst
include docs/conf.py
include docs/make.bat
include docs/Makefile
7 changes: 7 additions & 0 deletions pvmismatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@
@author: mmikofski
"""

from pvconstants import PVconstants
from pvmodule import PVmodule
from pvstring import PVstring
from pvsystem import PVsystem

__version__ = '1.6'
__release__ = 'German Goulash'
__all__ = ['pvconstants', 'pvmodule', 'pvstring', 'pvsystem']
22 changes: 6 additions & 16 deletions pvmismatch/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,18 @@ def calcSystem(self):
return (Isys, Vsys, Psys)

def calcMPP_IscVocFFeff(self):
Pmp = np.max(self.Psys)
# np.interp only likes 1-D data & xp must be increasing
# Psys is *not* monotonically increasing but its derivative *is*
dP = np.diff(self.Psys, axis=0) # (1000, 1)
dV = np.diff(self.Vsys, axis=0) # (1000, 1)
Pv = dP / dV # (1000, 1) decreasing
# reshape(scalar) converts 2-D array to 1-D array (vector)
Pv = np.flipud(Pv.reshape(self.pvconst.npts - 1)) # (1000,) increasing
Vhalf = (self.Vsys[1:] + self.Vsys[:-1]) / 2 # (1000, 1) increasing
Vhalf = np.flipud(Vhalf.reshape(self.pvconst.npts - 1)) # (1000,)
Vmp = np.interp(0., Pv, Vhalf) # estimate Vmp
Imp = Pmp / Vmp # calculate Imp
mpp = np.argmax(self.Psys)
Pmp = self.Psys[mpp,0]
Vmp = self.Vsys[mpp,0]
Imp = self.Isys[mpp,0]
# xp must be increasing
Isys = self.Isys.reshape(self.pvconst.npts) # IGNORE:E1103
Vsys = self.Vsys.reshape(self.pvconst.npts) # IGNORE:E1103
xp = np.flipud(Isys)
fp = np.flipud(Vsys)
Voc = np.interp(0., xp, fp) # calucalte Voc
Voc = np.interp(0, xp, fp) # calculate Voc
xp = Vsys
fp = Isys
ImpCheck = np.interp(Vmp, xp, fp) # check Imp
print "Imp Error = {:10.4g}%".format((Imp - ImpCheck) / Imp * 100)
Isc = np.interp(0, xp, fp)
FF = Pmp / Isc / Voc
totalSuns = 0
Expand All @@ -134,7 +124,7 @@ def calcMPP_IscVocFFeff(self):
# convert cellArea from cm^2 to m^2
Psun = self.pvconst.E0 * totalSuns * self.pvconst.cellArea / 100 / 100
eff = Pmp / Psun
return (Imp, Vmp, Pmp, Isc, Voc, FF, eff)
return Imp, Vmp, Pmp, Isc, Voc, FF, eff

def setSuns(self, Ee):
"""
Expand Down
23 changes: 23 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
__author__ = 'mmikofski'

try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from pvmismatch import __version__ as VERSION, __name__ as NAME


setup(name=NAME,
version=VERSION,
description='PV Mismatch Calculator',
author=__author__,
author_email='mark.mikofski@sunpower.com',
url='https://github.com/SunPower/PVMismatch',
packages=['pvmismatch', 'pvmismatch_tk'],
requires=['numpy (>=1.8)', 'matplotlib (>=1.3)', 'scipy (>=0.12.0)'],
scripts=['pv_tk.py'],
package_data={'pvmismatch_tk':
['pvmismatch_json/messagetext.English.json',
'pvmismatch_json/validationConstants.json',
'res/logo.png', 'res/logo_bg.png', 'docs/conf.py',
'docs/*.rst', 'docs/Makefile', 'docs/make.bat']})

0 comments on commit 623adb8

Please sign in to comment.