#!/usr/bin/env python # coding: utf-8 # Open In Colab # In[5]: get_ipython().system('pip install pvmismatch pvlib') # In[6]: import numpy as np from matplotlib import pyplot as plt from pvmismatch.contrib.gen_coeffs import gen_two_diode from pvmismatch import * def last_guess(sol): isat1 = np.exp(sol.x[0]) isat2 = np.exp(sol.x[1]) rs = sol.x[2] ** 2.0 rsh = sol.x[3] ** 2.0 return isat1, isat2, rs, rsh # # example generation of 2-diode coefficients # [Trina Vertex_DEG19RC.20_EN_2022A](https://static.trinasolar.com/sites/default/files/DT-M-0034A_Datasheet_Vertex_DEG19RC.20_EN_2022A.pdf) # In[7]: electrical_data = { 550: {"vmp": 37.2, "imp": 14.78, "voc": 44.8, "isc": 15.76}} beta_voc = -0.0025 # per degC alpha_isc = 0.0004 # per degC nseries = 66 nparallel = 2 tc = 25.0 # degC # In[8]: isc, voc = electrical_data[550]['isc'], electrical_data[550]['voc'] imp, vmp = electrical_data[550]['imp'], electrical_data[550]['vmp'] x, sol = gen_two_diode(isc, voc, imp, vmp, nseries, nparallel, tc) sol # In[9]: x # In[10]: last_guess(sol) # In[11]: pvc = pvcell.PVcell( Isat1_T0=x[0], Isat2_T0=x[1], Rs=x[2], Rsh=x[3], Isc0_T0=isc/nparallel, alpha_Isc=alpha_isc) # In[12]: pvc.Voc*nseries # In[13]: mpp = np.argmax(pvc.Pcell) # In[14]: pvc.Vcell[mpp][0]*nseries # In[15]: pvc.Icell[mpp][0]*nparallel # In[16]: halfcell132 = pvmodule.crosstied_cellpos_pat([22, 22, 22], 2, partial=True) # In[17]: pvm = pvmodule.PVmodule(cell_pos=halfcell132, pvcells=[pvc]*132) # In[18]: # make some comparison plots pvm.plotMod() # plot the pvmm module plt.tight_layout() f = plt.gcf() ax = f.axes ax[0].set_ylim([0, 20]) ax[0].plot(0, isc, 'or') ax[0].plot(voc, 0, 'or') ax[0].plot(vmp, imp, 'or') ax[0].plot(0, pvm.Isc.mean()*nparallel, 'xk') ax[0].plot(pvm.Voc.sum()/nparallel, 0, 'xk') mpp = np.argmax(pvm.Pmod) ax[0].plot(pvm.Vmod[mpp], pvm.Imod[mpp], 'xk') ax[1].plot(vmp, imp*vmp, 'or') ax[1].plot(pvm.Vmod[mpp], pvm.Pmod[mpp], 'xk') # In[19]: mpp = np.argmax(pvm.Pmod) pvm.Vmod[mpp], pvm.Imod[mpp] # In[19]: # In[20]: pvm.Vcell[:, mpp].shape # In[20]: