1 /***************************************************************************
3 * Gains.cpp Copyright (C) 2008 by Jon Rumble *
4 * j.w.rumble@reading.ac.uk *
6 * This file is part of HECS, *
8 * HECS is free software: you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation, either version 2 of the License, or *
11 * (at your option) any later version. *
13 * HECS is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * You should have received a copy of the GNU General Public License *
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
21 ***************************************************************************/
25 // Constructors/Destructors
28 Gains::Gains (const ConfigParser
& config
, WaterHeating
*waterheat
,
29 HeatLosses
*heatingLosses
,DwellingDimensions
*dims
)
32 ptrWaterHeat
= waterheat
;
33 ptrHeatLosses
= heatingLosses
;
51 void Gains::setLightAppCookMetabolicGains ( double val_in
) {
52 m_lightAppCookMetabolicGains
= val_in
;
55 double Gains::getLightAppCookMetabolicGains ( ) {
56 return m_lightAppCookMetabolicGains
;
59 void Gains::setLowEnergyLightRed ( double val_in
) {
60 m_lowEnergyLightRed
= val_in
;
63 double Gains::getLowEnergyLightRed ( ) {
64 return m_lowEnergyLightRed
;
67 void Gains::setAddtnGains ( double val_in
) {
68 m_addtnGains
= val_in
;
71 double Gains::getAddtnGains ( ) {
75 void Gains::setWaterHeating ( double val_in
) {
76 m_waterHeating
= val_in
;
79 double Gains::getWaterHeating ( ) {
80 return m_waterHeating
;
83 void Gains::setTotalIntGains ( double val_in
) {
84 m_totalIntGains
= val_in
;
87 double Gains::getTotalIntGains ( ) {
88 return m_totalIntGains
;
91 void Gains::setTotalGains ( double val_in
) {
92 m_totalGains
= val_in
;
95 double Gains::getTotalGains ( ) {
99 void Gains::setSolarGLR ( double val_in
) {
103 double Gains::getSolarGLR ( ) {
107 void Gains::setSolarUtilFactor ( double val_in
) {
108 m_solarUtilFactor
= val_in
;
111 double Gains::getSolarUtilFactor ( ) {
112 return m_solarUtilFactor
;
115 void Gains::setTotalSolarGains ( double val_in
) {
116 m_totalSolarGains
= val_in
;
119 double Gains::getTotalSolarGains ( ) {
120 return m_totalSolarGains
;
123 void Gains::setMeanTempLivingArea ( double val_in
) {
124 m_meanTempLivingArea
= val_in
;
127 double Gains::getMeanTempLivingArea ( ) {
128 return m_meanTempLivingArea
;
131 void Gains::setTempAdjustment ( double val_in
) {
132 m_tempAdjustment
= val_in
;
135 double Gains::getTempAdjustment ( ) {
136 return m_tempAdjustment
;
139 void Gains::setAdjustForGains ( double val_in
) {
140 m_adjustForGains
= val_in
;
143 double Gains::getAdjustForGains ( ) {
144 return m_adjustForGains
;
147 void Gains::setAdjustLivingTemp ( double val_in
) {
148 m_adjustLivingTemp
= val_in
;
151 double Gains::getAdjustLivingTemp ( ) {
152 return m_adjustLivingTemp
;
155 void Gains::setTempDiffZones ( double val_in
) {
156 m_tempDiffZones
= val_in
;
159 double Gains::getTempDiffZones ( ) {
160 return m_tempDiffZones
;
163 void Gains::setLivingAreaFrac ( double val_in
) {
164 m_livingAreaFrac
= val_in
;
167 double Gains::getLivingAreaFrac ( ) {
168 return m_livingAreaFrac
;
171 void Gains::setRestOfHouseFrac ( double val_in
) {
172 m_restOfHouseFrac
= val_in
;
175 double Gains::getRestOfHouseFrac ( ) {
176 return m_restOfHouseFrac
;
179 void Gains::setMeanIntTemp ( double val_in
) {
180 m_meanIntTemp
= val_in
;
183 double Gains::getMeanIntTemp ( ) {
184 return m_meanIntTemp
;
187 void Gains::setTempRiseFromGains ( double val_in
) {
188 m_tempRiseFromGains
= val_in
;
191 double Gains::getTempRiseFromGains ( ) {
192 return m_tempRiseFromGains
;
195 void Gains::setBaseTemp ( double val_in
) {
199 double Gains::getBaseTemp ( ) {
203 void Gains::setDegreeDays ( double val_in
) {
204 m_degreeDays
= val_in
;
207 double Gains::getDegreeDays ( ) {
211 void Gains::setSpaceHeatingReq ( double val_in
) {
212 m_spaceHeatingReq
= val_in
;
215 double Gains::getSpaceHeatingReq ( ) {
216 return m_spaceHeatingReq
;
219 double Gains::getGainLossRatio ( ) {
220 return m_gainLossRatio
;
223 void Gains::setGainLossRatio (double val_in
) {
224 m_gainLossRatio
= val_in
;
227 double Gains::getUtilisationFactor ( ) {
228 return m_utilisationFactor
;
231 void Gains::setUtilisationFactor (double val_in
) {
232 m_utilisationFactor
= val_in
;
235 double Gains::getUsefulGains ( ) {
236 return m_usefulGains
;
239 void Gains::setUsefulGains (double val_in
) {
240 m_usefulGains
= val_in
;
243 double Gains::getAnnualLightEnergy(){
244 return m_annualLightEnergy
;
247 void Gains::setAnnualLightEnergy(double val_in
){
248 m_annualLightEnergy
= val_in
;
254 void Gains::calcLightingEnergy()
256 //Fixed Low Energy Lightbulbs
259 //Ratio of Enegry saving to standard lights
260 double C_1
= 0.00, C_2
= 0.00, GL
= 0.00;
261 C_1
= 1 - 0.50 * m_lightRatio
;
266 GL
= m_totalSolarGains
/ ptrDims
->get_totalFloorArea();
269 C_2
= (52.2 * (GL
* GL
)) - 9.94 * GL
+ 1.433;
273 m_annualLightEnergy
= 9.3 *
274 ptrDims
->get_totalFloorArea() *
279 //Gains From Lighting
280 m_lowEnergyLightRed
= m_annualLightEnergy
* 0.15;
283 void Gains::calcMeanIntTempLiving ()
285 double HLP
= ptrHeatLosses
->getHeatLossParam();
290 QList
<double> tmpList
;
292 QMap
<double,QList
<double> >::const_iterator i
;
296 m_meanTempLivingArea
= table8
.value(1.00).at(m_heatingTypeControl
);
298 else if (HLP
>= 6.00)
301 m_meanTempLivingArea
= table8
.value(6.00).at(m_heatingTypeControl
);
307 i
= table8
.upperBound(HLP
);
310 y3
= tmpList
.at(m_heatingTypeControl
);
311 //Decrement by 1 for lower bound
315 y1
= tmpList
.at(m_heatingTypeControl
);
317 m_meanTempLivingArea
= lerp(x1
,HLP
,x3
,y1
,y3
);
323 void Gains::calctempDiffBetweenZones()
325 double HLP
= ptrHeatLosses
->getHeatLossParam();
330 QList
<double> tmpList
;
332 QMap
<double,QList
<double> >::const_iterator i
;
336 m_tempDiffZones
= table9
.value(1.00).at(m_controlType
);
338 else if (HLP
>= 6.00)
341 m_tempDiffZones
= table9
.value(6.00).at(m_controlType
);
347 i
= table9
.upperBound(HLP
);
350 y3
= tmpList
.at(m_controlType
);
351 //Decrement by 1 for lower bound
355 y1
= tmpList
.at(m_controlType
);
357 m_tempDiffZones
= lerp(x1
,HLP
,x3
,y1
,y3
);
361 void Gains::calcDegreeDays()
367 QList
<double> tmpList
;
368 m_tempRiseFromGains
= m_usefulGains
/
369 ptrHeatLosses
->getHeatLossCoeff();
371 m_baseTemp
= m_meanIntTemp
- m_tempRiseFromGains
;
373 if (m_baseTemp
< 1.00)
375 else if(m_baseTemp
> 20.50)
376 m_degreeDays
= 3330.00;
381 QMap
<double,QList
<double> >::const_iterator i
;
384 i
= table10
.upperBound(m_baseTemp
);
388 //Decrement by 1 for lower bound
394 m_degreeDays
= lerp(x1
,m_baseTemp
,x3
,y1
,y3
);
398 void Gains::calcTotalInternalGains()
401 double N
= 0.00, W
= 0.00, SFP
=0.00;
402 double TFA
= ptrDims
->get_totalFloorArea();
407 N
= 0.035 * TFA
- 0.000038 * (TFA
* TFA
);
414 W
= 74.00 + 2.66 * TFA
+ 75.5 * N
;
416 W
= 824.00 + 75.5 * N
;
418 m_lightAppCookMetabolicGains
= W
;
420 if(m_specificFanPower
== 1)
426 switch (m_addtnGainsTableVal
)
428 case 1: //Central Heating Pump
429 m_addtnGains
= 10.00;
431 case 2: //Oil Boiler Pump, inside dwelling
432 m_addtnGains
= 10.00;
435 case 3://Warm air heating system fans
436 m_addtnGains
= 0.06 * ptrDims
->get_dwellingVolume();
439 m_addtnGains
= SFP
* 0.06 * ptrDims
->get_dwellingVolume();
443 } /* ----- end switch ----- */
446 m_waterHeating
= ptrWaterHeat
->getHotWaterHeatGains() / 8.76 ;
447 m_totalIntGains
= m_lightAppCookMetabolicGains
+
453 void Gains::calcUsefulSolarGains()
455 QMapIterator
<QString
, SolarGains
> i(gainsList
);
460 SolarGains temp
= i
.value();
461 m_totalSolarGains
+= temp
.getSolarGains();
465 m_totalGains
= m_totalIntGains
+ m_totalSolarGains
;
467 m_gainLossRatio
= m_totalGains
/ ptrHeatLosses
->getHeatLossCoeff();
469 //Calculate Utilisation Factor
470 m_utilisationFactor
= 1 - exp(-18/m_gainLossRatio
);
472 m_usefulGains
= m_totalSolarGains
* m_utilisationFactor
;
476 void Gains::calcSpaceHeatReq()
478 m_spaceHeatingReq
= 0.024 *
480 ptrHeatLosses
->getHeatLossCoeff();
483 void Gains::calcMeanInternalTemp()
485 //Needs work to Fix !!!!
489 //Calc Mean Internal Living Room Temperature
490 calcMeanIntTempLiving();
492 //TODO - adjust from table 4e
494 //TODO - responsiveness, defaulting to 1.00 for now !!
496 m_adjustForGains
= (m_usefulGains
/
497 ptrHeatLosses
->getHeatLossCoeff() - 4.0) *
501 m_adjustLivingTemp
= m_meanTempLivingArea
+
505 calctempDiffBetweenZones();
507 m_livingAreaFrac
= ptrDims
->get_livingRoomArea() /
508 ptrDims
->get_totalFloorArea();
510 m_restOfHouseFrac
= 1.00 - m_livingAreaFrac
;
511 m_meanIntTemp
= m_adjustLivingTemp
-
512 (m_tempDiffZones
* m_restOfHouseFrac
);
516 void Gains::initVars()
521 m_lightAppCookMetabolicGains
= cf
.getValueDouble("Gains:lightAppCookMetabolicGains");
522 m_lowEnergyLightRed
= cf
.getValueDouble("Gains:lowEnergyLightRed");
523 m_addtnGains
= cf
.getValueDouble("Gains:addtnGains");
524 m_waterHeating
= cf
.getValueDouble("Gains:waterHeating");
525 m_totalIntGains
= cf
.getValueDouble("Gains:totalIntGains");
526 m_totalGains
= cf
.getValueDouble("Gains:totalGains");
527 m_solarGLR
= cf
.getValueDouble("Gains:solarGLR");
528 m_solarUtilFactor
= cf
.getValueDouble("Gains:solarUtilFactor");
529 m_totalSolarGains
= cf
.getValueDouble("Gains:totalSolarGains");
530 m_meanTempLivingArea
= cf
.getValueDouble("Gains:meanTempLivingArea");
531 m_tempAdjustment
= cf
.getValueDouble("Gains:tempAdjustment");
532 m_adjustForGains
= cf
.getValueDouble("Gains:adjustForGains");
533 m_adjustLivingTemp
= cf
.getValueDouble("Gains:adjustLivingTemp");
534 m_tempDiffZones
= cf
.getValueDouble("Gains:tempDiffZones");
535 m_livingAreaFrac
= cf
.getValueDouble("Gains:livingAreaFrac");
536 m_restOfHouseFrac
= cf
.getValueDouble("Gains:restOfHouseFrac");
537 m_meanIntTemp
= cf
.getValueDouble("Gains:meantIntTemp");
538 m_tempRiseFromGains
= cf
.getValueDouble("Gains:tempRiseFromGains");
539 m_baseTemp
= cf
.getValueDouble("Gains:baseTemp");
540 m_degreeDays
= cf
.getValueDouble("Gains:degreeDays");
541 m_spaceHeatingReq
= cf
.getValueDouble("Gains:spaceHeatingReq");
542 m_usefulGains
= cf
.getValueDouble("Gains:usefulGains");
543 m_gainLossRatio
= cf
.getValueDouble("Gains:gainLossRatio");
544 m_utilisationFactor
= cf
.getValueDouble("Gains:utilisationFactor");
545 m_lightRatio
= cf
.getValueDouble("Gains:lightRatio");
546 m_addtnGainsTableVal
= cf
.getValueInt("Gains:addtnGainsTableVal");
547 m_specificFanPower
= cf
.getValueInt("Gains:specificFanPower");
548 m_heatingTypeControl
= cf
.getValueInt("Gains:heatingTypeControl");
549 m_controlType
= cf
.getValueInt("Gains:controlType");
550 m_annualLightEnergy
= cf
.getValueInt("Gains:annualLightEnergy");
552 loadSolarGain("North");
553 loadSolarGain("South");
554 loadSolarGain("East");
555 loadSolarGain("West");
556 loadSolarGain("NorthEast");
557 loadSolarGain("SouthEast");
558 loadSolarGain("NorthWest");
559 loadSolarGain("SouthWest");
560 loadSolarGain("Rooflights");
564 void Gains::loadSolarGain(const QString
& gainName
)
566 int overshadow
= 0,orientation
=0;
567 int frameType
, glazingType
= 0;
570 QString searchStr
= "SG" + gainName
+ ":";
571 overshadow
= cf
.getValueInt(searchStr
+"overshadow");
572 orientation
= cf
.getValueInt(searchStr
+"orientation");
573 area
= cf
.getValueDouble(searchStr
+"area");
574 frameType
= cf
.getValueInt(searchStr
+"frameType");
575 glazingType
= cf
.getValueInt(searchStr
+"glazingType");
577 createSolarGain(gainName
,
586 void Gains::buildLT()
588 //TEST BEFORE REMOVAL
589 DoubleReader
t1 ("table9");
590 table9
= t1
.getDoubleMap();
591 DoubleReader
t2 ("table8");
592 table8
= t2
.getDoubleMap();
593 DoubleReader
t3 ("table10");
594 table10
= t3
.getDoubleMap();
596 /* //dr.readFile("table8");
597 DoubleReader table8r ("table8");
598 table8 = table8r.getDoubleMap();
600 DoubleReader table9r ("table9");
601 table9 = table9r.getDoubleMap();
604 //dr.readFile("table10");
605 DoubleReader table10r ("table10");
606 table10 = table10r.getDoubleMap();*/
609 void Gains::createSolarGain(QString gainName
,
617 SolarGains
gain(overshadow
,orientation
,area
,
618 frameType
,glazingType
,season
);
619 gainsList
[gainName
] = gain
;
622 void Gains::calcAll()
624 calcTotalInternalGains();
625 calcUsefulSolarGains();
626 calcLightingEnergy();
627 calcMeanInternalTemp();