Tuesday, December 19, 2017

Python version problems.



Python version problems

Different versions of Python have enough differences to be troublesome.

Version 2.7.4 calculations use implicit integer types where version 3.6.0 uses implicit float types.
The following examples illustrate the problem:
V2: 7/5=1; -7/5= -2
V3: 7/5=1.4;-7/5= -1.4
Adding a decimal to numbers in V2 converts them to floats:
V2: 7.0/5=1.4
A manual conversion also works:
V2 float(7)/5=1.4

The problem, for me, is version 2.7.4 has the ephemeris module installed. In the computer’s Raspbian operating system, version 2.4 is installed and installing version 3.6 has to be without modules. Hence, the ephemeris module will be absent with 3.6.0. Again, the problem? Different scripts are written with different versions of Python. One or two large sophisticated programs require simultaneous versions of Python.
I decided to use my translation of an Excel spreadsheet instead of the ephemeris. Only version 3.6.0 is required and is summoned with:
“python3.6 NOAA.py”
My calculations of solar incident and solar module irradiation are compatible with version 3.6.0.



Wednesday, December 13, 2017

An instance of translation from Excel to Python.

This is an instance of the translation of an Excel spreadsheet formula into the Python equivalent.


EXCEL:
#AH2=Sun Azimuth degrees clockwise from North
=IF(AC2>0,MOD(DEGREES(ACOS(((SIN(RADIANS(Lat))*COS(RADIANS(AD2)))-SIN(RADIANS(T2)))/(COS(RADIANS(Lat))*SIN(RADIANS(AD2)))))+180,360),MOD(540-DEGREES(ACOS(((SIN(RADIANS(Lat))*COS(RADIANS(AD2)))-SIN(RADIANS(T2)))/(COS(RADIANS(Lat))*SIN(RADIANS(AD2))))),360))



PYTHON:
#AH2=Sun Azimuth degrees clockwise from North
AH2a1=math.acos(((math.sin((B3/r)) * math.cos((AD2/r))) - math.sin((T2/r))) / ((math.cos((B3/r)) * math.sin(AD2/r))))*r + 180
AH2b1=360
AH2a2=540-math.acos(((math.sin(B3/r)*math.cos(AD2/r))-math.sin(T2/r))/((math.cos(B3/r)*math.sin(AD2/r))))*r
AH2b2=AH2b1
if AC2 > 0 : AH2=AH2a1-int(AH2a1/AH2b1)*AH2b1
else : AH2=AH2a2-int(AH2a2/AH2b2)*AH2b2

Tuesday, December 12, 2017

