Commit 48e1b8ea authored by acs-ede's avatar acs-ede

first version finished - results to be checked with Marco

parent 662d16d0
No preview for this file type
import numpy as np
from classes.sun_position import sun_position
from classes.irradiation_calc import irradiation_calc
from classes.POA_irradiance import POA_irradiance
import matplotlib.pyplot as plt
class PV_generator:
def __init__(self):
class PV_generator:
def __init__(self, **kwargs):
for key in kwargs:
if key == "cloudiness_level":
self.cloudiness_level = kwargs[key]
self.latitude = 50.77 # default value for Aachen
self.longitude = 6.09 # default value for Aachen
self.gmt_diff = 1 # default value for Aachen
......@@ -28,7 +33,7 @@ class PV_generator:
else:
self.minute_str = str(self.minute)
self.cloudiness_time_list.append(self.hour_str + ':' + self.minute_str)
self.cloudiness_matrix = [0,24,2]
self.cloudiness_matrix = [0,24,self.cloudiness_level]
self.number_units = 1
self.pv_list = '1'
self.pvdata = np.matrix([[1,30,180,0.2]])
......@@ -215,11 +220,24 @@ class PV_generator:
irradiation_calculation = irradiation_calc(self.num_day, self.theta_zenith, self.cloudiness_matrix)
[self.GHI, self.DNI,self.DHI, self.extraterr_radiation] = irradiation_calculation.output()
self.pv_profiles = np.matrix(np.zeros((self.number_units,86400)))
for i in range(self.number_units):
albedo = self.pvdata[i,3]
tilt_pv = self.pvdata[i,1]
azimuth_pv = self.pvdata[i,2]
power = self.pvdata[i,0]
POA = POA_irradiance(self.GHI,self.DNI,self.DHI,self.theta_zenith,self.theta_azimuth,self.extraterr_radiation,albedo,tilt_pv,azimuth_pv)
PV_output = POA.output()
self.pv_profiles[i] = np.transpose(PV_output)*power
if __name__ == "__main__":
PVgen = PV_generator()
PVgen = PV_generator(cloudiness_level=2)
PVgen.get_Data_1(latitude=50.77, longitude=6.09, gmt_diff= 1, day =1, month=1)
PVgen.get_Data_1(latitude=50.77, longitude=6.09, gmt_diff= 1, day =1, month=6)
PVgen.get_Data_2(number_units=1, pv_power=[1],tilt_angle=[30], azimuth_angle=[180], albedo=[0.2])
PVgen.generate_profiles()
PVprofiles = PVgen.pv_profiles
plt.figure(1)
plt.plot(np.array(PVprofiles)[0])
plt.show()
\ No newline at end of file
import numpy as np
class POA_irradiance():
def __init__(self,GHI, DNI, DHI, theta_zenith, theta_azimuth, extraterr_radiation, albedo, tilt_pv, azimuth_pv):
tilt_pv = tilt_pv*np.pi/180
azimuth_pv = azimuth_pv*np.pi/180
AOI = np.arccos(np.multiply(np.cos(theta_zenith),np.cos(tilt_pv))+np.multiply(np.sin(theta_zenith)*np.sin(tilt_pv), np.cos(theta_azimuth-azimuth_pv)))
Ai = DNI/extraterr_radiation
Eb = np.multiply(DNI,np.cos(AOI))
Ed = np.multiply(DHI,(np.multiply(Ai,np.cos(AOI))+np.multiply((1-Ai),(1+np.cos(tilt_pv)))/2))
Eg = GHI*albedo*(1-np.cos(tilt_pv))/2
POA = Eb+Ed+Eg
POA[np.where(POA<0.0)[0],0] = 0
if np.remainder(np.shape(POA)[0],2) == 1:
self.POA1 = POA[0:int(np.shape(POA)[0]/2-0.5),0]
self.POA2 = POA[int(np.shape(POA)[0]/2+0.5):int((np.shape(POA))[0]),0]
elif np.remainder(np.shape(POA)[0],2) == 0:
self.POA1 = POA[0:int(np.shape(POA)[0]/2),0]
self.POA2 = POA[int(np.shape(POA)[0]/2):int((np.shape(POA))[0])+1,0]
indx1 = np.matrix(np.where(self.POA1==0)[0])
len_indx1 = np.shape(indx1)[1]
indx2 = indx1[0,len_indx1-1]
self.POA1[0:indx2,0] = 0
indx1 = np.matrix(np.where(self.POA2==0)[0])
indx2 = indx1[0,0]
self.POA2[indx2:np.shape(self.POA2)[0],0] = 0
def output(self):
self.PV_output = np.concatenate((self.POA1/1000,self.POA2/1000),axis=0)
return self.PV_output
......@@ -59,10 +59,10 @@ class irradiation_calc():
'''
I think there is an error in the matlab file
'''
# if np.any(m<=20):
# dr = 1/(6.6296 + 1.7513*m - 0.1202*np.power(m,2) + 0.0065*np.power(m,3) - 0.00013*np.power(m,4))
# else:
dr = 1/(10.4 + 0.718*m)
if np.any(m<=20):
dr = 1/(6.6296 + 1.7513*m - 0.1202*np.power(m,2) + 0.0065*np.power(m,3) - 0.00013*np.power(m,4))
else:
dr = 1/(10.4 + 0.718*m)
self.DNI = self.Extraterr_radiation*np.exp(-0.8662*Tlk*np.multiply(m,dr))
def cloud_generator(self):
......
......@@ -41,9 +41,9 @@ class sun_position():
#% If procedure to put the azimuth between 0 and pi when the hour angle is negative and between -pi and 0 when the hour angle is positive
for i in range(len(self.theta_azimuth)):
if theta_azimuth2[i] < 0 and theta_azimuth1[i]<np.pi/2:
self.theta_azimuth = 2*np.pi + theta_azimuth2[i]
if theta_azimuth2[i] < 0 and theta_azimuth1[i]>np.pi/2:
self.theta_azimuth = 2*np.pi - theta_azimuth1[i]
self.theta_azimuth[i,0] = 2*np.pi + theta_azimuth2[i]
elif theta_azimuth2[i] < 0 and theta_azimuth1[i]>np.pi/2:
self.theta_azimuth[i,0] = 2*np.pi - theta_azimuth1[i]
def output(self):
return self.theta_zenith, self.theta_azimuth
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment