Ejemplo n.º 1
0
def srfIrradiance(plane,hourOfYr,epwdata):
  """calculates irradiance striking a given plane at a given hour for a given location
  plane (fp.Ray) the plane in question
  hour (int) the hour of the year to test, 0-8760
  epwdata (dict) a dictionary of epw data
  out: the amount of radition striking the plane
  """
  #calculate the solar vector
  day = int(hourOfYr/24)
  hour = hourOfYr%24
  sunvec = sg.calc_sunVector(epwdata['lat'], epwdata['long'], epwdata['timezone'], day, hour)
  #print sunvec
  print day
  print hour
  #print
  print hourOfYr
  
  #find the angle between our plane and the sun direction
  incidenceAngle = abs(sunvec.angle(plane.vec))
  #print incidenceAngle
  if incidenceAngle > math.pi/2 : srfIrr = 0.0 #if the sun is behind our plane, return zero
  else : srfIrr = epwdata['radiation'][hourOfYr] * math.cos(incidenceAngle) # otherwise, calculate the amout of radition striking our surface
  #print max(x)
  #print '{} w/m2 for hour {} at angle {} in {}'.format(srfIrr,hourOfYr,incidenceAngle,epwdata['name'])
  #print max(incidenceAngle)
  #print max(epwdata['radiation'][hourOfYr])
  print srfIrr
  return srfIrr
Ejemplo n.º 2
0
def sunEnvelope(plane, epwdata, daystart, dayend, hourstart, hourend):
  envelope = []
  for day in range(daystart, dayend):
    for hour in range(hourstart, hourend):
      sunvec = sg.calc_sunVector(epwdata['lat'], epwdata['long'], epwdata['timezone'], day, hour)
      incidenceAngle = abs(sunvec.angle(plane.vec))
      if incidenceAngle < math.pi/2: envelope.append(sunvec)
  
  return envelope
Ejemplo n.º 3
0
def srfIrradiance(plane, hourOfYr, epwdata):
    """calculates irradiance striking a given plane at a given hour for a given location
  plane (fp.Ray) the plane in question
  hour (int) the hour of the year to test, 0-8760
  epwdata (dict) a dictionary of epw data
  out: the amount of radition striking the plane
  """
    # calculate the solar vector
    day = int(hourOfYr / 24)
    hour = hourOfYr % 24
    sunvec = sg.calc_sunVector(epwdata["lat"], epwdata["long"], epwdata["timezone"], day, hour)

    # find the angle between our plane and the sun direction
    incidenceAngle = abs(sunvec.angle(plane.vec))
    if incidenceAngle > math.pi / 2:
        srfIrr = 0.0  # if the sun is behind our plane, return zero
    else:
        srfIrr = epwdata["radiation"][hourOfYr] * math.cos(
            incidenceAngle
        )  # otherwise, calculate the amout of radition striking our surface
    # print srfIrr
    return srfIrr
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
def srfIrradiance(plane, hourOfYr, epwdata):
    """calculates irradiance striking a given plane at a given hour for a given location
  plane (fp.Ray) the plane in question
  hour (int) the hour of the year to test, 0-8760
  epwdata (dict) a dictionary of epw data
  out: the amount of radition striking the plane
  """
    #calculate the solar vector
    day = int(hourOfYr / 24)
    hour = hourOfYr % 24
    sunvec = sg.calc_sunVector(epwdata['lat'], epwdata['long'],
                               epwdata['timezone'], day, hour)

    #find the angle between our plane and the sun direction
    incidenceAngle = abs(sunvec.angle(plane.vec))
    #print incidenceAngle
    if incidenceAngle > math.pi / 2:
        srfIrr = 0.0  #if the sun is behind our plane, return zero
    else:
        srfIrr = epwdata['radiation'][hourOfYr] * math.cos(
            incidenceAngle
        )  # otherwise, calculate the amout of radition striking our surface
    return srfIrr
Ejemplo n.º 6
0


# 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 
dayStart = sg.calc_dayOfYear("03/21")
dayEnd = sg.calc_dayOfYear("06/21")
Ejemplo n.º 7
0

# 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