Initial Commit
[HECS.git] / WaterHeating.cpp
blob03f99b580d3084e77e9d4bae6a92a6b2411bedc3
1 /***************************************************************************
2 * *
3 * WaterHeating.cpp Copyright (C) 2008 by Jon Rumble *
4 * j.w.rumble@reading.ac.uk *
5 * *
6 * This file is part of HECS, *
7 * *
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. *
12 * *
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. *
17 * *
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 "WaterHeating.h"
25 // Constructors/Destructors
26 //
28 WaterHeating::WaterHeating (const ConfigParser& config, DwellingDimensions *dims)
30 cf = config;
31 ptrDims = dims;
32 initVars();
33 calcAll();
36 WaterHeating::WaterHeating () { }
38 WaterHeating::~WaterHeating ( ) { }
40 //
41 // Methods
42 //
45 // Accessor methods
46 //
49 // Other methods
50 //
53 void WaterHeating::setEnergyContentHotWater ( double val_in ) {
54 m_energyContentHotWater = val_in;
57 double WaterHeating::getEnergyContentHotWater ( ) {
58 return m_energyContentHotWater;
62 void WaterHeating::setDistributionLoss ( double val_in ) {
63 m_distributionLoss = val_in;
67 double WaterHeating::getDistributionLoss ( ) {
68 return m_distributionLoss;
72 void WaterHeating::setHotWaterUsage ( double val_in ) {
73 m_hotWaterUsage = val_in;
77 double WaterHeating::getHotWaterUsage ( ) {
78 return m_hotWaterUsage;
82 void WaterHeating::setManDeclaredLoss ( double val_in ) {
83 m_manDeclaredLoss = val_in;
87 double WaterHeating::getManDeclaredLoss ( ) {
88 return m_manDeclaredLoss;
92 void WaterHeating::setTempFactor ( double val_in ) {
93 m_tempFactor = val_in;
97 double WaterHeating::getTempFactor ( ) {
98 return m_tempFactor;
102 void WaterHeating::setEnergyLostWaterStore ( double val_in ) {
103 m_energyLostWaterStore = val_in;
107 double WaterHeating::getEnergyLostWaterStore ( ) {
108 return m_energyLostWaterStore;
112 void WaterHeating::setCylinderVolume ( double val_in ) {
113 m_cylinderVolume = val_in;
117 double WaterHeating::getCylinderVolume ( ) {
118 return m_cylinderVolume;
122 void WaterHeating::setHotWaterStoreLossFactor ( double val_in ) {
123 m_hotWaterStoreLossFactor = val_in;
127 double WaterHeating::getHotWaterStoreLossFactor ( ) {
128 return m_hotWaterStoreLossFactor;
132 void WaterHeating::setVolumeFactor ( double val_in ) {
133 m_volumeFactor = val_in;
137 double WaterHeating::getVolumeFactor ( ) {
138 return m_volumeFactor;
142 void WaterHeating::setSolarStorageVal ( double val_in ) {
143 m_solarStorageVal = val_in;
147 double WaterHeating::getSolarStorageVal ( ) {
148 return m_solarStorageVal;
152 void WaterHeating::setPrimaryCircuitLoss ( double val_in ) {
153 m_primaryCircuitLoss = val_in;
157 double WaterHeating::getPrimaryCircuitLoss ( ) {
158 return m_primaryCircuitLoss;
161 void WaterHeating::setCombiLoss ( double val_in ) {
162 m_combiLoss = val_in;
166 double WaterHeating::getCombiLoss ( ) {
167 return m_combiLoss;
171 void WaterHeating::setSolarDhw ( double val_in ) {
172 m_solarDhw = val_in;
176 double WaterHeating::getSolarDhw ( ) {
177 return m_solarDhw;
181 void WaterHeating::setWaterHeaterOutput ( double val_in ) {
182 m_waterHeaterOutput = val_in;
186 double WaterHeating::getWaterHeaterOutput ( ) {
187 return m_waterHeaterOutput;
191 void WaterHeating::setHotWaterHeatGains ( double val_in ) {
192 m_hotWaterHeatGains = val_in;
196 double WaterHeating::getHotWaterHeatGains ( ) {
197 return m_hotWaterHeatGains;
200 void WaterHeating::calcAll()
202 calcHotWaterGains();
206 void WaterHeating::calcHotWaterGains()
208 //Some Temp Vars for ease
209 double N= 0.00, TFA= 0.00;
210 TFA = ptrDims->get_totalFloorArea();
213 if (TFA <= 420.00)
214 N = 0.035 * TFA - 0.000038 * TFA*TFA;
215 else
216 //Floor Area is above 420 sq Meters,
217 N = 8;
219 m_hotWaterUsage = (25 * N) + 38;
220 m_energyContentHotWater = ((61 * N)+ 92) * 0.85 * 8.76;
221 m_distributionLoss = ((61 * N) + 92) * 0.15 * 8.76;
224 //Method A
225 if (m_declaredLossKnown == 1)
227 m_tempFactor = tempFactorLossKnown();
228 m_energyLostWaterStore = (m_manDeclaredLoss * m_tempFactor)*365;
231 //Method B
232 else
234 double L = 0.00, VF= 0.00;
236 if (m_looseJacket == 1)
237 L = 0.005 + 1.76 / (m_insultaionThickness + 12.80);
238 else
239 L = 0.005 + 0.55 / (m_insultaionThickness + 4.00);
241 VF = pow((120.00 / m_cylinderVolume),0.33333333);
243 m_tempFactor = tempFactorLossNotKnown();
244 m_energyLostWaterStore = m_cylinderVolume*
246 VF *
247 m_tempFactor *
248 365;
251 //m_solarStorageVal = m_energyLostWaterStore;
253 primaryCircuitLoss();
255 m_solarDhw = 0.00; //FIX
257 m_waterHeaterOutput = m_energyContentHotWater +
258 m_distributionLoss +
259 m_solarStorageVal +
260 m_primaryCircuitLoss +
261 m_combiLoss -
262 m_solarDhw;
264 m_hotWaterHeatGains = 0.25 * (m_energyContentHotWater + m_combiLoss) +
265 0.8 *
266 (m_distributionLoss + m_solarStorageVal +
267 m_primaryCircuitLoss);
271 double WaterHeating::tempFactorLossKnown()
274 switch (m_storageType)
276 //Cylinder
277 case 1:
278 m_tempFactor = 0.60;
279 break;
280 //Cylinder - Cylinder Thermostat Absent.
281 case 2:
282 m_tempFactor = 0.60*1.3;
283 break;
284 //Cylinder - Seperate time control
285 case 3:
286 m_tempFactor = 0.60*0.9;
287 break;
288 //Combi-Primary
289 case 4:
290 m_tempFactor = 0.00;
291 break;
292 //Combi-Secondary
293 case 5:
294 m_tempFactor = 0.00;
295 break;
296 //Hot water only thermal store
297 case 6:
298 m_tempFactor = 0.89;
299 break;
300 //Hot water only thermal store - seperate timer
301 case 7:
302 m_tempFactor = 0.89*0.81;
303 break;
304 //Hot water only thermal store - not in airing cupboard
305 case 8:
306 m_tempFactor = 0.89*1.1;
307 break;
308 //Integrated thermal store gasfired CPSU
309 case 9:
310 m_tempFactor = 0.89;
311 break;
312 //Integrated thermal store gasfired CPSU - seperate timer
313 case 10:
314 m_tempFactor = 0.89*0.81;
315 break;
316 //Integrated thermal store gasfired CPSU - not in airing cupboard
317 case 11:
318 m_tempFactor = 0.89*1.1;
319 break;
320 //Electrical CPSU winter op temp 85C
321 case 12:
322 m_tempFactor = 1.09;
323 break;
324 //Electrical CPSU winter op temp 90C
325 case 13:
326 m_tempFactor = 1.15;
327 break;
328 //Electrical CPSU winter op temp 95C
329 case 14:
330 m_tempFactor = 1.21;
331 break;
332 default:
333 break;
334 } /* ----- end switch ----- */
335 return m_tempFactor;
338 double WaterHeating::tempFactorLossNotKnown()
340 switch (m_storageType)
342 //Cylinder
343 case 1:
344 m_tempFactor = 0.60;
345 break;
346 //Cylinder - Cylinder Thermostat Absent.
347 case 2:
348 m_tempFactor = 0.60*1.3;
349 break;
350 //Cylinder - Seperate time control
351 case 3:
352 m_tempFactor = 0.60*0.9;
353 break;
354 //Combi-Primary
355 case 4:
356 if (m_combiStore >= 115.00)
357 m_tempFactor = 0.82;
358 else
359 m_tempFactor = 0.82 + 0.0022 * (115.00 - m_combiStore);
360 break;
362 //Combi-Secondary
363 case 5:
364 if (m_combiStore >= 115.00)
365 m_tempFactor = 0.60;
366 else
367 m_tempFactor = 0.60 + 0.0016 * (115.00 - m_combiStore);
368 break;
369 //Hot water only thermal store
370 case 6:
371 m_tempFactor = 1.08;
372 break;
373 //Hot water only thermal store - seperate timer
374 case 7:
375 m_tempFactor = 1.08*0.81;
376 break;
377 //Hot water only thermal store - not in airing cupboard
378 case 8:
379 m_tempFactor = 1.08*1.1;
380 break;
381 //Integrated thermal store gasfired CPSU
382 case 9:
383 m_tempFactor = 1.08;
384 break;
385 //Integrated thermal store gasfired CPSU - seperate timer
386 case 10:
387 m_tempFactor = 1.08*0.81;
388 break;
389 //Integrated thermal store gasfired CPSU - not in airing cupboard
390 case 11:
391 m_tempFactor = 1.08*1.1;
392 break;
393 //Electrical CPSU winter op temp 85C
394 case 12:
395 m_tempFactor = 1.00;
396 break;
397 //Electrical CPSU winter op temp 90C
398 case 13:
399 m_tempFactor = 1.00;
400 break;
401 //Electrical CPSU winter op temp 95C
402 case 14:
403 m_tempFactor = 1.00;
404 break;
405 default:
406 break;
407 } /* ----- end switch ----- */
408 return m_tempFactor;
412 void WaterHeating::primaryCircuitLoss()
415 switch (m_systemType)
417 //Electric Immersion Heater
418 case 1:
419 m_primaryCircuitLoss = 0.00;
420 break;
421 //Boiler Uninsulated Pipework, no cyl thermostat
422 case 2:
423 m_primaryCircuitLoss = 1220.00;
424 break;
425 //Boiler insulated Pipework, no cyl thermostat
426 case 3:
427 m_primaryCircuitLoss = 610.00;
428 break;
429 //Boiler uninsulated Pipework, cyl thermostat
430 case 4:
431 m_primaryCircuitLoss = 610.00;
432 break;
433 //Boiler insulated Pipework, cyl thermostat
434 case 5:
435 m_primaryCircuitLoss = 360.00;
436 break;
437 //Combi Boiler
438 case 6:
439 m_primaryCircuitLoss = 0.00;
440 break;
441 //CPSU (including electric CPSU)
442 case 7:
443 m_primaryCircuitLoss = 0.00;
444 break;
445 //Boiler and thermal store within a single casing (cyl, thermo present)
446 case 8:
447 m_primaryCircuitLoss = 0.00;
448 break;
449 //Sep. boiler and thermal store 1.5m<= of ins pipe.
450 case 9:
451 m_tempFactor = 0.00;
452 break;
453 //Sep boiler and thermal store - uninsulated pipework
454 case 10:
455 m_tempFactor = 470.00;
456 break;
457 //Sep boiler and thermal store - >=1.5m insulated pipework
458 case 11:
459 m_tempFactor = 280.00;
460 break;
461 //Community Heating
462 case 12:
463 m_tempFactor = 360.00;
464 break;
465 default:
466 break;
467 } /* ----- end switch ----- */
471 void WaterHeating::initVars ( ) {
473 m_energyContentHotWater = cf.getValueDouble ("WaterHeating:energyContentHotWater");
474 m_distributionLoss = cf.getValueDouble ("WaterHeating:distributionLoss");
475 m_hotWaterUsage = cf.getValueDouble ("WaterHeating:distributionLoss");
476 m_manDeclaredLoss = cf.getValueDouble ("WaterHeating:manDeclaredLoss");
477 m_tempFactor = cf.getValueDouble ("WaterHeating:tempFactor");
478 m_energyLostWaterStore = cf.getValueDouble ("WaterHeating:energyLostWaterStore");
479 m_cylinderVolume = cf.getValueDouble ("WaterHeating:cylinderVolume");
480 m_hotWaterStoreLossFactor = cf.getValueDouble ("WaterHeating:hotWaterStoreLossFactor");
481 m_volumeFactor = cf.getValueDouble ("WaterHeating:volumeFactor");
482 m_solarStorageVal = cf.getValueDouble ("WaterHeating:solarStorageVal");
483 m_primaryCircuitLoss = cf.getValueDouble ("WaterHeating:primaryCircuitLoss");
484 m_solarDhw = cf.getValueDouble ("WaterHeating:solarDhw");
485 m_waterHeaterOutput = cf.getValueDouble ("WaterHeating:waterHeaterOutput");
486 m_hotWaterHeatGains = cf.getValueDouble ("WaterHeating:hotWaterHeatGains");
487 m_insultaionThickness = cf.getValueDouble ("WaterHeating:insulationThickness");
488 m_declaredLossKnown = cf.getValueInt ("WaterHeating:declaredLossKnown");
489 m_looseJacket = cf.getValueDouble ("WaterHeating:looseJacket");
490 m_combiStore = cf.getValueDouble ("WaterHeating:combiStore");
491 m_storageType= cf.getValueDouble ("WaterHeating:storageType");
492 m_systemType = cf.getValueDouble ("WaterHeating:systemType");