def main(): """a simple example of calculating solar incident radiation. given a user-defined plane to evaluate, a hard-coded position, and a EPW file that associates date/time with radiation level, calculates the amount of radition striking the plane and produces a simple visualization. """ outie = fp.make_out(fp.outies.Rhino, "solar incidence") outie.set_color(Color(0.75)) # getting user input pathPrefix = "" path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw" epwdata = epwData(path) plane = Ray(Point(0, 0, 0), Vec(1, -5, 2)) #user-defined plane # Calculates the Yearly Average or Yearly Maximum Incident Radiation #irrArr = [] #for h in range(8760): irrArr.append(srfIrradiance(plane,h,epwdata)) #maxIrr = max(irrArr) #Calculates Yearly Maximum Radiation #avgIrr = (sum(irrArr))/(len(irrArr)) #Calculates Yearly Average Radiation #print '{} Yearly Maximum Radiation w/m2'.format(maxIrr) #print '{} Yearly Average Radiation w/m2'.format(avgIrr) dateStart = "1/1" dateEnd = "12/31" dayStart = sg.calc_dayOfYear(dateStart) dayEnd = sg.calc_dayOfYear(dateEnd) startTime = 9 endTime = 18 envelope = sunEnvelope(plane, epwdata, dayStart, dayEnd, startTime, endTime) print "size of envelope = " + str(len(envelope)) #visualize results #normalizedVal = maxIrr/1000 #sets a range of 0w/m2 -> 1000w/m2 normalizedVal = 0.5 colorA = Color.HSB( 0.75) #saturation and brightness of HSB colors default to 1.0 colorB = Color.HSB( 0.0) #saturation and brightness of HSB colors default to 1.0 color = Color.interpolate(colorA, colorB, normalizedVal) plane.set_color(color) plane.vec.length = normalizedVal * 10 outie.put([plane]) outie.put(envelope) outie.draw()
def main(): """a simple example of calculating solar incident radiation. given a user-defined plane to evaluate, a hard-coded position, and a EPW file that associates date/time with radiation level, calculates the amount of radition striking the plane and produces a simple visualization. """ outie = fp.make_out(fp.outies.Rhino, "solar incidence") outie.set_color(Color(0.75)) # getting user input pathPrefix = "" path = pathPrefix + "USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw" epwdata = epwData(path) plane = Ray(Point(0,0,0), Vec(1, -5, 2)) #user-defined plane # Calculates the Yearly Average or Yearly Maximum Incident Radiation #irrArr = [] #for h in range(8760): irrArr.append(srfIrradiance(plane,h,epwdata)) #maxIrr = max(irrArr) #Calculates Yearly Maximum Radiation #avgIrr = (sum(irrArr))/(len(irrArr)) #Calculates Yearly Average Radiation #print '{} Yearly Maximum Radiation w/m2'.format(maxIrr) #print '{} Yearly Average Radiation w/m2'.format(avgIrr) dateStart = "1/1" dateEnd = "12/31" dayStart = sg.calc_dayOfYear(dateStart) dayEnd = sg.calc_dayOfYear(dateEnd) startTime= 9 endTime = 18 envelope = sunEnvelope(plane, epwdata, dayStart, dayEnd, startTime, endTime) print "size of envelope = " + str(len(envelope)) #visualize results #normalizedVal = maxIrr/1000 #sets a range of 0w/m2 -> 1000w/m2 normalizedVal = 0.5 colorA = Color.HSB(0.75) #saturation and brightness of HSB colors default to 1.0 colorB = Color.HSB(0.0) #saturation and brightness of HSB colors default to 1.0 color = Color.interpolate(colorA,colorB,normalizedVal) plane.set_color(color) plane.vec.length = normalizedVal * 10 outie.put([plane]) outie.put(envelope) outie.draw()
def main(): """a simple example of calculating solar incident radiation. given a user-defined plane to evaluate, a hard-coded position, and a EPW file that associates date/time with radiation level, calculates the amount of radition striking the plane and produces a simple visualization. """ outie = fp.make_out(fp.outies.Rhino, "solar incidence") outie.set_color(Color(0.75)) # getting user input epwdata = epwData("USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw") plane = Ray(Point(0, 0, 2), Vec(5, 2, 1)) #user-defined plane day = sg.calc_dayOfYear( "01/03") #day of the year to calculate solar incidence hour = (24 * (day - 1)) + int(sg.calc_hourDecimal( "14:00")) #hour of the day to calculate solar incidence #Yearly Average srfIrr = 0 for h in range(hour, hour + 1): srfIrr = (srfIrradiance(plane, h, epwdata)) #/24 print srfIrr #print srfIrr #srfIrr = 0 #for irrVal in srfIrr: # irrVal += srfIrr # print irrVal #for srfIrr in range(24): #srfIrr += (srfIrradiance(plane,h,epwdata))/8760 print '{} total w/m2 for first 48 hours'.format(srfIrr) #visualize results colorA = Color.HSB( 0.0) #saturation and brightness of HSB colors default to 1.0 colorB = Color.HSB( 0.75) #saturation and brightness of HSB colors default to 1.0 color = Color.interpolate(colorA, colorB, srfIrr * .001) plane.set_color(color) plane.vec.length = srfIrr / 10 outie.put([plane]) outie.draw()
def main(): """a simple example of calculating solar incident radiation. given a user-defined plane to evaluate, a hard-coded position, and a EPW file that associates date/time with radiation level, calculates the amount of radition striking the plane and produces a simple visualization. """ outie = fp.make_out(fp.outies.Rhino, "solar incidence") outie.set_color(Color(0.75)) # getting user input epwdata = epwData("USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw") plane = Ray(Point(0,0,2), Vec(5,2,1)) #user-defined plane day = sg.calc_dayOfYear("01/03") #day of the year to calculate solar incidence hour = (24*(day-1))+int(sg.calc_hourDecimal("14:00")) #hour of the day to calculate solar incidence #Yearly Average srfIrr = 0 for h in range(hour, hour+1): srfIrr = (srfIrradiance(plane,h,epwdata))#/24 print srfIrr #print srfIrr #srfIrr = 0 #for irrVal in srfIrr: # irrVal += srfIrr # print irrVal #for srfIrr in range(24): #srfIrr += (srfIrradiance(plane,h,epwdata))/8760 print '{} total w/m2 for first 48 hours'.format(srfIrr) #visualize results colorA = Color.HSB(0.0) #saturation and brightness of HSB colors default to 1.0 colorB = Color.HSB(0.75) #saturation and brightness of HSB colors default to 1.0 color = Color.interpolate(colorA,colorB,srfIrr*.001) plane.set_color(color) plane.vec.length = srfIrr/10 outie.put([plane]) outie.draw()
def main(): """a simple example of calculating solar incident radiation. given a user-defined plane to evaluate, and hard-coded position, date/time and radiation level, calculates the amount of radition striking the plane and produces a simple visualization. """ outie = fp.make_out(fp.outies.Rhino, "solar incidence") outie.set_color(Color(0.75)) # getting user input lat,long,tmz = 40.75,-73.5,-5.0 #global position plane = Ray(Point(0,0,0), Vec(5,2,1)) #user-defined plane date,hour = "05/16", "12:00" #hard-coded date/time radiation = 1000 #user-defined solar intensity (direct normal) #calculate the solar vector day = sg.calc_dayOfYear(date) hour = sg.calc_hourDecimal(hour) sunvec = sg.calc_sunVector(lat, long, tmz, day, hour) #find the angle between our plane and the sun direction incidenceAngle = sunvec.angle(plane.vec) if incidenceAngle > math.pi/2 or radiation == 0: #if the sun is behind our plane then no radiation is possible print "Solar Incidence on the Surface = 0" return else : #calculate the amout of radition striking our surface srfIrr = radiation * math.cos(incidenceAngle) print "srfIrr = {}".format(srfIrr) #visualize results colorA = Color.HSB(0.75) #saturation and brightness of HSB colors default to 1.0 colorB = Color.HSB(0.0) #saturation and brightness of HSB colors default to 1.0 color = Color.interpolate(colorA,colorB,srfIrr/100) plane.set_color(color) #assign HSB color to user-defined plane plane.vec.length = srfIrr/10 #scale the vector to a length proportional to the surface irradiance outie.put([plane,sunvec]) outie.draw()
v = rs.VectorScale(n, factor) AddVector(v, p1) # Get the points of the tower tower = getPointsTower(30, 10) print tower # Fix a location latitude = 40.75 longitude = -73.5 timezone = -5.0 #---------------------------------------------------------------------------------------------------------------- # First calculate surface irradiance on the tower for a fixed hour of a given day day = sg.calc_dayOfYear("03/16") hour = sg.calc_hourDecimal("13:00") sun = rs.VectorUnitize(sg.calc_sunVector(latitude, longitude, timezone, day, hour)) #define the direct normal data file to use for irradiance values file = open("c:\dirNormals.txt", "r") dirNormalIrad=dirNormalIrad_fromFile(file) #retrieve the corresponding value of I_n for the particular hour that we're interested in; #I_n = dirNormalIrad_Placeholder(day, h) I_n = dirNormalIrad[int((day-1)*24 + hour -1)] #currently rounds to the nearest hour if reading from file surfaceIrradiance_fixed(tower, sun, I_n) #---------------------------------------------------------------------------------------------------------------- #Next, let's calculate an aggregated surface irradiance over a consecutive period of time
) / 200 #200 is just to shorten the vector to something manageable v = rs.VectorScale(n, factor) AddVector(v, p1) # Get the points of the tower tower = getPointsTower(30, 10) print tower # Fix a location latitude = 40.75 longitude = -73.5 timezone = -5.0 #---------------------------------------------------------------------------------------------------------------- # First calculate surface irradiance on the tower for a fixed hour of a given day day = sg.calc_dayOfYear("03/16") hour = sg.calc_hourDecimal("13:00") sun = rs.VectorUnitize( sg.calc_sunVector(latitude, longitude, timezone, day, hour)) #define the direct normal data file to use for irradiance values file = open("c:\dirNormals.txt", "r") dirNormalIrad = dirNormalIrad_fromFile(file) #retrieve the corresponding value of I_n for the particular hour that we're interested in; #I_n = dirNormalIrad_Placeholder(day, h) I_n = dirNormalIrad[ int((day - 1) * 24 + hour - 1)] #currently rounds to the nearest hour if reading from file surfaceIrradiance_fixed(tower, sun, I_n)