NOAA equations for solar data (sunrise, sunset, elevation, azimuth, Julian Day, Equation of Time, etc..



   In a recent post I presented the equation for energy incident on a solar panel (Sm).
Here I present the set of equations used to calculate sunrise, sunset, and solar elevation and azimuth.

=============================================================

#This particular set was extracted from an Excel spreadsheet made available by NOAA.

#360 deg/2*pi=57.29578
#if in radians, do sin(x/r) to get degrees
#sin(45d)=.7071
#sin(45r)=0.8509

LT: Local Tiime
UT:Universal Time
TZ:Time Zone
LT=UT+TZ

JDg1=367*Y-int(7*(Y+int((M+9)/12))/4)-int(3*(int((Y+(M-9)/7)/100)+1)/4)+int(275*M/9)+D+1721028.5+UT/24
JDg2=367*Y-int(7*(Y+int((M+9)/12))/4)+int(275*M/9)+D+1721013.5+UT/24

#For the Day:
#B3=Latitude, + to N
#B4=Longitude + to E
#B5=Time Zone + to E    ( calculations use TZ)
#B7=Date
#H=Blank
#--------------------------

#D2=date
=date, mm/dd/yyyy , Calculations use JD

#E2=T past local midnight (used in TST and Elev refraction calc)
#sum of 0.1/24 from midnight to current with .1/24 increments (fraction of the day in tenths of an hour ; 6 min = 0.0041666 day)
=LT/24
# In the JD, the previous day +.5 is midnight since the calendar sarts at noon.
#F2=Julian Day
=D2+2415018.5+E2-TimeZone(TZ)/24
JDg2=D2+2415018.5+E2-TimeZone(TZ)/24


#G=Julian , used in other functions, translated into radians. Functions that make up S and T use G (P,R,Q).
=(F2-2451545)/36525

#H=Blank

#I=Geom Mean Long Sun
=MOD(280.46646+G2*(36000.76983+G2*0.0003032),360)
#mod()=a-int(a/b)*b

#J=Geometric Mean Anomaly of the Sun
=357.52911+G2*(35999.05029-0.0001537*G2)

#K=Eccentricity of Earth orbit
=0.016708634-G2*(0.000042037+0.0000001267*G2)

#L=Sun Eq of Ctr
=SIN(RADIANS(J2))*(1.914602-G2*(0.004817+0.000014*G2))+SIN(RADIANS(2*J2))*(0.019993-0.000101*G2)+SIN(RADIANS(3*J2))*0.000289

#M=Sun True Long degrees
=I2+L2

#N=Sun True Anomaly degrees
=J2+L2

#O=Sun Radius Vector, A.U.
=(1.000001018*(1-K2*K2))/(1+K2*COS(RADIANS(N2)))

#P=Sun Apparent Long
=M2-0.00569-0.00478*SIN(RADIANS(125.04-1934.136*G2))

#Q=Mean Oblique Ecliptic degrees
=23+(26+((21.448-G2*(46.815+G2*(0.00059-G2*0.001813))))/60)/60

#R=Oblique Correction factor
=Q2+0.00256*COS(RADIANS(125.04-1934.136*G2))

#S=Right Ascension degrees
=DEGREES(ATAN2(COS(RADIANS(P2)),COS(RADIANS(R2))*SIN(RADIANS(P2))))

#T=Declination in degrees
=DEGREES(ASIN(SIN(RADIANS(R2))*SIN(RADIANS(P2))))

#U=var y
=TAN(RADIANS(R2/2))*TAN(RADIANS(R2/2))

#V=EoT minutes
=4*DEGREES(U2*SIN(2*RADIANS(I2))-2*K2*SIN(RADIANS(J2))+4*K2*U2*SIN(RADIANS(J2))*COS(2*RADIANS(I2))-0.5*U2*U2*SIN(4*RADIANS(I2))-1.25*K2*K2*SIN(2*RADIANS(J2)))

#W=HA Sunrise degrees
=DEGREES(ACOS(COS(RADIANS(90.833))/(COS(RADIANS(Lat))*COS(RADIANS(T2)))-TAN(RADIANS(Lat))*TAN(RADIANS(T2))))

#X=Sun noon LST
=(720-4*Lon-V2+TZ*60)/1440

#Y=Sunrise time
#Y=Sunrise time
Y2=X-W*4/1440
#Z=Sunset time
Z2=X+W*4/1440

#AA2=Sunlight duration
=8*W2

#AB2=TST
=MOD(E2*1440+V2+4*Lon-60*TZ,1440)

#AC2=Hour Angle
=IF(AB2/4<0,AB2/4+180,AB2/4-180)

#AD2=Zenith
=DEGREES(ACOS(SIN(RADIANS(Lat))*SIN(RADIANS(T2))+COS(RADIANS(Lat))*COS(RADIANS(T2))*COS(RADIANS(AC2))))

#AE2= Sun elevation in degrees
90-AD2

#AF2=Atmospheric refraction un degrees
=IF(AE2>85,0,IF(AE2>5,58.1/TAN(RADIANS(AE2))-0.07/POWER(TAN(RADIANS(AE2)),3)+0.000086/POWER(TAN(RADIANS(AE2)),5),IF(AE2>-0.575,1735+AE2*(-518.2+AE2*(103.4+AE2*(-12.79+AE2*0.711))),-20.772/TAN(RADIANS(AE2)))))/3600

#AG2=Sun Elevation corrected for refraction
=AE2+AF2

#AH2=Sun Azimuth degrees clockwise from North
=IF(AC2>0,MOD(DEGREES(ACOS(((SIN(RADIANS(Lat))*COS(RADIANS(AD2)))-SIN(RADIANS(T2)))/(COS(RADIANS(Lat))*SIN(RADIANS(AD2)))))+180,360),MOD(540-DEGREES(ACOS(((SIN(RADIANS(Lat))*COS(RADIANS(AD2)))-SIN(RADIANS(T2)))/(COS(RADIANS(Lat))*SIN(RADIANS(AD2))))),360))









=====================================================================





Friday, December 1, 2017

Linear actuator installed. Possible changes.



   I've been building my power station with n eye to minimizing the cost without sacrificing quality.
I've mounted the array on a one inch steel pipe leaning against an  aluminum ladder. The ladder was damaged beyond intended use, so I've re-purposed the ladder, for the time being, as a support frame for the array. I drilled holes to mount a piece of wood to strengthen the weak area. I also drilled holes to attach the linear actuator. I've mounted the linear actuator in the first trial position. The actuator is a heavy duty, hazardous environment, model suitable for outdoors, all season use. The unit can push or pull 10 kN, or 10000 N. That is equivalent to 2,200 pounds, or, a little over one ton (2000 lbs). The unit is working with a small load which will drain little power from the battery bank, even on a cloudy day.
   I will be able to program the tracking to follow the sun using calculations, mm/rpm specs from the manufacturer, and a solar detector composed of four small solar cells attached to the array. If the day is cloudy, the sensor will respond with characteristic data that can be responded to in program.
   The motor power wiring has to be run from the indoor station to the unit unless the control computer is mounted near the array in a weather proof box.
   The idea of moving the entire station out to the array is appealing. The problem I have is the battery bank. What is the effect of low temperatures on flooded lead-acid batteries? My first thought is to build an enclosure big enough to insulate. The minicomputer I'm using was not necessarily designed for harsh environments, though electronic circuitry tends to be very hardy. There is a more utilitarian version of the computer that may be a better choice. I may place the mini computer and charge controller at the array and keep the battery bank and inverter indoors. That makes powering the mini computer an issue. The unit is currently powered by the battery bank. Running DC power lines to the array for the unit seems impractical. A smaller battery dedicated to the mini computer would be a better choice. In fact, I have a left over charge controller and inverter that could supply the unit. A small solar panel could be added to the array specifically for the computer. The mini computer, RPi, typically uses onlly 5 watts of power and that makes powering the unit inexpensive and simple.
   The charge controller is a Zantrex 60A PWM model. The inverter is a 300 watt pure sine wave type. Add a small battery and a solar panel and the parts list is complete.
   The second power supply will, like the RPi, need to be enclosed in a weatherproof container.
   The mini computer is a Raspberry Pi 3B with USB ports, WiFi, and GPIO ports. Software installed includes the Apache web server, PHP, Python, an RTL hardware clock driver, a USB driver for the charge controller, WiFi access point software, and a small 16Gb SD card and reader.



Friday, November 24, 2017

Eclipse graph




   I posted I would present the graph for the day of the partial solar eclipse (northeast Tennessee) for interest. The data was collected on a clear day with a few short intrusions. The time was still Daylight Savings Time.




Data predictions



   Predicting the amount of solar energy that can be collected is useful. Steps can be taken to prepare for low or high energy days.
   There are several publicly available databases of historical weather data as well as at least one that publishes data based on a mathematical model.
   Days that are statistically more likely to be cloudy or overcast can be anticipated with a measured level of reliability The likelihood of a likelihood.
   A comparison of the historical data and real time current data can be interesting.

   My first attempt to describe the data I collected using a graphic curve were based on best-fit-polynomial equations. In my case, I used spreadsheet software for this. The best curve to be had was with a two term polynomial. There was no benefit to increasing the number of terms.



   The results were not satisfactory. I began looking for an improved method. I was familiar with several websites that make solar cell/panel/array information available. PVEducation.org is a site that has more information any other I examined, which not to say there isn't one with more. I began perusing the site. I discovered mathamatical equations for several Sun and cell related phenomenon.

   I used the formulas for solar radiation orthogonal to, and incident to, a cell. That equation was incorporated into the equation for the effective solar radiation at a given tilt and angle and included the effects of air mass, refraction, and the curvature of the Earth's surface.


   The difference between the suggested curve and the curve of prediction in the above image, is due to limitations on charging current for the battery bank, by the MPPT controller's designers. A limit of about 2.5 amperes is placed on charging the batteries. This results in a loss of efficiency in terms of the amount of energy available. Where 585 watts is available, only 260 watts is typically used, maximum.

   The battery type I use is the deep cycle, flooded lead-acid type.The suggested charging current is 2.5 amperes:

10%-13% of the C20 rating which is, in this case, 108Ahr.
10% of 108Ahr = 10.8 amperes
13% of 108Ahr is 14.04 amperes
2.3% of 108Ahr is 2.5 amperes, the esuggested rate used by the controller's designers.

   A low charge rate is said to correlate with a longer battery life while a higher charge rate correlates with a shorter battery life. There is a trade-off for the lifetime of the battery and the convenience of energy availability. More batteries must be added for a low charge rate to achieve the availability goals. The cost of more batteries may cancel out the shorter lifetime caused by higher charge rates.
   The issue seems to become one of pay now or pay later, the end cost will not be much different. This is presumptuous. I do not have enough data about the effects of charge rates on deep cycle lead-acid batteries. The choice is open.
 

Seasonal changes in the solar path.



   Previously, I posted the impracticality of sensing resistors in a solar arry. I've decided that such sensors are needed. I do not have any of the design details of the MPPT controller I'm using, but I suspect the device is not up to parr with the rest of the system. A sensing resistor in series with the mainline will let me verify the power transfers taking place in the system. A small ADC board will convert analog data into computer compatible, digital data. I have all the parts and software on hand.

   If knowing the details of the panel system were crucial, I could insert a series of relays into the circuitry and a digital switching system to isolate each component in turn. Doing the same for the battery system would make SoC data available. I could then implement any of a series of algorithms.

   I stated in the last post, I would publish a series of graphs illustrating the seasonal changes in the amount of sunlight available. I do that here. First, I'll preface that series with a discussion of the variables involved.

   Throughout the year, the Sun's path through the sky changes. On June 21st, the Sun is closest to the Earth and highest in the sky at noon. On December 21, the Sun is farthest from the Earth and lowest in the sky at noon. Visualize an arc in the sky. The arc sinks lower as the days pass, until the lowest point occurs in December, then begins to rise till June, when the highest point is reached. This arc represents the path of the Sun throughout the day.

   One of the results is the lengthening of shadows in Winter. Since the Sun is lower in the sky at noon, the shadows will be longer. In Summer, the Sun is highest in the sky and the shadows will be shortest. What this means to me, is that solar energy is least when needed most, and most abundant, when needed least. For this reason, a system needs to be designed for Winter, the low energy months.

Note, in particular, the difference between the first, June 3, and the last, October 31. The difference is the effect of a changing solar path and shadows. Also note that most of the images were constructed from data collected on a clear day.

Here are the graphs:















Battery bank wiring modification

  The battery bank has been wired in parallel with system connections at the closest battery. This creates an unbalanced load on the bank.  ...