Shared2019-10-26-222803.ipynbOpen in CoCalc
Views : 27
In [ ]:
# Configure Jupyter so figures appear in the notebook
%matplotlib inline

# Configure Jupyter to display the assigned value after an assignment
%config InteractiveShell.ast_node_interactivity='last_expr_or_assign'

# import functions from the modsim.py module
from modsim import *

from mpl_toolkits import mplot3d
import matplotlib.gridspec as gridspec
from scipy import integrate


### Question

The question that we wanted to answer was: How does the ambient temperature increase due to global warming affect solar panel efficiency? This would be an explanatory question because we are trying to understand one of the causes of reduced efficiency of solar panels. This is an important question because it allows the customer or prospective customer to better understand where the energy from their panels is going and where some of it is being lost. On a larger scale, the losses would be much more significant, so the customer can see if it would be viable for them to install cooling.

### Methodology

To simulate the incidence power from sunlight over the course of the day, we are taking irradiance data from the course of a day in Needham (July). From this data, we factor in the albedo of the solar panels (how much energy is absorbed by the panel) to find the amount of power it is converting to electricity. We also factored in how many panels we are using, the surface area of the cells, and the time step for each datapoint of irradiance (30 minutes). We then took the specifications of the solar panel (such as maximum power production capacity, the power loss coefficient, and specific heat of the cells) and incorporated them into a set of equations that calculate the energy lost due to inefficiency over the course of the day. From that, we were able to plot the output over time and compare it to the ideal power generation with optimal conditions and visually see the inefficiency of the panel over the course of the day. Taking the integral of that allows us to see the cumilative energy loss over the course of the day.

