# given data
import math
n=319 # 15th November
gamma=math.radians(30) # angle in radian
beta=math.radians(45) # angle in radian
phi=math.radians(18.9) # latitude in radian
solartime=13.5-4*(81.733-72.816)/60 +14.74/60 # in hours
delta=23.45*(math.sin(math.radians(360.0*(284.0+n)/365.0))) # in radian
B=45#(360.0*(n-81)/364)
E=9.87*math.sin(2*B)-7.53*math.cos(B)-15*math.sin(B)
w=math.radians((solartime-12)*15) # hour angle
thetai=math.acos((math.cos(phi)*math.cos(beta)+math.sin(phi)*math.sin(beta)*math.cos(gamma))*math.cos(delta)*math.cos(w) + math.cos(delta)*math.sin(w)*math.sin(beta)*math.sin(gamma) + math.sin(delta)*(math.sin(phi)*math.cos(beta)-math.cos(phi)*math.sin(beta)*math.cos(gamma)))
print round(math.degrees(thetai),2),"degree"
# The answer in the textbook is wrong due to wrong expression of Cos(Thetai)
# given data
import math
n1=1 # 1st january
n2=182 # july 1
phi=34.083 # latitude in degree
delta1=23.45*math.sin(math.radians(360.0*(284.0+n1)/365.0)) # in degree
delta2=23.45*math.sin(math.radians(360.0*(284.0+n2)/365.0)) # in degree
td1=(2.0/15)*math.degrees(math.acos(math.tan(phi)/math.tan(delta1))) # daylight hours for january 1
td2=(2.0/15)*math.degrees(math.acos(math.tan(phi)/math.tan(delta2))) # daylight hours for july 1
print "daylight hours for january 1 are",round(td1,2),"hours"
print "daylight hours for july 1 are",round(td2,2),"hours"
# the answers are slightly different in textbook due to approximation while here ansers are precise
# given data
import math
a=0.25 # constant for delhi from table 4.1
b=0.57 # constant for delhi from table 4.1
phi=27.166 # latitute in degrees
n=17 # day
nbar=7 # sunshine hours
delta=23.45*(math.sin(math.radians(360.0*(284.0+n)/365.0))) # in radian
wt=math.acos(math.radians(-math.tan(phi)*(math.tan(delta)))) # hour angle at sunrise
Nbar=(2*math.degrees(wt)/15.0)# day length
Ho=3600*(24.0/math.pi)*1.367*(1+0.033*math.cos((360.0*n/365)))*(math.cos(phi)*cos(delta)*sin(wt)+1.3728*sin(delta)*sin(phi)) # in kj/m^2 per day
Hg=Ho*(a+b*(nbar/Nbar)) # in kj/m^2 per day
print "The monthly average is ",round(-Hg,2)," in kj/m^2 per day"
# the answer in the book is wrong due to wrong calculations
# given data
import math
Hg=19160.94 # in kj/m^2 per day from previous example
Ho=32107.62 # in kj/m^2 per day from previous example
KT=Hg/Ho # unitless
Hd=Hg*(1.354-1.570*KT) # in kj/m^2 per day
Hb= Hg-Hd # in kj/m^2 per day
print "Monthly average of daily diffused is ",round(Hd,2),"in kj/m^2 per day"
print "beam radiation is ",round(Hb,2),"in kj/m^2 per day"
# the solution inthe textbook is wrong as the values from previous examples are used which too are incorrect
# given data
import math
# most of the data is used is from previous example:
phi=27.166 # in degree
n=17 # day
ws=78.66 # degrees
delta=-20.96 # in degrees
Ho=22863.3 # kj/m^2 per day
Hg=14413.82 # kj/m^2 per day
Hd=5259.6 # kj/m^2 per day
w=(11.5-12)*15 # in degrees
Io=3600*1.367*(1+0.033*math.cos(360*17/365.0))*(math.cos(math.radians(phi))*math.cos(math.radians(delta))*math.cos(math.radians(w)))+math.sin(math.radians(delta))*math.sin(math.radians(phi))
a=0.409+0.5016*math.sin(ws-60)
b=0.6609-0.4767*math.sin(ws-60)
Ig=Hg*(a+b*math.cos(w))*Io/Ho # in kJ/m^2-h
print "The monthly average of hourly global radiation is ",round(Ig,2),"kJ/m^2-h"
adash=0.4922+(0.27/(Hd/Hg))
bdash=2*(1-adash)*(math.sin(math.radians(ws)))-1.7328*math.cos(math.radians(78.66))/(1.7328-0.5*math.sin(math.radians(2*78.66)))
Id=5259.6*(1.2321-0.3983*math.cos(math.radians(w)))*Io/Ho # kJ/m^2-h
print "The hourly diffuse radiations are",round(Id,2),"kJ/m^2-h"
# the solution inthe textbook is wrong as the values from previous examples are used which too are incorrect
# given data
import math
phi=28.58 # in degree
n=135 # may 15
delta=23.45*math.sin(math.radians(360*(284+n)/365.0))
w=(13.5-12)*15 # in degrees
A=3981.6 # in W/m^2 from table 4.2
B=0.177# from table 4.2
C=0.130 # from table 4.2
costhetaz=math.cos(phi)*math.cos(delta)*math.cos(w)+math.sin(delta)*math.sin(phi)
Ibn=A*math.exp(-B/0.922)# kJ/m^2-h
Id=C*Ibn # kJ/m^2-h
print "The diffused radiation is ",round(Id,2),"kJ/m^2-h"
Ib=Ibn*0.922 # in kJ/m^2-h
print "The beam radiation is ",round(Ib,2),"kJ/m^2-h"
Ig=Ib+Id # in kJ/m^2-h
print "The global radiation is ",round(Ig,2),"kJ/m^2-h"
# given data
import math
phi=28.58 # in degree
B=30 # in degree
n=318 # november 14
Hg=16282.8 # in kJ/m^2-day from Table C1 appendix C
Hd=4107.6 # in kJ/m^2-day from Table C2 appendix C
delta=23.45*(math.sin(math.radians(360.0*(284.0+n)/365.0))) # in radians
ws=math.acos(math.radians(-math.tan(phi)*(math.tan(delta)))) # hour angle at sunrise
Rb=(ws*sin(math.radians(delta))*math.sin(phi-B)+math.cos((delta))*math.sin(ws)*math.cos(phi-B))/(ws*sin((delta))*math.sin(math.radians(phi))+math.cos(math.radians(delta))*math.sin(ws)*math.cos(math.radians(phi)))
Rd=(1+math.cos(math.radians(B)))/2
Rr=0.2*(1-math.cos(math.radians(B)))/2
Ht=((1-(Hd/Hg))*1.56+(Hd/Hg)*Rd + Rr)*Hg
print "Monthly average total radiation is",round(Ht,2),"kJ/m^2-h"