1 /***************************************************************************
3 * HeatLosses.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 ***************************************************************************/
23 #include "HeatLosses.h"
24 // Constructors/Destructors
27 HeatLosses::HeatLosses(const ConfigParser
& config
,
28 DwellingDimensions
*dims
,
29 Ventilation
*ventilation
)
32 ptrVentilation
= ventilation
;
37 HeatLosses::~HeatLosses ( )
46 // Calculate U-Value For Windows
48 double HeatLosses::calcUValueWindow (double uW
)
50 double uWeffec
= 1 / ((1/uW
)+ 0.04);
54 void HeatLosses::buildLT()
56 int regionSel
= ptrDims
->get_region();
58 TableReader
tr ("uValsEnglandWales");
63 //England & Wales U-Values
66 uValuesMap
= tr
.getTableMap();
71 tr
.readFile("uValsScotland");
72 uValuesMap
= tr
.getTableMap();
75 //Northern Ireland U-Values
77 tr
.readFile("uValsNorthernIreland");
78 uValuesMap
= tr
.getTableMap();
81 //England & Wales by default....
83 tr
.readFile("uValsEnglandWales");
84 uValuesMap
= tr
.getTableMap();
86 } /* ----- end switch ----- */
91 void HeatLosses::setTotalAreaElems ( double val_in
) {
92 m_totalAreaElems
= val_in
;
96 double HeatLosses::getTotalAreaElems ( ) {
97 return m_totalAreaElems
;
101 void HeatLosses::setFabricHeatLoss ( double val_in
) {
102 m_fabricHeatLoss
= val_in
;
106 double HeatLosses::getFabricHeatLoss ( ) {
107 return m_fabricHeatLoss
;
111 void HeatLosses::setThermalBridges ( double val_in
) {
112 m_thermalBridges
= val_in
;
116 double HeatLosses::getThermalBridges ( ) {
117 return m_thermalBridges
;
121 void HeatLosses::setTotalFabricHeatLoss ( double val_in
) {
122 m_totalFabricHeatLoss
= val_in
;
126 double HeatLosses::getTotalFabricHeatLoss ( ) const {
127 return m_totalFabricHeatLoss
;
131 void HeatLosses::setVentilationHeatLoss ( double val_in
) {
132 m_ventilationHeatLoss
= val_in
;
136 double HeatLosses::getVentilationHeatLoss ( ) {
137 return m_ventilationHeatLoss
;
141 void HeatLosses::setHeatLossCoeff ( double val_in
) {
142 m_heatLossCoeff
= val_in
;
146 double HeatLosses::getHeatLossCoeff ( ) {
147 return m_heatLossCoeff
;
151 void HeatLosses::setHeatLossParam ( double val_in
) {
152 m_heatLossParam
= val_in
;
156 double HeatLosses::getHeatLossParam ( ) {
157 return m_heatLossParam
;
160 void HeatLosses::createHeatLossElement(const QString
& elemNameIn
)
162 if(!elementMap
.contains(elemNameIn
))
164 HeatLossElement heatLoss
;
165 elementMap
.insert(elemNameIn
,heatLoss
);
169 void HeatLosses::addHeatLoss(const QString
& elemName
,
170 const QString
& lossName
,
175 QMapIterator
<QString
,HeatLossElement
> i (elementMap
);
180 if (i
.key() == elemName
)
184 HeatLossElement temp
=i
.value();
186 temp
.insertLoss(lossName
,area
,uValue
);
187 elementMap
.insert(elemName
,temp
);
190 void HeatLosses::calcTotalAreaElems()
192 QMapIterator
<QString
,HeatLossElement
> i(elementMap
);
194 m_totalAreaElems
= 0.00, m_fabricHeatLoss
= 0.00;
198 HeatLossElement temp
= i
.value();
199 temp
.calcElementTotal();
200 m_totalAreaElems
+= temp
.getElementAreaTotal();
201 m_fabricHeatLoss
+= temp
.getElementLossTotal();
206 void HeatLosses::calcHeatLossParam ()
210 m_thermalBridges
= 0.15 * m_totalAreaElems
;
211 m_totalFabricHeatLoss
= m_fabricHeatLoss
+ m_thermalBridges
;
212 m_ventilationHeatLoss
= ptrVentilation
->get_effecAirChangeRate() *
214 ptrDims
->get_dwellingVolume();
216 m_heatLossCoeff
= m_totalFabricHeatLoss
+ m_ventilationHeatLoss
;
218 m_heatLossParam
= m_heatLossCoeff
/
219 ptrDims
->get_totalFloorArea();
223 void HeatLosses::calcAll()
225 //Calculate Element Area + Fabric Heatloss W/K totals
226 calcTotalAreaElems();
230 void HeatLosses::initVars()
236 m_totalAreaElems
= cf
.getValueDouble("HeatLosses:totalAreaElems");
237 m_fabricHeatLoss
= cf
.getValueDouble("HeatLosses:fabricHeatLoss");
238 m_thermalBridges
= cf
.getValueDouble("HeatLosses:thermalBridges");
239 m_totalFabricHeatLoss
= cf
.getValueDouble("HeatLosses:totalFabricHeatLoss");
240 m_ventilationHeatLoss
= cf
.getValueDouble("HeatLosses:ventilationHeatLoss");
241 m_heatLossCoeff
= cf
.getValueDouble("HeatLosses:heatLossCoeff");
242 m_heatLossParam
= cf
.getValueDouble("HeatLosses:heatLossParam");
247 void HeatLosses::fetchHeatLosses()
250 QStringList names
, allElements
, subList
;
251 QString elemName
, lossName
, currItem
;
252 //entries = cf.findHleEntries();
253 double areaOut
= 0.00, uValueOut
= 0.00;
254 allElements
= cf
.getElementKeyNames();
255 names
= cf
.findHleEntries();
256 //QMap <QString, QString> hleMap = cf.getInputData();
258 //Search For elements
259 for (int i
=0; i
< names
.size(); ++i
)
261 subList
= allElements
.filter(names
.at(i
));
262 elemName
= names
.at(i
);
265 createHeatLossElement(elemName
);
267 //Search For individual Losees - IMPORTANT Relies on ini file order
268 //wont work otherwise !!
269 for (int j
=0; j
< subList
.size(); ++j
)
271 currItem
= subList
.at(j
);
273 if (currItem
.contains("name"))
274 lossName
= cf
.getValueString(currItem
);
275 if (currItem
.contains("area"))
276 areaOut
= cf
.getValueDouble(currItem
);
277 if (currItem
.contains("uValue"))
279 uValueOut
= cf
.getValueDouble(currItem
);
280 addHeatLoss(elemName
,lossName
,areaOut
,uValueOut
);
288 //addHeatLoss(elemName,lossName,areaOut,uValueOut);