In [ ]:
def make_system(absorb,weight,loss_coeff,specif,area):
init = State(temp = 25, irradiance=[0,0,0,0,0,0,0,0,0,1,33,97,157,259,328,396,496,567,
617,676,700,720,739,694,684,686,639,549,412,393,290
,226,204,223,142,58,40,19,4,0,0,0,0,0,0,0,0] )
temp_year = [274.8, 272.95, 276.6, 282.1, 287.55, 293, 296.15, 295.4, 291.4, 285.35, 280.2, 274.65]
irr_year = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 75, 147, 233, 318, 378, 421, 448, 444,                       404,373,325,237,154,86,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 4, 27, 58, 93, 148, 201, 217, 225, 187, 177, 194, 294, 411, 372, 341, 295, 230, 150, 89, 37, 4, 0, 0, 0, 0, 0, 0 ,0 ,0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 68, 161, 251, 314, 397, 503, 571, 621, 609, 583,  668, 550, 387, 300,  260, 296, 266, 236, 181, 117, 46, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 24, 54, 97, 117, 282, 343, 461, 516, 580, 597, 568, 616, 531, 459, 427, 388, 302, 386, 459, 381, 303, 239, 126, 57, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 87, 186, 264, 317, 483, 428, 615, 621, 641, 708, 580, 389, 220, 446, 829, 880, 837, 782, 677, 554, 543, 433, 277, 176, 98, 48, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 42, 88, 126, 208, 137, 268, 392, 384, 450, 409, 465, 429, 347, 294, 294, 287, 366, 352, 326, 379, 320, 253, 264, 189, 109, 64, 47, 22, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
[0,0,0,0,0,0,0,0,0,1,33,97,157,259,328,396,496,567, 617,676,700,720,739,694,684,686,639,549,412,393,290,226,204,223,142,58,40,19,4,0,0,0,0,0,0,0,0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 28, 54, 110, 173, 264, 297, 374, 274, 195, 259, 228, 252, 232, 233, 187, 241, 383, 283, 450, 387, 375, 331, 313, 227, 200, 117, 47, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 101, 170, 266, 349, 388, 468, 565, 699,743, 793, 837, 837, 822, 792, 552, 426, 555, 446, 390, 212, 135, 100, 50, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 11, 20, 32, 45, 58, 71, 82, 90, 97, 101, 95, 98, 95, 63, 87, 83, 81, 56, 22, 21, 10, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 4, 18, 37, 54, 40, 49, 126, 96, 119, 93,  112, 199, 143, 115, 142, 100, 103, 51, 15, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 66, 137, 210, 279, 339, 388, 425, 448, 456, 451, 428, 399, 353, 260, 174, 114, 58, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
t_0 = 0
t_end = 1440
dt = 30

return System(init=init, absorb=absorb, weight=weight, loss_coeff=loss_coeff, specif=specif, area=area, t_0=t_0, t_end=t_end, dt=dt, panel_num= 19,maxPower=320, irr_year = irr_year, temp_year = temp_year)

In [ ]:
system = make_system(.833,26.847,.005,710.08,30.547)



In [ ]:
def simulation_day(system):
p_loss_percent = [] #creates an empty list
ducalc = [] #creates an empty list
ucalc = [] #creates an empty list
delta_u = [] #creates an empty list
delta_T = [] #creates an empty list
T_celcius = [] #creates an empty list
T_current = [295.15] #creates a list for the starting temperature
kwh_final = [0]           #creates a list with stored value of 0
delta_irradiance = [0] #creates a list with stored value of 0
ideal_produced = [] #creates an empty list
real_produced = [] #creates an empty list
real_kwh = [] #creates an empty list
ideal_psum = [0] #creates a list with stored value of 0
ideal_kwh = [] #creates an empty list
real_psum = [0] #creates a list with stored value of 0
kwh_sum_real = [0] #creates a list with stored value of 0
kwh_sum_ideal = [0] #creates a list with stored value of 0
irradiance1=[0,0,0,0,0,0,0,0,0,1,33,97,157,259,328,396,496,567, #creates a list with the values of irradiance over the course of 24 hours (30 min intervals)
617,676,700,720,739,694,684,686,639,549,412,393,290
,226,204,223,142,58,40,19,4,0,0,0,0,0,0,0,0]
stamp = linrange(system.t_0, system.t_end, system.dt) #creates a timeseries with starting time at 0 minutes, an interval of 30 minutes, and an ending time of 1440 minutes)
for i in range(47): #creates a forloop with 47 iterations
diffU = system.area * irradiance[i] * system.absorb #calculates how much energy is absorbed by the PV Panels from irradiance
ducalc.append(diffU) #adds diffU to the list "ducalc"
UU = ducalc[i] * system.dt #multiplies the "ducalc" of the current list by dt
ucalc.append(UU) #places "UU" in the list "ucalc"
delta_u.append(ucalc[i]- ucalc[i-1]) #subtracts "ucalc" from the previous value of "ucalc", then places the answer in a list named "delta_u"
delta_T.append(delta_u[i] / (system.specif * system.weight) ) #divides "delta_u" by the product of "system.specif" and "system.weight", then places it in a list named "delta_T"
T_current.append(delta_T[i] + T_current[i]) #adds "delta_T" or change in temperature from the current iteration to the current temperature ("T_current"), then adds it to a  list
T_celcius.append(T_current[i] - 273.15) #converts the current temperature from Kelvin to Celcius, then adds it to a list
p_loss_percent.append(T_celcius[i] * system.loss_coeff) #multiplies the current temperature by the loss coefficient of the PV panels, then adds it to a list
ideal_produced.append(system.maxPower * system.panel_num * irradiance1[i] / 1000) #calculates the ideal amount of power produced by the PV panels without inefficiencies due to heat, then adds it to a list
real_produced.append(ideal_produced[i]*( 1 - p_loss_percent[i])) #calculated the actual power produced by the PV panels, then adds it to a list
return(stamp, real_produced, ideal_produced,p_loss_percent,real_kwh,ideal_kwh) #returns the outputs

In [ ]:
stamp_day, real_produced_day, ideal_produced_day, p_loss, real_kwh_day, ideal_kwh_day = simulation_day(system) #places the outputs of the system into each of 6 variables

In [ ]:


In [ ]:
def integrator(produced): #defines new variable with parameter "produced"
kwh_conv = [0] #creates a list with stored value of 0
stamp_h = [0] #creates a list with stored value of 0
stamp = linrange(system.t_0, system.t_end-30, system.dt) #creates a timeseries
for i in range(47): #runs  a forloop for 47 iterations
kwh_conv.append(produced[i] / 1000) #converts the output of Wh to KWh and places it in a list
stamp_h.append(stamp[i]/60) #converts minutes to hours and places it in a list
stamp_int = (integrate.cumtrapz(kwh_conv, stamp_h)) #takes the integral of the KWh's produced with respect to time to produce "stamp_int"
return stamp_int #returns "stamp_int"

In [ ]:
kwh_real = integrator(real_produced_day) #takes the integral of "real_produced_day"
kwh_ideal = integrator(ideal_produced_day) #takes the integral of "ideal_produced_day"

In [ ]:
def plot_2D(ideal, real): #defines a new plot with parameters "real" and "ideal"
stamp_h = [] #creates a new empty list
stamp = linrange(system.t_0, system.t_end-30, system.dt) #creates a timeseries named "stamp"
for i in range(47): #creates a forloop with 47 iterations
stamp_h.append(stamp[i]/60)
plot(stamp_h,real)
plot(stamp_h,ideal)
decorate(title = 'Kwh total Generated over a day ideal vs heat inefficiency',
xlabel='Time (hours)',
ylabel='Total Kwh Generated over a day')

In [ ]:
plot_2D(real_produced_day, ideal_produced_day)

In [ ]:
plot_2D(kwh_real, kwh_ideal)

In [ ]:


In [ ]:
def simulation_year(system):
p_loss_percent = [[],[],[],[],[],[],[],[],[],[],[],[]]
ducalc = [[],[],[],[],[],[],[],[],[],[],[],[]]
ucalc = [[],[],[],[],[],[],[],[],[],[],[],[]]
delta_u = [[],[],[],[],[],[],[],[],[],[],[],[]]
delta_T = [[],[],[],[],[],[],[],[],[],[],[],[]]
T_celcius = [[],[],[],[],[],[],[],[],[],[],[],[]]
kwh_final = [0]
ideal_produced = [[],[],[],[],[],[],[],[],[],[],[],[]]
real_produced = [[],[],[],[],[],[],[],[],[],[],[],[]]
ideal_produced_month = []
real_produced_month = []
T_current = [[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0]]
ideal_produced_month_total= []
real_produced_month_total = []
for j in range(11):
for i in range(46):
diffU = system.area * irradiance[j][i] * system.absorb
ducalc[j].append(diffU)
UU = ducalc[j][i] * system.dt
ucalc[j].append(UU)
delta_u[j].append(ucalc[j][i]- ucalc[j][i-1])
delta_T[j].append(delta_u[j][i] / (system.specif * system.weight) )
T_current[j][i] = temp[j]
T_current[j].append(delta_T[j][i] + T_current[j][i])
T_celcius[j].append(T_current[j][i] - 273.15)
p_loss_percent[j].append(T_celcius[j][i] * system.loss_coeff)
ideal_produced[j].append(system.maxPower * system.panel_num * irradiance[j][i] / 1000)
ideal_produced_month.append(ideal_produced[j])
real_produced[j].append(ideal_produced_month[j][i]*( 1 - p_loss_percent[j][i]))
real_produced_month.append(real_produced[j])
ideal_produced_month_total.append(sum(ideal_produced_month[j]*30))
real_produced_month_total.append(sum(real_produced_month[j]*30))
return(real_produced_month, ideal_produced_month,ideal_produced_month_total,real_produced_month_total )

In [ ]:
RPM, IPM, IPMT, RPMT = simulation_year(system)

In [ ]:
plot(IDM[2])

In [14]:
def integrator_year(produced):
monthly_sum = []
kwh_conv = [0]
stamp_h = [0]
tot_int = []
stamp = linrange(system.t_0, system.t_end-60, system.dt)
for j in range(11):
monthly_sum.append(sum(produced[j]))
print(monthly_sum)
#             kwh_conv.append(produced[j][i] / 1000)
#             stamp_h.append(stamp[i]/60)
#         stamp_int = (integrate.trapz(kwh_conv, stamp_h))
#         tot_int.append(stamp_int)

In [ ]:
integrator_year(RDM)

In [ ]:
kwh_r_year = integrator_year(RDM)

In [ ]:
plot(kwh_r_year)




In [ ]:


In [ ]:
plot(stamp2,ideal_produced)

In [ ]:
plot(stamp2,real_produced)


### Results

The chart titled "Kwh total Generated over a day ideal vs heat inefficiency" displays how there is a direct correlation between irradiance, the power generated by the PV panels, and the inefficiency due to heat. It is visable that the graph that accounts for the inefficiencies due to heat is just a scaled down version of the ideal graph, and power generation peaks at the same time that irradiance does. We can also see from the cumilative inefficiency (energy lost due to the inefficiency caused by heat of the solar panels) over the course of the day that there is a total loss of 7.33 KWh or 78.2% of its full potential given the same irradiance. It is very clear that higher temperatures of PV cells have a significant negative impact on their efficiency.

### Interpretation

The final plot represents total energy loss over the course of the day due to the inefficiency of the panel (over the x and z axes) and what the irradiance (inefficiency is directly correlated with irradiance) is over the course of the day as well (over the y and y axes). However, as inefficiency peaks during that time of the day, power production also peaks because the energy generated due to the irradiance increase outpreforms the energy loss due to the inefficiency increase. This essentially means that power loss due to inefficency increase has to be accounted for when investing in solar panels as it is an inherent flaw of the technology. This also means that efficiency could be significantly improved with the addition of some passive cooling system. Connecting this to sustainability; since we know that the temperature of a solar cell is directly correlated to the cell's inefficiency and that aggregate global temperatures are also increasing, we can deduce that the aggregate equillibrium temperature the solar panel reaches as it dissipates its thermal energy to the surrounding environment also increases. In other words, global warming is worsening the efficiency of solar panels.

In [ ]: