Skip to content

Commit 3486069

Browse files
committed
Create mismatch_modifiers.ipynb
1 parent 0747a43 commit 3486069

File tree

1 file changed

+209
-0
lines changed

1 file changed

+209
-0
lines changed
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
{
2+
"cells": [
3+
{
4+
"attachments": {},
5+
"cell_type": "markdown",
6+
"metadata": {},
7+
"source": [
8+
"# Mismatch Modifiers\n",
9+
"Learn to use mismatch modifiers with this notebook!\n",
10+
"Feel free to add other models, be sure to update the index and give you credit ;)\n",
11+
"\n",
12+
"Table of contents:\n",
13+
"1. [Setup](#setup)\n",
14+
"1. [N. Martin & J. M. Ruiz Experimental Mismatch Modifier](#n-martin--j-m-ruiz-experimental-mismatch-modifier)\n",
15+
"\n",
16+
"Authors:\n",
17+
"* Echedey Luis (@echedey-ls), 2023 Feb"
18+
]
19+
},
20+
{
21+
"attachments": {},
22+
"cell_type": "markdown",
23+
"metadata": {},
24+
"source": [
25+
"## Setup\n",
26+
"Let's prepare the environment:"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": 1,
32+
"metadata": {},
33+
"outputs": [],
34+
"source": [
35+
"# Show matplotlib's figures in the notebook\n",
36+
"%matplotlib inline\n",
37+
"import matplotlib.pyplot as plt\n",
38+
"\n",
39+
"import pandas as pd\n",
40+
"\n",
41+
"# And pvlib\n",
42+
"import pvlib"
43+
]
44+
},
45+
{
46+
"attachments": {},
47+
"cell_type": "markdown",
48+
"metadata": {},
49+
"source": [
50+
"### N. Martin & J. M. Ruiz Experimental Mismatch Modifier\n",
51+
"This modifier takes into account the responsivities to different spectrums,\n",
52+
"characterized by the airmass and the clearness index, as two independent\n",
53+
"variables. In fact, it is 3 different modifiers, each one for each component\n",
54+
"(``poa_direct``, ``poa_sky_diffuse``, ``poa_ground_diffuse``)\n",
55+
"\n",
56+
"The formula for each component has three coefficients; we are lucky the authors\n",
57+
"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+
]
60+
},
61+
{
62+
"attachments": {},
63+
"cell_type": "markdown",
64+
"metadata": {},
65+
"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."
67+
]
68+
},
69+
{
70+
"cell_type": "code",
71+
"execution_count": 2,
72+
"metadata": {},
73+
"outputs": [],
74+
"source": [
75+
"site = pvlib.location.Location(40.4534, -3.7270, altitude=664,\n",
76+
" name='IES-UPM, Madrid', tz='CET')\n",
77+
"\n",
78+
"surface_tilt = 40\n",
79+
"surface_azimuth = 180 # Pointing South\n",
80+
"\n",
81+
"tmy_data, _, _, _ = pvlib.iotools.get_pvgis_tmy(site.latitude, site.longitude, map_variables=True,\n",
82+
" startyear=2005, endyear=2015)\n",
83+
"tmy_data.index = [ts.replace(year=2022) for ts in tmy_data.index]\n",
84+
"\n",
85+
"solar_pos = site.get_solarposition(tmy_data.index)\n",
86+
"\n",
87+
"extra_rad = pvlib.irradiance.get_extra_radiation(tmy_data.index)\n",
88+
"\n",
89+
"poa_sky_diffuse = pvlib.irradiance.haydavies(surface_tilt, surface_azimuth, tmy_data['dhi'],\n",
90+
" tmy_data['dni'], extra_rad,\n",
91+
" solar_pos['apparent_zenith'], solar_pos['azimuth'])\n",
92+
"\n",
93+
"poa_ground_diffuse = pvlib.irradiance.get_ground_diffuse(surface_tilt, tmy_data['ghi'])\n",
94+
"\n",
95+
"aoi = pvlib.irradiance.aoi(surface_tilt, surface_azimuth, solar_pos['apparent_zenith'], solar_pos['azimuth'])\n",
96+
"\n",
97+
"# Let's consider this the irradiances without modifiers\n",
98+
"poa_irrad = pvlib.irradiance.poa_components(aoi, tmy_data['dni'], poa_sky_diffuse, poa_ground_diffuse)\n",
99+
"\n",
100+
"# Following part will be needed later\n",
101+
"thermal_params = pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_polymer']\n",
102+
"pvtemps = pvlib.temperature.sapm_cell(poa_irrad['poa_global'], tmy_data['temp_air'], tmy_data['wind_speed'], **thermal_params)\n",
103+
"\n",
104+
"sandia_modules = pvlib.pvsystem.retrieve_sam(name='SandiaMod')\n",
105+
"sandia_module = sandia_modules['Canadian_Solar_CS5P_220M___2009_']"
106+
]
107+
},
108+
{
109+
"attachments": {},
110+
"cell_type": "markdown",
111+
"metadata": {},
112+
"source": [
113+
"Here comes the modifier. Let's calculate it and examine the introduced\n",
114+
"difference.\n"
115+
]
116+
},
117+
{
118+
"attachments": {},
119+
"cell_type": "markdown",
120+
"metadata": {},
121+
"source": [
122+
"That was a lot, yeah. But don't worry, now we can find the effective irradiance, the mismatch modifier (with the airmass and clearness index)"
123+
]
124+
},
125+
{
126+
"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+
],
138+
"source": [
139+
"# First, let's find the airmass and the clearness index\n",
140+
"# Little caution: default values for this model were fitted obtaining the airmass through the kasten1966 method, not used by default\n",
141+
"airmass = site.get_airmass(solar_position=solar_pos, model='kasten1966')\n",
142+
"clearness = pvlib.irradiance.clearness_index(ghi=tmy_data['ghi'],\n",
143+
" solar_zenith=solar_pos['zenith'],\n",
144+
" extra_radiation=extra_rad)\n",
145+
"# Check module is m-Si (monocrystalline silicon)\n",
146+
"print('Module type is: ' + sandia_module['Material']) #-Reports 'c-Si'\n",
147+
"\n",
148+
"# Get the mismatch modifiers\n",
149+
"modifiers = pvlib.spectrum.martin_ruiz_spectral_modifier(clearness,\n",
150+
" airmass['airmass_absolute'],\n",
151+
" cell_type='monosi')\n"
152+
]
153+
},
154+
{
155+
"cell_type": "code",
156+
"execution_count": 16,
157+
"metadata": {},
158+
"outputs": [],
159+
"source": [
160+
"poa_irrad_modified = pd.Series(dtype=pd.Float64Dtype)\n",
161+
"poa_irrad_modified['poa_direct'] = poa_irrad['poa_direct'] * modifiers['direct']\n",
162+
"poa_irrad_modified['poa_sky_diffuse'] = poa_irrad['poa_sky_diffuse'] * modifiers['sky_diffuse']\n",
163+
"poa_irrad_modified['poa_ground_diffuse'] = poa_irrad['poa_ground_diffuse'] * modifiers['ground_diffuse']"
164+
]
165+
},
166+
{
167+
"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": []
180+
}
181+
],
182+
"metadata": {
183+
"kernelspec": {
184+
"display_name": "venv",
185+
"language": "python",
186+
"name": "python3"
187+
},
188+
"language_info": {
189+
"codemirror_mode": {
190+
"name": "ipython",
191+
"version": 3
192+
},
193+
"file_extension": ".py",
194+
"mimetype": "text/x-python",
195+
"name": "python",
196+
"nbconvert_exporter": "python",
197+
"pygments_lexer": "ipython3",
198+
"version": "3.10.4"
199+
},
200+
"orig_nbformat": 4,
201+
"vscode": {
202+
"interpreter": {
203+
"hash": "e7b76f25baca03aa641c501db0912de76daa352e2d97ceb6fcf3025f206f2928"
204+
}
205+
}
206+
},
207+
"nbformat": 4,
208+
"nbformat_minor": 2
209+
}

0 commit comments

Comments
 (0)