Skip to content

Commit 8f3b965

Browse files
committed
Update mismatch_modifiers.ipynb
1 parent 3486069 commit 8f3b965

File tree

1 file changed

+159
-34
lines changed

1 file changed

+159
-34
lines changed

docs/tutorials/mismatch_modifiers.ipynb

Lines changed: 159 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
{
3030
"cell_type": "code",
31-
"execution_count": 1,
31+
"execution_count": null,
3232
"metadata": {},
3333
"outputs": [],
3434
"source": [
@@ -37,6 +37,7 @@
3737
"import matplotlib.pyplot as plt\n",
3838
"\n",
3939
"import pandas as pd\n",
40+
"import numpy as np\n",
4041
"\n",
4142
"# And pvlib\n",
4243
"import pvlib"
@@ -47,28 +48,29 @@
4748
"cell_type": "markdown",
4849
"metadata": {},
4950
"source": [
50-
"### N. Martin & J. M. Ruiz Experimental Mismatch Modifier\n",
51+
"### N. Martin & J. M. Ruiz Mismatch Modifier\n",
5152
"This modifier takes into account the responsivities to different spectrums,\n",
5253
"characterized by the airmass and the clearness index, as two independent\n",
5354
"variables. In fact, it is 3 different modifiers, each one for each component\n",
5455
"(``poa_direct``, ``poa_sky_diffuse``, ``poa_ground_diffuse``)\n",
5556
"\n",
5657
"The formula for each component has three coefficients; we are lucky the authors\n",
5758
"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?? ###]"
5961
]
6062
},
6163
{
6264
"attachments": {},
6365
"cell_type": "markdown",
6466
"metadata": {},
6567
"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."
6769
]
6870
},
6971
{
7072
"cell_type": "code",
71-
"execution_count": 2,
73+
"execution_count": null,
7274
"metadata": {},
7375
"outputs": [],
7476
"source": [
@@ -101,8 +103,9 @@
101103
"thermal_params = pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_polymer']\n",
102104
"pvtemps = pvlib.temperature.sapm_cell(poa_irrad['poa_global'], tmy_data['temp_air'], tmy_data['wind_speed'], **thermal_params)\n",
103105
"\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']"
106109
]
107110
},
108111
{
@@ -124,17 +127,9 @@
124127
},
125128
{
126129
"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": [],
138133
"source": [
139134
"# First, let's find the airmass and the clearness index\n",
140135
"# Little caution: default values for this model were fitted obtaining the airmass through the kasten1966 method, not used by default\n",
@@ -143,40 +138,170 @@
143138
" solar_zenith=solar_pos['zenith'],\n",
144139
" extra_radiation=extra_rad)\n",
145140
"# 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",
147142
"\n",
148143
"# Get the mismatch modifiers\n",
149144
"modifiers = pvlib.spectrum.martin_ruiz_spectral_modifier(clearness,\n",
150145
" 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."
152155
]
153156
},
154157
{
155158
"cell_type": "code",
156-
"execution_count": 16,
159+
"execution_count": null,
157160
"metadata": {},
158161
"outputs": [],
159162
"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",
161165
"poa_irrad_modified['poa_direct'] = poa_irrad['poa_direct'] * modifiers['direct']\n",
162166
"poa_irrad_modified['poa_sky_diffuse'] = poa_irrad['poa_sky_diffuse'] * modifiers['sky_diffuse']\n",
163167
"poa_irrad_modified['poa_ground_diffuse'] = poa_irrad['poa_ground_diffuse'] * modifiers['ground_diffuse']"
164168
]
165169
},
166170
{
167171
"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+
]
180305
}
181306
],
182307
"metadata": {

0 commit comments

Comments
 (0)