forked from NREL/bifacial_radiance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path19 - Example Simulation - East West Sheds.py
147 lines (90 loc) · 4.33 KB
/
19 - Example Simulation - East West Sheds.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env python
# coding: utf-8
# # 19 - Example Simluation: East West Sheds
#
# This simulates a particular case where you have alternating rows facing east and west, in "E-W sheds".
#
# 
#
#
# To simulate this, we will use the bases learned in Journal 7 of using multipe scene objects. One scene object will be all the "East facing modules", while the West facing modules will be the second scene object. We have to know some geometry to offset the modules, and that is calculated below:
#
# 
#
# In[1]:
import os
import numpy as np
import pandas as pd
from pathlib import Path
import bifacial_radiance
# In[2]:
bifacial_radiance.__version__
# In[3]:
testfolder = testfolder = str(Path().resolve().parent.parent / 'bifacial_radiance' / 'Tutorial_01')
if not os.path.exists(testfolder):
os.makedirs(testfolder)
demo = bifacial_radiance.RadianceObj("tutorial_19", path = testfolder) # Create a RadianceObj 'object'
demo.setGround(0.62)
epwfile = demo.getEPW(lat = 37.5, lon = -77.6)
metdata = demo.readWeatherFile(epwfile, coerce_year=2001)
timestamp = metdata.datetime.index(pd.to_datetime('2001-06-17 13:0:0 -5'))
demo.gendaylit(timestamp)
# Define your shed characteristics. In this case it is a 4-up landscape setup:
# In[4]:
# For sanity check, we are creating the same module but with different names for each orientation.
numpanels=4
ygap = 0.02 # m Spacing between modules on each shed.
y=1 # m. module size, one side
x=1.7 # m. module size, other side. for landscape, x > y
mymoduleEast = demo.makeModule(name='test-module_East',y=y,x=x, numpanels=numpanels, ygap=ygap)
mymoduleWest = demo.makeModule(name='test-module_West',y=y,x=x, numpanels=numpanels, ygap=ygap)
# Calculate the spacings so we can offset the West Facing modules properly:
#
# 
#
#
# In[5]:
tilt = 30
gap_between_EW_sheds = 1 # m
gap_between_shed_rows = 2 #m
CW = mymoduleEast.sceney
ground_underneat_shed = CW * np.cos(np.radians(tilt))
pitch = ground_underneat_shed*2 + gap_between_EW_sheds + gap_between_shed_rows
offset_westshed = -(ground_underneat_shed+gap_between_EW_sheds)
# Define the other characteristics of our array:
# In[6]:
clearance_height = 1.2 # m
nMods = 21
nRows = 7
# Create the Scene Objects and the Scene:
# In[7]:
sceneDict = {'tilt':tilt,'pitch':pitch,'clearance_height':clearance_height,'azimuth':90, 'nMods': nMods, 'nRows': nRows,
'appendRadfile':True}
sceneObj1 = demo.makeScene(mymoduleEast, sceneDict)
sceneDict2 = {'tilt':tilt,'pitch':pitch,'clearance_height':clearance_height,'azimuth':270, 'nMods': nMods, 'nRows': nRows,
'originx': offset_westshed, 'originy': 0,
'appendRadfile':True}
sceneObj2 = demo.makeScene(mymoduleWest, sceneDict2)
# Finally get all the files together by creating the Octfile:
# In[8]:
octfile = demo.makeOct(demo.getfilelist())
# #### View the Geometry
#
# You can check the geometry on rvu with the following commands. You can run it in jupyter/Python if you comment the line, but the program will not continue processing until you close the rvu window. ( if running rvu directly on the console, navigate to the folder where you have the simulation, and don't use the exclamation point at the beginning)
#
# Top view:
# In[9]:
#!rvu -vf views\front.vp -e .01 -pe 0.3 -vp 1 -45 40 -vd 0 0.7 -0.7 MultipleObj.oct
# another view, close up:
# In[10]:
# !rvu -vf views\front.vp -e .01 -pe 0.3 -vp -4 -29 3.5 -vd 0 1 0 MultipleObj.oct
# #### Analysis:
#
# We have to analyze the East and the West shed independently.
# In[11]:
sensorsy=4 # 1 per module. consider increasing the number but be careful with sensors in the space between modules.
analysis = bifacial_radiance.AnalysisObj(octfile, demo.basename)
frontscan, backscan = analysis.moduleAnalysis(sceneObj1, sensorsy=sensorsy)
frontdict, backdict = analysis.analysis(octfile, "EastFacingShed", frontscan, backscan) # compare the back vs front irradiance
frontscan, backscan = analysis.moduleAnalysis(sceneObj2, sensorsy=sensorsy )
frontdict2, backdict2 = analysis.analysis(octfile, "WestFacingShed", frontscan, backscan) # compare the back vs front irradiance