|
28 | 28 | },
|
29 | 29 | {
|
30 | 30 | "cell_type": "code",
|
31 |
| - "execution_count": 1, |
| 31 | + "execution_count": null, |
32 | 32 | "metadata": {},
|
33 | 33 | "outputs": [],
|
34 | 34 | "source": [
|
|
37 | 37 | "import matplotlib.pyplot as plt\n",
|
38 | 38 | "\n",
|
39 | 39 | "import pandas as pd\n",
|
| 40 | + "import numpy as np\n", |
40 | 41 | "\n",
|
41 | 42 | "# And pvlib\n",
|
42 | 43 | "import pvlib"
|
|
47 | 48 | "cell_type": "markdown",
|
48 | 49 | "metadata": {},
|
49 | 50 | "source": [
|
50 |
| - "### N. Martin & J. M. Ruiz Experimental Mismatch Modifier\n", |
| 51 | + "### N. Martin & J. M. Ruiz Mismatch Modifier\n", |
51 | 52 | "This modifier takes into account the responsivities to different spectrums,\n",
|
52 | 53 | "characterized by the airmass and the clearness index, as two independent\n",
|
53 | 54 | "variables. In fact, it is 3 different modifiers, each one for each component\n",
|
54 | 55 | "(``poa_direct``, ``poa_sky_diffuse``, ``poa_ground_diffuse``)\n",
|
55 | 56 | "\n",
|
56 | 57 | "The formula for each component has three coefficients; we are lucky the authors\n",
|
57 | 58 | "of this model computed fitting values for m-Si, p-Si and a-Si!\n",
|
58 |
| - "However, if you would like to compute and/or use your own values, keep reading." |
| 59 | + "However, if you would like to compute and/or use your own values, keep reading.\n", |
| 60 | + "[TODO: LO HAGO O NO LO HAGO?? ###]" |
59 | 61 | ]
|
60 | 62 | },
|
61 | 63 | {
|
62 | 64 | "attachments": {},
|
63 | 65 | "cell_type": "markdown",
|
64 | 66 | "metadata": {},
|
65 | 67 | "source": [
|
66 |
| - "First step is get to the effective irradiance. For simplicity, we will copy the procedure explained in the tutorial ``tmy_to_power.ipynb`` [TODO: HOW CAN I LINK THIS?]. Please refer to it to get a more in depth explanation." |
| 68 | + "First step is get to the effective irradiance. For simplicity, we will copy the procedure explained in the tutorial ``tmy_to_power.ipynb``. Please refer to it to get a more in depth explanation." |
67 | 69 | ]
|
68 | 70 | },
|
69 | 71 | {
|
70 | 72 | "cell_type": "code",
|
71 |
| - "execution_count": 2, |
| 73 | + "execution_count": null, |
72 | 74 | "metadata": {},
|
73 | 75 | "outputs": [],
|
74 | 76 | "source": [
|
|
101 | 103 | "thermal_params = pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_polymer']\n",
|
102 | 104 | "pvtemps = pvlib.temperature.sapm_cell(poa_irrad['poa_global'], tmy_data['temp_air'], tmy_data['wind_speed'], **thermal_params)\n",
|
103 | 105 | "\n",
|
104 |
| - "sandia_modules = pvlib.pvsystem.retrieve_sam(name='SandiaMod')\n", |
105 |
| - "sandia_module = sandia_modules['Canadian_Solar_CS5P_220M___2009_']" |
| 106 | + "# Note that we use the CEC Module provided for the singledionde subsection\n", |
| 107 | + "cec_modules = pvlib.pvsystem.retrieve_sam(name='CECMod')\n", |
| 108 | + "cec_module = cec_modules['Canadian_Solar_Inc__CS5P_220M']" |
106 | 109 | ]
|
107 | 110 | },
|
108 | 111 | {
|
|
124 | 127 | },
|
125 | 128 | {
|
126 | 129 | "cell_type": "code",
|
127 |
| - "execution_count": 9, |
128 |
| - "metadata": {}, |
129 |
| - "outputs": [ |
130 |
| - { |
131 |
| - "name": "stdout", |
132 |
| - "output_type": "stream", |
133 |
| - "text": [ |
134 |
| - "Module type is: c-Si\n" |
135 |
| - ] |
136 |
| - } |
137 |
| - ], |
| 130 | + "execution_count": null, |
| 131 | + "metadata": {}, |
| 132 | + "outputs": [], |
138 | 133 | "source": [
|
139 | 134 | "# First, let's find the airmass and the clearness index\n",
|
140 | 135 | "# Little caution: default values for this model were fitted obtaining the airmass through the kasten1966 method, not used by default\n",
|
|
143 | 138 | " solar_zenith=solar_pos['zenith'],\n",
|
144 | 139 | " extra_radiation=extra_rad)\n",
|
145 | 140 | "# Check module is m-Si (monocrystalline silicon)\n",
|
146 |
| - "print('Module type is: ' + sandia_module['Material']) #-Reports 'c-Si'\n", |
| 141 | + "print('Module type is: ' + cec_module['Technology'])\n", |
147 | 142 | "\n",
|
148 | 143 | "# Get the mismatch modifiers\n",
|
149 | 144 | "modifiers = pvlib.spectrum.martin_ruiz_spectral_modifier(clearness,\n",
|
150 | 145 | " airmass['airmass_absolute'],\n",
|
151 |
| - " cell_type='monosi')\n" |
| 146 | + " cell_type='monosi')" |
| 147 | + ] |
| 148 | + }, |
| 149 | + { |
| 150 | + "attachments": {}, |
| 151 | + "cell_type": "markdown", |
| 152 | + "metadata": {}, |
| 153 | + "source": [ |
| 154 | + "And then we can find the modified irradiances by means of a simple multiplication." |
152 | 155 | ]
|
153 | 156 | },
|
154 | 157 | {
|
155 | 158 | "cell_type": "code",
|
156 |
| - "execution_count": 16, |
| 159 | + "execution_count": null, |
157 | 160 | "metadata": {},
|
158 | 161 | "outputs": [],
|
159 | 162 | "source": [
|
160 |
| - "poa_irrad_modified = pd.Series(dtype=pd.Float64Dtype)\n", |
| 163 | + "# TODO: find a pythonic way\n", |
| 164 | + "poa_irrad_modified = pd.Series(dtype=pd.Float64Dtype) # Suppress FutureWarning about dtype default\n", |
161 | 165 | "poa_irrad_modified['poa_direct'] = poa_irrad['poa_direct'] * modifiers['direct']\n",
|
162 | 166 | "poa_irrad_modified['poa_sky_diffuse'] = poa_irrad['poa_sky_diffuse'] * modifiers['sky_diffuse']\n",
|
163 | 167 | "poa_irrad_modified['poa_ground_diffuse'] = poa_irrad['poa_ground_diffuse'] * modifiers['ground_diffuse']"
|
164 | 168 | ]
|
165 | 169 | },
|
166 | 170 | {
|
167 | 171 | "cell_type": "code",
|
168 |
| - "execution_count": 15, |
169 |
| - "metadata": {}, |
170 |
| - "outputs": [ |
171 |
| - { |
172 |
| - "name": "stdout", |
173 |
| - "output_type": "stream", |
174 |
| - "text": [ |
175 |
| - "22.054707712730973\n" |
176 |
| - ] |
177 |
| - } |
178 |
| - ], |
179 |
| - "source": [] |
| 172 | + "execution_count": null, |
| 173 | + "metadata": {}, |
| 174 | + "outputs": [], |
| 175 | + "source": [ |
| 176 | + "# # TODO: find a pythonic way\n", |
| 177 | + "# poa_irrad_modified2 = pd.Series(dtype=pd.Float64Dtype) # Suppress FutureWarning about dtype default\n", |
| 178 | + "# modifiers2 = modifiers.rename(index={\n", |
| 179 | + "# 'direct': 'poa_direct',\n", |
| 180 | + "# 'sky_diffuse': 'poa_sky_diffuse',\n", |
| 181 | + "# 'ground_diffuse': 'poa_ground_diffuse'\n", |
| 182 | + "# })\n", |
| 183 | + "# poa_irrad_modified2 = poa_irrad.multiply(modifiers2)" |
| 184 | + ] |
| 185 | + }, |
| 186 | + { |
| 187 | + "attachments": {}, |
| 188 | + "cell_type": "markdown", |
| 189 | + "metadata": {}, |
| 190 | + "source": [ |
| 191 | + "Now, we compute the global modified irradiance, to be used in the output power calculation." |
| 192 | + ] |
| 193 | + }, |
| 194 | + { |
| 195 | + "cell_type": "code", |
| 196 | + "execution_count": null, |
| 197 | + "metadata": {}, |
| 198 | + "outputs": [], |
| 199 | + "source": [ |
| 200 | + "poa_irrad_modified = pvlib.irradiance.poa_components(aoi,\n", |
| 201 | + " poa_irrad_modified['poa_direct'],\n", |
| 202 | + " poa_irrad_modified['poa_sky_diffuse'],\n", |
| 203 | + " poa_irrad_modified['poa_ground_diffuse'])" |
| 204 | + ] |
| 205 | + }, |
| 206 | + { |
| 207 | + "attachments": {}, |
| 208 | + "cell_type": "markdown", |
| 209 | + "metadata": {}, |
| 210 | + "source": [ |
| 211 | + "Let's plot the raw vs modified global irradiances, and the difference." |
| 212 | + ] |
| 213 | + }, |
| 214 | + { |
| 215 | + "cell_type": "code", |
| 216 | + "execution_count": null, |
| 217 | + "metadata": {}, |
| 218 | + "outputs": [], |
| 219 | + "source": [ |
| 220 | + "poa_irrad_global_diff = poa_irrad['poa_global'] - poa_irrad_modified['poa_global']\n", |
| 221 | + "poa_irrad['poa_global'].plot()\n", |
| 222 | + "poa_irrad_modified['poa_global'].plot()\n", |
| 223 | + "poa_irrad_global_diff.plot()\n", |
| 224 | + "plt.legend(['Original', 'Modified', 'Difference'])\n", |
| 225 | + "plt.ylabel('Irradiance [W/m²]')\n", |
| 226 | + "plt.show()" |
| 227 | + ] |
| 228 | + }, |
| 229 | + { |
| 230 | + "attachments": {}, |
| 231 | + "cell_type": "markdown", |
| 232 | + "metadata": {}, |
| 233 | + "source": [ |
| 234 | + "Finally, we can get the power result. Instead of using\n", |
| 235 | + "``pvlib.pvsystem.sapm_effective_irradiance``, which already applies another\n", |
| 236 | + "experimental model for the response of the solar module, we have to use the\n", |
| 237 | + "diode model.\n", |
| 238 | + "\n", |
| 239 | + "Have a look to subsection ``DC power using single diode`` in notebook\n", |
| 240 | + "``tmy_to_power.ipynb``. This is just the same two times." |
| 241 | + ] |
| 242 | + }, |
| 243 | + { |
| 244 | + "cell_type": "code", |
| 245 | + "execution_count": null, |
| 246 | + "metadata": {}, |
| 247 | + "outputs": [], |
| 248 | + "source": [ |
| 249 | + "module_params = {k: cec_module[k] for k in ['a_ref', 'I_L_ref', 'I_o_ref', 'R_sh_ref', 'R_s', 'alpha_sc']}" |
| 250 | + ] |
| 251 | + }, |
| 252 | + { |
| 253 | + "attachments": {}, |
| 254 | + "cell_type": "markdown", |
| 255 | + "metadata": {}, |
| 256 | + "source": [ |
| 257 | + "Again, we compute one considering the modifier and another one without it." |
| 258 | + ] |
| 259 | + }, |
| 260 | + { |
| 261 | + "cell_type": "code", |
| 262 | + "execution_count": null, |
| 263 | + "metadata": {}, |
| 264 | + "outputs": [], |
| 265 | + "source": [ |
| 266 | + "# With modifier\n", |
| 267 | + "photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth = \\\n", |
| 268 | + " pvlib.pvsystem.calcparams_desoto(poa_irrad_modified['poa_global'],\n", |
| 269 | + " pvtemps,\n", |
| 270 | + " EgRef=1.121,\n", |
| 271 | + " dEgdT=-0.0002677,\n", |
| 272 | + " **module_params)\n", |
| 273 | + "single_diode_out_modified = pvlib.pvsystem.singlediode(photocurrent, saturation_current,\n", |
| 274 | + " resistance_series, resistance_shunt,\n", |
| 275 | + " nNsVth)\n", |
| 276 | + "# Without modifier\n", |
| 277 | + "photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth = \\\n", |
| 278 | + " pvlib.pvsystem.calcparams_desoto(poa_irrad['poa_global'],\n", |
| 279 | + " pvtemps,\n", |
| 280 | + " EgRef=1.121,\n", |
| 281 | + " dEgdT=-0.0002677,\n", |
| 282 | + " **module_params)\n", |
| 283 | + "single_diode_out = pvlib.pvsystem.singlediode(photocurrent, saturation_current,\n", |
| 284 | + " resistance_series, resistance_shunt,\n", |
| 285 | + " nNsVth)" |
| 286 | + ] |
| 287 | + }, |
| 288 | + { |
| 289 | + "cell_type": "code", |
| 290 | + "execution_count": null, |
| 291 | + "metadata": {}, |
| 292 | + "outputs": [], |
| 293 | + "source": [ |
| 294 | + "# Calculate difference of max power output\n", |
| 295 | + "single_diode_out_max_pwr_diff = (single_diode_out['p_mp']\n", |
| 296 | + " - single_diode_out_modified['p_mp'])\n", |
| 297 | + "# Plot results\n", |
| 298 | + "single_diode_out['p_mp'].plot()\n", |
| 299 | + "single_diode_out_modified['p_mp'].plot()\n", |
| 300 | + "single_diode_out_max_pwr_diff.plot()\n", |
| 301 | + "plt.legend(['Original', 'Modified', 'Difference'])\n", |
| 302 | + "plt.ylabel('DC Power (W)')\n", |
| 303 | + "plt.show()" |
| 304 | + ] |
180 | 305 | }
|
181 | 306 | ],
|
182 | 307 | "metadata": {
|
|
0 commit comments