![]() |
Search   |
|
|
This is the source code for CollectorCls and CollectorECurveCls classes.
This is just to take a look at before you download -- if you want to download it, then download all the solar classes here: Solar Tools Source
This class models a solar collector based on its efficiency curve. The efficiency of the collector and collector output are estimated as a function of inlet and ambient temperature, and solar radiation input.
'Solar Analysis Tools - 'Copyright (C) 2005 Gary Reysa (gary@BuildItSolar.com)
' This program is free software; you can redistribute it and/or modify it ' under the terms of the GNU General Public License as published by the Free ' Software Foundation; either version 2 of the License, or (at your option) ' any later version.
' This program is distributed in the hope that it will be useful and encourage ' further development of solar tools, but WITHOUT ANY WARRANTY; without even ' the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ' See the GNU General Public License for more details.
' CollectorEcurveCls ' This class models a solar collector in which the efficiency ' curve for the collector is known. ' It inherits from CollectorCls ' Adds Inputs: ' YIntercept -- the Y intercept on the collector efficiency curve (ie max efic) ' Slope -- the slope of the collector curve in (BTU/hr-ft^2-F) (input as a negative number) ' Ti -- collector fluid inlet temperature (F) ' Ta -- ambient temperature (F) ' Adds Outputs: ' ColEfic -- collector efficiency (ratio of collector output/solar input ' Qout -- collector output in BTU/hr (defined as ColEfic * SolarInput) ' ' 11/08/05 ' Appears to be working OK -- gives general agreement with SRCC data -- should do more detailed checking.
Imports System.Math Imports System.IO
Public Class CollectorEcurveCls Inherits CollectorCls
Private mTi As Double ' collector inlet temp (F) Private mTa As Double ' ambient temp (F) Private mYIntercept As Double ' Y intercept on efic curve (no units) Private mSlope As Double ' Slope of collector efficiency curve (BTU/hr-ft^2-F)
Private mEfic As Double ' collector efficiency Private mQout As Double ' power output of collector (BTU/hr)
' New input properties:
' Collector inlet temperature (F)
Public Property Ti() As Double
Get
Return mTi
End Get
Set(ByVal Value As Double)
mTi = Value
ReCalcECurve()
End Set
End Property
' Ambient temperature (F)
Public Property Ta() As Double
Get
Return mTa
End Get
Set(ByVal Value As Double)
mTa = Value
ReCalcECurve()
End Set
End Property
' Slope of the collector efficiency curve (BTU/hr-ft^2-F) -- this will normally be a negative number
Public Property Slope() As Double
Get
Return mSlope
End Get
Set(ByVal Value As Double)
mSlope = Value
ReCalcECurve()
End Set
End Property
' Y (efficiency) intercept of the collector efficiency curve (no units)
' This is the efficiency of the collector when the parameter (Ti-Ta)/Isun = 0
Public Property YIntercept() As Double
Get
Return mYIntercept
End Get
Set(ByVal Value As Double)
mYIntercept = Value
ReCalcECurve()
End Set
End Property
'New Output Properties:
' Efficiency of the collector
ReadOnly Property Efic() As Double
Get
Return mEfic
End Get
End Property
' Output of the collector in (BTU/hr)
ReadOnly Property QOut() As Double
Get
Return mQout
End Get
End Property
Sub New()
' how do I run parent constructor? -- seems to get run automatically
mSlope = -1.0
mYIntercept = 0.8
mTi = 120.0
mTa = 30.0
End Sub
Private Sub ReCalcECurve()
' call parent ReCalc
ReCalc()
' now calc new parms
Dim parm As Double
If Icoltot < 0.1 Then
parm = 100
Else
parm = (mTi - mTa) / mIcoltot
End If
mEfic = mYIntercept + parm * mSlope
If mEfic < 0 Then mEfic = 0
mQout = mEfic * mIcoltot * mArea
End Sub
Public Sub DumpEC()
Dump()
Console.WriteLine(" Eficiency {0,6:F3}", mEfic)
Console.WriteLine(" Qout {0,8:F0}", mQout)
Console.WriteLine(" Yinter, Slope {0,6:F3} {1,7:F3}", mYIntercept, mSlope)
End Sub
End Class
This is the base class for the CollectorECurve Class listed above, and any future collector classes to model different types of collectors.
'Solar Analysis Tools - 'Copyright (C) 2005 Gary Reysa (gary@BuildItSolar.com)
' This program is free software; you can redistribute it and/or modify it ' under the terms of the GNU General Public License as published by the Free ' Software Foundation; either version 2 of the License, or (at your option) ' any later version.
' This program is distributed in the hope that it will be useful and encourage ' further development of solar tools, but WITHOUT ANY WARRANTY; without even ' the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ' See the GNU General Public License for more details.
' Collector Class -- instances of this class represent a solar collector ' This is the base class for all other collector classes.
' When provided with Collector Area, Collector Orientation, Direction to Sun, ' and incident solar radiation, objects of this class will provide the ' incidence angle, and the direct, diffuse and total radiation on collector. ' Programs using this class must calculate collector gain and loss using ' thier own logic.
' The collector updates itself every time any input is changed, so its ' always up-to-date with its inputs. This causes some needless calculation, ' but the speed seems quite acceptable.
' Inputs to define a CollectorCls object are:
' Area Net area of collector (ft^2) ' Tilt Tilt from horizontal Rad) ' Azimuth Direction collector is pointed -- measured from South, and + to east (Rad) ' SunVec Vector to sun -- used for performance calcs ' Idn Solar direct normal radiation (perpendicular to SunVec) (BTU/hr-ft^2) ' Idif Solar diffuse radiation (BTU/hr-ft^2)
' Ouputs from objects of this class are: 'Outputs: ' ColNor A vector normal to the collector surface ' IncidAngle The angle of incidence for solar rays on collector (rad) ' Icoldir Direct solar radiation on collector surface (BTU/hr-ft^2) ' Icoldif Diffuse solar radiaition on collector surface (BTU/hr-ft^2) ' Icoltot Total solar radiation energy on collector = sum of Icoldir and Icoldif (BTU/hr-ft^2) ' ' Basic scheme to use Collector Class is: ' 1) Provide inputs that define collector geometry and performance ' (Area, orientation) ' 2) Provide solar Idn and Idif and solar direction ' ' Any change in inputs will trigger a recalc of the collector outputs. ' So, in a simulation, ' You initialize collector with geom ' Then set a start time ' Look up sun parms for current time and send to collector ' (use TMY or SunTool for this) ' Retrieve collector outputs and store/sum/plot ' Increment time ' Repeat from start
Imports System.Math Imports System.IO
Public Class CollectorCls Const DegPerRad As Single = 57.3
'Inputs: 'col - geometry/orientation Protected mArea As Double ' Area of collector (ft^2) Protected mTilt As Double ' Tilt angle of collector from horz (rad) Protected mAzimuth As Double ' Azimuth angle of collector (rad) -- South = 0, + to East, - to West
'sun Protected mSunVec As New VectorCls ' A unit vector pointing toward sun Protected mIdn As Double ' Direct component of radiation from sun (BTU/hr-ft^2) Protected mIhorzdif As Double ' Indirect component of radiation from sun (BTU/hr-ft^2)
'Outputs: Protected mColNor As New VectorCls ' A unit vector normal to the collector surface Protected mIncidAngle As Double ' The incidence angle that a ray from sun makes to collector surface (rad) Protected mIcoltot As Double ' radiation energy on collector = sum of mIcoldir and mIcoldif (BTU/hr-ft^2) Protected mIcoldir As Double ' direct radiation on collector surface (BTU/hr -ft^2) Protected mIcoldif As Double ' diffuse rediaition on collector surface (BTU/hr-ft^2)
'Inputs:
' Collect Area (sqft)
Public Property Area() As Double
Get
Return mArea
End Get
Set(ByVal Value As Double)
mArea = Value
ReCalc()
End Set
End Property
'Tilt -- collector tilt -- horz to plane of collector (rad)
Public Property Tilt() As Double
Get
Return mTilt
End Get
Set(ByVal Value As Double)
mTilt = Value
ReCalc()
End Set
End Property
'Azimuth -- collector Azimuth -- South is zero, + is toward East (rad)
Public Property Azimuth() As Double
Get
Return mAzimuth
End Get
Set(ByVal Value As Double)
mAzimuth = Value
ReCalc()
End Set
End Property
'Sun Vector -- a unit vector from the sun
Public Property SunVector() As VectorCls
Get
Return mSunVec
End Get
Set(ByVal Value As VectorCls)
mSunVec = Value
ReCalc()
End Set
End Property
'Idn -- direct normal solar radiation (on surface Perp to sun direction)
Public Property Idn() As Double
Get
Return mIdn
End Get
Set(ByVal Value As Double)
mIdn = Value
ReCalc()
End Set
End Property
'Ihorzdif -- diffuse solar radiation on horz surface
Public Property Idif() As Double
Get
Return mIhorzdif
End Get
Set(ByVal Value As Double)
mIhorzdif = Value
ReCalc()
End Set
End Property
'Icoldir -- direct radiation on collector (= cos(IncidAng)*Idn)
ReadOnly Property Icoldir() As Double
Get
Return mIcoldir
End Get
End Property
'Icoldif -- diffuse ratdiation on collector -- is a fractin of Ihorzdiffuse
ReadOnly Property Icoldif() As Double
Get
Return mIcoldif
End Get
End Property
'Icoltot -- Radiation input into collector BTU/hr
ReadOnly Property Icoltot() As Double
Get
Return mIcoltot
End Get
End Property
ReadOnly Property IncidAngle() As Double
Get
Return mIncidAngle
End Get
End Property
''----------- Methods -------
' Constructor ' By default, construct a 1 ft^2, vertical collector facing south. Sub New() mArea = 1.0 mTilt = 90.0 / DegPerRad mAzimuth = 0.0
'sun mSunVec.X = 0.707 mSunVec.Y = 0.0 mSunVec.Z = 0.707 mIdn = 400 mIhorzdif = 20 End Sub
Protected Sub ReCalc()
' calc solar output per the following method:
' update collector vector -- based on tilt and azimuth
mColNor = VectorCls.AzElevVector(mAzimuth, 90 / DegPerRad - mTilt)
' update solar input to collector
Dim ColDotSun As Double
ColDotSun = mColNor.Dot(mSunVec)
mIncidAngle = Acos(ColDotSun)
If ColDotSun < 0 Then ' if sun vector is on back side of panel, made dot prod zero and incid 90
ColDotSun = 0
mIncidAngle = 90 / DegPerRad
End If
' Update radiation on collector values
mIcoldir = mIdn * ColDotSun
mIcoldif = mIhorzdif * ((1 + Cos(mTilt)) / 2)
mIcoltot = mIdn * ColDotSun + mIcoldif
End Sub ' Recalc
Public Sub Dump()
Console.WriteLine()
Console.WriteLine("Sun:")
Console.WriteLine(" ToSunVector {0,6:F3} {1,6:F3} {2,6:F3} ", mSunVec.X, mSunVec.Y, mSunVec.Z)
Console.WriteLine(" Sun: Idn, Ihorzdif {0,8:F1} {1,8:F1} ", Idn, Idif)
Console.WriteLine("Collector:")
Console.WriteLine(" Area {0,8:F1} ", Area)
Console.WriteLine(" Azimuth, Tilt: {0,6:F2} {1,6:F2} ", Azimuth * DegPerRad, Tilt * DegPerRad)
Console.WriteLine(" Incid Angle {0,8:F1}", IncidAngle * DegPerRad)
Console.WriteLine(" Icoltot, Icoldir, Icoldif {0,8:F1} {1,8:F1} {2,8:F1}", mIcoltot, mIcoldir, mIcoldif) ' solar radiation on collector glazing
End Sub
End Class