From 623adb8e8259b13c40c8b043f18bef3ec04599cc Mon Sep 17 00:00:00 2001 From: Mark Mikofski Date: Sat, 16 May 2015 01:42:34 -0700 Subject: [PATCH] fixes #9 * 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 --- .gitignore | 17 +++++--- CHANGES | 95 ++++++++++++++++++++++++++++++++++++++++++ MANIFEST.in | 7 ++++ pvmismatch/__init__.py | 7 ++++ pvmismatch/pvsystem.py | 22 +++------- setup.py | 23 ++++++++++ 6 files changed, 150 insertions(+), 21 deletions(-) create mode 100644 CHANGES create mode 100644 MANIFEST.in create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 263e6c9..525c56e 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/CHANGES b/CHANGES new file mode 100644 index 0000000..a063741 --- /dev/null +++ b/CHANGES @@ -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 \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..a0fcf3f --- /dev/null +++ b/MANIFEST.in @@ -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 \ No newline at end of file diff --git a/pvmismatch/__init__.py b/pvmismatch/__init__.py index e40c901..4c937b6 100644 --- a/pvmismatch/__init__.py +++ b/pvmismatch/__init__.py @@ -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'] diff --git a/pvmismatch/pvsystem.py b/pvmismatch/pvsystem.py index 5804641..d5c7523 100644 --- a/pvmismatch/pvsystem.py +++ b/pvmismatch/pvsystem.py @@ -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 @@ -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): """ diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..da9312b --- /dev/null +++ b/setup.py @@ -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']})