From abcf04bac0fe9b7b8358af6ed4e2f11d9bbb0fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20Ri=C3=9F?= Date: Sat, 6 Feb 2010 00:19:05 +0100 Subject: .................................... --- House.cpp | 17 +++++++++-------- House.h | 2 +- Sun.h | 4 ++-- Temparray.cpp | 20 +++++++++++++++++++- Temparray.h | 4 +++- 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/House.cpp b/House.cpp index fb0f848..bf1724c 100644 --- a/House.cpp +++ b/House.cpp @@ -13,6 +13,7 @@ House::House(float inittemp0, int earthx0, int earthy0, int earthz0, float colle calcefficiency(); calctemp(); calcneededenergy(); + collectorstatus = TRANSVERSAL; } void House::calcefficiency() { @@ -461,26 +462,26 @@ void House::calccollectoroutput(int day, int time, int month) { } void House::calcprobeinput(int day, int time, int month) { - static float E; + /*static float E; calccollectoroutput(day, time, month); if(time == 0) E = neededenergy[month][time]; if(E>=collectoroutput && collectoroutput>0) {E -= collectoroutput; collectoroutput=0;} - else if(E0) {collectoroutput -= E; E=0;} - - if(E==0) probeinput = collectoroutput; - else probeinput = 0; + else if(E0) {collectoroutput -= E; E=0;}*/ + calccollectoroutput(day, time, month); + std::cout << collectoroutput << std::endl; + collectoroutput-=neededenergy[month][time]; } void House::controller(){ - static int day=0, time=0, month=0; + static int day=90, time=0, month=0; calcprobeinput(day, time, month); temp.setprobetemp(collectortemp); - temp.setinput(probeinput); + temp.setinput(collectoroutput); temp.calcTemp(); ++time; if(time > 23){ - //std::cerr << day << std::endl; +// std::cerr << day << " " << temp.getaverage() << std::endl; time = 0; ++day; } diff --git a/House.h b/House.h index aab0883..12cd725 100644 --- a/House.h +++ b/House.h @@ -36,7 +36,7 @@ class House Temparray temp; Sun sun; float collectortemp, latitude, radiation, eta0, k1, k2, watthoursperhuman, collectorarea, - heaterenergy, roofangle, collectoroutput, probeinput; + heaterenergy, roofangle, collectoroutput; float tempinside[24], tempoutside[12][24], efficiencyflat[100], efficiencyvacuum[100], anglecorrectionflat[91], anglecorrectiontransversal[91], anglecorrectionlongitudinal[91], tempdifference[12][24], neededenergy[12][24]; diff --git a/Sun.h b/Sun.h index 9e6f144..a242e5f 100644 --- a/Sun.h +++ b/Sun.h @@ -11,8 +11,8 @@ class Sun void setlatitude(float latitude0){latitude=latitude0;}; - float declination(int day) {return 23.4*sin(2*M_PI*(284+day)/365);} - float hourangle(int time) {return 15*(time-12);} + float declination(int day) {return 23.4*sin(2*M_PI*(284+day+1)/365);} + float hourangle(int time) {return 15*(time+1/*-12*/);} float elevationangle(int day, int time) { return asin(sin(declination(day)*M_PI/180)* sin(latitude*M_PI/180)* diff --git a/Temparray.cpp b/Temparray.cpp index ddbcc25..0686ef0 100644 --- a/Temparray.cpp +++ b/Temparray.cpp @@ -154,7 +154,7 @@ void Temparray::calcTemp(){ inputpower = loadableenergy; input -= loadableenergy; } - else if (input <= loadableenergy) { + else if (input < loadableenergy) { inputpower = input; input = 0; } @@ -165,6 +165,24 @@ void Temparray::calcTemp(){ *thermalresistance*factor*(1-exp(-(1/tau12))); } } + if (input < 0){ + if(unloadableenergy <= 0) + inputpower = 0; + else if (input > unloadableenergy) { + inputpower = unloadableenergy; + input -= unloadableenergy; + } + else if (input <= unloadableenergy) { + inputpower = input; + input = 0; + } + if(inputpower > 0) { + factor = inputpower/unloadableenergy; + temperaturenew(i, j, k, l, m) = + temperaturenew(i, j, k, l, m) + (21.5-temperatureold(i, j, k, l, m)) + *thermalresistance*factor*(1-exp(-(1/tau12))); + } + } } } } diff --git a/Temparray.h b/Temparray.h index 0886c9d..409b780 100644 --- a/Temparray.h +++ b/Temparray.h @@ -25,6 +25,8 @@ class Temparray void setprobetemp(float t){probetemp = t;} void setinput(float input0){input = input0;} + + float getaverage(){return averagetemp;} private: float *temparrayold, *temparraynew; @@ -73,7 +75,7 @@ class Temparray } } averagetemp = tempcache/times; - std::cerr << averagetemp << std::endl; +// std::cerr << averagetemp << std::endl; } }; -- cgit v1.2.3