Archive for the solar Category

curve fitting and graphing.

Posted in Linux, solar on January 16, 2011 by makingthingswork

Here’s how i do the curve fits and resulting graphing.

I use the free program ‘gnuplot’ which is pretty powerful, can do curve-fits, and graph everything.

Steps:

1: measure your curve and get some points. I created a file called ‘measured.dat’:

0  .0044
.1 .0123
.2 .0218
.3 .0382
.4 .0636
.5 .098
.6 .157
.7 .221
.8 .300
.9 .404
1 .495

2)  fit the curve. I use a cubic parabola: Ax3+Bx2+Cx+D

shell$ gnuplot
...
gnuplot> f(x)=a*x*x*x+b*x*x+c*x+d
gnuplot> fit f(x) './measured.dat' via a,b,c,d
...
Final set of parameters            Asymptotic Standard Error
=======================            ==========================a               = 0.142852         +/- 0.07749      (54.25%)
b               = 0.385536         +/- 0.1181       (30.63%)
c               = -0.035066        +/- 0.0493       (140.6%)
d               = 0.00833846       +/- 0.005414     (64.93%)
So now you have your coefficients: a,b,c,d

3) plug them into a graphing file. here’s mine:

# let's call this file "fit.gnuplot"
# you can keep the body of the file the same, and just
# modify a,b,c,d each time you run a new curve
a=0.142852
b=0.385536
c=-0.035066
d=0.00833846

#Cubic Parabola
#C=ax3 + bx2 + cx + d
B(x)=a*x**3+b*x**2+c*x+d
# this trick limits the curve to x=0 through x=1.05
C(x)= (x>0 && x<1.05) ? B(x) : 1/0

# tangent slope, derivative of cantilever
# D = B'=3ax2 + 2bx + c
D(x)=3*a*x**2+2*b*x+c

#focus (reflected) line slope (ts = tangent slope)
# y = 1/(TAN(2*(ATAN(1/ts))))
# incidence angle (0 = directly above,
#                  + means low in the sky
#                  - means high in the sky

# radians = degrees x PI / 180
# precalculate one, just showing the formula, not used
ideg= 0;
irad = ideg*pi/180

## slope of reflected ray
F(ts)=1/tan(2*atan(1/ts)-irad)
# focus y-int
G(tp)=C(tp)-(tp*F(D(tp)))

## where will the graph be drawn?
set xrange [-.5:1.2]
set yrange [-.1:1.2]

## setup graphing
set multiplot
# offset (first ray will be ioff+istep)
ioff=-3
istep=1.5
# each ray will offset on x axis by this much
xstep=.1
# arrow number
ar=0
# tangent point
tp=0
ideg=ioff
irad = ideg*pi/180

## how far to the left of the x-axis to extend arrows?
xp = -.35

## increment various counters
ar=ar+1; tp=tp+xstep

## downward ray
set arrow ar from tp,5 to tp,C(tp) lt rgb 'black'

## normal reflected ray
ideg=ideg+istep; irad = ideg*pi/180; ar=ar+1;
set arrow ar from tp,C(tp) to xp,F(D(tp))*xp+G(tp) lt rgb 'red'

## plus 1 step
ideg=ideg+istep; irad = ideg*pi/180; ar=ar+1;
set arrow ar from tp,C(tp) to xp,F(D(tp))*xp+G(tp) lt rgb 'black'

## plus another step
ideg=ideg+istep; irad = ideg*pi/180; ar=ar+1;
set arrow ar from tp,C(tp) to xp,F(D(tp))*xp+G(tp) lt rgb 'green'

## repeat this stanza as many times as you need
## next set
ideg=ioff; irad = ideg*pi/180
ar=ar+1; tp=tp+xstep
set arrow ar from tp,5 to tp,C(tp)  lt rgb 'black'   
ideg=ideg+istep; irad = ideg*pi/180; ar=ar+1;
set arrow ar from tp,C(tp) to xp,F(D(tp))*xp+G(tp) lt rgb 'red'
ideg=ideg+istep; irad = ideg*pi/180; ar=ar+1;
set arrow ar from tp,C(tp) to xp,F(D(tp))*xp+G(tp) lt rgb 'black'
ideg=ideg+istep; irad = ideg*pi/180; ar=ar+1;
set arrow ar from tp,C(tp) to xp,F(D(tp))*xp+G(tp) lt rgb 'green'

