From 13115efb805470ceb12e5e33e91a46e3665bfbc5 Mon Sep 17 00:00:00 2001 From: Saurabh Aneja Date: Wed, 26 Jan 2022 15:07:07 -0500 Subject: [PATCH 01/11] adding initial gallery examples --- docs/examples/bifacial/README.rst | 3 + docs/examples/bifacial/plot_bifi_model_mc.py | 95 ++++++++++++++++ .../bifacial/plot_bifi_model_pvwatts.py | 102 ++++++++++++++++++ 3 files changed, 200 insertions(+) create mode 100644 docs/examples/bifacial/README.rst create mode 100644 docs/examples/bifacial/plot_bifi_model_mc.py create mode 100644 docs/examples/bifacial/plot_bifi_model_pvwatts.py diff --git a/docs/examples/bifacial/README.rst b/docs/examples/bifacial/README.rst new file mode 100644 index 0000000000..1c29b82ead --- /dev/null +++ b/docs/examples/bifacial/README.rst @@ -0,0 +1,3 @@ +Bifacial Modeling +----------------- + diff --git a/docs/examples/bifacial/plot_bifi_model_mc.py b/docs/examples/bifacial/plot_bifi_model_mc.py new file mode 100644 index 0000000000..70f8c007e7 --- /dev/null +++ b/docs/examples/bifacial/plot_bifi_model_mc.py @@ -0,0 +1,95 @@ +""" +Bifacial Modeling - modelchain +============================== + +Example of bifacial modeling +""" + +# %% +# This example shows how to complete a bifacial modeling example using the +# :py:class:`pvlib.modelchain.ModelChain` with the +# :py:func:`pvlib.bifacial.pvfactors_timeseries` function to transpose +# GHI data to both front and rear Plane of Array (POA) irradiance. + +import pandas as pd +from pvlib import pvsystem +from pvlib import location +from pvlib import modelchain +from pvlib import temperature +from pvlib import bifacial + +# create site location and times characteristics +lat, lon = 36.084, -79.817 +tz = 'Etc/GMT+5' +times = pd.date_range('2021-06-21', '2021-6-22', freq='1T', tz=tz) + +# create site system characteristics +axis_tilt = 0 +axis_azimuth = 180 +gcr = 0.35 +max_angle = 60 +pvrow_height = 3 +pvrow_width = 4 +albedo = 0.2 + +# load temperature parameters and module/inverter specifications +temperature_model_parameters = temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_polymer'] +sandia_modules = pvsystem.retrieve_sam('SandiaMod') +cec_inverters = pvsystem.retrieve_sam('cecinverter') +sandia_module = sandia_modules['Sanyo_HIP_200DA3_Bifacial__2007__E__'] +cec_inverter = cec_inverters['ABB__MICRO_0_25_I_OUTD_US_208__208V_'] + +# create a location for site, and get solar position and clearsky data +site_location = location.Location(lat, lon, tz=tz, name='Greensboro, NC') +solar_position = site_location.get_solarposition(times) +cs = site_location.get_clearsky(times) + +# load solar position and tracker orientation for use in pvsystem object +sat_mount = pvsystem.SingleAxisTrackerMount(axis_tilt=axis_tilt, + axis_azimuth=axis_azimuth, + max_angle=max_angle, + backtrack=True, + gcr=gcr) +# dc arrays +array = pvsystem.Array(mount=sat_mount, + module_parameters=sandia_module, + temperature_model_parameters=temperature_model_parameters) + +# +system = pvsystem.PVSystem(arrays=[array], + inverter_parameters=cec_inverter, + ) + +# created for use in pvfactors timeseries +orientation = sat_mount.get_orientation(solar_position['apparent_zenith'], + solar_position['azimuth'] + ) + +# get rear and front side irradiance from pvfactors transposition engine +irrad = pd.concat(bifacial.pvfactors_timeseries(solar_position['azimuth'], + solar_position['apparent_zenith'], + orientation['surface_azimuth'], + orientation['surface_tilt'], + axis_azimuth, + times, + cs['dni'], + cs['dhi'], + gcr, + pvrow_height, + pvrow_width, + albedo + ), axis=1) + +# define bifaciality coefficient (specific to module type being used) +# create bifacial effective irradiance using aoi-corrected timeseries values +bifaciality = 0.75 +irrad['effective_irradiance'] = irrad['total_abs_front'] + (irrad['total_abs_back'] * bifaciality) + +# create a new modelchain object using the location and system +mc = modelchain.ModelChain(system, site_location) + +# run bifacial simulation +mc.run_model_from_effective_irradiance(irrad) + +# plot results +mc.results.ac.plot() \ No newline at end of file diff --git a/docs/examples/bifacial/plot_bifi_model_pvwatts.py b/docs/examples/bifacial/plot_bifi_model_pvwatts.py new file mode 100644 index 0000000000..269cb99d9d --- /dev/null +++ b/docs/examples/bifacial/plot_bifi_model_pvwatts.py @@ -0,0 +1,102 @@ +""" +Bifacial Modeling - procedural +============================== + +Example of bifacial modeling +""" + +# %% +# This example shows how to complete a bifacial modeling example using the +# :py:class:`pvlib.modelchain.ModelChain` with the +# :py:func:`pvlib.bifacial.pvfactors_timeseries` function to transpose +# GHI data to both front and rear Plane of Array (POA) irradiance. + +import pandas as pd +from pvlib import location +from pvlib import solarposition +from pvlib import tracking +from pvlib import bifacial +from pvlib import temperature +from pvlib import pvsystem +import matplotlib.pyplot as plt + +# using Greensboro, NC for this example +lat, lon = 36.084, -79.817 +tz = 'Etc/GMT+5' +times = pd.date_range('2021-06-21', '2021-6-22', freq='1T', tz=tz) + +# create location object and get clearsky data +site_location = location.Location(lat, lon, tz=tz, name='Greensboro, NC') +cs = site_location.get_clearsky(times) + + +# get solar position data +solar_position = solarposition.get_solarposition(cs.index, + lat, + lon + ) + +# set ground coverage ratio and max_angle to +# pull orientation data for a single-axis tracker +gcr = 0.35 +max_phi = 60 +orientation = tracking.singleaxis(solar_position['apparent_zenith'], + solar_position['azimuth'], + max_angle=max_phi, + backtrack=True, + gcr=gcr + ) + +# set axis_azimuth, albedo, pvrow width and height, and use +# the pvfactors engine for both front and rear-side absorbed irradiance +axis_azmuth = 180 +pvrow_height = 3 +pvrow_width = 4 +albedo = 0.2 +irrad = bifacial.pvfactors_timeseries(solar_position['azimuth'], + solar_position['apparent_zenith'], + orientation['surface_azimuth'], + orientation['surface_tilt'], + axis_azmuth, + cs.index, + cs['dni'], + cs['dhi'], + gcr, + pvrow_height, + pvrow_width, + albedo + ) + +# using bifaciality factor and pvfactors results, create effective +# irradiance data +bifaciality = 0.75 +effective_irrad_bifi = irrad[2] + (irrad[3] * bifaciality) +effective_irrad_mono = irrad[2] + +# get cell temperature using the Faiman model +temp_cell = temperature.faiman(irrad[0], 25, 1) + +# using the pvwatts_dc model and parameters detailed above, +# set pdc0 and return DC power for both bifacial and monofacial +pdc0 = 1 +gamma_pdc = -0.0043 +pdc_bifi = pvsystem.pvwatts_dc(effective_irrad_bifi, + temp_cell, + pdc0, + gamma_pdc=gamma_pdc + ).fillna(0) + +pdc_mono = pvsystem.pvwatts_dc(effective_irrad_mono, + temp_cell, + pdc0, + gamma_pdc=gamma_pdc + ).fillna(0) + + +# plot result +plt.figure() +plt.title('Bifacial vs Monofacial Simulation') +plt.plot(pdc_bifi) +plt.plot(pdc_mono) +plt.legend(['bifi', 'mono']) +plt.ylabel('DC Power') \ No newline at end of file From f81a44ca85707b8dd0c7f8b2c3de4b9812aaa4af Mon Sep 17 00:00:00 2001 From: Saurabh Aneja Date: Thu, 27 Jan 2022 11:01:07 -0500 Subject: [PATCH 02/11] updating bifacial examples added pvfactors into setup.py, cleaned up some white spacing, and hoping for the best... --- docs/examples/bifacial/plot_bifi_model_mc.py | 41 +++++++++++-------- .../bifacial/plot_bifi_model_pvwatts.py | 18 ++++---- setup.py | 2 +- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/docs/examples/bifacial/plot_bifi_model_mc.py b/docs/examples/bifacial/plot_bifi_model_mc.py index 70f8c007e7..363f8175a1 100644 --- a/docs/examples/bifacial/plot_bifi_model_mc.py +++ b/docs/examples/bifacial/plot_bifi_model_mc.py @@ -2,7 +2,7 @@ Bifacial Modeling - modelchain ============================== -Example of bifacial modeling +Example of bifacial modeling using the modelchain """ # %% @@ -17,6 +17,7 @@ from pvlib import modelchain from pvlib import temperature from pvlib import bifacial +import matplotlib.pyplot as plt # create site location and times characteristics lat, lon = 36.084, -79.817 @@ -66,17 +67,17 @@ ) # get rear and front side irradiance from pvfactors transposition engine -irrad = pd.concat(bifacial.pvfactors_timeseries(solar_position['azimuth'], - solar_position['apparent_zenith'], - orientation['surface_azimuth'], - orientation['surface_tilt'], +irrad = pd.concat(bifacial.pvfactors_timeseries(solar_position['azimuth'], + solar_position['apparent_zenith'], + orientation['surface_azimuth'], + orientation['surface_tilt'], axis_azimuth, - times, - cs['dni'], - cs['dhi'], + times, + cs['dni'], + cs['dhi'], gcr, - pvrow_height, - pvrow_width, + pvrow_height, + pvrow_width, albedo ), axis=1) @@ -85,11 +86,19 @@ bifaciality = 0.75 irrad['effective_irradiance'] = irrad['total_abs_front'] + (irrad['total_abs_back'] * bifaciality) -# create a new modelchain object using the location and system -mc = modelchain.ModelChain(system, site_location) +# create modelchain object for bifacial system and run bifacial simulation +mc_bifi = modelchain.ModelChain(system, site_location) +mc_bifi.run_model_from_effective_irradiance(irrad) -# run bifacial simulation -mc.run_model_from_effective_irradiance(irrad) +# for illustration, perform simulation on monofacial system +# first create a new 'effective_irradiance' column from pvfactors data +irrad_mono = irrad.copy() +irrad_mono['effective_irradiance'] = irrad_mono['total_abs_front'] -# plot results -mc.results.ac.plot() \ No newline at end of file +# create modelchain object for monofacial system run monofacial simulation +mc_mono = modelchain.ModelChain(system, site_location) +mc_mono.run_model_from_effective_irradiance(irrad_mono) + +# plot results of both monofacial and bifacial +mc_bifi.results.ac.plot(title='Bifacial vs Monofacial Simulation on Clearsky Day') +mc_mono.results.ac.plot(ylabel='AC Power') \ No newline at end of file diff --git a/docs/examples/bifacial/plot_bifi_model_pvwatts.py b/docs/examples/bifacial/plot_bifi_model_pvwatts.py index 269cb99d9d..346902905e 100644 --- a/docs/examples/bifacial/plot_bifi_model_pvwatts.py +++ b/docs/examples/bifacial/plot_bifi_model_pvwatts.py @@ -2,7 +2,7 @@ Bifacial Modeling - procedural ============================== -Example of bifacial modeling +Example of bifacial modeling using procedural method """ # %% @@ -29,10 +29,9 @@ site_location = location.Location(lat, lon, tz=tz, name='Greensboro, NC') cs = site_location.get_clearsky(times) - # get solar position data -solar_position = solarposition.get_solarposition(cs.index, - lat, +solar_position = solarposition.get_solarposition(cs.index, + lat, lon ) @@ -40,7 +39,7 @@ # pull orientation data for a single-axis tracker gcr = 0.35 max_phi = 60 -orientation = tracking.singleaxis(solar_position['apparent_zenith'], +orientation = tracking.singleaxis(solar_position['apparent_zenith'], solar_position['azimuth'], max_angle=max_phi, backtrack=True, @@ -81,7 +80,7 @@ pdc0 = 1 gamma_pdc = -0.0043 pdc_bifi = pvsystem.pvwatts_dc(effective_irrad_bifi, - temp_cell, + temp_cell, pdc0, gamma_pdc=gamma_pdc ).fillna(0) @@ -92,11 +91,10 @@ gamma_pdc=gamma_pdc ).fillna(0) - -# plot result +# plot results plt.figure() -plt.title('Bifacial vs Monofacial Simulation') +plt.title('Bifacial vs Monofacial Simulation on Clearsky Day') plt.plot(pdc_bifi) plt.plot(pdc_mono) -plt.legend(['bifi', 'mono']) +plt.legend(['bifacial', 'monofacial']) plt.ylabel('DC Power') \ No newline at end of file diff --git a/setup.py b/setup.py index b2cbf486d5..ff175b5270 100755 --- a/setup.py +++ b/setup.py @@ -59,7 +59,7 @@ 'doc': ['ipython', 'matplotlib', 'sphinx == 3.1.2', 'pydata-sphinx-theme', 'sphinx-gallery', 'docutils == 0.15.2', 'pillow', 'netcdf4', 'siphon', - 'sphinx-toggleprompt >= 0.0.5'], + 'sphinx-toggleprompt >= 0.0.5', 'pvfactors'], 'test': TESTS_REQUIRE } EXTRAS_REQUIRE['all'] = sorted(set(sum(EXTRAS_REQUIRE.values(), []))) From c883a0a640462b7cef1a16da6111b7ffb7a72ad7 Mon Sep 17 00:00:00 2001 From: Saurabh Aneja Date: Thu, 27 Jan 2022 16:11:34 -0500 Subject: [PATCH 03/11] gallery_updates --- docs/examples/bifacial/plot_bifi_model_mc.py | 60 ++++++++----------- .../bifacial/plot_bifi_model_pvwatts.py | 25 +++++--- 2 files changed, 42 insertions(+), 43 deletions(-) diff --git a/docs/examples/bifacial/plot_bifi_model_mc.py b/docs/examples/bifacial/plot_bifi_model_mc.py index 363f8175a1..42adf3ee41 100644 --- a/docs/examples/bifacial/plot_bifi_model_mc.py +++ b/docs/examples/bifacial/plot_bifi_model_mc.py @@ -15,9 +15,8 @@ from pvlib import pvsystem from pvlib import location from pvlib import modelchain -from pvlib import temperature +from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS as PARAMS from pvlib import bifacial -import matplotlib.pyplot as plt # create site location and times characteristics lat, lon = 36.084, -79.817 @@ -34,7 +33,7 @@ albedo = 0.2 # load temperature parameters and module/inverter specifications -temperature_model_parameters = temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_polymer'] +temp_model_parameters = PARAMS['sapm']['open_rack_glass_polymer'] sandia_modules = pvsystem.retrieve_sam('SandiaMod') cec_inverters = pvsystem.retrieve_sam('cecinverter') sandia_module = sandia_modules['Sanyo_HIP_200DA3_Bifacial__2007__E__'] @@ -54,51 +53,44 @@ # dc arrays array = pvsystem.Array(mount=sat_mount, module_parameters=sandia_module, - temperature_model_parameters=temperature_model_parameters) + temperature_model_parameters=temp_model_parameters) -# +# create system object system = pvsystem.PVSystem(arrays=[array], - inverter_parameters=cec_inverter, - ) + inverter_parameters=cec_inverter) # created for use in pvfactors timeseries orientation = sat_mount.get_orientation(solar_position['apparent_zenith'], - solar_position['azimuth'] - ) + solar_position['azimuth']) # get rear and front side irradiance from pvfactors transposition engine -irrad = pd.concat(bifacial.pvfactors_timeseries(solar_position['azimuth'], - solar_position['apparent_zenith'], - orientation['surface_azimuth'], - orientation['surface_tilt'], - axis_azimuth, - times, - cs['dni'], - cs['dhi'], - gcr, - pvrow_height, - pvrow_width, - albedo - ), axis=1) +irrad = bifacial.pvfactors_timeseries(solar_position['azimuth'], + solar_position['apparent_zenith'], + orientation['surface_azimuth'], + orientation['surface_tilt'], + axis_azimuth, + times, + cs['dni'], + cs['dhi'], + gcr, + pvrow_height, + pvrow_width, + albedo) + +# turn into pandas DataFrame +irrad = pd.concat(irrad, axis=1) # define bifaciality coefficient (specific to module type being used) # create bifacial effective irradiance using aoi-corrected timeseries values bifaciality = 0.75 -irrad['effective_irradiance'] = irrad['total_abs_front'] + (irrad['total_abs_back'] * bifaciality) +irrad['effective_irradiance'] = ( + irrad['total_abs_front'] + (irrad['total_abs_back'] * bifaciality) +) # create modelchain object for bifacial system and run bifacial simulation mc_bifi = modelchain.ModelChain(system, site_location) mc_bifi.run_model_from_effective_irradiance(irrad) -# for illustration, perform simulation on monofacial system -# first create a new 'effective_irradiance' column from pvfactors data -irrad_mono = irrad.copy() -irrad_mono['effective_irradiance'] = irrad_mono['total_abs_front'] - -# create modelchain object for monofacial system run monofacial simulation -mc_mono = modelchain.ModelChain(system, site_location) -mc_mono.run_model_from_effective_irradiance(irrad_mono) - # plot results of both monofacial and bifacial -mc_bifi.results.ac.plot(title='Bifacial vs Monofacial Simulation on Clearsky Day') -mc_mono.results.ac.plot(ylabel='AC Power') \ No newline at end of file +mc_bifi.results.ac.plot(title='Bifacial Simulation on June Solstice', + ylabel='AC Power') diff --git a/docs/examples/bifacial/plot_bifi_model_pvwatts.py b/docs/examples/bifacial/plot_bifi_model_pvwatts.py index 346902905e..0db76db9da 100644 --- a/docs/examples/bifacial/plot_bifi_model_pvwatts.py +++ b/docs/examples/bifacial/plot_bifi_model_pvwatts.py @@ -35,7 +35,7 @@ lon ) -# set ground coverage ratio and max_angle to +# set ground coverage ratio and max_angle to # pull orientation data for a single-axis tracker gcr = 0.35 max_phi = 60 @@ -70,7 +70,7 @@ # irradiance data bifaciality = 0.75 effective_irrad_bifi = irrad[2] + (irrad[3] * bifaciality) -effective_irrad_mono = irrad[2] + # get cell temperature using the Faiman model temp_cell = temperature.faiman(irrad[0], 25, 1) @@ -84,17 +84,24 @@ pdc0, gamma_pdc=gamma_pdc ).fillna(0) +pdc_bifi.plot(title='Bifacial Simulation on June Solstice', ylabel='DC Power') + +# %% +# For illustration, perform monofacial simulation using pvfactors front-side +# irradiance (AOI-corrected), and plot along with bifacial results. +effective_irrad_mono = irrad[2] pdc_mono = pvsystem.pvwatts_dc(effective_irrad_mono, - temp_cell, + temp_cell, pdc0, gamma_pdc=gamma_pdc ).fillna(0) -# plot results +# plot monofacial results plt.figure() -plt.title('Bifacial vs Monofacial Simulation on Clearsky Day') -plt.plot(pdc_bifi) -plt.plot(pdc_mono) -plt.legend(['bifacial', 'monofacial']) -plt.ylabel('DC Power') \ No newline at end of file +plt.title('Bifacial vs Monofacial Simulation - June Solstice') +pdc_bifi.plot(label='Bifacial') +pdc_mono.plot(label='Monofacial') +plt.ylabel('DC Power') +plt.legend() +# sphinx_gallery_thumbnail_number = 2 From 758455e8da27e3313f78e76ab9d09b91068fa225 Mon Sep 17 00:00:00 2001 From: Saurabh Aneja Date: Thu, 27 Jan 2022 16:21:59 -0500 Subject: [PATCH 04/11] whatsnew --- docs/sphinx/source/whatsnew/v0.9.1.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.1.rst b/docs/sphinx/source/whatsnew/v0.9.1.rst index 4ddcb9bd51..309cecc334 100644 --- a/docs/sphinx/source/whatsnew/v0.9.1.rst +++ b/docs/sphinx/source/whatsnew/v0.9.1.rst @@ -32,7 +32,10 @@ Documentation ~~~~~~~~~~~~~ * Fix documentation return error in :py:meth:`pvlib.forecast.ForecastModel.cloud_cover_to_transmittance_linear` (:issue:`1367`, :pull:`1370`) - +* Add gallery example illustrating bifacial simulation using :py:class:`pvlib.modelchain.ModelChain` + and the :py:func:`pvlib.bifacial.pvfactors_timeseries` function (:pull:`1394`) +* Add gallery example illustrating bifacial simulation using procedural functions + and the :py:func:`pvlib.bifacial.pvfactors_timeseries` function (:pull:`1394`) Requirements ~~~~~~~~~~~~ @@ -46,3 +49,4 @@ Contributors * Kevin Anderson (:ghuser:`kanderso-nrel`) * Adam R. Jensen (:ghuser:`AdamRJensen`) * Johann Loux (:ghuser:`JoLo90`) +* Saurabh Aneja (:ghuser:`spaneja`) From a96a1ae34ce20faca99174e610e15cebdbb021e1 Mon Sep 17 00:00:00 2001 From: Saurabh Aneja Date: Wed, 2 Feb 2022 12:17:55 -0500 Subject: [PATCH 05/11] updates from comments --- docs/examples/bifacial/plot_bifi_model_mc.py | 41 ++++++++++++------- .../bifacial/plot_bifi_model_pvwatts.py | 28 +++++++------ 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/docs/examples/bifacial/plot_bifi_model_mc.py b/docs/examples/bifacial/plot_bifi_model_mc.py index 42adf3ee41..e84c700044 100644 --- a/docs/examples/bifacial/plot_bifi_model_mc.py +++ b/docs/examples/bifacial/plot_bifi_model_mc.py @@ -10,6 +10,14 @@ # :py:class:`pvlib.modelchain.ModelChain` with the # :py:func:`pvlib.bifacial.pvfactors_timeseries` function to transpose # GHI data to both front and rear Plane of Array (POA) irradiance. +# +# Unfortunately ``ModelChain`` does not yet support bifacial simulation +# directly so we have to do the bifacial irradiance simulation ourselves. +# Once the combined front + rear irradiance is known, we can pass that +# to ``ModelChain`` and proceed as usual. +# +# Future versions of pvlib may make it easier to do bifacial modeling +# with ``ModelChain``. import pandas as pd from pvlib import pvsystem @@ -31,12 +39,13 @@ pvrow_height = 3 pvrow_width = 4 albedo = 0.2 +bifaciality = 0.75 # load temperature parameters and module/inverter specifications -temp_model_parameters = PARAMS['sapm']['open_rack_glass_polymer'] -sandia_modules = pvsystem.retrieve_sam('SandiaMod') +temp_model_parameters = PARAMS['sapm']['open_rack_glass_glass'] +cec_modules = pvsystem.retrieve_sam('CECMod') +cec_module = cec_modules['Trina_Solar_TSM_300DEG5C_07_II_'] cec_inverters = pvsystem.retrieve_sam('cecinverter') -sandia_module = sandia_modules['Sanyo_HIP_200DA3_Bifacial__2007__E__'] cec_inverter = cec_inverters['ABB__MICRO_0_25_I_OUTD_US_208__208V_'] # create a location for site, and get solar position and clearsky data @@ -50,14 +59,6 @@ max_angle=max_angle, backtrack=True, gcr=gcr) -# dc arrays -array = pvsystem.Array(mount=sat_mount, - module_parameters=sandia_module, - temperature_model_parameters=temp_model_parameters) - -# create system object -system = pvsystem.PVSystem(arrays=[array], - inverter_parameters=cec_inverter) # created for use in pvfactors timeseries orientation = sat_mount.get_orientation(solar_position['apparent_zenith'], @@ -82,15 +83,27 @@ # define bifaciality coefficient (specific to module type being used) # create bifacial effective irradiance using aoi-corrected timeseries values -bifaciality = 0.75 irrad['effective_irradiance'] = ( irrad['total_abs_front'] + (irrad['total_abs_back'] * bifaciality) ) +# %% +# With effective irradiance, we can pass data to ModelChain for +# bifacial simulation. + +# dc arrays +array = pvsystem.Array(mount=sat_mount, + module_parameters=cec_module, + temperature_model_parameters=temp_model_parameters) + +# create system object +system = pvsystem.PVSystem(arrays=[array], + inverter_parameters=cec_inverter) + # create modelchain object for bifacial system and run bifacial simulation -mc_bifi = modelchain.ModelChain(system, site_location) +mc_bifi = modelchain.ModelChain(system, site_location, aoi_model='no_loss') mc_bifi.run_model_from_effective_irradiance(irrad) -# plot results of both monofacial and bifacial +# plot results mc_bifi.results.ac.plot(title='Bifacial Simulation on June Solstice', ylabel='AC Power') diff --git a/docs/examples/bifacial/plot_bifi_model_pvwatts.py b/docs/examples/bifacial/plot_bifi_model_pvwatts.py index 0db76db9da..04eda0b810 100644 --- a/docs/examples/bifacial/plot_bifi_model_pvwatts.py +++ b/docs/examples/bifacial/plot_bifi_model_pvwatts.py @@ -7,13 +7,12 @@ # %% # This example shows how to complete a bifacial modeling example using the -# :py:class:`pvlib.modelchain.ModelChain` with the +# :py:func:`pvlib.pvsystem.pvwatts_dc` with the # :py:func:`pvlib.bifacial.pvfactors_timeseries` function to transpose # GHI data to both front and rear Plane of Array (POA) irradiance. import pandas as pd from pvlib import location -from pvlib import solarposition from pvlib import tracking from pvlib import bifacial from pvlib import temperature @@ -23,17 +22,14 @@ # using Greensboro, NC for this example lat, lon = 36.084, -79.817 tz = 'Etc/GMT+5' -times = pd.date_range('2021-06-21', '2021-6-22', freq='1T', tz=tz) +times = pd.date_range('2021-06-21', '2021-06-22', freq='1T', tz=tz) # create location object and get clearsky data site_location = location.Location(lat, lon, tz=tz, name='Greensboro, NC') cs = site_location.get_clearsky(times) # get solar position data -solar_position = solarposition.get_solarposition(cs.index, - lat, - lon - ) +solar_position = site_location.get_solarposition(times) # set ground coverage ratio and max_angle to # pull orientation data for a single-axis tracker @@ -48,7 +44,7 @@ # set axis_azimuth, albedo, pvrow width and height, and use # the pvfactors engine for both front and rear-side absorbed irradiance -axis_azmuth = 180 +axis_azimuth = 180 pvrow_height = 3 pvrow_width = 4 albedo = 0.2 @@ -56,7 +52,7 @@ solar_position['apparent_zenith'], orientation['surface_azimuth'], orientation['surface_tilt'], - axis_azmuth, + axis_azimuth, cs.index, cs['dni'], cs['dhi'], @@ -66,14 +62,22 @@ albedo ) +# turn into pandas DataFrame +irrad = pd.concat(irrad, axis=1) + # using bifaciality factor and pvfactors results, create effective # irradiance data bifaciality = 0.75 -effective_irrad_bifi = irrad[2] + (irrad[3] * bifaciality) +effective_irrad_bifi = irrad['total_abs_front'] + (irrad['total_abs_back'] + * bifaciality) # get cell temperature using the Faiman model -temp_cell = temperature.faiman(irrad[0], 25, 1) +# it is worth noting that this example uses total frontside incident +# irradiance, however, for bifacial modeling, total irradiance (inclusive of +# front and rear side) may be needed. +temp_cell = temperature.faiman(irrad['total_inc_front'], temp_air=25, + wind_speed=1) # using the pvwatts_dc model and parameters detailed above, # set pdc0 and return DC power for both bifacial and monofacial @@ -90,7 +94,7 @@ # For illustration, perform monofacial simulation using pvfactors front-side # irradiance (AOI-corrected), and plot along with bifacial results. -effective_irrad_mono = irrad[2] +effective_irrad_mono = irrad['total_abs_front'] pdc_mono = pvsystem.pvwatts_dc(effective_irrad_mono, temp_cell, pdc0, From 932b7d9c269200613f29d398613e2afdaf0f7ccd Mon Sep 17 00:00:00 2001 From: Saurabh Aneja Date: Thu, 3 Feb 2022 14:59:47 -0500 Subject: [PATCH 06/11] comment update --- docs/examples/bifacial/plot_bifi_model_mc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/examples/bifacial/plot_bifi_model_mc.py b/docs/examples/bifacial/plot_bifi_model_mc.py index e84c700044..4641de2709 100644 --- a/docs/examples/bifacial/plot_bifi_model_mc.py +++ b/docs/examples/bifacial/plot_bifi_model_mc.py @@ -81,7 +81,6 @@ # turn into pandas DataFrame irrad = pd.concat(irrad, axis=1) -# define bifaciality coefficient (specific to module type being used) # create bifacial effective irradiance using aoi-corrected timeseries values irrad['effective_irradiance'] = ( irrad['total_abs_front'] + (irrad['total_abs_back'] * bifaciality) From 72aa0a7dec526d97ecf4071740ea978009ee9cae Mon Sep 17 00:00:00 2001 From: Saurabh Aneja Date: Wed, 9 Feb 2022 10:35:45 -0500 Subject: [PATCH 07/11] updated comments, warnings, and variables --- docs/examples/bifacial/plot_bifi_model_mc.py | 16 ++++++++++++-- .../bifacial/plot_bifi_model_pvwatts.py | 22 +++++++++++-------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/docs/examples/bifacial/plot_bifi_model_mc.py b/docs/examples/bifacial/plot_bifi_model_mc.py index 4641de2709..93a69b2e3b 100644 --- a/docs/examples/bifacial/plot_bifi_model_mc.py +++ b/docs/examples/bifacial/plot_bifi_model_mc.py @@ -25,6 +25,10 @@ from pvlib import modelchain from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS as PARAMS from pvlib import bifacial +import warnings + +# supressing shapely warnings that occur on import of pvfactors +warnings.filterwarnings(action='ignore', module='pvfactors') # create site location and times characteristics lat, lon = 36.084, -79.817 @@ -65,6 +69,8 @@ solar_position['azimuth']) # get rear and front side irradiance from pvfactors transposition engine +# explicity simulate on pvarray with 3 rows, with sensor placed in middle row +# users may select different values depending on needs irrad = bifacial.pvfactors_timeseries(solar_position['azimuth'], solar_position['apparent_zenith'], orientation['surface_azimuth'], @@ -76,7 +82,10 @@ gcr, pvrow_height, pvrow_width, - albedo) + albedo, + n_pvrows=3, + index_observed_pvrow=1 + ) # turn into pandas DataFrame irrad = pd.concat(irrad, axis=1) @@ -99,7 +108,10 @@ system = pvsystem.PVSystem(arrays=[array], inverter_parameters=cec_inverter) -# create modelchain object for bifacial system and run bifacial simulation +# ModelChain requires the parameter aoi_loss to have a value. pvfactors +# applies surface reflection models in the calculation of front and back +# irradiance, so assign aoi_model='no_loss' to avoid double counting +# reflections. mc_bifi = modelchain.ModelChain(system, site_location, aoi_model='no_loss') mc_bifi.run_model_from_effective_irradiance(irrad) diff --git a/docs/examples/bifacial/plot_bifi_model_pvwatts.py b/docs/examples/bifacial/plot_bifi_model_pvwatts.py index 04eda0b810..dfd16c260e 100644 --- a/docs/examples/bifacial/plot_bifi_model_pvwatts.py +++ b/docs/examples/bifacial/plot_bifi_model_pvwatts.py @@ -18,6 +18,10 @@ from pvlib import temperature from pvlib import pvsystem import matplotlib.pyplot as plt +import warnings + +# supressing shapely warnings that occur on import of pvfactors +warnings.filterwarnings(action='ignore', module='pvfactors') # using Greensboro, NC for this example lat, lon = 36.084, -79.817 @@ -43,11 +47,14 @@ ) # set axis_azimuth, albedo, pvrow width and height, and use -# the pvfactors engine for both front and rear-side absorbed irradiance +# the pvfactors engine for both front and rear-side absorbed irradiance axis_azimuth = 180 pvrow_height = 3 pvrow_width = 4 albedo = 0.2 + +# explicity simulate on pvarray with 3 rows, with sensor placed in middle row +# users may select different values depending on needs irrad = bifacial.pvfactors_timeseries(solar_position['azimuth'], solar_position['apparent_zenith'], orientation['surface_azimuth'], @@ -59,24 +66,21 @@ gcr, pvrow_height, pvrow_width, - albedo + albedo, + n_pvrows=3, + index_observed_pvrow=1 ) # turn into pandas DataFrame irrad = pd.concat(irrad, axis=1) -# using bifaciality factor and pvfactors results, create effective -# irradiance data +# using bifaciality factor and pvfactors results, create effective irradiance bifaciality = 0.75 effective_irrad_bifi = irrad['total_abs_front'] + (irrad['total_abs_back'] * bifaciality) - # get cell temperature using the Faiman model -# it is worth noting that this example uses total frontside incident -# irradiance, however, for bifacial modeling, total irradiance (inclusive of -# front and rear side) may be needed. -temp_cell = temperature.faiman(irrad['total_inc_front'], temp_air=25, +temp_cell = temperature.faiman(effective_irrad_bifi, temp_air=25, wind_speed=1) # using the pvwatts_dc model and parameters detailed above, From 0fb980cbf16b49ea445518e5c0888604e9b0670f Mon Sep 17 00:00:00 2001 From: Saurabh Aneja Date: Wed, 9 Feb 2022 10:37:11 -0500 Subject: [PATCH 08/11] whitespace --- docs/examples/bifacial/plot_bifi_model_mc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/bifacial/plot_bifi_model_mc.py b/docs/examples/bifacial/plot_bifi_model_mc.py index 93a69b2e3b..b73e23abcf 100644 --- a/docs/examples/bifacial/plot_bifi_model_mc.py +++ b/docs/examples/bifacial/plot_bifi_model_mc.py @@ -111,7 +111,7 @@ # ModelChain requires the parameter aoi_loss to have a value. pvfactors # applies surface reflection models in the calculation of front and back # irradiance, so assign aoi_model='no_loss' to avoid double counting -# reflections. +# reflections. mc_bifi = modelchain.ModelChain(system, site_location, aoi_model='no_loss') mc_bifi.run_model_from_effective_irradiance(irrad) From e4b97d9851b1be5a8f9083c9f02e09128f69030e Mon Sep 17 00:00:00 2001 From: Saurabh Aneja Date: Tue, 22 Feb 2022 11:26:03 -0500 Subject: [PATCH 09/11] small edits --- docs/examples/bifacial/plot_bifi_model_mc.py | 36 +++++++++---------- .../bifacial/plot_bifi_model_pvwatts.py | 36 +++++++++---------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/docs/examples/bifacial/plot_bifi_model_mc.py b/docs/examples/bifacial/plot_bifi_model_mc.py index b73e23abcf..dcf394ad58 100644 --- a/docs/examples/bifacial/plot_bifi_model_mc.py +++ b/docs/examples/bifacial/plot_bifi_model_mc.py @@ -8,8 +8,8 @@ # %% # This example shows how to complete a bifacial modeling example using the # :py:class:`pvlib.modelchain.ModelChain` with the -# :py:func:`pvlib.bifacial.pvfactors_timeseries` function to transpose -# GHI data to both front and rear Plane of Array (POA) irradiance. +# :py:func:`pvlib.bifacial.pvfactors.pvfactors_timeseries` function +# to transpose GHI data to both front and rear Plane of Array (POA) irradiance. # # Unfortunately ``ModelChain`` does not yet support bifacial simulation # directly so we have to do the bifacial irradiance simulation ourselves. @@ -24,7 +24,7 @@ from pvlib import location from pvlib import modelchain from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS as PARAMS -from pvlib import bifacial +from pvlib.bifacial.pvfactors import pvfactors_timeseries import warnings # supressing shapely warnings that occur on import of pvfactors @@ -71,21 +71,21 @@ # get rear and front side irradiance from pvfactors transposition engine # explicity simulate on pvarray with 3 rows, with sensor placed in middle row # users may select different values depending on needs -irrad = bifacial.pvfactors_timeseries(solar_position['azimuth'], - solar_position['apparent_zenith'], - orientation['surface_azimuth'], - orientation['surface_tilt'], - axis_azimuth, - times, - cs['dni'], - cs['dhi'], - gcr, - pvrow_height, - pvrow_width, - albedo, - n_pvrows=3, - index_observed_pvrow=1 - ) +irrad = pvfactors_timeseries(solar_position['azimuth'], + solar_position['apparent_zenith'], + orientation['surface_azimuth'], + orientation['surface_tilt'], + axis_azimuth, + times, + cs['dni'], + cs['dhi'], + gcr, + pvrow_height, + pvrow_width, + albedo, + n_pvrows=3, + index_observed_pvrow=1 + ) # turn into pandas DataFrame irrad = pd.concat(irrad, axis=1) diff --git a/docs/examples/bifacial/plot_bifi_model_pvwatts.py b/docs/examples/bifacial/plot_bifi_model_pvwatts.py index dfd16c260e..05a6a07b31 100644 --- a/docs/examples/bifacial/plot_bifi_model_pvwatts.py +++ b/docs/examples/bifacial/plot_bifi_model_pvwatts.py @@ -8,13 +8,13 @@ # %% # This example shows how to complete a bifacial modeling example using the # :py:func:`pvlib.pvsystem.pvwatts_dc` with the -# :py:func:`pvlib.bifacial.pvfactors_timeseries` function to transpose -# GHI data to both front and rear Plane of Array (POA) irradiance. +# :py:func:`pvlib.bifacial.pvfactors.pvfactors_timeseries` function to +# transpose GHI data to both front and rear Plane of Array (POA) irradiance. import pandas as pd from pvlib import location from pvlib import tracking -from pvlib import bifacial +from pvlib.bifacial.pvfactors import pvfactors_timeseries from pvlib import temperature from pvlib import pvsystem import matplotlib.pyplot as plt @@ -55,21 +55,21 @@ # explicity simulate on pvarray with 3 rows, with sensor placed in middle row # users may select different values depending on needs -irrad = bifacial.pvfactors_timeseries(solar_position['azimuth'], - solar_position['apparent_zenith'], - orientation['surface_azimuth'], - orientation['surface_tilt'], - axis_azimuth, - cs.index, - cs['dni'], - cs['dhi'], - gcr, - pvrow_height, - pvrow_width, - albedo, - n_pvrows=3, - index_observed_pvrow=1 - ) +irrad = pvfactors_timeseries(solar_position['azimuth'], + solar_position['apparent_zenith'], + orientation['surface_azimuth'], + orientation['surface_tilt'], + axis_azimuth, + cs.index, + cs['dni'], + cs['dhi'], + gcr, + pvrow_height, + pvrow_width, + albedo, + n_pvrows=3, + index_observed_pvrow=1 + ) # turn into pandas DataFrame irrad = pd.concat(irrad, axis=1) From 9cc00ac7a4241af4285b986f0337d8722d928e8c Mon Sep 17 00:00:00 2001 From: Saurabh Aneja <63314623+spaneja@users.noreply.github.com> Date: Mon, 28 Feb 2022 14:59:05 -0500 Subject: [PATCH 10/11] Apply suggestions from code review Co-authored-by: Cliff Hansen --- docs/examples/bifacial/plot_bifi_model_mc.py | 2 +- docs/examples/bifacial/plot_bifi_model_pvwatts.py | 2 +- docs/sphinx/source/whatsnew/v0.9.1.rst | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/examples/bifacial/plot_bifi_model_mc.py b/docs/examples/bifacial/plot_bifi_model_mc.py index dcf394ad58..caa5cf7ce4 100644 --- a/docs/examples/bifacial/plot_bifi_model_mc.py +++ b/docs/examples/bifacial/plot_bifi_model_mc.py @@ -2,7 +2,7 @@ Bifacial Modeling - modelchain ============================== -Example of bifacial modeling using the modelchain +Example of bifacial modeling using pvfactors and ModelChain """ # %% diff --git a/docs/examples/bifacial/plot_bifi_model_pvwatts.py b/docs/examples/bifacial/plot_bifi_model_pvwatts.py index 05a6a07b31..3a0a7674a6 100644 --- a/docs/examples/bifacial/plot_bifi_model_pvwatts.py +++ b/docs/examples/bifacial/plot_bifi_model_pvwatts.py @@ -2,7 +2,7 @@ Bifacial Modeling - procedural ============================== -Example of bifacial modeling using procedural method +Example of bifacial modeling using pvfactors and procedural method """ # %% diff --git a/docs/sphinx/source/whatsnew/v0.9.1.rst b/docs/sphinx/source/whatsnew/v0.9.1.rst index 80bddce02e..16cc47e711 100644 --- a/docs/sphinx/source/whatsnew/v0.9.1.rst +++ b/docs/sphinx/source/whatsnew/v0.9.1.rst @@ -53,10 +53,10 @@ Documentation ~~~~~~~~~~~~~ * Fix documentation return error in :py:meth:`pvlib.forecast.ForecastModel.cloud_cover_to_transmittance_linear` (:issue:`1367`, :pull:`1370`) -* Add gallery example illustrating bifacial simulation using :py:class:`pvlib.modelchain.ModelChain` - and the :py:func:`pvlib.bifacial.pvfactors_timeseries` function (:pull:`1394`) -* Add gallery example illustrating bifacial simulation using procedural functions - and the :py:func:`pvlib.bifacial.pvfactors_timeseries` function (:pull:`1394`) +* Add gallery example illustrating bifacial simulation using the + :py:func:`pvlib.bifacial.pvfactors_timeseries` function and either + :py:class:`pvlib.modelchain.ModelChain` or procedural functions. + (:pull:`1394`) Requirements ~~~~~~~~~~~~ From f486d81d10514ab7a076b5dc8d00a6641418351b Mon Sep 17 00:00:00 2001 From: Kevin Anderson <57452607+kanderso-nrel@users.noreply.github.com> Date: Mon, 28 Feb 2022 13:18:04 -0700 Subject: [PATCH 11/11] Update docs/sphinx/source/whatsnew/v0.9.1.rst --- docs/sphinx/source/whatsnew/v0.9.1.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sphinx/source/whatsnew/v0.9.1.rst b/docs/sphinx/source/whatsnew/v0.9.1.rst index 2f237d2e45..363fca15a9 100644 --- a/docs/sphinx/source/whatsnew/v0.9.1.rst +++ b/docs/sphinx/source/whatsnew/v0.9.1.rst @@ -55,8 +55,8 @@ Documentation (:issue:`1367`, :pull:`1370`) * Add gallery example illustrating bifacial simulation using the :py:func:`pvlib.bifacial.pvfactors_timeseries` function and either - :py:class:`pvlib.modelchain.ModelChain` or procedural functions. - (:pull:`1394`) + :py:class:`pvlib.modelchain.ModelChain` or procedural functions. + (:pull:`1394`) * Fix some typos (:pull:`1414`) Requirements