add irradiance support
authorAndrew Tridgell <tridge@samba.org>
Tue, 31 Aug 2010 06:12:19 +0000 (16:12 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 31 Aug 2010 06:12:19 +0000 (16:12 +1000)
pv_model

index ebf40b5e722385ffc68cb2bb3bdf2a9f048dba2c..54a107d84db17c4cb6902c6f35fa07340aebefb1 100755 (executable)
--- a/pv_model
+++ b/pv_model
@@ -36,6 +36,8 @@ subpanel_Roc = 0.1
 
 def find_best(err, lower, upper):
     '''wrapper around scipy optimisation function'''
+    if upper == lower:
+        return lower
     if upper <= lower:
         raise Exception('lower<upper')
     def err1(x):
@@ -77,6 +79,15 @@ def temperature_adjust(t):
     cell_Vmp += (cell_VT/cell_scale) * (t-25)
     cell_Imp += cell_IT * (t-25)
 
+def irradiance_adjust(i):
+    '''adjust irradiance sensitive coefficients. This is very rough'''
+    global cell_Voc, cell_Isc, cell_Vmp, cell_Imp
+    v_scale=1e6
+    cell_Voc *= math.log(v_scale*(i+1))/math.log(v_scale*1001)
+    cell_Vmp *= math.log(v_scale*(i+1))/math.log(v_scale*1001)
+    cell_Isc *= i/1000.0
+    cell_Imp *= i/1000.0
+
 
 # a cache hack ... we evaluate the same parms a lot of times
 # assumes that return only depends on function args
@@ -641,7 +652,7 @@ def cell_T():
     pylab.show()
 
 def panel_T():
-    '''panel temperature sensitivity'''
+    '''panel power temperature sensitivity'''
     global cell_Voc, cell_Isc, cell_Vmp, cell_Imp
     saved = (cell_Isc, cell_Voc, cell_Imp, cell_Vmp)
     for t in range(-5, 65, 10):
@@ -655,8 +666,8 @@ def panel_T():
     pylab.legend()
     pylab.show()
 
-def panel_VI_T():
-    '''panel VI temperature sensitivity'''
+def panel_IV_T():
+    '''panel IV temperature sensitivity'''
     global cell_Voc, cell_Isc, cell_Vmp, cell_Imp
     saved = (cell_Isc, cell_Voc, cell_Imp, cell_Vmp)
     for t in range(-5, 65, 10):
@@ -666,7 +677,37 @@ def panel_VI_T():
         (cell_Isc, cell_Voc, cell_Imp, cell_Vmp) = saved
     pylab.xlabel('Voltage (V)')
     pylab.ylabel('Current (A)')
-    pylab.title("Panel VI temperature effect")
+    pylab.title("Panel IV temperature effect")
+    pylab.legend()
+    pylab.show()
+
+def panel_L():
+    '''panel power light sensitivity'''
+    global cell_Voc, cell_Isc, cell_Vmp, cell_Imp
+    saved = (cell_Isc, cell_Voc, cell_Imp, cell_Vmp)
+    for w in range(0, 1500, 250):
+        irradiance_adjust(w)
+        c=panel()
+        plotit(c.P, 0, round(c.V(0), 20), label='%d W/m2' % w)
+        (cell_Isc, cell_Voc, cell_Imp, cell_Vmp) = saved
+    pylab.xlabel('Voltage (V)')
+    pylab.ylabel('Power (W)')
+    pylab.title("Panel light effect")
+    pylab.legend()
+    pylab.show()
+
+def panel_IV_L():
+    '''panel VI light sensitivity'''
+    global cell_Voc, cell_Isc, cell_Vmp, cell_Imp
+    saved = (cell_Isc, cell_Voc, cell_Imp, cell_Vmp)
+    for w in range(0, 1500, 250):
+        irradiance_adjust(w)
+        c=panel()
+        plotit(c.I, 0, round(c.V(0), 20), label='%d W/m2' % w)
+        (cell_Isc, cell_Voc, cell_Imp, cell_Vmp) = saved
+    pylab.xlabel('Voltage (V)')
+    pylab.ylabel('Current (A)')
+    pylab.title("Panel VI light effect")
     pylab.legend()
     pylab.show()
 
@@ -686,7 +727,9 @@ if __name__ == "__main__":
         "panel_VI"     : panel_VI,
         "panel_P"      : panel_P,
         "panel_T"      : panel_T,
-        "panel_VI_T"   : panel_VI_T,
+        "panel_IV_T"   : panel_IV_T,
+        "panel_L"      : panel_L,
+        "panel_IV_L"   : panel_IV_L,
         "string_P"     : string_P,
         "string_P"     : string_P,
         "2MPP-loss"    : mpp_loss,
@@ -709,7 +752,8 @@ if __name__ == "__main__":
     parser.add_option("", "--cell-Vmp", dest="cell_Vmp", help="max power cell voltage", type='float')
     parser.add_option("", "--inverter-MPP-min", dest="inverter_MPP_min", help="inverter MPP minimum", type='int')
     parser.add_option("", "--inverter-MPP-max", dest="inverter_MPP_max", help="inverter MPP maximum", type='int')
-    parser.add_option("", "--temperature", dest="temperature", help="cell temperature (C)",type='float')
+    parser.add_option("", "--temperature", dest="temperature", help="cell temperature (C)",type='float', default=25)
+    parser.add_option("", "--irradiance", dest="irradiance", help="light level (W/m2)",type='float', default=1000)
     parser.add_option("", "--subpanels", dest="num_subpanels", help="subpanels per panel",
                       type='int', default=1)
     parser.add_option("", "--cells-per-subpanel", dest="cells_per_subpanel", help="cells per subpanel",
@@ -746,8 +790,9 @@ if __name__ == "__main__":
         inverter_range[0] = float(opts.inverter_MPP_min)
     if opts.inverter_MPP_max:
         inverter_range[1] = float(opts.inverter_MPP_max)
-    if opts.temperature:
-        temperature_adjust(opts.temperature)
+
+    temperature_adjust(opts.temperature)
+    irradiance_adjust(opts.irradiance)
 
     try:
         functions[f]()