set label "  red: 1.5 degrees high\nblack: perfectly aimed\ngreen: 1.5 degrees low" at -.4,.2

set key at 1,.05
plot C(x) lt 2 title 'best fit line for measured sheet'
set key at 1,0
plot 'measured.dat' with points title 'measured points'

unset multiplot
pause -1

Now you have a graph definition that will do all the fancy arrows and such.

4) Show the graph:

shell$ gnuplot fit.gnuplot

Here’s what it makes:

You’ll need to duplicate the ‘repeat this stanza’ section once more for each point without a reflection on it.

Advertisements

Concetrating parabolic trough – part 1

Posted in i make things, solar on January 16, 2011 by makingthingswork

I’ve been looking into solar for water heating and (less so) power generation. I’ve decided that i like concentrating collectors since there’s less to insulate.

I did some tests and decided that while a parabolic collector is great, you can make a ‘good enough’ collector with far less precise construction techniques. I like that. I’m terrible at making things accurately, especially when they can be subjected to nature, and made from wood or other materials (not necessarily straight).

I’m a big fan of ‘coroplast’, aka corrugated plastic sheet. It costs about $15 for a 4×8 sheet of the stuff and it has some great qualities. Most of it is polypropylene, and can be heat welded if that’s what you’re after.

The concept is like this:

Take a piece of wood and attach some plastic sheet to it on one side.

Build a riser about 3′ out and put a pipe or other support on it, which will force the plastic sheet up into a bent shape.

Build an insulated collection mechanism on the top.

This has several key benefits:

  • Small surface to collect. Small surface means less materials and less surface to lose heat from
  • Insulation above collector. Convection is the dominant heat loss mechanism in these collectors, and by keeping all the hot air below insulation, you will lose a lot less
  • ease of construction. Not much to it at all

The main drawback is that you will have to aim it periodically. Thats another post.

After reading some engineering pages, i learned that a cantilever subjected to a strain at the end of it (like proposed above) will form a parabola-like shape. This is apparently well known in amateur radio circles as a ‘stressed parabola’. To get a good focus, you need a long focal length. For solar heat, i think you can get by with a looser focus.

I figured out the math to calculate the focus points for this kind of curve, and within a 10degree arc of aiming (eg if 0 deg is aimed directly at the sun, a +/- 5 deg range) it focuses all the light at a 7-8″ wide spot about 18″ off the origin point (eg x=0,y=0)

So i did a ton of calculations, sought some feedback, and was told it wouldn’t work. So i built a little one. I took a 2×4 piece of coroplast and leaned it on a char, then measured the height every 10 cm. I then did a curve-fit and plotted the focus. It was not anywhere near the same equation as was predicted by the engineering data i had, but the curve fit was spot on just the same, and it gave a 6″ focus! That’s great.

I then built a rig which would be a little more like what i would actually use:

The plastic is attached at 3 points: base, about 1/3 and at the top. It was minimally forced into place, but the middle support was pushed down a little, and i attached them in this order: bottom, middle, top. I should have fixed the top and bottom then attached the middle as ‘insurance’. As you will see later, forcing the middle throws off the curve-fit.

Basic theory:

Every point on a curve has a tangent line, which is the line that just ‘kisses’ the curve at that spot. When a ray of light hits the curve, it will reflect as if it had ‘bounced’ off the tangent line.

The Tangent can be calculated as the derivative of the curve, which is basic Calculus, but isn’t really very difficult to do.

So, to calculate the reflection slope, you do this:

F(ts)=1/tan(2*atan(1/ts)-irad)

ts is the tangent slope. irad is the offset of the inbound ray from vertical in radians.

You can then calculate the y-intercept of the line, and plot it.

Here are some graphs:

The colored lines should show ‘inbound’ (eg top to curve), but i didn’t plot them backwards. Too lazy.

This graph shows where the focus of the reflections would be. As you can see, it’s a pretty tight focus, however the curve does not match as well for this setup, so will need experimental verification.

I should note that the plastic will be coated with some sort of reflective coating (reflective mylar, etc)